156038Sbostic#!/bin/sh - 256038Sbostic# 3*64471Sbostic# @(#)run.test 8.6 (Berkeley) 09/07/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 1764444Sbostic if [ $# -ge 1 ]; then 1864444Sbostic for i in "$*"; do 1964444Sbostic test$i 2064444Sbostic done 2164444Sbostic else 2264444Sbostic test1 2364444Sbostic test2 2464444Sbostic test3 2564444Sbostic test4 2664444Sbostic test5 2764444Sbostic test6 2864444Sbostic test7 2964444Sbostic test8 3064444Sbostic test9 3164444Sbostic test10 3264444Sbostic test11 3364444Sbostic test12 3464444Sbostic test13 3564444Sbostic test20 3664444Sbostic fi 3764451Sbostic rm -f $TMP1 $TMP2 $TMP3 3856999Sbostic exit 0 3956038Sbostic} 4056038Sbostic 4156038Sbostic# Take the first hundred entries in the dictionary, and make them 4256038Sbostic# be key/data pairs. 4356038Sbostictest1() 4456038Sbostic{ 4564444Sbostic echo "Test 1: btree, hash: small key, small data pairs" 4656085Sbostic sed 200q $DICT > $TMP1 4756038Sbostic for type in btree hash; do 4856038Sbostic rm -f $TMP2 $TMP3 4956038Sbostic for i in `sed 200q $DICT`; do 5064444Sbostic echo p 5164444Sbostic echo k$i 5264444Sbostic echo d$i 5364444Sbostic echo g 5464444Sbostic echo k$i 5556038Sbostic done > $TMP2 5656058Sbostic $PROG -o $TMP3 $type $TMP2 5757460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 5856038Sbostic else 5964444Sbostic echo "test1: type $type: failed" 6056038Sbostic exit 1 6156038Sbostic fi 6256038Sbostic done 6364444Sbostic echo "Test 1: recno: small key, small data pairs" 6456038Sbostic rm -f $TMP2 $TMP3 6556038Sbostic sed 200q $DICT | 6656058Sbostic awk '{ 6756058Sbostic ++i; 6856058Sbostic printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); 6956058Sbostic }' > $TMP2 7056058Sbostic $PROG -o $TMP3 recno $TMP2 7157460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 7256038Sbostic else 7364444Sbostic echo "test1: type recno: failed" 7456038Sbostic exit 1 7556038Sbostic fi 7656038Sbostic} 7756038Sbostic 7857455Sbostic# Take the first 200 entries in the dictionary, and give them 7956038Sbostic# each a medium size data entry. 8056038Sbostictest2() 8156038Sbostic{ 8264444Sbostic echo "Test 2: btree, hash: small key, medium data pairs" 8356038Sbostic mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz 8456038Sbostic echo $mdata | 8556058Sbostic awk '{ for (i = 1; i < 201; ++i) print $0 }' > $TMP1 8656038Sbostic for type in hash btree; do 8756038Sbostic rm -f $TMP2 $TMP3 8856038Sbostic for i in `sed 200q $DICT`; do 8964444Sbostic echo p 9064444Sbostic echo k$i 9164444Sbostic echo d$mdata 9264444Sbostic echo g 9364444Sbostic echo k$i 9456038Sbostic done > $TMP2 9556058Sbostic $PROG -o $TMP3 $type $TMP2 9657460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 9756038Sbostic else 9864444Sbostic echo "test2: type $type: failed" 9956038Sbostic exit 1 10056038Sbostic fi 10156038Sbostic done 10264444Sbostic echo "Test 2: recno: small key, medium data pairs" 10356038Sbostic rm -f $TMP2 $TMP3 10456038Sbostic echo $mdata | 10556058Sbostic awk '{ for (i = 1; i < 201; ++i) 10656058Sbostic printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); 10756058Sbostic }' > $TMP2 10856058Sbostic $PROG -o $TMP3 recno $TMP2 10957460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 11056038Sbostic else 11164444Sbostic echo "test2: type recno: failed" 11256038Sbostic exit 1 11356038Sbostic fi 11456038Sbostic} 11556038Sbostic 11656038Sbostic# Insert the programs in /bin with their paths as their keys. 11756038Sbostictest3() 11856038Sbostic{ 11964444Sbostic echo "Test 3: hash: small key, big data pairs" 12056038Sbostic rm -f $TMP1 12156038Sbostic (find /bin -type f -print | xargs cat) > $TMP1 12260233Sbostic for type in hash; do 12356038Sbostic rm -f $TMP2 $TMP3 12456038Sbostic for i in `find /bin -type f -print`; do 12564444Sbostic echo p 12664444Sbostic echo k$i 12764444Sbostic echo D$i 12864444Sbostic echo g 12964444Sbostic echo k$i 13056038Sbostic done > $TMP2 13156058Sbostic $PROG -o $TMP3 $type $TMP2 13257460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 13356038Sbostic else 13464444Sbostic echo "test3: $type: failed" 13556038Sbostic exit 1 13656038Sbostic fi 13756038Sbostic done 13864444Sbostic echo "Test 3: btree: small key, big data pairs" 13960233Sbostic for psize in 512 16384 65536; do 14064444Sbostic echo " page size $psize" 14160233Sbostic for type in btree; do 14260233Sbostic rm -f $TMP2 $TMP3 14360233Sbostic for i in `find /bin -type f -print`; do 14464444Sbostic echo p 14564444Sbostic echo k$i 14664444Sbostic echo D$i 14764444Sbostic echo g 14864444Sbostic echo k$i 14960233Sbostic done > $TMP2 15060233Sbostic $PROG -i psize=$psize -o $TMP3 $type $TMP2 15160233Sbostic if (cmp -s $TMP1 $TMP3) ; then : 15260233Sbostic else 15364444Sbostic echo "test3: $type: page size $psize: failed" 15460233Sbostic exit 1 15560233Sbostic fi 15660233Sbostic done 15760233Sbostic done 15864444Sbostic echo "Test 3: recno: big data pairs" 15956038Sbostic rm -f $TMP2 $TMP3 16056038Sbostic find /bin -type f -print | 16156058Sbostic awk '{ 16256058Sbostic ++i; 16356058Sbostic printf("p\nk%d\nD%s\ng\nk%d\n", i, $0, i); 16456058Sbostic }' > $TMP2 16560233Sbostic for psize in 512 16384 65536; do 16664444Sbostic echo " page size $psize" 16760233Sbostic $PROG -i psize=$psize -o $TMP3 recno $TMP2 16860233Sbostic if (cmp -s $TMP1 $TMP3) ; then : 16960233Sbostic else 17064444Sbostic echo "test3: recno: page size $psize: failed" 17160233Sbostic exit 1 17260233Sbostic fi 17360233Sbostic done 17456038Sbostic} 17556038Sbostic 17656038Sbostic# Do random recno entries. 17756038Sbostictest4() 17856038Sbostic{ 17964444Sbostic echo "Test 4: recno: random entries" 18056050Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 18156058Sbostic awk '{ 18264444Sbostic for (i = 37; i <= 37 + 88 * 17; i += 17) { 183*64471Sbostic if (i % 41) 184*64471Sbostic s = substr($0, 1, i % 41); 185*64471Sbostic else 186*64471Sbostic s = substr($0, 1); 18764444Sbostic printf("input key %d: %s\n", i, s); 18864444Sbostic } 18964444Sbostic for (i = 1; i <= 15; ++i) { 190*64471Sbostic if (i % 41) 191*64471Sbostic s = substr($0, 1, i % 41); 192*64471Sbostic else 193*64471Sbostic s = substr($0, 1); 19464444Sbostic printf("input key %d: %s\n", i, s); 19564444Sbostic } 19664444Sbostic for (i = 19234; i <= 19234 + 61 * 27; i += 27) { 197*64471Sbostic if (i % 41) 198*64471Sbostic s = substr($0, 1, i % 41); 199*64471Sbostic else 200*64471Sbostic s = substr($0, 1); 20164444Sbostic printf("input key %d: %s\n", i, s); 20264444Sbostic } 20356058Sbostic exit 20456058Sbostic }' > $TMP1 20564287Sbostic rm -f $TMP2 $TMP3 20656058Sbostic cat $TMP1 | 20756058Sbostic awk 'BEGIN { 20856058Sbostic i = 37; 20956058Sbostic incr = 17; 21056058Sbostic } 21156058Sbostic { 21256058Sbostic printf("p\nk%d\nd%s\n", i, $0); 21356058Sbostic if (i == 19234 + 61 * 27) 21456058Sbostic exit; 21556058Sbostic if (i == 37 + 88 * 17) { 21656058Sbostic i = 1; 21756058Sbostic incr = 1; 21856058Sbostic } else if (i == 15) { 21956058Sbostic i = 19234; 22056058Sbostic incr = 27; 22156058Sbostic } else 22256058Sbostic i += incr; 22356058Sbostic } 22456058Sbostic END { 22556038Sbostic for (i = 37; i <= 37 + 88 * 17; i += 17) 22656058Sbostic printf("g\nk%d\n", i); 22756038Sbostic for (i = 1; i <= 15; ++i) 22856058Sbostic printf("g\nk%d\n", i); 22956038Sbostic for (i = 19234; i <= 19234 + 61 * 27; i += 27) 23056058Sbostic printf("g\nk%d\n", i); 23156058Sbostic }' > $TMP2 23256058Sbostic $PROG -o $TMP3 recno $TMP2 23357460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 23456038Sbostic else 23564444Sbostic echo "test4: type recno: failed" 23656038Sbostic exit 1 23756038Sbostic fi 23856038Sbostic} 23956050Sbostic 24056050Sbostic# Do reverse order recno entries. 24156050Sbostictest5() 24256050Sbostic{ 24364444Sbostic echo "Test 5: recno: reverse order entries" 24456050Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 24556058Sbostic awk ' { 24664444Sbostic for (i = 1500; i; --i) { 247*64471Sbostic if (i % 34) 248*64471Sbostic s = substr($0, 1, i % 34); 249*64471Sbostic else 250*64471Sbostic s = substr($0, 1); 25164444Sbostic printf("input key %d: %s\n", i, s); 25264444Sbostic } 25356058Sbostic exit; 25456058Sbostic }' > $TMP1 25564287Sbostic rm -f $TMP2 $TMP3 25656058Sbostic cat $TMP1 | 25756058Sbostic awk 'BEGIN { 25856058Sbostic i = 1500; 25956058Sbostic } 26056058Sbostic { 26156058Sbostic printf("p\nk%d\nd%s\n", i, $0); 26256058Sbostic --i; 26356058Sbostic } 26456058Sbostic END { 26556058Sbostic for (i = 1500; i; --i) 26656058Sbostic printf("g\nk%d\n", i); 26756058Sbostic }' > $TMP2 26856058Sbostic $PROG -o $TMP3 recno $TMP2 26957460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 27056050Sbostic else 27164444Sbostic echo "test5: type recno: failed" 27256050Sbostic exit 1 27356050Sbostic fi 27456050Sbostic} 27556038Sbostic 27656050Sbostic# Do alternating order recno entries. 27756050Sbostictest6() 27856050Sbostic{ 27964444Sbostic echo "Test 6: recno: alternating order entries" 28056050Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 28156058Sbostic awk ' { 28264444Sbostic for (i = 1; i < 1200; i += 2) { 283*64471Sbostic if (i % 34) 284*64471Sbostic s = substr($0, 1, i % 34); 285*64471Sbostic else 286*64471Sbostic s = substr($0, 1); 28764444Sbostic printf("input key %d: %s\n", i, s); 28864444Sbostic } 28964444Sbostic for (i = 2; i < 1200; i += 2) { 290*64471Sbostic if (i % 34) 291*64471Sbostic s = substr($0, 1, i % 34); 292*64471Sbostic else 293*64471Sbostic s = substr($0, 1); 29464444Sbostic printf("input key %d: %s\n", i, s); 29564444Sbostic } 29656058Sbostic exit; 29756058Sbostic }' > $TMP1 29864444Sbostic rm -f $TMP2 $TMP3 29956058Sbostic cat $TMP1 | 30056058Sbostic awk 'BEGIN { 30156058Sbostic i = 1; 30256058Sbostic even = 0; 30356058Sbostic } 30456058Sbostic { 30556058Sbostic printf("p\nk%d\nd%s\n", i, $0); 30656058Sbostic i += 2; 30756058Sbostic if (i >= 1200) { 30856058Sbostic if (even == 1) 30956058Sbostic exit; 31056058Sbostic even = 1; 31156058Sbostic i = 2; 31256050Sbostic } 31356058Sbostic } 31456058Sbostic END { 31556058Sbostic for (i = 1; i < 1200; ++i) 31656058Sbostic printf("g\nk%d\n", i); 31756058Sbostic }' > $TMP2 31856058Sbostic $PROG -o $TMP3 recno $TMP2 31956050Sbostic sort -o $TMP1 $TMP1 32056050Sbostic sort -o $TMP3 $TMP3 32157460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 32256050Sbostic else 32364444Sbostic echo "test6: type recno: failed" 32456050Sbostic exit 1 32556050Sbostic fi 32656050Sbostic} 32756050Sbostic 32856058Sbostic# Delete cursor record 32956058Sbostictest7() 33056058Sbostic{ 33164444Sbostic echo "Test 7: btree, recno: delete cursor record" 33256058Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 33356058Sbostic awk '{ 33456058Sbostic for (i = 1; i <= 120; ++i) 33556058Sbostic printf("%05d: input key %d: %s\n", i, i, $0); 33656058Sbostic printf("%05d: input key %d: %s\n", 120, 120, $0); 33756058Sbostic printf("get failed, no such key\n"); 33856058Sbostic printf("%05d: input key %d: %s\n", 1, 1, $0); 33956058Sbostic printf("%05d: input key %d: %s\n", 2, 2, $0); 34056058Sbostic exit; 34156058Sbostic }' > $TMP1 34264444Sbostic rm -f $TMP2 $TMP3 34356763Sbostic 34456058Sbostic for type in btree recno; do 34556058Sbostic cat $TMP1 | 34656058Sbostic awk '{ 34756058Sbostic if (i == 120) 34856058Sbostic exit; 34956058Sbostic printf("p\nk%d\nd%s\n", ++i, $0); 35056058Sbostic } 35156058Sbostic END { 35256058Sbostic printf("fR_NEXT\n"); 35356058Sbostic for (i = 1; i <= 120; ++i) 35456058Sbostic printf("s\n"); 35556058Sbostic printf("fR_CURSOR\ns\nk120\n"); 35656058Sbostic printf("r\nk120\n"); 35756058Sbostic printf("fR_NEXT\ns\n"); 35856058Sbostic printf("fR_CURSOR\ns\nk1\n"); 35956058Sbostic printf("r\nk1\n"); 36056058Sbostic printf("fR_FIRST\ns\n"); 36156058Sbostic }' > $TMP2 36256058Sbostic $PROG -o $TMP3 recno $TMP2 36357460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 36456058Sbostic else 36564444Sbostic echo "test7: type $type: failed" 36656058Sbostic exit 1 36756058Sbostic fi 36856058Sbostic done 36956058Sbostic} 37056058Sbostic 37156495Sbostic# Make sure that overflow pages are reused. 37256085Sbostictest8() 37356085Sbostic{ 37464444Sbostic echo "Test 8: btree, hash: repeated small key, big data pairs" 37556495Sbostic rm -f $TMP1 37664444Sbostic echo "" | 37756495Sbostic awk 'BEGIN { 37856556Sbostic for (i = 1; i <= 10; ++i) { 37956495Sbostic printf("p\nkkey1\nD/bin/sh\n"); 38056495Sbostic printf("p\nkkey2\nD/bin/csh\n"); 38156554Sbostic if (i % 8 == 0) { 38256554Sbostic printf("c\nkkey2\nD/bin/csh\n"); 38356554Sbostic printf("c\nkkey1\nD/bin/sh\n"); 38456763Sbostic printf("e\t%d of 10 (comparison)\r\n", i); 38556554Sbostic } else 38656763Sbostic printf("e\t%d of 10 \r\n", i); 38756495Sbostic printf("r\nkkey1\nr\nkkey2\n"); 38856495Sbostic } 38956556Sbostic printf("e\n"); 39056556Sbostic printf("eend of test8 run\n"); 39156495Sbostic }' > $TMP1 39256554Sbostic $PROG btree $TMP1 39364444Sbostic# $PROG hash $TMP1 39456495Sbostic # No explicit test for success. 39556495Sbostic} 39656495Sbostic 39757001Sbostic# Test btree duplicate keys 39857001Sbostictest9() 39957001Sbostic{ 40064444Sbostic echo "Test 9: btree: duplicate keys" 40157001Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 40257001Sbostic awk '{ 40357001Sbostic for (i = 1; i <= 543; ++i) 40457001Sbostic printf("%05d: input key %d: %s\n", i, i, $0); 40557001Sbostic exit; 40657001Sbostic }' > $TMP1 40764444Sbostic rm -f $TMP2 $TMP3 40857001Sbostic 40957001Sbostic for type in btree; do 41057001Sbostic cat $TMP1 | 41157001Sbostic awk '{ 41257001Sbostic if (i++ % 2) 41357001Sbostic printf("p\nkduplicatekey\nd%s\n", $0); 41457001Sbostic else 41557001Sbostic printf("p\nkunique%dkey\nd%s\n", i, $0); 41657001Sbostic } 41757001Sbostic END { 41857001Sbostic printf("o\n"); 41957001Sbostic }' > $TMP2 42057001Sbostic $PROG -iflags=1 -o $TMP3 $type $TMP2 42157001Sbostic sort -o $TMP3 $TMP3 42257460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 42357001Sbostic else 42464444Sbostic echo "test9: type $type: failed" 42557001Sbostic exit 1 42657001Sbostic fi 42757001Sbostic done 42857001Sbostic} 42957001Sbostic 43056999Sbostic# Test use of cursor flags without initialization 43156999Sbostictest10() 43256999Sbostic{ 43364444Sbostic echo "Test 10: btree, recno: test cursor flag use" 43456999Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 43556999Sbostic awk '{ 43656999Sbostic for (i = 1; i <= 20; ++i) 43756999Sbostic printf("%05d: input key %d: %s\n", i, i, $0); 43856999Sbostic exit; 43956999Sbostic }' > $TMP1 44064444Sbostic rm -f $TMP2 $TMP3 44156999Sbostic 44256999Sbostic # Test that R_CURSOR doesn't succeed before cursor initialized 44356999Sbostic for type in btree recno; do 44456999Sbostic cat $TMP1 | 44556999Sbostic awk '{ 44656999Sbostic if (i == 10) 44756999Sbostic exit; 44856999Sbostic printf("p\nk%d\nd%s\n", ++i, $0); 44956999Sbostic } 45056999Sbostic END { 45156999Sbostic printf("fR_CURSOR\nr\nk1\n"); 45256999Sbostic printf("eR_CURSOR SHOULD HAVE FAILED\n"); 45356999Sbostic }' > $TMP2 45456999Sbostic $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1 45556999Sbostic if [ -s $TMP3 ] ; then 45664444Sbostic echo "Test 10: delete: R_CURSOR SHOULD HAVE FAILED" 45756999Sbostic exit 1 45856999Sbostic fi 45956999Sbostic done 46056999Sbostic for type in btree recno; do 46156999Sbostic cat $TMP1 | 46256999Sbostic awk '{ 46356999Sbostic if (i == 10) 46456999Sbostic exit; 46556999Sbostic printf("p\nk%d\nd%s\n", ++i, $0); 46656999Sbostic } 46756999Sbostic END { 46856999Sbostic printf("fR_CURSOR\np\nk1\ndsome data\n"); 46956999Sbostic printf("eR_CURSOR SHOULD HAVE FAILED\n"); 47056999Sbostic }' > $TMP2 47156999Sbostic $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1 47256999Sbostic if [ -s $TMP3 ] ; then 47364444Sbostic echo "Test 10: put: R_CURSOR SHOULD HAVE FAILED" 47456999Sbostic exit 1 47556999Sbostic fi 47656999Sbostic done 47756999Sbostic} 47856999Sbostic 47956999Sbostic# Test insert in reverse order. 48056999Sbostictest11() 48156999Sbostic{ 48264444Sbostic echo "Test 11: recno: reverse order insert" 48356999Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 48456999Sbostic awk '{ 48556999Sbostic for (i = 1; i <= 779; ++i) 48656999Sbostic printf("%05d: input key %d: %s\n", i, i, $0); 48756999Sbostic exit; 48856999Sbostic }' > $TMP1 48964444Sbostic rm -f $TMP2 $TMP3 49056999Sbostic 49156999Sbostic for type in recno; do 49256999Sbostic cat $TMP1 | 49356999Sbostic awk '{ 49456999Sbostic if (i == 0) { 49556999Sbostic i = 1; 49656999Sbostic printf("p\nk1\nd%s\n", $0); 49756999Sbostic printf("%s\n", "fR_IBEFORE"); 49856999Sbostic } else 49956999Sbostic printf("p\nk1\nd%s\n", $0); 50056999Sbostic } 50156999Sbostic END { 50256999Sbostic printf("or\n"); 50356999Sbostic }' > $TMP2 50456999Sbostic $PROG -o $TMP3 $type $TMP2 50557460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 50656999Sbostic else 50764444Sbostic echo "test11: type $type: failed" 50856999Sbostic exit 1 50956999Sbostic fi 51056999Sbostic done 51156999Sbostic} 51256999Sbostic 51357455Sbostic# Take the first 20000 entries in the dictionary, reverse them, and give 51457455Sbostic# them each a small size data entry. Use a small page size to make sure 51557455Sbostic# the btree split code gets hammered. 51657455Sbostictest12() 51757455Sbostic{ 51864444Sbostic echo "Test 12: btree: lots of keys, small page size" 51957455Sbostic mdata=abcdefghijklmnopqrstuvwxy 52057455Sbostic echo $mdata | 52157455Sbostic awk '{ for (i = 1; i < 20001; ++i) print $0 }' > $TMP1 52257455Sbostic for type in btree; do 52357455Sbostic rm -f $TMP2 $TMP3 52457455Sbostic for i in `sed 20000q $DICT | rev`; do 52564444Sbostic echo p 52664444Sbostic echo k$i 52764444Sbostic echo d$mdata 52864444Sbostic echo g 52964444Sbostic echo k$i 53057455Sbostic done > $TMP2 53157455Sbostic $PROG -i psize=512 -o $TMP3 $type $TMP2 53257460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 53357455Sbostic else 53464444Sbostic echo "test12: type $type: failed" 53557455Sbostic exit 1 53657455Sbostic fi 53757455Sbostic done 53857455Sbostic} 53957455Sbostic 54059633Sbostic# Test different byte orders. 54159633Sbostictest13() 54259633Sbostic{ 54364444Sbostic echo "Test 13: btree, hash: differing byte orders" 54459633Sbostic sed 50q $DICT > $TMP1 54559633Sbostic for order in 1234 4321; do 54659633Sbostic for type in btree hash; do 54759633Sbostic rm -f byte.file $TMP2 $TMP3 54859633Sbostic for i in `sed 50q $DICT`; do 54964444Sbostic echo p 55064444Sbostic echo k$i 55164444Sbostic echo d$i 55264444Sbostic echo g 55364444Sbostic echo k$i 55459633Sbostic done > $TMP2 55559633Sbostic $PROG -ilorder=$order -f byte.file -o $TMP3 $type $TMP2 55659633Sbostic if (cmp -s $TMP1 $TMP3) ; then : 55759633Sbostic else 55864444Sbostic echo "test13: $type/$order put failed" 55959633Sbostic exit 1 56059633Sbostic fi 56159633Sbostic for i in `sed 50q $DICT`; do 56264444Sbostic echo g 56364444Sbostic echo k$i 56459633Sbostic done > $TMP2 56559633Sbostic $PROG -ilorder=$order -f byte.file -o $TMP3 $type $TMP2 56659633Sbostic if (cmp -s $TMP1 $TMP3) ; then : 56759633Sbostic else 56864444Sbostic echo "test13: $type/$order get failed" 56959633Sbostic exit 1 57059633Sbostic fi 57159633Sbostic done 57259633Sbostic done 57359633Sbostic rm -f byte.file 57459633Sbostic} 57559633Sbostic 57656495Sbostic# Try a variety of bucketsizes and fill factors for hashing 57756999Sbostictest20() 57856495Sbostic{ 57964444Sbostic echo\ 58064444Sbostic "Test 20: hash: bucketsize, fill factor; nelem 25000 cachesize 65536" 581*64471Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 582*64471Sbostic awk '{ 583*64471Sbostic for (i = 1; i <= 10000; ++i) { 584*64471Sbostic if (i % 34) 585*64471Sbostic s = substr($0, 1, i % 34); 586*64471Sbostic else 587*64471Sbostic s = substr($0, 1); 588*64471Sbostic printf("%s\n", s); 589*64471Sbostic } 590*64471Sbostic exit; 59156085Sbostic }' > $TMP1 59256085Sbostic sed 10000q $DICT | 593*64471Sbostic awk 'BEGIN { 594*64471Sbostic ds="abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" 595*64471Sbostic } 596*64471Sbostic { 597*64471Sbostic if (++i % 34) 598*64471Sbostic s = substr(ds, 1, i % 34); 599*64471Sbostic else 600*64471Sbostic s = substr(ds, 1); 601*64471Sbostic printf("p\nk%s\nd%s\n", $0, s); 60256085Sbostic }' > $TMP2 60356085Sbostic sed 10000q $DICT | 60456085Sbostic awk '{ 60556085Sbostic ++i; 60656085Sbostic printf("g\nk%s\n", $0); 60756085Sbostic }' >> $TMP2 60856085Sbostic bsize=256 60956085Sbostic for ffactor in 11 14 21; do 61064444Sbostic echo " bucketsize $bsize, fill factor $ffactor" 61156495Sbostic $PROG -o$TMP3 \ 61256085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 61356085Sbostic hash $TMP2 61457460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 61556085Sbostic else 61664444Sbostic echo "test20: type hash:\ 61764444Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" 61856085Sbostic exit 1 61956085Sbostic fi 62056085Sbostic done 62156085Sbostic bsize=512 62256085Sbostic for ffactor in 21 28 43; do 62364444Sbostic echo " bucketsize $bsize, fill factor $ffactor" 62456495Sbostic $PROG -o$TMP3 \ 62556085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 62656085Sbostic hash $TMP2 62757460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 62856085Sbostic else 62964444Sbostic echo "test20: type hash:\ 63064444Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" 63156085Sbostic exit 1 63256085Sbostic fi 63356085Sbostic done 63456085Sbostic bsize=1024 63556085Sbostic for ffactor in 43 57 85; do 63664444Sbostic echo " bucketsize $bsize, fill factor $ffactor" 63756495Sbostic $PROG -o$TMP3 \ 63856085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 63956085Sbostic hash $TMP2 64057460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 64156085Sbostic else 64264444Sbostic echo "test20: type hash:\ 64364444Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" 64456085Sbostic exit 1 64556085Sbostic fi 64656085Sbostic done 64756085Sbostic bsize=2048 64856085Sbostic for ffactor in 85 114 171; do 64964444Sbostic echo " bucketsize $bsize, fill factor $ffactor" 65056495Sbostic $PROG -o$TMP3 \ 65156085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 65256085Sbostic hash $TMP2 65357460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 65456085Sbostic else 65564444Sbostic echo "test20: type hash:\ 65664444Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" 65756085Sbostic exit 1 65856085Sbostic fi 65956085Sbostic done 66056085Sbostic bsize=4096 66156085Sbostic for ffactor in 171 228 341; do 66264444Sbostic echo " bucketsize $bsize, fill factor $ffactor" 66356495Sbostic $PROG -o$TMP3 \ 66456085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 66556085Sbostic hash $TMP2 66657460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 66756085Sbostic else 66864444Sbostic echo "test20: type hash:\ 66964444Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" 67056085Sbostic exit 1 67156085Sbostic fi 67256085Sbostic done 67356085Sbostic bsize=8192 67456085Sbostic for ffactor in 341 455 683; do 67564444Sbostic echo " bucketsize $bsize, fill factor $ffactor" 67656495Sbostic $PROG -o$TMP3 \ 67756085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 67856085Sbostic hash $TMP2 67957460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 68056085Sbostic else 68164444Sbostic echo "test20: type hash:\ 68264444Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" 68356085Sbostic exit 1 68456085Sbostic fi 68556085Sbostic done 68656085Sbostic} 68756085Sbostic 68864444Sbosticmain $* 689