156038Sbostic#!/bin/sh - 256038Sbostic# 3*64487Sbostic# @(#)run.test 8.7 (Berkeley) 09/16/93 456038Sbostic# 556038Sbostic 656038Sbostic# db regression tests 756038Sbosticmain() 856038Sbostic{ 964444Sbostic 1064448SbosticDICT=/usr/share/dict/words 1164448Sbostic#DICT=/usr/dict/words 1264448SbosticPROG=./dbtest 1364448SbosticTMP1=t1 1464448SbosticTMP2=t2 1564448SbosticTMP3=t3 1656038Sbostic 17*64487Sbostic if [ $# -eq 0 ]; then 18*64487Sbostic for t in 1 2 3 4 5 6 7 8 9 10 11 12 13 20; do 19*64487Sbostic test$t 2064444Sbostic done 21*64487Sbostic else 22*64487Sbostic while [ $# -gt 0 ] 23*64487Sbostic do case "$1" in 24*64487Sbostic test*) 25*64487Sbostic $1;; 26*64487Sbostic [0-9]*) 27*64487Sbostic test$1;; 28*64487Sbostic btree) 29*64487Sbostic for t in 1 2 3 7 8 9 10 12 13; do 30*64487Sbostic test$t 31*64487Sbostic done;; 32*64487Sbostic hash) 33*64487Sbostic for t in 1 2 3 8 13 20; do 34*64487Sbostic test$t 35*64487Sbostic done;; 36*64487Sbostic recno) 37*64487Sbostic for t in 1 2 3 4 5 6 7 10 11; do 38*64487Sbostic test$t 39*64487Sbostic done;; 40*64487Sbostic *) 41*64487Sbostic echo "run.test: unknown test $1" 42*64487Sbostic echo "usage: run.test test# | type" 43*64487Sbostic exit 1 44*64487Sbostic esac 45*64487Sbostic shift 46*64487Sbostic done 4764444Sbostic fi 4864451Sbostic rm -f $TMP1 $TMP2 $TMP3 4956999Sbostic exit 0 5056038Sbostic} 5156038Sbostic 5256038Sbostic# Take the first hundred entries in the dictionary, and make them 5356038Sbostic# be key/data pairs. 5456038Sbostictest1() 5556038Sbostic{ 5664444Sbostic echo "Test 1: btree, hash: small key, small data pairs" 5756085Sbostic sed 200q $DICT > $TMP1 5856038Sbostic for type in btree hash; do 5956038Sbostic rm -f $TMP2 $TMP3 6056038Sbostic for i in `sed 200q $DICT`; do 6164444Sbostic echo p 6264444Sbostic echo k$i 6364444Sbostic echo d$i 6464444Sbostic echo g 6564444Sbostic echo k$i 6656038Sbostic done > $TMP2 6756058Sbostic $PROG -o $TMP3 $type $TMP2 6857460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 6956038Sbostic else 7064444Sbostic echo "test1: type $type: failed" 7156038Sbostic exit 1 7256038Sbostic fi 7356038Sbostic done 7464444Sbostic echo "Test 1: recno: small key, small data pairs" 7556038Sbostic rm -f $TMP2 $TMP3 7656038Sbostic sed 200q $DICT | 7756058Sbostic awk '{ 7856058Sbostic ++i; 7956058Sbostic printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); 8056058Sbostic }' > $TMP2 8156058Sbostic $PROG -o $TMP3 recno $TMP2 8257460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 8356038Sbostic else 8464444Sbostic echo "test1: type recno: failed" 8556038Sbostic exit 1 8656038Sbostic fi 8756038Sbostic} 8856038Sbostic 8957455Sbostic# Take the first 200 entries in the dictionary, and give them 9056038Sbostic# each a medium size data entry. 9156038Sbostictest2() 9256038Sbostic{ 9364444Sbostic echo "Test 2: btree, hash: small key, medium data pairs" 9456038Sbostic mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz 9556038Sbostic echo $mdata | 9656058Sbostic awk '{ for (i = 1; i < 201; ++i) print $0 }' > $TMP1 9756038Sbostic for type in hash btree; do 9856038Sbostic rm -f $TMP2 $TMP3 9956038Sbostic for i in `sed 200q $DICT`; do 10064444Sbostic echo p 10164444Sbostic echo k$i 10264444Sbostic echo d$mdata 10364444Sbostic echo g 10464444Sbostic echo k$i 10556038Sbostic done > $TMP2 10656058Sbostic $PROG -o $TMP3 $type $TMP2 10757460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 10856038Sbostic else 10964444Sbostic echo "test2: type $type: failed" 11056038Sbostic exit 1 11156038Sbostic fi 11256038Sbostic done 11364444Sbostic echo "Test 2: recno: small key, medium data pairs" 11456038Sbostic rm -f $TMP2 $TMP3 11556038Sbostic echo $mdata | 11656058Sbostic awk '{ for (i = 1; i < 201; ++i) 11756058Sbostic printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); 11856058Sbostic }' > $TMP2 11956058Sbostic $PROG -o $TMP3 recno $TMP2 12057460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 12156038Sbostic else 12264444Sbostic echo "test2: type recno: failed" 12356038Sbostic exit 1 12456038Sbostic fi 12556038Sbostic} 12656038Sbostic 12756038Sbostic# Insert the programs in /bin with their paths as their keys. 12856038Sbostictest3() 12956038Sbostic{ 13064444Sbostic echo "Test 3: hash: small key, big data pairs" 13156038Sbostic rm -f $TMP1 13256038Sbostic (find /bin -type f -print | xargs cat) > $TMP1 13360233Sbostic for type in hash; do 13456038Sbostic rm -f $TMP2 $TMP3 13556038Sbostic for i in `find /bin -type f -print`; do 13664444Sbostic echo p 13764444Sbostic echo k$i 13864444Sbostic echo D$i 13964444Sbostic echo g 14064444Sbostic echo k$i 14156038Sbostic done > $TMP2 14256058Sbostic $PROG -o $TMP3 $type $TMP2 14357460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 14456038Sbostic else 14564444Sbostic echo "test3: $type: failed" 14656038Sbostic exit 1 14756038Sbostic fi 14856038Sbostic done 14964444Sbostic echo "Test 3: btree: small key, big data pairs" 15060233Sbostic for psize in 512 16384 65536; do 15164444Sbostic echo " page size $psize" 15260233Sbostic for type in btree; do 15360233Sbostic rm -f $TMP2 $TMP3 15460233Sbostic for i in `find /bin -type f -print`; do 15564444Sbostic echo p 15664444Sbostic echo k$i 15764444Sbostic echo D$i 15864444Sbostic echo g 15964444Sbostic echo k$i 16060233Sbostic done > $TMP2 16160233Sbostic $PROG -i psize=$psize -o $TMP3 $type $TMP2 16260233Sbostic if (cmp -s $TMP1 $TMP3) ; then : 16360233Sbostic else 16464444Sbostic echo "test3: $type: page size $psize: failed" 16560233Sbostic exit 1 16660233Sbostic fi 16760233Sbostic done 16860233Sbostic done 16964444Sbostic echo "Test 3: recno: big data pairs" 17056038Sbostic rm -f $TMP2 $TMP3 17156038Sbostic find /bin -type f -print | 17256058Sbostic awk '{ 17356058Sbostic ++i; 17456058Sbostic printf("p\nk%d\nD%s\ng\nk%d\n", i, $0, i); 17556058Sbostic }' > $TMP2 17660233Sbostic for psize in 512 16384 65536; do 17764444Sbostic echo " page size $psize" 17860233Sbostic $PROG -i psize=$psize -o $TMP3 recno $TMP2 17960233Sbostic if (cmp -s $TMP1 $TMP3) ; then : 18060233Sbostic else 18164444Sbostic echo "test3: recno: page size $psize: failed" 18260233Sbostic exit 1 18360233Sbostic fi 18460233Sbostic done 18556038Sbostic} 18656038Sbostic 18756038Sbostic# Do random recno entries. 18856038Sbostictest4() 18956038Sbostic{ 19064444Sbostic echo "Test 4: recno: random entries" 19156050Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 19256058Sbostic awk '{ 19364444Sbostic for (i = 37; i <= 37 + 88 * 17; i += 17) { 19464471Sbostic if (i % 41) 19564471Sbostic s = substr($0, 1, i % 41); 19664471Sbostic else 19764471Sbostic s = substr($0, 1); 19864444Sbostic printf("input key %d: %s\n", i, s); 19964444Sbostic } 20064444Sbostic for (i = 1; i <= 15; ++i) { 20164471Sbostic if (i % 41) 20264471Sbostic s = substr($0, 1, i % 41); 20364471Sbostic else 20464471Sbostic s = substr($0, 1); 20564444Sbostic printf("input key %d: %s\n", i, s); 20664444Sbostic } 20764444Sbostic for (i = 19234; i <= 19234 + 61 * 27; i += 27) { 20864471Sbostic if (i % 41) 20964471Sbostic s = substr($0, 1, i % 41); 21064471Sbostic else 21164471Sbostic s = substr($0, 1); 21264444Sbostic printf("input key %d: %s\n", i, s); 21364444Sbostic } 21456058Sbostic exit 21556058Sbostic }' > $TMP1 21664287Sbostic rm -f $TMP2 $TMP3 21756058Sbostic cat $TMP1 | 21856058Sbostic awk 'BEGIN { 21956058Sbostic i = 37; 22056058Sbostic incr = 17; 22156058Sbostic } 22256058Sbostic { 22356058Sbostic printf("p\nk%d\nd%s\n", i, $0); 22456058Sbostic if (i == 19234 + 61 * 27) 22556058Sbostic exit; 22656058Sbostic if (i == 37 + 88 * 17) { 22756058Sbostic i = 1; 22856058Sbostic incr = 1; 22956058Sbostic } else if (i == 15) { 23056058Sbostic i = 19234; 23156058Sbostic incr = 27; 23256058Sbostic } else 23356058Sbostic i += incr; 23456058Sbostic } 23556058Sbostic END { 23656038Sbostic for (i = 37; i <= 37 + 88 * 17; i += 17) 23756058Sbostic printf("g\nk%d\n", i); 23856038Sbostic for (i = 1; i <= 15; ++i) 23956058Sbostic printf("g\nk%d\n", i); 24056038Sbostic for (i = 19234; i <= 19234 + 61 * 27; i += 27) 24156058Sbostic printf("g\nk%d\n", i); 24256058Sbostic }' > $TMP2 24356058Sbostic $PROG -o $TMP3 recno $TMP2 24457460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 24556038Sbostic else 24664444Sbostic echo "test4: type recno: failed" 24756038Sbostic exit 1 24856038Sbostic fi 24956038Sbostic} 25056050Sbostic 25156050Sbostic# Do reverse order recno entries. 25256050Sbostictest5() 25356050Sbostic{ 25464444Sbostic echo "Test 5: recno: reverse order entries" 25556050Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 25656058Sbostic awk ' { 25764444Sbostic for (i = 1500; i; --i) { 25864471Sbostic if (i % 34) 25964471Sbostic s = substr($0, 1, i % 34); 26064471Sbostic else 26164471Sbostic s = substr($0, 1); 26264444Sbostic printf("input key %d: %s\n", i, s); 26364444Sbostic } 26456058Sbostic exit; 26556058Sbostic }' > $TMP1 26664287Sbostic rm -f $TMP2 $TMP3 26756058Sbostic cat $TMP1 | 26856058Sbostic awk 'BEGIN { 26956058Sbostic i = 1500; 27056058Sbostic } 27156058Sbostic { 27256058Sbostic printf("p\nk%d\nd%s\n", i, $0); 27356058Sbostic --i; 27456058Sbostic } 27556058Sbostic END { 27656058Sbostic for (i = 1500; i; --i) 27756058Sbostic printf("g\nk%d\n", i); 27856058Sbostic }' > $TMP2 27956058Sbostic $PROG -o $TMP3 recno $TMP2 28057460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 28156050Sbostic else 28264444Sbostic echo "test5: type recno: failed" 28356050Sbostic exit 1 28456050Sbostic fi 28556050Sbostic} 28656038Sbostic 28756050Sbostic# Do alternating order recno entries. 28856050Sbostictest6() 28956050Sbostic{ 29064444Sbostic echo "Test 6: recno: alternating order entries" 29156050Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 29256058Sbostic awk ' { 29364444Sbostic for (i = 1; i < 1200; i += 2) { 29464471Sbostic if (i % 34) 29564471Sbostic s = substr($0, 1, i % 34); 29664471Sbostic else 29764471Sbostic s = substr($0, 1); 29864444Sbostic printf("input key %d: %s\n", i, s); 29964444Sbostic } 30064444Sbostic for (i = 2; i < 1200; i += 2) { 30164471Sbostic if (i % 34) 30264471Sbostic s = substr($0, 1, i % 34); 30364471Sbostic else 30464471Sbostic s = substr($0, 1); 30564444Sbostic printf("input key %d: %s\n", i, s); 30664444Sbostic } 30756058Sbostic exit; 30856058Sbostic }' > $TMP1 30964444Sbostic rm -f $TMP2 $TMP3 31056058Sbostic cat $TMP1 | 31156058Sbostic awk 'BEGIN { 31256058Sbostic i = 1; 31356058Sbostic even = 0; 31456058Sbostic } 31556058Sbostic { 31656058Sbostic printf("p\nk%d\nd%s\n", i, $0); 31756058Sbostic i += 2; 31856058Sbostic if (i >= 1200) { 31956058Sbostic if (even == 1) 32056058Sbostic exit; 32156058Sbostic even = 1; 32256058Sbostic i = 2; 32356050Sbostic } 32456058Sbostic } 32556058Sbostic END { 32656058Sbostic for (i = 1; i < 1200; ++i) 32756058Sbostic printf("g\nk%d\n", i); 32856058Sbostic }' > $TMP2 32956058Sbostic $PROG -o $TMP3 recno $TMP2 33056050Sbostic sort -o $TMP1 $TMP1 33156050Sbostic sort -o $TMP3 $TMP3 33257460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 33356050Sbostic else 33464444Sbostic echo "test6: type recno: failed" 33556050Sbostic exit 1 33656050Sbostic fi 33756050Sbostic} 33856050Sbostic 33956058Sbostic# Delete cursor record 34056058Sbostictest7() 34156058Sbostic{ 34264444Sbostic echo "Test 7: btree, recno: delete cursor record" 34356058Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 34456058Sbostic awk '{ 34556058Sbostic for (i = 1; i <= 120; ++i) 34656058Sbostic printf("%05d: input key %d: %s\n", i, i, $0); 34756058Sbostic printf("%05d: input key %d: %s\n", 120, 120, $0); 34856058Sbostic printf("get failed, no such key\n"); 34956058Sbostic printf("%05d: input key %d: %s\n", 1, 1, $0); 35056058Sbostic printf("%05d: input key %d: %s\n", 2, 2, $0); 35156058Sbostic exit; 35256058Sbostic }' > $TMP1 35364444Sbostic rm -f $TMP2 $TMP3 35456763Sbostic 35556058Sbostic for type in btree recno; do 35656058Sbostic cat $TMP1 | 35756058Sbostic awk '{ 35856058Sbostic if (i == 120) 35956058Sbostic exit; 36056058Sbostic printf("p\nk%d\nd%s\n", ++i, $0); 36156058Sbostic } 36256058Sbostic END { 36356058Sbostic printf("fR_NEXT\n"); 36456058Sbostic for (i = 1; i <= 120; ++i) 36556058Sbostic printf("s\n"); 36656058Sbostic printf("fR_CURSOR\ns\nk120\n"); 36756058Sbostic printf("r\nk120\n"); 36856058Sbostic printf("fR_NEXT\ns\n"); 36956058Sbostic printf("fR_CURSOR\ns\nk1\n"); 37056058Sbostic printf("r\nk1\n"); 37156058Sbostic printf("fR_FIRST\ns\n"); 37256058Sbostic }' > $TMP2 37356058Sbostic $PROG -o $TMP3 recno $TMP2 37457460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 37556058Sbostic else 37664444Sbostic echo "test7: type $type: failed" 37756058Sbostic exit 1 37856058Sbostic fi 37956058Sbostic done 38056058Sbostic} 38156058Sbostic 38256495Sbostic# Make sure that overflow pages are reused. 38356085Sbostictest8() 38456085Sbostic{ 38564444Sbostic echo "Test 8: btree, hash: repeated small key, big data pairs" 38656495Sbostic rm -f $TMP1 38764444Sbostic echo "" | 38856495Sbostic awk 'BEGIN { 38956556Sbostic for (i = 1; i <= 10; ++i) { 39056495Sbostic printf("p\nkkey1\nD/bin/sh\n"); 39156495Sbostic printf("p\nkkey2\nD/bin/csh\n"); 39256554Sbostic if (i % 8 == 0) { 39356554Sbostic printf("c\nkkey2\nD/bin/csh\n"); 39456554Sbostic printf("c\nkkey1\nD/bin/sh\n"); 39556763Sbostic printf("e\t%d of 10 (comparison)\r\n", i); 39656554Sbostic } else 39756763Sbostic printf("e\t%d of 10 \r\n", i); 39856495Sbostic printf("r\nkkey1\nr\nkkey2\n"); 39956495Sbostic } 40056556Sbostic printf("e\n"); 40156556Sbostic printf("eend of test8 run\n"); 40256495Sbostic }' > $TMP1 40356554Sbostic $PROG btree $TMP1 40464444Sbostic# $PROG hash $TMP1 40556495Sbostic # No explicit test for success. 40656495Sbostic} 40756495Sbostic 40857001Sbostic# Test btree duplicate keys 40957001Sbostictest9() 41057001Sbostic{ 41164444Sbostic echo "Test 9: btree: duplicate keys" 41257001Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 41357001Sbostic awk '{ 41457001Sbostic for (i = 1; i <= 543; ++i) 41557001Sbostic printf("%05d: input key %d: %s\n", i, i, $0); 41657001Sbostic exit; 41757001Sbostic }' > $TMP1 41864444Sbostic rm -f $TMP2 $TMP3 41957001Sbostic 42057001Sbostic for type in btree; do 42157001Sbostic cat $TMP1 | 42257001Sbostic awk '{ 42357001Sbostic if (i++ % 2) 42457001Sbostic printf("p\nkduplicatekey\nd%s\n", $0); 42557001Sbostic else 42657001Sbostic printf("p\nkunique%dkey\nd%s\n", i, $0); 42757001Sbostic } 42857001Sbostic END { 42957001Sbostic printf("o\n"); 43057001Sbostic }' > $TMP2 43157001Sbostic $PROG -iflags=1 -o $TMP3 $type $TMP2 43257001Sbostic sort -o $TMP3 $TMP3 43357460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 43457001Sbostic else 43564444Sbostic echo "test9: type $type: failed" 43657001Sbostic exit 1 43757001Sbostic fi 43857001Sbostic done 43957001Sbostic} 44057001Sbostic 44156999Sbostic# Test use of cursor flags without initialization 44256999Sbostictest10() 44356999Sbostic{ 44464444Sbostic echo "Test 10: btree, recno: test cursor flag use" 44556999Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 44656999Sbostic awk '{ 44756999Sbostic for (i = 1; i <= 20; ++i) 44856999Sbostic printf("%05d: input key %d: %s\n", i, i, $0); 44956999Sbostic exit; 45056999Sbostic }' > $TMP1 45164444Sbostic rm -f $TMP2 $TMP3 45256999Sbostic 45356999Sbostic # Test that R_CURSOR doesn't succeed before cursor initialized 45456999Sbostic for type in btree recno; do 45556999Sbostic cat $TMP1 | 45656999Sbostic awk '{ 45756999Sbostic if (i == 10) 45856999Sbostic exit; 45956999Sbostic printf("p\nk%d\nd%s\n", ++i, $0); 46056999Sbostic } 46156999Sbostic END { 46256999Sbostic printf("fR_CURSOR\nr\nk1\n"); 46356999Sbostic printf("eR_CURSOR SHOULD HAVE FAILED\n"); 46456999Sbostic }' > $TMP2 46556999Sbostic $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1 46656999Sbostic if [ -s $TMP3 ] ; then 46764444Sbostic echo "Test 10: delete: R_CURSOR SHOULD HAVE FAILED" 46856999Sbostic exit 1 46956999Sbostic fi 47056999Sbostic done 47156999Sbostic for type in btree recno; do 47256999Sbostic cat $TMP1 | 47356999Sbostic awk '{ 47456999Sbostic if (i == 10) 47556999Sbostic exit; 47656999Sbostic printf("p\nk%d\nd%s\n", ++i, $0); 47756999Sbostic } 47856999Sbostic END { 47956999Sbostic printf("fR_CURSOR\np\nk1\ndsome data\n"); 48056999Sbostic printf("eR_CURSOR SHOULD HAVE FAILED\n"); 48156999Sbostic }' > $TMP2 48256999Sbostic $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1 48356999Sbostic if [ -s $TMP3 ] ; then 48464444Sbostic echo "Test 10: put: R_CURSOR SHOULD HAVE FAILED" 48556999Sbostic exit 1 48656999Sbostic fi 48756999Sbostic done 48856999Sbostic} 48956999Sbostic 49056999Sbostic# Test insert in reverse order. 49156999Sbostictest11() 49256999Sbostic{ 49364444Sbostic echo "Test 11: recno: reverse order insert" 49456999Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 49556999Sbostic awk '{ 49656999Sbostic for (i = 1; i <= 779; ++i) 49756999Sbostic printf("%05d: input key %d: %s\n", i, i, $0); 49856999Sbostic exit; 49956999Sbostic }' > $TMP1 50064444Sbostic rm -f $TMP2 $TMP3 50156999Sbostic 50256999Sbostic for type in recno; do 50356999Sbostic cat $TMP1 | 50456999Sbostic awk '{ 50556999Sbostic if (i == 0) { 50656999Sbostic i = 1; 50756999Sbostic printf("p\nk1\nd%s\n", $0); 50856999Sbostic printf("%s\n", "fR_IBEFORE"); 50956999Sbostic } else 51056999Sbostic printf("p\nk1\nd%s\n", $0); 51156999Sbostic } 51256999Sbostic END { 51356999Sbostic printf("or\n"); 51456999Sbostic }' > $TMP2 51556999Sbostic $PROG -o $TMP3 $type $TMP2 51657460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 51756999Sbostic else 51864444Sbostic echo "test11: type $type: failed" 51956999Sbostic exit 1 52056999Sbostic fi 52156999Sbostic done 52256999Sbostic} 52356999Sbostic 52457455Sbostic# Take the first 20000 entries in the dictionary, reverse them, and give 52557455Sbostic# them each a small size data entry. Use a small page size to make sure 52657455Sbostic# the btree split code gets hammered. 52757455Sbostictest12() 52857455Sbostic{ 52964444Sbostic echo "Test 12: btree: lots of keys, small page size" 53057455Sbostic mdata=abcdefghijklmnopqrstuvwxy 53157455Sbostic echo $mdata | 53257455Sbostic awk '{ for (i = 1; i < 20001; ++i) print $0 }' > $TMP1 53357455Sbostic for type in btree; do 53457455Sbostic rm -f $TMP2 $TMP3 53557455Sbostic for i in `sed 20000q $DICT | rev`; do 53664444Sbostic echo p 53764444Sbostic echo k$i 53864444Sbostic echo d$mdata 53964444Sbostic echo g 54064444Sbostic echo k$i 54157455Sbostic done > $TMP2 54257455Sbostic $PROG -i psize=512 -o $TMP3 $type $TMP2 54357460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 54457455Sbostic else 54564444Sbostic echo "test12: type $type: failed" 54657455Sbostic exit 1 54757455Sbostic fi 54857455Sbostic done 54957455Sbostic} 55057455Sbostic 55159633Sbostic# Test different byte orders. 55259633Sbostictest13() 55359633Sbostic{ 55464444Sbostic echo "Test 13: btree, hash: differing byte orders" 55559633Sbostic sed 50q $DICT > $TMP1 55659633Sbostic for order in 1234 4321; do 55759633Sbostic for type in btree hash; do 55859633Sbostic rm -f byte.file $TMP2 $TMP3 55959633Sbostic for i in `sed 50q $DICT`; do 56064444Sbostic echo p 56164444Sbostic echo k$i 56264444Sbostic echo d$i 56364444Sbostic echo g 56464444Sbostic echo k$i 56559633Sbostic done > $TMP2 56659633Sbostic $PROG -ilorder=$order -f byte.file -o $TMP3 $type $TMP2 56759633Sbostic if (cmp -s $TMP1 $TMP3) ; then : 56859633Sbostic else 56964444Sbostic echo "test13: $type/$order put failed" 57059633Sbostic exit 1 57159633Sbostic fi 57259633Sbostic for i in `sed 50q $DICT`; do 57364444Sbostic echo g 57464444Sbostic echo k$i 57559633Sbostic done > $TMP2 57659633Sbostic $PROG -ilorder=$order -f byte.file -o $TMP3 $type $TMP2 57759633Sbostic if (cmp -s $TMP1 $TMP3) ; then : 57859633Sbostic else 57964444Sbostic echo "test13: $type/$order get failed" 58059633Sbostic exit 1 58159633Sbostic fi 58259633Sbostic done 58359633Sbostic done 58459633Sbostic rm -f byte.file 58559633Sbostic} 58659633Sbostic 58756495Sbostic# Try a variety of bucketsizes and fill factors for hashing 58856999Sbostictest20() 58956495Sbostic{ 59064444Sbostic echo\ 59164444Sbostic "Test 20: hash: bucketsize, fill factor; nelem 25000 cachesize 65536" 59264471Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 59364471Sbostic awk '{ 59464471Sbostic for (i = 1; i <= 10000; ++i) { 59564471Sbostic if (i % 34) 59664471Sbostic s = substr($0, 1, i % 34); 59764471Sbostic else 59864471Sbostic s = substr($0, 1); 59964471Sbostic printf("%s\n", s); 60064471Sbostic } 60164471Sbostic exit; 60256085Sbostic }' > $TMP1 60356085Sbostic sed 10000q $DICT | 60464471Sbostic awk 'BEGIN { 60564471Sbostic ds="abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" 60664471Sbostic } 60764471Sbostic { 60864471Sbostic if (++i % 34) 60964471Sbostic s = substr(ds, 1, i % 34); 61064471Sbostic else 61164471Sbostic s = substr(ds, 1); 61264471Sbostic printf("p\nk%s\nd%s\n", $0, s); 61356085Sbostic }' > $TMP2 61456085Sbostic sed 10000q $DICT | 61556085Sbostic awk '{ 61656085Sbostic ++i; 61756085Sbostic printf("g\nk%s\n", $0); 61856085Sbostic }' >> $TMP2 61956085Sbostic bsize=256 62056085Sbostic for ffactor in 11 14 21; do 62164444Sbostic echo " bucketsize $bsize, fill factor $ffactor" 62256495Sbostic $PROG -o$TMP3 \ 62356085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 62456085Sbostic hash $TMP2 62557460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 62656085Sbostic else 62764444Sbostic echo "test20: type hash:\ 62864444Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" 62956085Sbostic exit 1 63056085Sbostic fi 63156085Sbostic done 63256085Sbostic bsize=512 63356085Sbostic for ffactor in 21 28 43; do 63464444Sbostic echo " bucketsize $bsize, fill factor $ffactor" 63556495Sbostic $PROG -o$TMP3 \ 63656085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 63756085Sbostic hash $TMP2 63857460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 63956085Sbostic else 64064444Sbostic echo "test20: type hash:\ 64164444Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" 64256085Sbostic exit 1 64356085Sbostic fi 64456085Sbostic done 64556085Sbostic bsize=1024 64656085Sbostic for ffactor in 43 57 85; do 64764444Sbostic echo " bucketsize $bsize, fill factor $ffactor" 64856495Sbostic $PROG -o$TMP3 \ 64956085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 65056085Sbostic hash $TMP2 65157460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 65256085Sbostic else 65364444Sbostic echo "test20: type hash:\ 65464444Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" 65556085Sbostic exit 1 65656085Sbostic fi 65756085Sbostic done 65856085Sbostic bsize=2048 65956085Sbostic for ffactor in 85 114 171; do 66064444Sbostic echo " bucketsize $bsize, fill factor $ffactor" 66156495Sbostic $PROG -o$TMP3 \ 66256085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 66356085Sbostic hash $TMP2 66457460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 66556085Sbostic else 66664444Sbostic echo "test20: type hash:\ 66764444Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" 66856085Sbostic exit 1 66956085Sbostic fi 67056085Sbostic done 67156085Sbostic bsize=4096 67256085Sbostic for ffactor in 171 228 341; do 67364444Sbostic echo " bucketsize $bsize, fill factor $ffactor" 67456495Sbostic $PROG -o$TMP3 \ 67556085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 67656085Sbostic hash $TMP2 67757460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 67856085Sbostic else 67964444Sbostic echo "test20: type hash:\ 68064444Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" 68156085Sbostic exit 1 68256085Sbostic fi 68356085Sbostic done 68456085Sbostic bsize=8192 68556085Sbostic for ffactor in 341 455 683; do 68664444Sbostic echo " bucketsize $bsize, fill factor $ffactor" 68756495Sbostic $PROG -o$TMP3 \ 68856085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 68956085Sbostic hash $TMP2 69057460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 69156085Sbostic else 69264444Sbostic echo "test20: type hash:\ 69364444Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" 69456085Sbostic exit 1 69556085Sbostic fi 69656085Sbostic done 69756085Sbostic} 69856085Sbostic 69964444Sbosticmain $* 700