diff options
author | drh <drh@noemail.net> | 2017-03-10 01:05:38 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2017-03-10 01:05:38 +0000 |
commit | f157d10f9f557e4117d3267eba89d817141feead (patch) | |
tree | 32d166b6851bcec86c9527133d7dc99fb538b0a7 /src/shell.c | |
parent | fb546afb4dfa625b657ecd48b55cd936be617f4f (diff) | |
download | sqlite-f157d10f9f557e4117d3267eba89d817141feead.tar.gz sqlite-f157d10f9f557e4117d3267eba89d817141feead.zip |
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
Diffstat (limited to 'src/shell.c')
-rw-r--r-- | src/shell.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/shell.c b/src/shell.c index 17048adb3..4912639db 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; } |