1*56038Sbostic#!/bin/sh - 2*56038Sbostic# 3*56038Sbostic# Copyright (c) 1992 The Regents of the University of California. 4*56038Sbostic# All rights reserved. 5*56038Sbostic# 6*56038Sbostic# %sccs.include.redist.sh% 7*56038Sbostic# 8*56038Sbostic# @(#)run.test 5.1 (Berkeley) 08/26/92 9*56038Sbostic# 10*56038Sbostic 11*56038Sbostic# db regression tests 12*56038Sbostic 13*56038Sbosticmain() 14*56038Sbostic{ 15*56038Sbostic DICT=/usr/share/dict/words 16*56038Sbostic TMP1=t1 17*56038Sbostic TMP2=t2 18*56038Sbostic TMP3=t3 19*56038Sbostic 20*56038Sbostic test1 21*56038Sbostic test2 22*56038Sbostic test3 23*56038Sbostic test4 24*56038Sbostic rm -f $TMP1 $TMP2 $TMP3 25*56038Sbostic} 26*56038Sbostic 27*56038Sbostic# Take the first hundred entries in the dictionary, and make them 28*56038Sbostic# be key/data pairs. 29*56038Sbostictest1() 30*56038Sbostic{ 31*56038Sbostic printf "Test1: btree, hash: small key, small data pairs\n" 32*56038Sbostic for i in `sed 200q $DICT`; do 33*56038Sbostic printf "%s\n" $i 34*56038Sbostic done > $TMP1 35*56038Sbostic for type in btree hash; do 36*56038Sbostic rm -f $TMP2 $TMP3 37*56038Sbostic for i in `sed 200q $DICT`; do 38*56038Sbostic printf "p\nk%s\nd%s\ng\nk%s\n" $i $i $i 39*56038Sbostic done > $TMP2 40*56038Sbostic ./dbtest -o $TMP3 $type $TMP2 41*56038Sbostic if (cmp -s $TMP1 $TMP3) ; then 42*56038Sbostic else 43*56038Sbostic printf "test1: type %s: failed\n" $type 44*56038Sbostic exit 1 45*56038Sbostic fi 46*56038Sbostic done 47*56038Sbostic printf "Test1: recno: small key, small data pairs\n" 48*56038Sbostic rm -f $TMP2 $TMP3 49*56038Sbostic sed 200q $DICT | 50*56038Sbostic awk '{ 51*56038Sbostic ++i; 52*56038Sbostic printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); 53*56038Sbostic }' > $TMP2 54*56038Sbostic ./dbtest -o $TMP3 recno $TMP2 55*56038Sbostic if (cmp -s $TMP1 $TMP3) ; then 56*56038Sbostic else 57*56038Sbostic printf "test1: type recno: failed\n" 58*56038Sbostic exit 1 59*56038Sbostic fi 60*56038Sbostic} 61*56038Sbostic 62*56038Sbostic# Take the first hundred entries in the dictionary, and give them 63*56038Sbostic# each a medium size data entry. 64*56038Sbostictest2() 65*56038Sbostic{ 66*56038Sbostic printf "Test2: btree, hash: small key, medium data pairs\n" 67*56038Sbostic mdata=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz 68*56038Sbostic echo $mdata | 69*56038Sbostic awk '{ for (i = 1; i < 201; ++i) print $0 }' > $TMP1 70*56038Sbostic for type in hash btree; do 71*56038Sbostic rm -f $TMP2 $TMP3 72*56038Sbostic for i in `sed 200q $DICT`; do 73*56038Sbostic printf "p\nk%s\nd%s\ng\nk%s\n" $i $mdata $i 74*56038Sbostic done > $TMP2 75*56038Sbostic ./dbtest -o $TMP3 $type $TMP2 76*56038Sbostic if (cmp -s $TMP1 $TMP3) ; then 77*56038Sbostic else 78*56038Sbostic printf "test2: type %s: failed\n" $type 79*56038Sbostic exit 1 80*56038Sbostic fi 81*56038Sbostic done 82*56038Sbostic printf "Test2: recno: small key, medium data pairs\n" 83*56038Sbostic rm -f $TMP2 $TMP3 84*56038Sbostic echo $mdata | 85*56038Sbostic awk '{ for (i = 1; i < 201; ++i) 86*56038Sbostic printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); 87*56038Sbostic }' > $TMP2 88*56038Sbostic ./dbtest -o $TMP3 recno $TMP2 89*56038Sbostic if (cmp -s $TMP1 $TMP3) ; then 90*56038Sbostic else 91*56038Sbostic printf "test2: type recno: failed\n" 92*56038Sbostic exit 1 93*56038Sbostic fi 94*56038Sbostic} 95*56038Sbostic 96*56038Sbostic# Insert the programs in /bin with their paths as their keys. 97*56038Sbostictest3() 98*56038Sbostic{ 99*56038Sbostic printf "Test3: btree, hash: small key, big data pairs\n" 100*56038Sbostic rm -f $TMP1 101*56038Sbostic (find /bin -type f -print | xargs cat) > $TMP1 102*56038Sbostic for type in hash btree; do 103*56038Sbostic rm -f $TMP2 $TMP3 104*56038Sbostic for i in `find /bin -type f -print`; do 105*56038Sbostic printf "p\nk%s\nD%s\ng\nk%s\n" $i $i $i 106*56038Sbostic done > $TMP2 107*56038Sbostic ./dbtest -o $TMP3 $type $TMP2 108*56038Sbostic if (cmp -s $TMP1 $TMP3) ; then 109*56038Sbostic else 110*56038Sbostic printf "test2: type %s: failed\n" $type 111*56038Sbostic exit 1 112*56038Sbostic fi 113*56038Sbostic done 114*56038Sbostic printf "Test3: recno: big data pairs\n" 115*56038Sbostic rm -f $TMP2 $TMP3 116*56038Sbostic find /bin -type f -print | 117*56038Sbostic awk '{ 118*56038Sbostic ++i; 119*56038Sbostic printf("p\nk%d\nD%s\ng\nk%d\n", i, $0, i); 120*56038Sbostic }' > $TMP2 121*56038Sbostic ./dbtest -o $TMP3 recno $TMP2 122*56038Sbostic if (cmp -s $TMP1 $TMP3) ; then 123*56038Sbostic else 124*56038Sbostic printf "test3: type recno: failed\n" 125*56038Sbostic exit 1 126*56038Sbostic fi 127*56038Sbostic} 128*56038Sbostic 129*56038Sbostic# Do random recno entries. 130*56038Sbostictest4() 131*56038Sbostic{ 132*56038Sbostic printf "Test4: recno: random entries\n" 133*56038Sbostic echo "abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" | 134*56038Sbostic awk '{ 135*56038Sbostic for (i = 37; i <= 37 + 88 * 17; i += 17) 136*56038Sbostic printf("input key %d: %s\n", i, $0); 137*56038Sbostic for (i = 1; i <= 15; ++i) 138*56038Sbostic printf("input key %d: %s\n", i, $0); 139*56038Sbostic for (i = 19234; i <= 19234 + 61 * 27; i += 27) 140*56038Sbostic printf("input key %d: %s\n", i, $0); 141*56038Sbostic exit 142*56038Sbostic }' > $TMP1 143*56038Sbostic rm -f TMP2 $TMP3 144*56038Sbostic cat $TMP1 | awk 'BEGIN { 145*56038Sbostic i = 37; 146*56038Sbostic incr = 17; 147*56038Sbostic } 148*56038Sbostic { 149*56038Sbostic printf("p\nk%d\nd%s\n", i, $0); 150*56038Sbostic if (i == 19234 + 61 * 27) 151*56038Sbostic exit; 152*56038Sbostic if (i == 37 + 88 * 17) { 153*56038Sbostic i = 1; 154*56038Sbostic incr = 1; 155*56038Sbostic } else if (i == 15) { 156*56038Sbostic i = 19234; 157*56038Sbostic incr = 27; 158*56038Sbostic } else 159*56038Sbostic i += incr; 160*56038Sbostic } 161*56038Sbostic END { 162*56038Sbostic for (i = 37; i <= 37 + 88 * 17; i += 17) 163*56038Sbostic printf("g\nk%d\n", i); 164*56038Sbostic for (i = 1; i <= 15; ++i) 165*56038Sbostic printf("g\nk%d\n", i); 166*56038Sbostic for (i = 19234; i <= 19234 + 61 * 27; i += 27) 167*56038Sbostic printf("g\nk%d\n", i); 168*56038Sbostic }' > $TMP2 169*56038Sbostic ./dbtest -o $TMP3 recno $TMP2 170*56038Sbostic if (cmp -s $TMP1 $TMP3) ; then 171*56038Sbostic else 172*56038Sbostic printf "test4: type recno: failed\n" 173*56038Sbostic exit 1 174*56038Sbostic fi 175*56038Sbostic} 176*56038Sbostic 177*56038Sbosticmain 178