156038Sbostic#!/bin/sh - 256038Sbostic# 356038Sbostic# Copyright (c) 1992 The Regents of the University of California. 456038Sbostic# All rights reserved. 556038Sbostic# 656038Sbostic# %sccs.include.redist.sh% 756038Sbostic# 8*60233Sbostic# @(#)run.test 5.17 (Berkeley) 05/22/93 956038Sbostic# 1056038Sbostic 1156038Sbostic# db regression tests 1256038Sbostic 1356038Sbosticmain() 1456038Sbostic{ 1556038Sbostic DICT=/usr/share/dict/words 1656058Sbostic PROG=obj/dbtest 1756038Sbostic TMP1=t1 1856038Sbostic TMP2=t2 1956038Sbostic TMP3=t3 2056038Sbostic 2156038Sbostic test1 2256038Sbostic test2 2356038Sbostic test3 2456038Sbostic test4 2556050Sbostic test5 2656050Sbostic test6 2756058Sbostic test7 2856085Sbostic test8 2957001Sbostic test9 3056765Sbostic test10 3156999Sbostic test11 3257455Sbostic test12 3359633Sbostic test13 3456999Sbostic test20 3556038Sbostic rm -f $TMP1 $TMP2 $TMP3 3656999Sbostic exit 0 3756038Sbostic} 3856038Sbostic 3956038Sbostic# Take the first hundred entries in the dictionary, and make them 4056038Sbostic# be key/data pairs. 4156038Sbostictest1() 4256038Sbostic{ 4356050Sbostic printf "Test 1: btree, hash: small key, small data pairs\n" 4456085Sbostic sed 200q $DICT > $TMP1 4556038Sbostic for type in btree hash; do 4656038Sbostic rm -f $TMP2 $TMP3 4756038Sbostic for i in `sed 200q $DICT`; do 4856038Sbostic printf "p\nk%s\nd%s\ng\nk%s\n" $i $i $i 4956038Sbostic done > $TMP2 5056058Sbostic $PROG -o $TMP3 $type $TMP2 5157460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 5256038Sbostic else 5356038Sbostic printf "test1: type %s: failed\n" $type 5456038Sbostic exit 1 5556038Sbostic fi 5656038Sbostic done 5756050Sbostic printf "Test 1: recno: small key, small data pairs\n" 5856038Sbostic rm -f $TMP2 $TMP3 5956038Sbostic sed 200q $DICT | 6056058Sbostic awk '{ 6156058Sbostic ++i; 6256058Sbostic printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); 6356058Sbostic }' > $TMP2 6456058Sbostic $PROG -o $TMP3 recno $TMP2 6557460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 6656038Sbostic else 6756038Sbostic printf "test1: type recno: failed\n" 6856038Sbostic exit 1 6956038Sbostic fi 7056038Sbostic} 7156038Sbostic 7257455Sbostic# Take the first 200 entries in the dictionary, and give them 7356038Sbostic# each a medium size data entry. 7456038Sbostictest2() 7556038Sbostic{ 7656050Sbostic printf "Test 2: btree, hash: small key, medium data pairs\n" 7756038Sbostic mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz 7856038Sbostic echo $mdata | 7956058Sbostic awk '{ for (i = 1; i < 201; ++i) print $0 }' > $TMP1 8056038Sbostic for type in hash btree; do 8156038Sbostic rm -f $TMP2 $TMP3 8256038Sbostic for i in `sed 200q $DICT`; do 8356038Sbostic printf "p\nk%s\nd%s\ng\nk%s\n" $i $mdata $i 8456038Sbostic done > $TMP2 8556058Sbostic $PROG -o $TMP3 $type $TMP2 8657460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 8756038Sbostic else 8856038Sbostic printf "test2: type %s: failed\n" $type 8956038Sbostic exit 1 9056038Sbostic fi 9156038Sbostic done 9256050Sbostic printf "Test 2: recno: small key, medium data pairs\n" 9356038Sbostic rm -f $TMP2 $TMP3 9456038Sbostic echo $mdata | 9556058Sbostic awk '{ for (i = 1; i < 201; ++i) 9656058Sbostic printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); 9756058Sbostic }' > $TMP2 9856058Sbostic $PROG -o $TMP3 recno $TMP2 9957460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 10056038Sbostic else 10156038Sbostic printf "test2: type recno: failed\n" 10256038Sbostic exit 1 10356038Sbostic fi 10456038Sbostic} 10556038Sbostic 10656038Sbostic# Insert the programs in /bin with their paths as their keys. 10756038Sbostictest3() 10856038Sbostic{ 109*60233Sbostic printf "Test 3: hash: small key, big data pairs\n" 11056038Sbostic rm -f $TMP1 11156038Sbostic (find /bin -type f -print | xargs cat) > $TMP1 112*60233Sbostic for type in hash; do 11356038Sbostic rm -f $TMP2 $TMP3 11456038Sbostic for i in `find /bin -type f -print`; do 11556038Sbostic printf "p\nk%s\nD%s\ng\nk%s\n" $i $i $i 11656038Sbostic done > $TMP2 11756058Sbostic $PROG -o $TMP3 $type $TMP2 11857460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 11956038Sbostic else 120*60233Sbostic printf "test3: %s: page size %d: failed\n" \ 121*60233Sbostic $type $psize 12256038Sbostic exit 1 12356038Sbostic fi 12456038Sbostic done 125*60233Sbostic printf "Test 3: btree: small key, big data pairs\n" 126*60233Sbostic for psize in 512 16384 65536; do 127*60233Sbostic printf "\tpage size %d\n" $psize 128*60233Sbostic for type in btree; do 129*60233Sbostic rm -f $TMP2 $TMP3 130*60233Sbostic for i in `find /bin -type f -print`; do 131*60233Sbostic printf "p\nk%s\nD%s\ng\nk%s\n" $i $i $i 132*60233Sbostic done > $TMP2 133*60233Sbostic $PROG -i psize=$psize -o $TMP3 $type $TMP2 134*60233Sbostic if (cmp -s $TMP1 $TMP3) ; then : 135*60233Sbostic else 136*60233Sbostic printf "test3: %s: page size %d: failed\n" \ 137*60233Sbostic $type $psize 138*60233Sbostic exit 1 139*60233Sbostic fi 140*60233Sbostic done 141*60233Sbostic done 14256050Sbostic printf "Test 3: recno: big data pairs\n" 14356038Sbostic rm -f $TMP2 $TMP3 14456038Sbostic find /bin -type f -print | 14556058Sbostic awk '{ 14656058Sbostic ++i; 14756058Sbostic printf("p\nk%d\nD%s\ng\nk%d\n", i, $0, i); 14856058Sbostic }' > $TMP2 149*60233Sbostic for psize in 512 16384 65536; do 150*60233Sbostic printf "\tpage size %d\n" $psize 151*60233Sbostic $PROG -i psize=$psize -o $TMP3 recno $TMP2 152*60233Sbostic if (cmp -s $TMP1 $TMP3) ; then : 153*60233Sbostic else 154*60233Sbostic printf "test3: recno: page size %d: failed\n" $psize 155*60233Sbostic exit 1 156*60233Sbostic fi 157*60233Sbostic done 15856038Sbostic} 15956038Sbostic 16056038Sbostic# Do random recno entries. 16156038Sbostictest4() 16256038Sbostic{ 16356050Sbostic printf "Test 4: recno: random entries\n" 16456050Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 16556058Sbostic awk '{ 16656058Sbostic for (i = 37; i <= 37 + 88 * 17; i += 17) 16756058Sbostic printf("input key %d: %.*s\n", i, i % 41, $0); 16856058Sbostic for (i = 1; i <= 15; ++i) 16956058Sbostic printf("input key %d: %.*s\n", i, i % 41, $0); 17056058Sbostic for (i = 19234; i <= 19234 + 61 * 27; i += 27) 17156058Sbostic printf("input key %d: %.*s\n", i, i % 41, $0); 17256058Sbostic exit 17356058Sbostic }' > $TMP1 17456058Sbostic rm -f TMP2 $TMP3 17556058Sbostic cat $TMP1 | 17656058Sbostic awk 'BEGIN { 17756058Sbostic i = 37; 17856058Sbostic incr = 17; 17956058Sbostic } 18056058Sbostic { 18156058Sbostic printf("p\nk%d\nd%s\n", i, $0); 18256058Sbostic if (i == 19234 + 61 * 27) 18356058Sbostic exit; 18456058Sbostic if (i == 37 + 88 * 17) { 18556058Sbostic i = 1; 18656058Sbostic incr = 1; 18756058Sbostic } else if (i == 15) { 18856058Sbostic i = 19234; 18956058Sbostic incr = 27; 19056058Sbostic } else 19156058Sbostic i += incr; 19256058Sbostic } 19356058Sbostic END { 19456038Sbostic for (i = 37; i <= 37 + 88 * 17; i += 17) 19556058Sbostic printf("g\nk%d\n", i); 19656038Sbostic for (i = 1; i <= 15; ++i) 19756058Sbostic printf("g\nk%d\n", i); 19856038Sbostic for (i = 19234; i <= 19234 + 61 * 27; i += 27) 19956058Sbostic printf("g\nk%d\n", i); 20056058Sbostic }' > $TMP2 20156058Sbostic $PROG -o $TMP3 recno $TMP2 20257460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 20356038Sbostic else 20456038Sbostic printf "test4: type recno: failed\n" 20556038Sbostic exit 1 20656038Sbostic fi 20756038Sbostic} 20856050Sbostic 20956050Sbostic# Do reverse order recno entries. 21056050Sbostictest5() 21156050Sbostic{ 21256050Sbostic printf "Test 5: recno: reverse order entries\n" 21356050Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 21456058Sbostic awk ' { 21556058Sbostic for (i = 1500; i; --i) 21656058Sbostic printf("input key %d: %.*s\n", i, i % 34, $0); 21756058Sbostic exit; 21856058Sbostic }' > $TMP1 21956050Sbostic rm -f TMP2 $TMP3 22056058Sbostic cat $TMP1 | 22156058Sbostic awk 'BEGIN { 22256058Sbostic i = 1500; 22356058Sbostic } 22456058Sbostic { 22556058Sbostic printf("p\nk%d\nd%s\n", i, $0); 22656058Sbostic --i; 22756058Sbostic } 22856058Sbostic END { 22956058Sbostic for (i = 1500; i; --i) 23056058Sbostic printf("g\nk%d\n", i); 23156058Sbostic }' > $TMP2 23256058Sbostic $PROG -o $TMP3 recno $TMP2 23357460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 23456050Sbostic else 23556050Sbostic printf "test5: type recno: failed\n" 23656050Sbostic exit 1 23756050Sbostic fi 23856050Sbostic} 23956038Sbostic 24056050Sbostic# Do alternating order recno entries. 24156050Sbostictest6() 24256050Sbostic{ 24356050Sbostic printf "Test 6: recno: alternating order entries\n" 24456050Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 24556058Sbostic awk ' { 24656058Sbostic for (i = 1; i < 1200; i += 2) 24756058Sbostic printf("input key %d: %.*s\n", i, i % 34, $0); 24856058Sbostic for (i = 2; i < 1200; i += 2) 24956058Sbostic printf("input key %d: %.*s\n", i, i % 34, $0); 25056058Sbostic exit; 25156058Sbostic }' > $TMP1 25256050Sbostic rm -f TMP2 $TMP3 25356058Sbostic cat $TMP1 | 25456058Sbostic awk 'BEGIN { 25556058Sbostic i = 1; 25656058Sbostic even = 0; 25756058Sbostic } 25856058Sbostic { 25956058Sbostic printf("p\nk%d\nd%s\n", i, $0); 26056058Sbostic i += 2; 26156058Sbostic if (i >= 1200) { 26256058Sbostic if (even == 1) 26356058Sbostic exit; 26456058Sbostic even = 1; 26556058Sbostic i = 2; 26656050Sbostic } 26756058Sbostic } 26856058Sbostic END { 26956058Sbostic for (i = 1; i < 1200; ++i) 27056058Sbostic printf("g\nk%d\n", i); 27156058Sbostic }' > $TMP2 27256058Sbostic $PROG -o $TMP3 recno $TMP2 27356050Sbostic sort -o $TMP1 $TMP1 27456050Sbostic sort -o $TMP3 $TMP3 27557460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 27656050Sbostic else 27756050Sbostic printf "test6: type recno: failed\n" 27856050Sbostic exit 1 27956050Sbostic fi 28056050Sbostic} 28156050Sbostic 28256058Sbostic# Delete cursor record 28356058Sbostictest7() 28456058Sbostic{ 28556058Sbostic printf "Test 7: btree, recno: delete cursor record\n" 28656058Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 28756058Sbostic awk '{ 28856058Sbostic for (i = 1; i <= 120; ++i) 28956058Sbostic printf("%05d: input key %d: %s\n", i, i, $0); 29056058Sbostic printf("%05d: input key %d: %s\n", 120, 120, $0); 29156058Sbostic printf("get failed, no such key\n"); 29256058Sbostic printf("%05d: input key %d: %s\n", 1, 1, $0); 29356058Sbostic printf("%05d: input key %d: %s\n", 2, 2, $0); 29456058Sbostic exit; 29556058Sbostic }' > $TMP1 29656058Sbostic rm -f TMP2 $TMP3 29756763Sbostic 29856058Sbostic for type in btree recno; do 29956058Sbostic cat $TMP1 | 30056058Sbostic awk '{ 30156058Sbostic if (i == 120) 30256058Sbostic exit; 30356058Sbostic printf("p\nk%d\nd%s\n", ++i, $0); 30456058Sbostic } 30556058Sbostic END { 30656058Sbostic printf("fR_NEXT\n"); 30756058Sbostic for (i = 1; i <= 120; ++i) 30856058Sbostic printf("s\n"); 30956058Sbostic printf("fR_CURSOR\ns\nk120\n"); 31056058Sbostic printf("r\nk120\n"); 31156058Sbostic printf("fR_NEXT\ns\n"); 31256058Sbostic printf("fR_CURSOR\ns\nk1\n"); 31356058Sbostic printf("r\nk1\n"); 31456058Sbostic printf("fR_FIRST\ns\n"); 31556058Sbostic }' > $TMP2 31656058Sbostic $PROG -o $TMP3 recno $TMP2 31757460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 31856058Sbostic else 31956058Sbostic printf "test7: type $type: failed\n" 32056058Sbostic exit 1 32156058Sbostic fi 32256058Sbostic done 32356058Sbostic} 32456058Sbostic 32556495Sbostic# Make sure that overflow pages are reused. 32656085Sbostictest8() 32756085Sbostic{ 32856495Sbostic printf "Test 8: btree, hash: repeated small key, big data pairs\n" 32956495Sbostic rm -f $TMP1 33056495Sbostic awk 'BEGIN { 33156556Sbostic for (i = 1; i <= 10; ++i) { 33256495Sbostic printf("p\nkkey1\nD/bin/sh\n"); 33356495Sbostic printf("p\nkkey2\nD/bin/csh\n"); 33456554Sbostic if (i % 8 == 0) { 33556554Sbostic printf("c\nkkey2\nD/bin/csh\n"); 33656554Sbostic printf("c\nkkey1\nD/bin/sh\n"); 33756763Sbostic printf("e\t%d of 10 (comparison)\r\n", i); 33856554Sbostic } else 33956763Sbostic printf("e\t%d of 10 \r\n", i); 34056495Sbostic printf("r\nkkey1\nr\nkkey2\n"); 34156495Sbostic } 34256556Sbostic printf("e\n"); 34356556Sbostic printf("eend of test8 run\n"); 34456495Sbostic }' > $TMP1 34556554Sbostic $PROG btree $TMP1 34656554Sbostic $PROG hash $TMP1 34756495Sbostic # No explicit test for success. 34856495Sbostic} 34956495Sbostic 35057001Sbostic# Test btree duplicate keys 35157001Sbostictest9() 35257001Sbostic{ 35357001Sbostic printf "Test 9: btree: duplicate keys\n" 35457001Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 35557001Sbostic awk '{ 35657001Sbostic for (i = 1; i <= 543; ++i) 35757001Sbostic printf("%05d: input key %d: %s\n", i, i, $0); 35857001Sbostic exit; 35957001Sbostic }' > $TMP1 36057001Sbostic rm -f TMP2 $TMP3 36157001Sbostic 36257001Sbostic for type in btree; do 36357001Sbostic cat $TMP1 | 36457001Sbostic awk '{ 36557001Sbostic if (i++ % 2) 36657001Sbostic printf("p\nkduplicatekey\nd%s\n", $0); 36757001Sbostic else 36857001Sbostic printf("p\nkunique%dkey\nd%s\n", i, $0); 36957001Sbostic } 37057001Sbostic END { 37157001Sbostic printf("o\n"); 37257001Sbostic }' > $TMP2 37357001Sbostic $PROG -iflags=1 -o $TMP3 $type $TMP2 37457001Sbostic sort -o $TMP3 $TMP3 37557460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 37657001Sbostic else 37757001Sbostic printf "test9: type $type: failed\n" 37857001Sbostic exit 1 37957001Sbostic fi 38057001Sbostic done 38157001Sbostic} 38257001Sbostic 38356999Sbostic# Test use of cursor flags without initialization 38456999Sbostictest10() 38556999Sbostic{ 38656999Sbostic printf "Test 10: btree, recno: test cursor flag use\n" 38756999Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 38856999Sbostic awk '{ 38956999Sbostic for (i = 1; i <= 20; ++i) 39056999Sbostic printf("%05d: input key %d: %s\n", i, i, $0); 39156999Sbostic exit; 39256999Sbostic }' > $TMP1 39356999Sbostic rm -f TMP2 $TMP3 39456999Sbostic 39556999Sbostic # Test that R_CURSOR doesn't succeed before cursor initialized 39656999Sbostic for type in btree recno; do 39756999Sbostic cat $TMP1 | 39856999Sbostic awk '{ 39956999Sbostic if (i == 10) 40056999Sbostic exit; 40156999Sbostic printf("p\nk%d\nd%s\n", ++i, $0); 40256999Sbostic } 40356999Sbostic END { 40456999Sbostic printf("fR_CURSOR\nr\nk1\n"); 40556999Sbostic printf("eR_CURSOR SHOULD HAVE FAILED\n"); 40656999Sbostic }' > $TMP2 40756999Sbostic $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1 40856999Sbostic if [ -s $TMP3 ] ; then 40956999Sbostic printf "Test 10: delete: R_CURSOR SHOULD HAVE FAILED\n" 41056999Sbostic exit 1 41156999Sbostic fi 41256999Sbostic done 41356999Sbostic for type in btree recno; do 41456999Sbostic cat $TMP1 | 41556999Sbostic awk '{ 41656999Sbostic if (i == 10) 41756999Sbostic exit; 41856999Sbostic printf("p\nk%d\nd%s\n", ++i, $0); 41956999Sbostic } 42056999Sbostic END { 42156999Sbostic printf("fR_CURSOR\np\nk1\ndsome data\n"); 42256999Sbostic printf("eR_CURSOR SHOULD HAVE FAILED\n"); 42356999Sbostic }' > $TMP2 42456999Sbostic $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1 42556999Sbostic if [ -s $TMP3 ] ; then 42656999Sbostic printf "Test 10: put: R_CURSOR SHOULD HAVE FAILED\n" 42756999Sbostic exit 1 42856999Sbostic fi 42956999Sbostic done 43056999Sbostic} 43156999Sbostic 43256999Sbostic# Test insert in reverse order. 43356999Sbostictest11() 43456999Sbostic{ 43556999Sbostic printf "Test 11: recno: reverse order insert\n" 43656999Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 43756999Sbostic awk '{ 43856999Sbostic for (i = 1; i <= 779; ++i) 43956999Sbostic printf("%05d: input key %d: %s\n", i, i, $0); 44056999Sbostic exit; 44156999Sbostic }' > $TMP1 44256999Sbostic rm -f TMP2 $TMP3 44356999Sbostic 44456999Sbostic for type in recno; do 44556999Sbostic cat $TMP1 | 44656999Sbostic awk '{ 44756999Sbostic if (i == 0) { 44856999Sbostic i = 1; 44956999Sbostic printf("p\nk1\nd%s\n", $0); 45056999Sbostic printf("%s\n", "fR_IBEFORE"); 45156999Sbostic } else 45256999Sbostic printf("p\nk1\nd%s\n", $0); 45356999Sbostic } 45456999Sbostic END { 45556999Sbostic printf("or\n"); 45656999Sbostic }' > $TMP2 45756999Sbostic $PROG -o $TMP3 $type $TMP2 45857460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 45956999Sbostic else 46056999Sbostic printf "test11: type $type: failed\n" 46156999Sbostic exit 1 46256999Sbostic fi 46356999Sbostic done 46456999Sbostic} 46556999Sbostic 46657455Sbostic# Take the first 20000 entries in the dictionary, reverse them, and give 46757455Sbostic# them each a small size data entry. Use a small page size to make sure 46857455Sbostic# the btree split code gets hammered. 46957455Sbostictest12() 47057455Sbostic{ 47157455Sbostic printf "Test 12: btree: lots of keys, small page size\n" 47257455Sbostic mdata=abcdefghijklmnopqrstuvwxy 47357455Sbostic echo $mdata | 47457455Sbostic awk '{ for (i = 1; i < 20001; ++i) print $0 }' > $TMP1 47557455Sbostic for type in btree; do 47657455Sbostic rm -f $TMP2 $TMP3 47757455Sbostic for i in `sed 20000q $DICT | rev`; do 47857455Sbostic printf "p\nk%s\nd%s\ng\nk%s\n" $i $mdata $i 47957455Sbostic done > $TMP2 48057455Sbostic $PROG -i psize=512 -o $TMP3 $type $TMP2 48157460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 48257455Sbostic else 48357455Sbostic printf "test12: type %s: failed\n" $type 48457455Sbostic exit 1 48557455Sbostic fi 48657455Sbostic done 48757455Sbostic} 48857455Sbostic 48959633Sbostic# Test different byte orders. 49059633Sbostictest13() 49159633Sbostic{ 49259633Sbostic printf "Test 13: btree, hash: differing byte orders\n" 49359633Sbostic sed 50q $DICT > $TMP1 49459633Sbostic for order in 1234 4321; do 49559633Sbostic for type in btree hash; do 49659633Sbostic rm -f byte.file $TMP2 $TMP3 49759633Sbostic for i in `sed 50q $DICT`; do 49859633Sbostic printf "p\nk%s\nd%s\ng\nk%s\n" $i $i $i 49959633Sbostic done > $TMP2 50059633Sbostic $PROG -ilorder=$order -f byte.file -o $TMP3 $type $TMP2 50159633Sbostic if (cmp -s $TMP1 $TMP3) ; then : 50259633Sbostic else 50359633Sbostic printf "test13: %s/%s put failed\n" $type $order 50459633Sbostic exit 1 50559633Sbostic fi 50659633Sbostic for i in `sed 50q $DICT`; do 50759633Sbostic printf "g\nk%s\n" $i 50859633Sbostic done > $TMP2 50959633Sbostic $PROG -ilorder=$order -f byte.file -o $TMP3 $type $TMP2 51059633Sbostic if (cmp -s $TMP1 $TMP3) ; then : 51159633Sbostic else 51259633Sbostic printf "test13: %s/%s get failed\n" $type $order 51359633Sbostic exit 1 51459633Sbostic fi 51559633Sbostic done 51659633Sbostic done 51759633Sbostic rm -f byte.file 51859633Sbostic} 51959633Sbostic 52056495Sbostic# Try a variety of bucketsizes and fill factors for hashing 52156999Sbostictest20() 52256495Sbostic{ 52356085Sbostic printf\ 52456999Sbostic "Test 20: hash: bucketsize, fill factor; nelem 25000 cachesize 65536\n" 52556085Sbostic awk 'BEGIN { 52656085Sbostic for (i = 1; i <= 10000; ++i) 52756085Sbostic printf("%.*s\n", i % 34, 52856085Sbostic "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg"); 52956085Sbostic }' > $TMP1 53056085Sbostic sed 10000q $DICT | 53156085Sbostic awk '{ 53256085Sbostic ++i; 53356085Sbostic printf("p\nk%s\nd%.*s\n", $0, i % 34, 53456085Sbostic "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg"); 53556085Sbostic }' > $TMP2 53656085Sbostic sed 10000q $DICT | 53756085Sbostic awk '{ 53856085Sbostic ++i; 53956085Sbostic printf("g\nk%s\n", $0); 54056085Sbostic }' >> $TMP2 54156085Sbostic bsize=256 54256085Sbostic for ffactor in 11 14 21; do 54359494Sbostic printf "\tbucketsize %d, fill factor %d\n" $bsize $ffactor 54456495Sbostic $PROG -o$TMP3 \ 54556085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 54656085Sbostic hash $TMP2 54757460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 54856085Sbostic else 54956999Sbostic printf "test20: type hash:\ 55056085Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed\n" 55156085Sbostic exit 1 55256085Sbostic fi 55356085Sbostic done 55456085Sbostic bsize=512 55556085Sbostic for ffactor in 21 28 43; do 55659494Sbostic printf "\tbucketsize %d, fill factor %d\n" $bsize $ffactor 55756495Sbostic $PROG -o$TMP3 \ 55856085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 55956085Sbostic hash $TMP2 56057460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 56156085Sbostic else 56256999Sbostic printf "test20: type hash:\ 56356085Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed\n" 56456085Sbostic exit 1 56556085Sbostic fi 56656085Sbostic done 56756085Sbostic bsize=1024 56856085Sbostic for ffactor in 43 57 85; do 56959494Sbostic printf "\tbucketsize %d, fill factor %d\n" $bsize $ffactor 57056495Sbostic $PROG -o$TMP3 \ 57156085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 57256085Sbostic hash $TMP2 57357460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 57456085Sbostic else 57556999Sbostic printf "test20: type hash:\ 57656085Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed\n" 57756085Sbostic exit 1 57856085Sbostic fi 57956085Sbostic done 58056085Sbostic bsize=2048 58156085Sbostic for ffactor in 85 114 171; do 58259494Sbostic printf "\tbucketsize %d, fill factor %d\n" $bsize $ffactor 58356495Sbostic $PROG -o$TMP3 \ 58456085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 58556085Sbostic hash $TMP2 58657460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 58756085Sbostic else 58856999Sbostic printf "test20: type hash:\ 58956085Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed\n" 59056085Sbostic exit 1 59156085Sbostic fi 59256085Sbostic done 59356085Sbostic bsize=4096 59456085Sbostic for ffactor in 171 228 341; do 59559494Sbostic printf "\tbucketsize %d, fill factor %d\n" $bsize $ffactor 59656495Sbostic $PROG -o$TMP3 \ 59756085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 59856085Sbostic hash $TMP2 59957460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 60056085Sbostic else 60156999Sbostic printf "test20: type hash:\ 60256085Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed\n" 60356085Sbostic exit 1 60456085Sbostic fi 60556085Sbostic done 60656085Sbostic bsize=8192 60756085Sbostic for ffactor in 341 455 683; do 60859494Sbostic printf "\tbucketsize %d, fill factor %d\n" $bsize $ffactor 60956495Sbostic $PROG -o$TMP3 \ 61056085Sbostic -ibsize=$bsize,ffactor=$ffactor,nelem=25000,cachesize=65536\ 61156085Sbostic hash $TMP2 61257460Sbostic if (cmp -s $TMP1 $TMP3) ; then : 61356085Sbostic else 61456999Sbostic printf "test20: type hash:\ 61556085Sbosticbsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed\n" 61656085Sbostic exit 1 61756085Sbostic fi 61856085Sbostic done 61956085Sbostic} 62056085Sbostic 62156038Sbosticmain 622