]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Enhance the --testset option on speedtest1 so that it can accept a
authordrh <drh@noemail.net>
Tue, 23 Jun 2020 20:03:57 +0000 (20:03 +0000)
committerdrh <drh@noemail.net>
Tue, 23 Jun 2020 20:03:57 +0000 (20:03 +0000)
comma-separated list of test modules to run in order.

FossilOrigin-Name: 780e8aaa231b2b585505c3886d5a13d39dba546fdd8020331ad4de2ae92922b0

manifest
manifest.uuid
test/speedtest1.c

index 0b3bcbb7cbcdd20e7712888ade3cf78e00570fad..82b7e9a8cf4fe39e12d2f7d54a2f63e7914e635a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,15 +1,16 @@
 B 7a876209a678a34c198b54ceef9e3c041f128a14dc73357f6a57cadadaa6cf7b
-C Try\sto\sremove\send-of-line\swhitespace\swhen\sbuilding\sthe\samalgamation.
-D 2020-06-23T17:57:08.246
+C Enhance\sthe\s--testset\soption\son\sspeedtest1\sso\sthat\sit\scan\saccept\sa\ncomma-separated\slist\sof\stest\smodules\sto\srun\sin\sorder.
+D 2020-06-23T20:03:57.052
 F Makefile.in 50fc38e4f846af70c248542d2ad4e3bca3d80e3f1b9137ce79b047743d4b642c
 F autoconf/Makefile.am a8d1d24affe52ebf8d7ddcf91aa973fa0316618ab95bb68c87cabf8faf527dc8
 F ext/lsm1/lsm_unix.c 11e0a5c19d754a4e1d93dfad06de8cc201f10f886b8e61a4c599ed34e334fc24
 F main.mk f3c3de159abc51086a16a72d0b48077d2dda6a8dfb96963f8a010136bfd98108
 F src/build.c ba1bbe563a3dc02d5fed20537603181e5289c13ea30ae5e775f552e7557adbfa
+F test/speedtest1.c ea201573f9b27542ea1e74a68e74f121e0eb04c89e67039f40ed68f1b833339f
 F tool/mkautoconfamal.sh f62353eb6c06ab264da027fd4507d09914433dbdcab9cb011cdc18016f1ab3b8
 F tool/mksqlite3c.tcl f4ef476510eca4124c874a72029f1e01bc54a896b1724e8f9eef0d8bfae0e84c
 F tool/mksqlite3h.tcl 1f5e4a1dbbbc43c83cc6e74fe32c6c620502240b66c7c0f33a51378e78fc4edf
-P da06168c09df5c0e8e10d0f9618e69217d4c0173a8199660bad2805f009d7b08
-R 7af66bc76cb343914228fa6828a4ffad
+P be3e7814e4cdbc09eaa5112d7d4135b3a2cedbfe66217d9973b1b39a44464e93
+R 47e65a6f24865bd9ab4c304f87268263
 U drh
-Z a5bf96a8fc83efdbdbe4a96339c12501
+Z f8b3e680afb6982734a50031a1a2994e
index 4b407558c0938161792555d80d1bebe69a309af0..b7330e92e58350644eb0317fe2be786aa6a4452e 100644 (file)
@@ -1 +1 @@
-be3e7814e4cdbc09eaa5112d7d4135b3a2cedbfe66217d9973b1b39a44464e93
\ No newline at end of file
+780e8aaa231b2b585505c3886d5a13d39dba546fdd8020331ad4de2ae92922b0
\ No newline at end of file
index 68ca5788cc4c46b67dd390a328c5aab1acf3efed..ddd2c359112d5befae3a47ec4f518a10f1725933 100644 (file)
@@ -372,6 +372,36 @@ void speedtest1_exec(const char *zFormat, ...){
   speedtest1_shrink_memory();
 }
 
