156038Sbostic#!/bin/sh - 256038Sbostic# 3*64451Sbostic# @(#)run.test 8.5 (Berkeley) 09/06/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 37*64451Sbostic 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) { 18364444Sbostic s = substr($0, 1, i % 41); 18464444Sbostic printf("input key %d: %s\n", i, s); 18564444Sbostic } 18664444Sbostic for (i = 1; i <= 15; ++i) { 18764444Sbostic s = substr($0, 1, i % 41); 18864444Sbostic printf("input key %d: %s\n", i, s); 18964444Sbostic } 19064444Sbostic for (i = 19234; i <= 19234 + 61 * 27; i += 27) { 19164444Sbostic s = substr($0, 1, i % 41); 19264444Sbostic printf("input key %d: %s\n", i, s); 19364444Sbostic } 19456058Sbostic exit 19556058Sbostic }' > $TMP1 19664287Sbostic rm -f $TMP2 $TMP3 19756058Sbostic cat $TMP1 | 19856058Sbostic awk 'BEGIN { 19956058Sbostic i = 37; 20056058Sbostic incr = 17; 20156058Sbostic } 20256058Sbostic { 20356058Sbostic printf("p\nk%d\nd%s\n", i, $0); 20456058Sbostic if (i == 19234 + 61 * 27) 20556058Sbostic exit; 20656058Sbostic if (i == 37 + 88 * 17) { 20756058Sbostic i = 1; 20856058Sbostic incr = 1; 20956058Sbostic } else if (i == 15) { 21056058Sbostic i = 19234; 21156058Sbostic incr = 27; 21256058Sbostic } else 21356058Sbostic i += incr; 21456058Sbostic } 21556058Sbostic END { 21656038Sbostic for (i = 37; i <= 37 + 88 * 17; i += 17) 21756058Sbostic printf("g\nk%d\n", i); 21856038Sbostic for (i = 1; i <= 15; ++i) 21956058Sbostic printf("g\nk%d\n", i); 22056038Sbostic for (i = 19234; i <= 19234 + 61 * 27; i += 27) 22156058Sbostic printf("g\nk%d\n", i); 22256058Sbostic }' > $TMP2 22356058Sbostic $PROG -o $TMP3 recno $TMP2 22457460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 22556038Sbostic else 22664444Sbostic echo "test4: type recno: failed" 22756038Sbostic exit 1 22856038Sbostic fi 22956038Sbostic} 23056050Sbostic 23156050Sbostic# Do reverse order recno entries. 23256050Sbostictest5() 23356050Sbostic{ 23464444Sbostic echo "Test 5: recno: reverse order entries" 23556050Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 23656058Sbostic awk ' { 23764444Sbostic for (i = 1500; i; --i) { 23864444Sbostic s = substr($0, 1, i % 34); 23964444Sbostic printf("input key %d: %s\n", i, s); 24064444Sbostic } 24156058Sbostic exit; 24256058Sbostic }' > $TMP1 24364287Sbostic rm -f $TMP2 $TMP3 24456058Sbostic cat $TMP1 | 24556058Sbostic awk 'BEGIN { 24656058Sbostic i = 1500; 24756058Sbostic } 24856058Sbostic { 24956058Sbostic printf("p\nk%d\nd%s\n", i, $0); 25056058Sbostic --i; 25156058Sbostic } 25256058Sbostic END { 25356058Sbostic for (i = 1500; i; --i) 25456058Sbostic printf("g\nk%d\n", i); 25556058Sbostic }' > $TMP2 25656058Sbostic $PROG -o $TMP3 recno $TMP2 25757460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 25856050Sbostic else 25964444Sbostic echo "test5: type recno: failed" 26056050Sbostic exit 1 26156050Sbostic fi 26256050Sbostic} 26356038Sbostic 26456050Sbostic# Do alternating order recno entries. 26556050Sbostictest6() 26656050Sbostic{ 26764444Sbostic echo "Test 6: recno: alternating order entries" 26856050Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 26956058Sbostic awk ' { 27064444Sbostic for (i = 1; i < 1200; i += 2) { 27164444Sbostic s = substr($0, 1, i % 34); 27264444Sbostic printf("input key %d: %s\n", i, s); 27364444Sbostic } 27464444Sbostic for (i = 2; i < 1200; i += 2) { 27564444Sbostic s = substr($0, 1, i % 34); 27664444Sbostic printf("input key %d: %s\n", i, s); 27764444Sbostic } 27856058Sbostic exit; 27956058Sbostic }' > $TMP1 28064444Sbostic rm -f $TMP2 $TMP3 28156058Sbostic cat $TMP1 | 28256058Sbostic awk 'BEGIN { 28356058Sbostic i = 1; 28456058Sbostic even = 0; 28556058Sbostic } 28656058Sbostic { 28756058Sbostic printf("p\nk%d\nd%s\n", i, $0); 28856058Sbostic i += 2; 28956058Sbostic if (i >= 1200) { 29056058Sbostic if (even == 1) 29156058Sbostic exit; 29256058Sbostic even = 1; 29356058Sbostic i = 2; 29456050Sbostic } 29556058Sbostic } 29656058Sbostic END { 29756058Sbostic for (i = 1; i < 1200; ++i) 29856058Sbostic printf("g\nk%d\n", i); 29956058Sbostic }' > $TMP2 30056058Sbostic $PROG -o $TMP3 recno $TMP2 30156050Sbostic sort -o $TMP1 $TMP1 30256050Sbostic sort -o $TMP3 $TMP3 30357460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 30456050Sbostic else 30564444Sbostic echo "test6: type recno: failed" 30656050Sbostic exit 1 30756050Sbostic fi 30856050Sbostic} 30956050Sbostic 31056058Sbostic# Delete cursor record 31156058Sbostictest7() 31256058Sbostic{ 31364444Sbostic echo "Test 7: btree, recno: delete cursor record" 31456058Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 31556058Sbostic awk '{ 31656058Sbostic for (i = 1; i <= 120; ++i) 31756058Sbostic printf("%05d: input key %d: %s\n", i, i, $0); 31856058Sbostic printf("%05d: input key %d: %s\n", 120, 120, $0); 31956058Sbostic printf("get failed, no such key\n"); 32056058Sbostic printf("%05d: input key %d: %s\n", 1, 1, $0); 32156058Sbostic printf("%05d: input key %d: %s\n", 2, 2, $0); 32256058Sbostic exit; 32356058Sbostic }' > $TMP1 32464444Sbostic rm -f $TMP2 $TMP3 32556763Sbostic 32656058Sbostic for type in btree recno; do 32756058Sbostic cat $TMP1 | 32856058Sbostic awk '{ 32956058Sbostic if (i == 120) 33056058Sbostic exit; 33156058Sbostic printf("p\nk%d\nd%s\n", ++i, $0); 33256058Sbostic } 33356058Sbostic END { 33456058Sbostic printf("fR_NEXT\n"); 33556058Sbostic for (i = 1; i <= 120; ++i) 33656058Sbostic printf("s\n"); 33756058Sbostic printf("fR_CURSOR\ns\nk120\n"); 33856058Sbostic printf("r\nk120\n"); 33956058Sbostic printf("fR_NEXT\ns\n"); 34056058Sbostic printf("fR_CURSOR\ns\nk1\n"); 34156058Sbostic printf("r\nk1\n"); 34256058Sbostic printf("fR_FIRST\ns\n"); 34356058Sbostic }' > $TMP2 34456058Sbostic $PROG -o $TMP3 recno $TMP2 34557460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 34656058Sbostic else 34764444Sbostic echo "test7: type $type: failed" 34856058Sbostic exit 1 34956058Sbostic fi 35056058Sbostic done 35156058Sbostic} 35256058Sbostic 35356495Sbostic# Make sure that overflow pages are reused. 35456085Sbostictest8() 35556085Sbostic{ 35664444Sbostic echo "Test 8: btree, hash: repeated small key, big data pairs" 35756495Sbostic rm -f $TMP1 35864444Sbostic echo "" | 35956495Sbostic awk 'BEGIN { 36056556Sbostic for (i = 1; i <= 10; ++i) { 36156495Sbostic printf("p\nkkey1\nD/bin/sh\n"); 36256495Sbostic printf("p\nkkey2\nD/bin/csh\n"); 36356554Sbostic if (i % 8 == 0) { 36456554Sbostic printf("c\nkkey2\nD/bin/csh\n"); 36556554Sbostic printf("c\nkkey1\nD/bin/sh\n"); 36656763Sbostic printf("e\t%d of 10 (comparison)\r\n", i); 36756554Sbostic } else 36856763Sbostic printf("e\t%d of 10 \r\n", i); 36956495Sbostic printf("r\nkkey1\nr\nkkey2\n"); 37056495Sbostic } 37156556Sbostic printf("e\n"); 37256556Sbostic printf("eend of test8 run\n"); 37356495Sbostic }' > $TMP1 37456554Sbostic $PROG btree $TMP1 37564444Sbostic# $PROG hash $TMP1 37656495Sbostic # No explicit test for success. 37756495Sbostic} 37856495Sbostic 37957001Sbostic# Test btree duplicate keys 38057001Sbostictest9() 38157001Sbostic{ 38264444Sbostic echo "Test 9: btree: duplicate keys" 38357001Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 38457001Sbostic awk '{ 38557001Sbostic for (i = 1; i <= 543; ++i) 38657001Sbostic printf("%05d: input key %d: %s\n", i, i, $0); 38757001Sbostic exit; 38857001Sbostic }' > $TMP1 38964444Sbostic rm -f $TMP2 $TMP3 39057001Sbostic 39157001Sbostic for type in btree; do 39257001Sbostic cat $TMP1 | 39357001Sbostic awk '{ 39457001Sbostic if (i++ % 2) 39557001Sbostic printf("p\nkduplicatekey\nd%s\n", $0); 39657001Sbostic else 39757001Sbostic printf("p\nkunique%dkey\nd%s\n", i, $0); 39857001Sbostic } 39957001Sbostic END { 40057001Sbostic printf("o\n"); 40157001Sbostic }' > $TMP2 40257001Sbostic $PROG -iflags=1 -o $TMP3 $type $TMP2 40357001Sbostic sort -o $TMP3 $TMP3 40457460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 40557001Sbostic else 40664444Sbostic echo "test9: type $type: failed" 40757001Sbostic exit 1 40857001Sbostic fi 40957001Sbostic done 41057001Sbostic} 41157001Sbostic 41256999Sbostic# Test use of cursor flags without initialization 41356999Sbostictest10() 41456999Sbostic{ 41564444Sbostic echo "Test 10: btree, recno: test cursor flag use" 41656999Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 41756999Sbostic awk '{ 41856999Sbostic for (i = 1; i <= 20; ++i) 41956999Sbostic printf("%05d: input key %d: %s\n", i, i, $0); 42056999Sbostic exit; 42156999Sbostic }' > $TMP1 42264444Sbostic rm -f $TMP2 $TMP3 42356999Sbostic 42456999Sbostic # Test that R_CURSOR doesn't succeed before cursor initialized 42556999Sbostic for type in btree recno; do 42656999Sbostic cat $TMP1 | 42756999Sbostic awk '{ 42856999Sbostic if (i == 10) 42956999Sbostic exit; 43056999Sbostic printf("p\nk%d\nd%s\n", ++i, $0); 43156999Sbostic } 43256999Sbostic END { 43356999Sbostic printf("fR_CURSOR\nr\nk1\n"); 43456999Sbostic printf("eR_CURSOR SHOULD HAVE FAILED\n"); 43556999Sbostic }' > $TMP2 43656999Sbostic $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1 43756999Sbostic if [ -s $TMP3 ] ; then 43864444Sbostic echo "Test 10: delete: R_CURSOR SHOULD HAVE FAILED" 43956999Sbostic exit 1 44056999Sbostic fi 44156999Sbostic done 44256999Sbostic for type in btree recno; do 44356999Sbostic cat $TMP1 | 44456999Sbostic awk '{ 44556999Sbostic if (i == 10) 44656999Sbostic exit; 44756999Sbostic printf("p\nk%d\nd%s\n", ++i, $0); 44856999Sbostic } 44956999Sbostic END { 45056999Sbostic printf("fR_CURSOR\np\nk1\ndsome data\n"); 45156999Sbostic printf("eR_CURSOR SHOULD HAVE FAILED\n"); 45256999Sbostic }' > $TMP2 45356999Sbostic $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1 45456999Sbostic if [ -s $TMP3 ] ; then 45564444Sbostic echo "Test 10: put: R_CURSOR SHOULD HAVE FAILED" 45656999Sbostic exit 1 45756999Sbostic fi 45856999Sbostic done 45956999Sbostic} 46056999Sbostic 46156999Sbostic# Test insert in reverse order. 46256999Sbostictest11() 46356999Sbostic{ 46464444Sbostic echo "Test 11: recno: reverse order insert" 46556999Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 46656999Sbostic awk '{ 46756999Sbostic for (i = 1; i <= 779; ++i) 46856999Sbostic printf("%05d: input key %d: %s\n", i, i, $0); 46956999Sbostic exit; 47056999Sbostic }' > $TMP1 47164444Sbostic rm -f $TMP2 $TMP3 47256999Sbostic 47356999Sbostic for type in recno; do 47456999Sbostic cat $TMP1 | 47556999Sbostic awk '{ 47656999Sbostic if (i == 0) { 47756999Sbostic i = 1; 47856999Sbostic printf("p\nk1\nd%s\n", $0); 47956999Sbostic printf("%s\n", "fR_IBEFORE"); 48056999Sbostic } else 48156999Sbostic printf("p\nk1\nd%s\n", $0); 48256999Sbostic } 48356999Sbostic END { 48456999Sbostic printf("or\n"); 48556999Sbostic }' > $TMP2 48656999Sbostic $PROG -o $TMP3 $type $TMP2 48757460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 48856999Sbostic else 48964444Sbostic echo "test11: type $type: failed" 49056999Sbostic exit 1 49156999Sbostic fi 49256999Sbostic done 49356999Sbostic} 49456999Sbostic 49557455Sbostic# Take the first 20000 entries in the dictionary, reverse them, and give 49657455Sbostic# them each a small size data entry. Use a small page size to make sure 49757455Sbostic# the btree split code gets hammered. 49857455Sbostictest12() 49957455Sbostic{ 50064444Sbostic echo "Test 12: btree: lots of keys, small page size" 50157455Sbostic mdata=abcdefghijklmnopqrstuvwxy 50257455Sbostic echo $mdata | 50357455Sbostic awk '{ for (i = 1; i < 20001; ++i) print $0 }' > $TMP1 50457455Sbostic for type in btree; do 50557455Sbostic rm -f $TMP2 $TMP3 50657455Sbostic for i in `sed 20000q $DICT | rev`; do 50764444Sbostic echo p 50864444Sbostic echo k$i 50964444Sbostic echo d$mdata 51064444Sbostic echo g 51164444Sbostic echo k$i 51257455Sbostic done > $TMP2 51357455Sbostic $PROG -i psize=512 -o $TMP3 $type $TMP2 51457460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 51557455Sbostic else 51664444Sbostic echo "test12: type $type: failed" 51757455Sbostic exit 1 51857455Sbostic fi 51957455Sbostic done 52057455Sbostic} 52157455Sbostic 52259633Sbostic# Test different byte orders. 52359633Sbostictest13() 52459633Sbostic{ 52564444Sbostic echo "Test 13: btree, hash: differing byte orders" 52659633Sbostic sed 50q $DICT > $TMP1 52759633Sbostic for order in 1234 4321; do 52859633Sbostic for type in btree hash; do 52959633Sbostic rm -f byte.file $TMP2 $TMP3 53059633Sbostic for i in `sed 50q $DICT`; do 53164444Sbostic echo p 53264444Sbostic echo k$i 53364444Sbostic echo d$i 53464444Sbostic echo g 53564444Sbostic echo k$i 53659633Sbostic done > $TMP2 53759633Sbostic $PROG -ilorder=$order -f byte.file -o $TMP3 $type $TMP2 53859633Sbostic if (cmp -s $TMP1 $TMP3) ; then : 53959633Sbostic else 54064444Sbostic echo "test13: $type/$order put failed" 54159633Sbostic exit 1 54259633Sbostic fi 54359633Sbostic for i in `sed 50q $DICT`; do 54464444Sbostic echo g 54564444Sbostic echo k$i 54659633Sbostic done > $TMP2 54759633Sbostic $PROG -ilorder=$order -f byte.file -o $TMP3 $type $TMP2 54859633Sbostic if (cmp -s $TMP1 $TMP3) ; then : 54959633Sbostic else 55064444Sbostic echo "test13: $type/$order get failed" 55159633Sbostic exit 1 55259633Sbostic fi 55359633Sbostic done 55459633Sbostic done 55559633Sbostic rm -f byte.file 55659633Sbostic} 55759633Sbostic 55856495Sbostic# Try a variety of bucketsizes and fill factors for hashing 55956999Sbostictest20() 56056495Sbostic{ 56164444Sbostic echo\ 56264444Sbostic "Test 20: hash: bucketsize, fill factor; nelem 25000 cachesize 65536" 56356085Sbostic awk 'BEGIN { 56456085Sbostic for (i = 1; i <= 10000; ++i) 56556085Sbostic printf("%.*s\n", i % 34, 56656085Sbostic "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg"); 56756085Sbostic }' > $TMP1 56856085Sbostic sed 10000q $DICT | 56956085Sbostic awk '{ 57056085Sbostic ++i; 57156085Sbostic printf("p\nk%s\nd%.*s\n", $0, i % 34, 57256085Sbostic "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg"); 57356085Sbostic }' > $TMP2 57456085Sbostic sed 10000q $DICT | 57556085Sbostic awk '{ 57656085Sbostic ++i; 57756085Sbostic printf("g\nk%s\n", $0); 57856085Sbostic }' >> $TMP2 57956085Sbostic bsize=256 58056085Sbostic for ffactor in 11 14 21; do 58164444Sbostic echo " bucketsize $bsize, fill factor $ffactor" 58256495Sbostic $PROG -o$TMP3 \ 58356085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 58456085Sbostic hash $TMP2 58557460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 58656085Sbostic else 58764444Sbostic echo "test20: type hash:\ 58864444Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" 58956085Sbostic exit 1 59056085Sbostic fi 59156085Sbostic done 59256085Sbostic bsize=512 59356085Sbostic for ffactor in 21 28 43; do 59464444Sbostic echo " bucketsize $bsize, fill factor $ffactor" 59556495Sbostic $PROG -o$TMP3 \ 59656085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 59756085Sbostic hash $TMP2 59857460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 59956085Sbostic else 60064444Sbostic echo "test20: type hash:\ 60164444Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" 60256085Sbostic exit 1 60356085Sbostic fi 60456085Sbostic done 60556085Sbostic bsize=1024 60656085Sbostic for ffactor in 43 57 85; do 60764444Sbostic echo " bucketsize $bsize, fill factor $ffactor" 60856495Sbostic $PROG -o$TMP3 \ 60956085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 61056085Sbostic hash $TMP2 61157460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 61256085Sbostic else 61364444Sbostic echo "test20: type hash:\ 61464444Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" 61556085Sbostic exit 1 61656085Sbostic fi 61756085Sbostic done 61856085Sbostic bsize=2048 61956085Sbostic for ffactor in 85 114 171; do 62064444Sbostic echo " bucketsize $bsize, fill factor $ffactor" 62156495Sbostic $PROG -o$TMP3 \ 62256085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 62356085Sbostic hash $TMP2 62457460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 62556085Sbostic else 62664444Sbostic echo "test20: type hash:\ 62764444Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" 62856085Sbostic exit 1 62956085Sbostic fi 63056085Sbostic done 63156085Sbostic bsize=4096 63256085Sbostic for ffactor in 171 228 341; do 63364444Sbostic echo " bucketsize $bsize, fill factor $ffactor" 63456495Sbostic $PROG -o$TMP3 \ 63556085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 63656085Sbostic hash $TMP2 63757460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 63856085Sbostic else 63964444Sbostic echo "test20: type hash:\ 64064444Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" 64156085Sbostic exit 1 64256085Sbostic fi 64356085Sbostic done 64456085Sbostic bsize=8192 64556085Sbostic for ffactor in 341 455 683; do 64664444Sbostic echo " bucketsize $bsize, fill factor $ffactor" 64756495Sbostic $PROG -o$TMP3 \ 64856085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 64956085Sbostic hash $TMP2 65057460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 65156085Sbostic else 65264444Sbostic echo "test20: type hash:\ 65364444Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed" 65456085Sbostic exit 1 65556085Sbostic fi 65656085Sbostic done 65756085Sbostic} 65856085Sbostic 65964444Sbosticmain $* 660