From 1e75280b15cfe2081c2feba52deba1e17b208380 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Thu, 12 Aug 2004 23:00:20 +0000 Subject: [PATCH] * run.test (getnwords): New function. Uses sed to get N words from $DICT as other functions did before, but discards blank lines. (test1, test2, test12, test13, test20): Call getnwords. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16660 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/db2/test/ChangeLog | 7 +++++++ src/util/db2/test/run.test | 25 ++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/util/db2/test/ChangeLog b/src/util/db2/test/ChangeLog index 82072aa85..3b1711366 100644 --- a/src/util/db2/test/ChangeLog +++ b/src/util/db2/test/ChangeLog @@ -1,3 +1,10 @@ +2004-08-12 Ken Raeburn + + * run.test (getnwords): New function. Uses sed to get N words + from $DICT as other functions did before, but discards blank + lines. + (test1, test2, test12, test13, test20): Call getnwords. + 2003-01-05 Sam Hartman * SEQ_TEST/t.c (main): Remove declaration of errno diff --git a/src/util/db2/test/run.test b/src/util/db2/test/run.test index af69c504e..8def66fae 100644 --- a/src/util/db2/test/run.test +++ b/src/util/db2/test/run.test @@ -68,15 +68,19 @@ main() exit 0 } +getnwords() { + sed -e ${1}q -e '/^$/d' $DICT +} + # Take the first hundred entries in the dictionary, and make them # be key/data pairs. test1() { echo "Test 1: btree, hash: small key, small data pairs" - sed 200q $DICT > $TMP1 + getnwords 200 > $TMP1 for type in btree hash; do rm -f $TMP2 $TMP3 - for i in `sed 200q $DICT`; do + for i in `cat $TMP1`; do echo p echo k$i echo d$i @@ -92,11 +96,10 @@ test1() done echo "Test 1: recno: small key, small data pairs" rm -f $TMP2 $TMP3 - sed 200q $DICT | awk '{ ++i; printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i); - }' > $TMP2 + }' < $TMP1 > $TMP2 $PROG -o $TMP3 recno $TMP2 if (cmp -s $TMP1 $TMP3) ; then : else @@ -115,7 +118,7 @@ test2() awk '{ for (i = 1; i < 201; ++i) print $0 }' > $TMP1 for type in hash btree; do rm -f $TMP2 $TMP3 - for i in `sed 200q $DICT`; do + for i in `getnwords 200`; do echo p echo k$i echo d$mdata @@ -566,7 +569,7 @@ test12() awk '{ for (i = 1; i < 20001; ++i) print $0 }' > $TMP1 for type in btree; do rm -f $TMP2 $TMP3 - for i in `sed 20000q $DICT | rev`; do + for i in `getnwords 20000 | rev`; do echo p echo k$i echo d$mdata @@ -586,11 +589,11 @@ test12() test13() { echo "Test 13: btree, hash: differing byte orders" - sed 50q $DICT > $TMP1 + getnwords 50 > $TMP1 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 + for i in `cat $TMP1`; do echo p echo k$i echo d$i @@ -603,7 +606,7 @@ test13() echo "test13: $type/$order put failed" exit 1 fi - for i in `sed 50q $DICT`; do + for i in `cat $TMP1`; do echo g echo k$i done > $TMP2 @@ -641,7 +644,7 @@ test20() } exit; }' > $TMP1 - sed 10000q $DICT | + getnwords 10000 | awk 'BEGIN { ds="abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg" } @@ -652,7 +655,7 @@ test20() s = substr(ds, 1); printf("p\nk%s\nd%s\n", $0, s); }' > $TMP2 - sed 10000q $DICT | + getnwords 10000 | awk '{ ++i; printf("g\nk%s\n", $0); -- 2.26.2