+/* Run SQL and return the first column of the first row as a string.  The
+** returned string is obtained from sqlite_malloc() and must be freed by
+** the caller.
+*/
+char *speedtest1_once(const char *zFormat, ...){
+  va_list ap;
+  char *zSql;
+  sqlite3_stmt *pStmt;
+  char *zResult = 0;
+  va_start(ap, zFormat);
+  zSql = sqlite3_vmprintf(zFormat, ap);
+  va_end(ap);
+  if( g.bSqlOnly ){
+    printSql(zSql);
+  }else{
+    int rc = sqlite3_prepare_v2(g.db, zSql, -1, &pStmt, 0);
+    if( rc ){
+      fatal_error("SQL error: %s\n", sqlite3_errmsg(g.db));
+    }
+    if( sqlite3_step(pStmt)==SQLITE_ROW ){
+      const char *z = (const char*)sqlite3_column_text(pStmt, 0);
+      if( z ) zResult = sqlite3_mprintf("%s", z);
+    }
+    sqlite3_finalize(pStmt);
+  }
+  sqlite3_free(zSql);
+  speedtest1_shrink_memory();
+  return zResult;
+}
+
 /* Prepare an SQL statement */
 void speedtest1_prepare(const char *zFormat, ...){
   va_list ap;
@@ -1987,7 +2017,7 @@ int main(int argc, char **argv){
   int showStats = 0;            /* True for --stats */
   int nThread = 0;              /* --threads value */
   int mmapSize = 0;             /* How big of a memory map to use */
-  const char *zTSet = "main";   /* Which --testset torun */
+  char *zTSet = "main";         /* Which --testset torun */
   int doTrace = 0;              /* True for --trace */
   const char *zEncoding = 0;    /* --utf16be or --utf16le */
   const char *zDbName = 0;      /* Name of the test database */
@@ -2197,30 +2227,65 @@ int main(int argc, char **argv){
   }
 
   if( g.bExplain ) printf(".explain\n.echo on\n");
-  if( strcmp(zTSet,"main")==0 ){
-    testset_main();
-  }else if( strcmp(zTSet,"debug1")==0 ){
-    testset_debug1();
-  }else if( strcmp(zTSet,"orm")==0 ){
-    testset_orm();
-  }else if( strcmp(zTSet,"cte")==0 ){
-    testset_cte();
-  }else if( strcmp(zTSet,"fp")==0 ){
-    testset_fp();
-  }else if( strcmp(zTSet,"trigger")==0 ){
-    testset_trigger();
-  }else if( strcmp(zTSet,"rtree")==0 ){
+  do{
+    char *zThisTest = zTSet;
+    char *zComma = strchr(zThisTest,',');
+    if( zComma ){
+      *zComma = 0;
+      zTSet = zComma+1;
+    }else{
+      zTSet = "";
+    }
+    if( strcmp(zThisTest,"main")==0 ){
+      testset_main();
+    }else if( strcmp(zThisTest,"debug1")==0 ){
+      testset_debug1();
+    }else if( strcmp(zThisTest,"orm")==0 ){
+      testset_orm();
+    }else if( strcmp(zThisTest,"cte")==0 ){
+      testset_cte();
+    }else if( strcmp(zThisTest,"fp")==0 ){
+      testset_fp();
+    }else if( strcmp(zThisTest,"trigger")==0 ){
+      testset_trigger();
+    }else if( strcmp(zThisTest,"rtree")==0 ){
 #ifdef SQLITE_ENABLE_RTREE
-    testset_rtree(6, 147);
+      testset_rtree(6, 147);
 #else
-    fatal_error("compile with -DSQLITE_ENABLE_RTREE to enable "
-                "the R-Tree tests\n");
+      fatal_error("compile with -DSQLITE_ENABLE_RTREE to enable "
+                  "the R-Tree tests\n");
 #endif
-  }else{
-    fatal_error("unknown testset: \"%s\"\n"
-                "Choices: cte debug1 fp main orm rtree trigger\n",
-                 zTSet);
-  }
+    }else{
+      fatal_error("unknown testset: \"%s\"\n"
+                  "Choices: cte debug1 fp main orm rtree trigger\n",
+                   zThisTest);
+    }
+    if( zTSet[0] ){
+      char *zSql, *zObj;
+      speedtest1_begin_test(999, "Reset the database");
+      while( 1 ){
+        zObj = speedtest1_once(
+             "SELECT name FROM main.sqlite_master"
+             " WHERE sql LIKE 'CREATE %%TABLE%%'");
+        if( zObj==0 ) break;
+        zSql = sqlite3_mprintf("DROP TABLE main.\"%w\"", zObj);
+        speedtest1_exec(zSql);
+        sqlite3_free(zSql);
+        sqlite3_free(zObj);
+      }
+      while( 1 ){
+        zObj = speedtest1_once(
+             "SELECT name FROM temp.sqlite_master"
+             " WHERE sql LIKE 'CREATE %%TABLE%%'");
+        if( zObj==0 ) break;
+        zSql = sqlite3_mprintf("DROP TABLE main.\"%w\"", zObj);
+        speedtest1_exec(zSql);
+        sqlite3_free(zSql);
+        sqlite3_free(zObj);
+      }
+      speedtest1_end_test();
+    }
+  }while( zTSet[0] );
   speedtest1_final();
 
   if( showStats ){