From c39ba47f61857bfee01651c14b8b51b2448c6f7c Mon Sep 17 00:00:00 2001 From: Gregory Burd Date: Tue, 1 Sep 2009 19:21:41 -0400 Subject: [PATCH] Finished a pass over all the non-SQLite derrived tests (which all live in scr050) and brought them up to date, some minor fixes along the way. A few tests don't work properly, I've noted those in the TODO file for some other time. --- TODO | 24 +++++++++++-- test/scr014/chk.err | 4 ++- test/scr018/chk.comma | 54 +++++++++++++++++++++++++++++ test/scr018/t.c | 46 ------------------------- test/scr019/chk.include | 2 ++ test/scr020/chk.inc | 2 ++ test/scr021/chk.flags | 75 +++++++++++++++++++++++++++++++++++++++++ test/scr021/t.c | 69 ------------------------------------- test/scr022/chk.rr | 23 +++++++------ test/scr026/chk.method | 10 +++--- test/scr030/chk.build | 14 ++++---- 11 files changed, 183 insertions(+), 140 deletions(-) delete mode 100644 test/scr018/t.c delete mode 100644 test/scr021/t.c diff --git a/TODO b/TODO index d8c927a..bbda7d6 100644 --- a/TODO +++ b/TODO @@ -1,25 +1,43 @@ * Check all DB API calls - Make sure a) we check return codes for for all calls into DB and + Make sure a) we check return codes for for all calls into DB and that b) when there is an error we output it only when configured to be verbose and c) then return the proper DBSQL error indicating what went wrong at a higher level. * Review all reused DB code - Make sure that we're up to date with the latest in DB. Things such + Make sure that we're up to date with the latest in DB. Things such as hashing, etc. +* Find printf/fprintf calls which print error messages + The library should never print messages unless configured to be + verbose. + * splint + Clean up all items pointed out by splint. * makedepend * valgrind + Fix all memory related bugs. + +* review dbsql/dbsql.c + General clean-up including changing calls to malloc, free, etc to + __os_malloc, __os_free, etc. * Review SQLite's latest lemon.c and lempar.c code * Review code for trailing spaces, tab characters, lines > 79 col * api.c/__os_sleep() - This is now static in DB's code, so to hack the compile I commented + This is now static in DB's code, so to hack the compile I commented out the use of __os_sleep() in api.c +* test/scr026 + This test has not been updated to check for DBSQL API calls rather + than DB API calls. Review and fix it. + +* test/scr030 + Update this test to match the configure script. Augment it so that + as the configure script changes the script reports options not tested. + diff --git a/test/scr014/chk.err b/test/scr014/chk.err index d6400b4..8132faf 100644 --- a/test/scr014/chk.err +++ b/test/scr014/chk.err @@ -15,6 +15,8 @@ d=../.. t1=__1 t2=__2 +trap 'rm -f $t1 $t2' 0 1 2 3 13 15 + egrep -- "define.*DBSQL_.*-509" $d/src/dbsql.in | awk '{print $2}' > $t1 sed -e '/^dbsql_strerror/,/^}/{' \ -e '/ case DBSQL_/{' \ @@ -27,6 +29,6 @@ sed -e '/^dbsql_strerror/,/^}/{' \ < $d/src/common/dbsql_err.c > $t2 cmp $t1 $t2 > /dev/null || -(echo "<<< db.h >>> db_strerror" && diff $t1 $t2 && exit 1) +(echo "<<< dbsql.h >>> db_strerror" && diff $t1 $t2 && exit 1) exit 0 diff --git a/test/scr018/chk.comma b/test/scr018/chk.comma index 83af9f3..66f4215 100644 --- a/test/scr018/chk.comma +++ b/test/scr018/chk.comma @@ -15,6 +15,60 @@ d=../.. exit 1 } +trap 'rm -f t t.c' 0 1 2 3 13 15 + +cat << END_OF_CODE > t.c +#include + +#include +#include +#include +#include +#include + +extern int isblank(int c); + +int +chk(f) + char *f; +{ + int ch, l, r; + + if (freopen(f, "r", stdin) == NULL) { + fprintf(stderr, "%s: %s\n", f, strerror(errno)); + exit (1); + } + for (l = 1, r = 0; (ch = getchar()) != EOF;) { + if (ch != ',') + goto next; + do { ch = getchar(); } while (isblank(ch)); + if (ch != '\n') + goto next; + ++l; + do { ch = getchar(); } while (isblank(ch)); + if (ch != '}') + goto next; + r = 1; + printf("%s: line %d\n", f, l); + +next: if (ch == '\n') + ++l; + } + return (r); +} + +int +main(int argc, char *argv[]) +{ + int r; + + for (r = 0; *++argv != NULL;) + if (chk(*argv)) + r = 1; + return (r); +} +END_OF_CODE + if cc -g -Wall -I.. t.c -o t; then : else diff --git a/test/scr018/t.c b/test/scr018/t.c deleted file mode 100644 index 4056a60..0000000 --- a/test/scr018/t.c +++ /dev/null @@ -1,46 +0,0 @@ -#include - -#include -#include -#include -#include - -int -chk(f) - char *f; -{ - int ch, l, r; - - if (freopen(f, "r", stdin) == NULL) { - fprintf(stderr, "%s: %s\n", f, strerror(errno)); - exit (1); - } - for (l = 1, r = 0; (ch = getchar()) != EOF;) { - if (ch != ',') - goto next; - do { ch = getchar(); } while (isblank(ch)); - if (ch != '\n') - goto next; - ++l; - do { ch = getchar(); } while (isblank(ch)); - if (ch != '}') - goto next; - r = 1; - printf("%s: line %d\n", f, l); - -next: if (ch == '\n') - ++l; - } - return (r); -} - -int -main(int argc, char *argv[]) -{ - int r; - - for (r = 0; *++argv != NULL;) - if (chk(*argv)) - r = 1; - return (r); -} diff --git a/test/scr019/chk.include b/test/scr019/chk.include index 74bfe0a..ef1ff10 100644 --- a/test/scr019/chk.include +++ b/test/scr019/chk.include @@ -13,6 +13,8 @@ d=../.. t1=__1 t2=__2 +trap 'rm -f $t1 $t2' 0 1 2 3 13 15 + egrep -- '#include[ ]' $d/src/inc/dbsql_int.in | sed -e '/[ ]db\.h'/d \ -e 's/^#include.//' \ diff --git a/test/scr020/chk.inc b/test/scr020/chk.inc index 4f1fad2..3a8ac1b 100644 --- a/test/scr020/chk.inc +++ b/test/scr020/chk.inc @@ -13,6 +13,8 @@ d=../.. t1=__1 t2=__2 +trap 'rm -f $t1 $t2' 0 1 2 3 13 15 + (cd $d && find . -name '*.[chys]' -o -name '*.cpp' | xargs egrep -l '#include.*dbsql_config.h') | tee /tmp/o > $t1 diff --git a/test/scr021/chk.flags b/test/scr021/chk.flags index 9f386d5..c6b7e65 100644 --- a/test/scr021/chk.flags +++ b/test/scr021/chk.flags @@ -6,6 +6,81 @@ d=../.. t1=__1 t2=__2 +trap 'rm -f $t1 $t2 t' 0 1 2 3 13 15 + +cat << END_OF_CODE > t.c +#include + +#include +#include +#include +#include +#include + +void +chk(f, str) + char *f, *str; +{ + char *s; + int ch, l, ok, pc; + + if (freopen(f, "r", stdin) == NULL) { + fprintf(stderr, "%s: %s\n", f, strerror(errno)); + exit (1); + } + + for (l = 1, ok = 1, s = str; (ch = getchar()) != EOF;) { + if (ch == '\n') + ++l; + if (!ok || ch != *s) { + s = str; + ok = !isalpha(ch) && !isdigit(ch) && ch != '_'; + continue; + } + if (*++s != '\0') + continue; + + /* Match. */ + printf("%s: %d: %s", f, l, str); + for (pc = 1; (ch = getchar()) != EOF;) { + switch (ch) { + case '(': + ++pc; + break; + case ')': + --pc; + break; + case '\n': + ++l; + break; + } + if (ch == '\n') + putchar(' '); + else + putchar(ch); + if (pc <= 0) { + putchar('\n'); + break; + } + } + s = str; + } +} + +int +main(int argc, char *argv[]) +{ + int r; + + for (r = 0; *++argv != NULL;) { + chk(*argv, "F_ISSET("); + chk(*argv, "F_CLR("); + chk(*argv, "F_SET("); + } + return (0); +} +END_OF_CODE + if cc -g -Wall -I.. t.c -o t; then : else diff --git a/test/scr021/t.c b/test/scr021/t.c deleted file mode 100644 index a45865c..0000000 --- a/test/scr021/t.c +++ /dev/null @@ -1,69 +0,0 @@ -#include - -#include -#include -#include -#include - -void -chk(f, str) - char *f, *str; -{ - char *s; - int ch, l, ok, pc; - - if (freopen(f, "r", stdin) == NULL) { - fprintf(stderr, "%s: %s\n", f, strerror(errno)); - exit (1); - } - - for (l = 1, ok = 1, s = str; (ch = getchar()) != EOF;) { - if (ch == '\n') - ++l; - if (!ok || ch != *s) { - s = str; - ok = !isalpha(ch) && !isdigit(ch) && ch != '_'; - continue; - } - if (*++s != '\0') - continue; - - /* Match. */ - printf("%s: %d: %s", f, l, str); - for (pc = 1; (ch = getchar()) != EOF;) { - switch (ch) { - case '(': - ++pc; - break; - case ')': - --pc; - break; - case '\n': - ++l; - break; - } - if (ch == '\n') - putchar(' '); - else - putchar(ch); - if (pc <= 0) { - putchar('\n'); - break; - } - } - s = str; - } -} - -int -main(int argc, char *argv[]) -{ - int r; - - for (r = 0; *++argv != NULL;) { - chk(*argv, "F_ISSET("); - chk(*argv, "F_CLR("); - chk(*argv, "F_SET("); - } - return (0); -} diff --git a/test/scr022/chk.rr b/test/scr022/chk.rr index b4a5595..d993e08 100644 --- a/test/scr022/chk.rr +++ b/test/scr022/chk.rr @@ -1,25 +1,26 @@ #!/bin/sh - # -# Check for DB_RUNRECOVERY being specified instead of a call -# to dbsql_panic. +# Check for DB_RUNRECOVERY being specified instead of a call to dbsql_panic. d=../.. t1=__1 -egrep DB_RUNRECOVERY $d/*/*.c | - sed -e '/__db_panic(.*, DB_RUNRECOVERY)/d' \ - -e '/case DB_RUNRECOVERY:/d' \ - -e '/db_dispatch.c:.*if (ret == DB_RUNRECOVERY/d' \ +trap 'rm -f $t1' 0 1 2 3 13 15 + +egrep DBSQL_RUNRECOVERY $d/*/*.c $d/*/*/*.c | + sed -e '/__db_panic(.*, DBSQL_RUNRECOVERY)/d' \ + -e '/case DBSQL_RUNRECOVERY:/d' \ + -e '/db_dispatch.c:.*if (ret == DBSQL_RUNRECOVERY/d' \ -e '/db_err.c:/d' \ - -e '/os_errno.c:.*evalue == DB_RUNRECOVERY/d' \ + -e '/os_errno.c:.*evalue == DBSQL_RUNRECOVERY/d' \ -e '/\/php_db4\//d' \ - -e '/rep_backup.c:.*Panic the env and return DB_RUNRECOVERY/d' \ - -e '/txn.c:.* \* DB_RUNRECOVERY and we need to/d' \ - -e '/txn.c:.*returned DB_RUNRECOVERY and we need to/d' \ + -e '/rep_backup.c:.*Panic the env and return DBSQL_RUNRECOVERY/d' \ + -e '/txn.c:.* \* DBSQL_RUNRECOVERY and we need to/d' \ + -e '/txn.c:.*returned DBSQL_RUNRECOVERY and we need to/d' \ > $t1 [ -s $t1 ] && { - echo "DB_RUNRECOVERY used; should be a call to dbsql_panic." + echo "DBSQL_RUNRECOVERY used; should be a call to dbsql_panic." cat $t1 exit 1 } diff --git a/test/scr026/chk.method b/test/scr026/chk.method index 46d1522..583744e 100644 --- a/test/scr026/chk.method +++ b/test/scr026/chk.method @@ -4,7 +4,9 @@ d=../.. -t=__1 +t1=__1 + +trap 'rm -f $t1' 0 1 2 3 13 15 echo ============================================================ echo "Check that DBSQL doesn't call DBSQL_ENV methods internally." @@ -80,10 +82,10 @@ sed \ -e '/db_iface.c:.*if ((t_ret = txn->abort(txn)) != 0)/d' \ -e '/db_iface.c:.*return (dbenv->txn_begin(dbenv, NULL, txnidp, 0));/d' \ -e '/rep_util.c:.*ret = dbenv->rep_send(dbenv, &cdbt, dbtp, &cntrl.lsn,/d' \ ->$t +>$t1 -test -s $t && { - cat $t +test -s $t1 && { + cat $t1 echo "FAIL: found DB/DB_ENV method calls DB library." exit 1 } diff --git a/test/scr030/chk.build b/test/scr030/chk.build index c993938..e412b8f 100644 --- a/test/scr030/chk.build +++ b/test/scr030/chk.build @@ -2,8 +2,10 @@ # # Build a program that calls the run-time API configuration functions. -trap 'rm -rf scr030 ; exit 0' 0 -trap 'rm -rf scr030 ; exit 1' 1 2 3 13 15 +t=__1 + +trap 'rm -rf $t ; exit 0' 0 +trap 'rm -rf $t ; exit 1' 1 2 3 13 15 [ -d ../../dist ] || { echo 'FAIL: unable to find top-level dist directory' @@ -38,9 +40,9 @@ s="\ r() { echo "run: $1 (`date`)" - rm -rf scr030 - mkdir scr030 - cd scr030 + rm -rf $t + mkdir $t + cd $t ../../../dist/configure $1 > config.OUT 2>&1 if test $? -ne 0; then echo "$i: FAILED in configure" @@ -67,7 +69,7 @@ r() exit 1 fi cd .. - rm -rf scr030 + rm -rf $t } # Run through all of the standard single options.