# @(#)run.test 8.1 (Berkeley) 6/4/93
DICT
=/usr
/share
/dict
/words
# Take the first hundred entries in the dictionary, and make them
printf "Test 1: btree, hash: small key, small data pairs\n"
for type in btree
hash; do
for i
in `sed 200q $DICT`; do
printf "p\nk%s\nd%s\ng\nk%s\n" $i $i $i
$PROG -o $TMP3 $type $TMP2
if (cmp -s $TMP1 $TMP3) ; then :
printf "test1: type %s: failed\n" $type
printf "Test 1: recno: small key, small data pairs\n"
printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i);
$PROG -o $TMP3 recno
$TMP2
if (cmp -s $TMP1 $TMP3) ; then :
printf "test1: type recno: failed\n"
# Take the first 200 entries in the dictionary, and give them
# each a medium size data entry.
printf "Test 2: btree, hash: small key, medium data pairs\n"
mdata
=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
awk '{ for (i = 1; i < 201; ++i) print $0 }' > $TMP1
for type in hash btree
; do
for i
in `sed 200q $DICT`; do
printf "p\nk%s\nd%s\ng\nk%s\n" $i $mdata $i
$PROG -o $TMP3 $type $TMP2
if (cmp -s $TMP1 $TMP3) ; then :
printf "test2: type %s: failed\n" $type
printf "Test 2: recno: small key, medium data pairs\n"
awk '{ for (i = 1; i < 201; ++i)
printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i);
$PROG -o $TMP3 recno
$TMP2
if (cmp -s $TMP1 $TMP3) ; then :
printf "test2: type recno: failed\n"
# Insert the programs in /bin with their paths as their keys.
printf "Test 3: hash: small key, big data pairs\n"
(find /bin
-type f
-print |
xargs cat) > $TMP1
for i
in `find /bin -type f -print`; do
printf "p\nk%s\nD%s\ng\nk%s\n" $i $i $i
$PROG -o $TMP3 $type $TMP2
if (cmp -s $TMP1 $TMP3) ; then :
printf "test3: %s: page size %d: failed\n" \
printf "Test 3: btree: small key, big data pairs\n"
for psize
in 512 16384 65536; do
printf "\tpage size %d\n" $psize
for i
in `find /bin -type f -print`; do
printf "p\nk%s\nD%s\ng\nk%s\n" $i $i $i
$PROG -i psize
=$psize -o $TMP3 $type $TMP2
if (cmp -s $TMP1 $TMP3) ; then :
printf "test3: %s: page size %d: failed\n" \
printf "Test 3: recno: big data pairs\n"
find /bin
-type f
-print |
printf("p\nk%d\nD%s\ng\nk%d\n", i, $0, i);
for psize
in 512 16384 65536; do
printf "\tpage size %d\n" $psize
$PROG -i psize
=$psize -o $TMP3 recno
$TMP2
if (cmp -s $TMP1 $TMP3) ; then :
printf "test3: recno: page size %d: failed\n" $psize
# Do random recno entries.
printf "Test 4: recno: random entries\n"
echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
for (i = 37; i <= 37 + 88 * 17; i += 17)
printf("input key %d: %.*s\n", i, i % 41, $0);
for (i = 1; i <= 15; ++i)
printf("input key %d: %.*s\n", i, i % 41, $0);
for (i = 19234; i <= 19234 + 61 * 27; i += 27)
printf("input key %d: %.*s\n", i, i % 41, $0);
printf("p\nk%d\nd%s\n", i, $0);
if (i == 19234 + 61 * 27)
for (i = 37; i <= 37 + 88 * 17; i += 17)
for (i = 1; i <= 15; ++i)
for (i = 19234; i <= 19234 + 61 * 27; i += 27)
$PROG -o $TMP3 recno
$TMP2
if (cmp -s $TMP1 $TMP3) ; then :
printf "test4: type recno: failed\n"
# Do reverse order recno entries.
printf "Test 5: recno: reverse order entries\n"
echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
printf("input key %d: %.*s\n", i, i % 34, $0);
printf("p\nk%d\nd%s\n", i, $0);
$PROG -o $TMP3 recno
$TMP2
if (cmp -s $TMP1 $TMP3) ; then :
printf "test5: type recno: failed\n"
# Do alternating order recno entries.
printf "Test 6: recno: alternating order entries\n"
echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
for (i = 1; i < 1200; i += 2)
printf("input key %d: %.*s\n", i, i % 34, $0);
for (i = 2; i < 1200; i += 2)
printf("input key %d: %.*s\n", i, i % 34, $0);
printf("p\nk%d\nd%s\n", i, $0);
for (i = 1; i < 1200; ++i)
$PROG -o $TMP3 recno
$TMP2
if (cmp -s $TMP1 $TMP3) ; then :
printf "test6: type recno: failed\n"
printf "Test 7: btree, recno: delete cursor record\n"
echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
for (i = 1; i <= 120; ++i)
printf("%05d: input key %d: %s\n", i, i, $0);
printf("%05d: input key %d: %s\n", 120, 120, $0);
printf("get failed, no such key\n");
printf("%05d: input key %d: %s\n", 1, 1, $0);
printf("%05d: input key %d: %s\n", 2, 2, $0);
for type in btree recno
; do
printf("p\nk%d\nd%s\n", ++i, $0);
for (i = 1; i <= 120; ++i)
printf("fR_CURSOR\ns\nk120\n");
printf("fR_CURSOR\ns\nk1\n");
$PROG -o $TMP3 recno
$TMP2
if (cmp -s $TMP1 $TMP3) ; then :
printf "test7: type $type: failed\n"
# Make sure that overflow pages are reused.
printf "Test 8: btree, hash: repeated small key, big data pairs\n"
for (i = 1; i <= 10; ++i) {
printf("p\nkkey1\nD/bin/sh\n");
printf("p\nkkey2\nD/bin/csh\n");
printf("c\nkkey2\nD/bin/csh\n");
printf("c\nkkey1\nD/bin/sh\n");
printf("e\t%d of 10 (comparison)\r\n", i);
printf("e\t%d of 10 \r\n", i);
printf("r\nkkey1\nr\nkkey2\n");
printf("eend of test8 run\n");
# No explicit test for success.
# Test btree duplicate keys
printf "Test 9: btree: duplicate keys\n"
echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
for (i = 1; i <= 543; ++i)
printf("%05d: input key %d: %s\n", i, i, $0);
printf("p\nkduplicatekey\nd%s\n", $0);
printf("p\nkunique%dkey\nd%s\n", i, $0);
$PROG -iflags=1 -o $TMP3 $type $TMP2
if (cmp -s $TMP1 $TMP3) ; then :
printf "test9: type $type: failed\n"
# Test use of cursor flags without initialization
printf "Test 10: btree, recno: test cursor flag use\n"
echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
for (i = 1; i <= 20; ++i)
printf("%05d: input key %d: %s\n", i, i, $0);
# Test that R_CURSOR doesn't succeed before cursor initialized
for type in btree recno
; do
printf("p\nk%d\nd%s\n", ++i, $0);
printf("fR_CURSOR\nr\nk1\n");
printf("eR_CURSOR SHOULD HAVE FAILED\n");
$PROG -o $TMP3 $type $TMP2 > /dev
/null
2>&1
printf "Test 10: delete: R_CURSOR SHOULD HAVE FAILED\n"
for type in btree recno
; do
printf("p\nk%d\nd%s\n", ++i, $0);
printf("fR_CURSOR\np\nk1\ndsome data\n");
printf("eR_CURSOR SHOULD HAVE FAILED\n");
$PROG -o $TMP3 $type $TMP2 > /dev
/null
2>&1
printf "Test 10: put: R_CURSOR SHOULD HAVE FAILED\n"
# Test insert in reverse order.
printf "Test 11: recno: reverse order insert\n"
echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" |
for (i = 1; i <= 779; ++i)
printf("%05d: input key %d: %s\n", i, i, $0);
printf("p\nk1\nd%s\n", $0);
printf("%s\n", "fR_IBEFORE");
printf("p\nk1\nd%s\n", $0);
$PROG -o $TMP3 $type $TMP2
if (cmp -s $TMP1 $TMP3) ; then :
printf "test11: type $type: failed\n"
# Take the first 20000 entries in the dictionary, reverse them, and give
# them each a small size data entry. Use a small page size to make sure
# the btree split code gets hammered.
printf "Test 12: btree: lots of keys, small page size\n"
mdata
=abcdefghijklmnopqrstuvwxy
awk '{ for (i = 1; i < 20001; ++i) print $0 }' > $TMP1
for i
in `sed 20000q $DICT | rev`; do
printf "p\nk%s\nd%s\ng\nk%s\n" $i $mdata $i
$PROG -i psize
=512 -o $TMP3 $type $TMP2
if (cmp -s $TMP1 $TMP3) ; then :
printf "test12: type %s: failed\n" $type
# Test different byte orders.
printf "Test 13: btree, hash: differing byte orders\n"
for order
in 1234 4321; do
for type in btree
hash; do
rm -f byte.
file $TMP2 $TMP3
for i
in `sed 50q $DICT`; do
printf "p\nk%s\nd%s\ng\nk%s\n" $i $i $i
$PROG -ilorder=$order -f byte.
file -o $TMP3 $type $TMP2
if (cmp -s $TMP1 $TMP3) ; then :
printf "test13: %s/%s put failed\n" $type $order
for i
in `sed 50q $DICT`; do
$PROG -ilorder=$order -f byte.
file -o $TMP3 $type $TMP2
if (cmp -s $TMP1 $TMP3) ; then :
printf "test13: %s/%s get failed\n" $type $order
# Try a variety of bucketsizes and fill factors for hashing
"Test 20: hash: bucketsize, fill factor; nelem 25000 cachesize 65536\n"
for (i = 1; i <= 10000; ++i)
"abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg");
printf("p\nk%s\nd%.*s\n", $0, i % 34,
"abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg");
for ffactor
in 11 14 21; do
printf "\tbucketsize %d, fill factor %d\n" $bsize $ffactor
-ibsize=$bsize,ffactor
=$ffactor,nelem
=25000,cachesize
=65536\
if (cmp -s $TMP1 $TMP3) ; then :
printf "test20: type hash:\
bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed\n"
for ffactor
in 21 28 43; do
printf "\tbucketsize %d, fill factor %d\n" $bsize $ffactor
-ibsize=$bsize,ffactor
=$ffactor,nelem
=25000,cachesize
=65536\
if (cmp -s $TMP1 $TMP3) ; then :
printf "test20: type hash:\
bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed\n"
for ffactor
in 43 57 85; do
printf "\tbucketsize %d, fill factor %d\n" $bsize $ffactor
-ibsize=$bsize,ffactor
=$ffactor,nelem
=25000,cachesize
=65536\
if (cmp -s $TMP1 $TMP3) ; then :
printf "test20: type hash:\
bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed\n"
for ffactor
in 85 114 171; do
printf "\tbucketsize %d, fill factor %d\n" $bsize $ffactor
-ibsize=$bsize,ffactor
=$ffactor,nelem
=25000,cachesize
=65536\
if (cmp -s $TMP1 $TMP3) ; then :
printf "test20: type hash:\
bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed\n"
for ffactor
in 171 228 341; do
printf "\tbucketsize %d, fill factor %d\n" $bsize $ffactor
-ibsize=$bsize,ffactor
=$ffactor,nelem
=25000,cachesize
=65536\
if (cmp -s $TMP1 $TMP3) ; then :
printf "test20: type hash:\
bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed\n"
for ffactor
in 341 455 683; do
printf "\tbucketsize %d, fill factor %d\n" $bsize $ffactor
-ibsize=$bsize,ffactor
=$ffactor,nelem
=25000,cachesize
=65536\
if (cmp -s $TMP1 $TMP3) ; then :
printf "test20: type hash:\
bsize=$bsize ffactor=$ffactor nelem=25000 cachesize=65536 failed\n"