From: drh Date: Fri, 10 Mar 2017 01:05:38 +0000 (+0000) Subject: Improvements to ".selftest --init". Tests are number in increments of 10 X-Git-Tag: version-3.18.0~63 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f157d10f9f557e4117d3267eba89d817141feead;p=thirdparty%2Fsqlite.git Improvements to ".selftest --init". Tests are number in increments of 10 starting with 100. The tests are generated inside a SAVEPOINT. Errors are reported during test generation. Tests can be appended to existing tests. Add a test case to verify the schema. FossilOrigin-Name: b044b152aac2ec606750940ea816ad4a4aef8eb6 --- diff --git a/manifest b/manifest index 3b64809139..5ebdb5663f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sthe\stest/dbselftest.c\sprogram.\s\sIn\sits\splace,\sadd\sthe\s".selftest"\ncommand\sto\sthe\sCLI.\s\sThe\snew\sCLI\sversion\sis\s.selftest\sis\sslightly\sdifferent\nin\sthat\sit\suses\sSHA3\shashing\sinstead\sof\sSHA1,\sso\sthe\snew\sis\ssubtly\s\nincompatible\swith\sthe\sold. -D 2017-03-09T22:00:33.842 +C Improvements\sto\s".selftest\s--init".\s\sTests\sare\snumber\sin\sincrements\sof\s10\nstarting\swith\s100.\s\sThe\stests\sare\sgenerated\sinside\sa\sSAVEPOINT.\s\sErrors\sare\nreported\sduring\stest\sgeneration.\s\sTests\scan\sbe\sappended\sto\sexisting\stests.\nAdd\sa\stest\scase\sto\sverify\sthe\sschema. +D 2017-03-10T01:05:38.013 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc a89ea37ab5928026001569f056973b9059492fe2 @@ -400,7 +400,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c 3e518b962d932a997fae373366880fc028c75706 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c d12f3539f80db38b09015561b569e0eb1c4b6c5f -F src/shell.c 2009654e24924b51a54afb925b49034f1c5460d4 +F src/shell.c 0435e7ea18865e8bd435c9fbe018e1a8431964a7 F src/sqlite.h.in 4d0c08f8640c586564a7032b259c5f69bf397850 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae @@ -1563,7 +1563,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 6c627e50622d8bcd25ec7d5503f3fafd725673a8 -R de6856f188fdc076241cbc67ee174b05 +P f4fcd46f08ba59d2a3e772cad98383129f648386 +R 2a153e04b79acc8e7981c04d4b205835 U drh -Z 85b6274077eac0b5500dd53648c9e848 +Z c20519a5ebf6e7586b129dc9c77c4f4b diff --git a/manifest.uuid b/manifest.uuid index e2ef7d5abf..d8526f73db 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f4fcd46f08ba59d2a3e772cad98383129f648386 \ No newline at end of file +b044b152aac2ec606750940ea816ad4a4aef8eb6 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 17048adb3d..4912639dbc 100644 --- a/src/shell.c +++ b/src/shell.c @@ -2073,14 +2073,26 @@ static int captureOutputCallback(void *pArg, int nArg, char **azArg, char **az){ ** Generate an appropriate SELFTEST table in the main database. */ static void createSelftestTable(ShellState *p){ + char *zErrMsg = 0; sqlite3_exec(p->db, - "CREATE TABLE selftest(\n" + "SAVEPOINT selftest_init;\n" + "CREATE TABLE IF NOT EXISTS selftest(\n" " tno INTEGER PRIMARY KEY,\n" /* Test number */ " op TEXT,\n" /* Operator: memo run */ " cmd TEXT,\n" /* Command text */ " ans TEXT\n" /* Desired answer */ ");" - "INSERT INTO selftest(op,cmd,ans)\n" + "CREATE TEMP TABLE [_shell$self](op,cmd,ans);\n" + "INSERT INTO [_shell$self](rowid,op,cmd)\n" + " VALUES(coalesce((SELECT (max(tno)+100)/10 FROM selftest),10),\n" + " 'memo','Tests generated by --init');\n" + "INSERT INTO [_shell$self]\n" + " SELECT 'run',\n" + " 'SELECT hex(sha3_query(''SELECT type,name,tbl_name,sql " + "FROM sqlite_master ORDER BY 2'',224))',\n" + " hex(sha3_query('SELECT type,name,tbl_name,sql " + "FROM sqlite_master ORDER BY 2',224));\n" + "INSERT INTO [_shell$self]\n" " SELECT 'run'," " 'SELECT hex(sha3_query(''SELECT * FROM \"' ||" " printf('%w',name) || '\" NOT INDEXED'',224))',\n" @@ -2092,9 +2104,17 @@ static void createSelftestTable(ShellState *p){ " AND coalesce(rootpage,0)>0\n" " )\n" " ORDER BY name;\n" - "INSERT INTO selftest(op,cmd,ans)\n" + "INSERT INTO [_shell$self]\n" " VALUES('run','PRAGMA integrity_check','ok');\n" - ,0,0,0); + "INSERT INTO selftest(tno,op,cmd,ans)" + " SELECT rowid*10,op,cmd,ans FROM [_shell$self];\n" + "DROP TABLE [_shell$self];" + ,0,0,&zErrMsg); + if( zErrMsg ){ + utf8_printf(stderr, "SELFTEST initialization failure: %s\n", zErrMsg); + sqlite3_free(zErrMsg); + } + sqlite3_exec(p->db, "RELEASE selftest_init",0,0,0); } @@ -5813,11 +5833,6 @@ static int do_meta_command(char *zLine, ShellState *p){ bSelftestExists = 1; } if( bIsInit ){ - if( bSelftestExists ){ - raw_printf(stderr, "The selftest table already exists\n"); - rc = 1; - goto meta_command_exit; - } createSelftestTable(p); bSelftestExists = 1; }