From: drh Date: Wed, 24 Jun 2015 13:25:34 +0000 (+0000) Subject: Rig the fuzzcheck test program so that it times out after 10 seconds in case X-Git-Tag: version-3.8.11~135 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=94701b048a87e9cc85e2aa720d3449ae14b9ab99;p=thirdparty%2Fsqlite.git Rig the fuzzcheck test program so that it times out after 10 seconds in case of an infinite loop in the test case. FossilOrigin-Name: 659cfc9d1e9db83db171d621f248a7c2a5b183f6 --- diff --git a/manifest b/manifest index 6e60dfd271..c7f2505145 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sdatabase\sfuzz\stest\scases\sto\scover\sall\srecent\sfindings. -D 2015-06-24T13:05:18.519 +C Rig\sthe\sfuzzcheck\stest\sprogram\sso\sthat\sit\stimes\sout\safter\s10\sseconds\sin\scase\nof\san\sinfinite\sloop\sin\sthe\stest\scase. +D 2015-06-24T13:25:34.917 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 1063c58075b7400d93326b0eb332b48a54f53025 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -657,7 +657,7 @@ F test/fuzz2.test 76dc35b32b6d6f965259508508abce75a6c4d7e1 F test/fuzz3.test efd384b896c647b61a2c1848ba70d42aad60a7b3 F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b F test/fuzz_malloc.test 328f70aaca63adf29b4c6f06505ed0cf57ca7c26 -F test/fuzzcheck.c 40f9db60546bef5a3b47858387f158f25b33dca9 +F test/fuzzcheck.c 4aa40bb9c64d25d0a196241ffe5bd99c8cc7a7fc F test/fuzzdata1.db 7ee3227bad0e7ccdeb08a9e6822916777073c664 F test/fuzzdata2.db f03a420d3b822cc82e4f894ca957618fbe9c4973 F test/fuzzdata3.db b83d0c20ae64113432c03d40c06ba473a4cb696b @@ -1286,7 +1286,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P db87664a224f44e01b85570a3f3b6ec1c81d6e0a -R 80987d833c6ea525b9447487da2124df +P 47ba7d96b1b91858ef1b592374839bc820719b95 +R d64b6eb4d6ad9abfcf40a6dbaad4e3c0 U drh -Z 3820c3951a0c18b6366e880d201a8261 +Z 7df3ede0c0593e9eda4cbc4099bb5c77 diff --git a/manifest.uuid b/manifest.uuid index 3d6a12cd9b..e895bcc8cf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -47ba7d96b1b91858ef1b592374839bc820719b95 \ No newline at end of file +659cfc9d1e9db83db171d621f248a7c2a5b183f6 \ No newline at end of file diff --git a/test/fuzzcheck.c b/test/fuzzcheck.c index 34c21adec3..4c63e4d701 100644 --- a/test/fuzzcheck.c +++ b/test/fuzzcheck.c @@ -71,6 +71,11 @@ #include #include "sqlite3.h" +#ifdef __unix__ +# include +# include +#endif + /* ** Files in the virtual file system. */ @@ -139,6 +144,28 @@ static void fatalError(const char *zFormat, ...){ exit(1); } +/* +** Timeout handler +*/ +#ifdef __unix__ +static void timeoutHandler(int NotUsed){ + (void)NotUsed; + fatalError("timeout\n"); +} +#endif + +/* +** Set the an alarm to go off after N seconds. Disable the alarm +** if N==0 +*/ +static void setAlarm(int N){ +#ifdef __unix__ + alarm(N); +#else + (void)N; +#endif +} + /* ** Reallocate memory. Show and error and quit if unable. */ @@ -682,6 +709,7 @@ int main(int argc, char **argv){ int onlyDbid = -1; /* --dbid */ int nativeFlag = 0; /* --native-vfs */ int rebuildFlag = 0; /* --rebuild */ + int timeoutTest = 0; /* undocumented --timeout-test flag */ int runFlags = 0; /* Flags sent to runSql() */ char *zMsg = 0; /* Add this message */ int nSrcDb = 0; /* Number of source databases */ @@ -693,6 +721,9 @@ int main(int argc, char **argv){ int cellSzCkFlag = 0; /* --cell-size-check */ iBegin = timeOfDay(); +#ifdef __unix__ + signal(SIGALRM, timeoutHandler); +#endif g.zArgv0 = argv[0]; zFailCode = getenv("TEST_FAILURE"); for(i=1; i=argc-1 ) fatalError("missing arguments on %s", argv[i]); onlySqlid = atoi(argv[++i]); }else + if( strcmp(z,"timeout-test")==0 ){ + timeoutTest = 1; +#ifndef __unix__ + fatalError("timeout is not available on non-unix systems"); +#endif + }else if( strcmp(z,"verbose")==0 || strcmp(z,"v")==0 ){ quietFlag = 0; verboseFlag = 1; @@ -900,7 +937,11 @@ int main(int argc, char **argv){ rc = sqlite3_open_v2("main.db", &db, openFlags, zVfs); if( rc ) fatalError("cannot open inmem database"); if( cellSzCkFlag ) runSql(db, "PRAGMA cell_size_check=ON", runFlags); - runSql(db, (char*)pSql->a, runFlags); + setAlarm(10); + do{ + runSql(db, (char*)pSql->a, runFlags); + }while( timeoutTest ); + setAlarm(0); sqlite3_close(db); if( sqlite3_memory_used()>0 ) fatalError("memory leak"); reformatVfs();