Annotation of researchv10no/cmd/cbt/verify, revision 1.1.1.1

1.1       root        1: export PATH
                      2: x=$1
                      3: if test $# = 0
                      4: then
                      5:        echo verify rec-cnt
                      6:        exit 1
                      7: fi
                      8: echo 1. loading a btree with $x empty records
                      9: cbt creat junk
                     10: awk '{for(i = 0; i < $1; i++) printf "%8.8d\n", i}' <<! | cbt build junk
                     11: $x
                     12: !
                     13: echo 1. does report think there are $x records
                     14: cbt report junk
                     15: echo 2. check them with cat, it will report errors
                     16: cbt cat junk | awk 'length != 9 || $0+0 != NR-1 {print length, $0+0, NR, "bad"}'
                     17: echo 2. end of load test
                     18: echo 3. delete all the records
                     19: awk '{for(i = 0; i < $1; i++) printf "%8.8d\n", i}' <<!| cbt delete junk
                     20: $x
                     21: !
                     22: echo 3. report should think they are all gone
                     23: cbt report junk
                     24: echo 4. cat should too
                     25: cbt cat junk | awk '{next}; END {print NR " records"}'
                     26: echo 4. there should be no records left
                     27: echo
                     28: echo 5. now load them back one at a time in different order
                     29: echo $x | awk '{for(i = $1; --i >= 0; ) printf "%8.8d\n", i}' |
                     30:        cbt add junk
                     31: echo 5. report should think there are $x records
                     32: cbt report junk
                     33: echo 6. cat should think so too
                     34: cbt cat junk | awk 'length != 9 || $0+0 != NR-1 {print length, $0+0, NR, "bad"}
                     35:        END {print NR " records"}'
                     36: echo 6. there should have been no bad records
                     37: echo
                     38: echo 7. now throw every other one away
                     39: awk '{for(i = 0; i < $1; i+=2) printf "%8.8d\n", i}' <<! | cbt delete junk
                     40: $x
                     41: !
                     42: echo 7. report should think they are gone
                     43: cbt report junk
                     44: echo 8. cat should too
                     45: cbt cat junk | awk '{next}; END {print NR " records"}'
                     46: echo 8. there should be half the records left
                     47: echo
                     48: echo 9. now squash the file
                     49: cbt squash junk
                     50: echo 9. report says
                     51: cbt report junk
                     52: echo 10. and can cat find them all:
                     53: cbt cat junk | awk 'length != 9 || $0+0 != 2*NR-1 {print length, $0+0, NR, "bad"}
                     54:        END {print NR " records"}'
                     55: echo 10. there should be half the records left
                     56: echo
                     57: echo 11. now put the other half back
                     58: echo $x | awk '{for(i = 0; i < $1; i+=2) printf "%8.8d\n", i}' |
                     59:        cbt add junk
                     60: echo 11. report should see $x records
                     61: cbt report junk
                     62: echo 12. so should cat
                     63: cbt cat junk | awk 'length != 9 || $0+0 != NR-1 {print length, $0+0, NR, "bad"}
                     64:        END {print NR " records"}'
                     65: echo 13. and they should all be there after squashing
                     66: cbt squash junk
                     67: echo 13. report should see $x records
                     68: cbt report junk
                     69: echo 14. so should cat
                     70: cbt cat junk | awk 'length != 9 || $0+0 != NR-1 {print length, $0+0, NR, "bad"}
                     71:        END {print NR " records"}'
                     72: echo and that is all I could think of doing

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.