diff --git a/Makefile.in b/Makefile.in index 6b3f18c35c..0a6045fa2a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -951,7 +951,7 @@ testfixture$(TEXE): $(TESTFIXTURE_SRC) -o $@ $(TESTFIXTURE_SRC) $(LIBTCL) $(TLIBS) # A very detailed test running most or all test cases -fulltest: testfixture$(TEXE) sqlite3$(TEXE) +fulltest: testfixture$(TEXE) sqlite3$(TEXE) fuzztest ./testfixture$(TEXE) $(TOP)/test/all.test # Really really long testing @@ -962,10 +962,14 @@ soaktest: testfixture$(TEXE) sqlite3$(TEXE) fulltestonly: testfixture$(TEXE) sqlite3$(TEXE) ./testfixture$(TEXE) $(TOP)/test/full.test +# Fuzz testing +fuzztest: fuzzershell$(TEXE) + ./fuzzershell$(TEXE) -f $(TOP)/test/fuzzdata1.txt + # This is the common case. Run many tests but not those that take # a really long time. # -test: testfixture$(TEXE) sqlite3$(TEXE) +test: testfixture$(TEXE) sqlite3$(TEXE) fuzztest ./testfixture$(TEXE) $(TOP)/test/veryquick.test # Run a test using valgrind. This can take a really long time diff --git a/main.mk b/main.mk index 22c4f3e02d..2001300a22 100644 --- a/main.mk +++ b/main.mk @@ -633,19 +633,22 @@ fts3-testfixture$(EXE): sqlite3.c fts3amal.c $(TESTSRC) $(TOP)/src/tclsqlite.c $(TESTSRC) $(TOP)/src/tclsqlite.c sqlite3.c fts3amal.c \ -o testfixture$(EXE) $(LIBTCL) $(THREADLIB) -fulltest: testfixture$(EXE) sqlite3$(EXE) +fulltest: testfixture$(EXE) sqlite3$(EXE) fuzztest ./testfixture$(EXE) $(TOP)/test/all.test soaktest: testfixture$(EXE) sqlite3$(EXE) ./testfixture$(EXE) $(TOP)/test/all.test -soak=1 -fulltestonly: testfixture$(EXE) sqlite3$(EXE) +fulltestonly: testfixture$(EXE) sqlite3$(EXE) fuzztest ./testfixture$(EXE) $(TOP)/test/full.test queryplantest: testfixture$(EXE) sqlite3$(EXE) ./testfixture$(EXE) $(TOP)/test/permutations.test queryplanner -test: testfixture$(EXE) sqlite3$(EXE) +fuzztest: fuzzershell$(EXE) + ./fuzzershell$(EXE) -f $(TOP)/test/fuzzdata1.txt + +test: testfixture$(EXE) sqlite3$(EXE) fuzztest ./testfixture$(EXE) $(TOP)/test/veryquick.test # The next two rules are used to support the "threadtest" target. Building diff --git a/manifest b/manifest index a831f63482..612fd47b58 100644 --- a/manifest +++ b/manifest @@ -1,7 +1,7 @@ -C Add\sthe\s--unique-cases\soption\sto\sfuzzershell. -D 2015-04-24T14:47:59.444 +C Add\sAFL-generated\stest\scases\sin\sthe\stest/fuzzdata1.txt\sfile.\s\sAutomatically\nrun\sfuzzershell\sagainst\sthose\scases\son\sa\s"make\stest". +D 2015-04-24T16:09:12.862 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in faaf75b89840659d74501bea269c7e33414761c1 +F Makefile.in a1e5faa26179818cfb4e7dac6cfa131d03f6b0ea F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.msc 32d8fe89ac5c130f9f14293fb4a59b120895c943 F Makefile.vxworks e1b65dea203f054e71653415bd8f96dcaed47858 @@ -152,7 +152,7 @@ F ext/userauth/userauth.c 5fa3bdb492f481bbc1709fc83c91ebd13460c69e F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60 -F main.mk 60aba7d38b9bd73e249693344dd8405aa24ac02a +F main.mk 3cb2fbae2405c63ad74be4f25070a29c46a56fe6 F mkopcodec.awk c2ff431854d702cdd2d779c9c0d1f58fa16fa4ea F mkopcodeh.awk d5e22023b5238985bb54a72d33e0ac71fe4f8a32 F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83 @@ -631,6 +631,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/fuzzdata1.txt c7929942f6820873fdd9ae6bb542651fefea40f7 F test/fuzzer1.test d4c52aaf3ef923da293a2653cfab33d02f718a36 F test/fuzzerfault.test 8792cd77fd5bce765b05d0c8e01b9edcf8af8536 F test/genesis.tcl 1e2e2e8e5cc4058549a154ff1892fe5c9de19f98 @@ -813,7 +814,7 @@ F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8 F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8 F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 -F test/releasetest.tcl a37cd82092c8be438255d65804b5951d6e3ecdae +F test/releasetest.tcl dcc5f4244098474b2dd4357123518258657807e0 F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb F test/rollback.test 458fe73eb3ffdfdf9f6ba3e9b7350a6220414dea F test/rollback2.test fc14cf6d1a2b250d2735ef16124b971bce152f14 @@ -1204,7 +1205,7 @@ F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 F tool/fast_vacuum.c 5ba0d6f5963a0a63bdc42840f678bad75b2ebce1 F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 -F tool/fuzzershell.c a49687f0d0eb3b60a9646054077127ae70273414 +F tool/fuzzershell.c ddb3cf6e1f8366f76498c75bd36d63a58ac57a97 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce @@ -1252,7 +1253,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P ed202ffac2eb85be9a18dca2a051ea3be16f8893 -R ecff9baf64ed1fb011f1359a05c25d2a +P 7cb718491b5de77d4a73d8484324b66a36815019 +R 5c239b072c2dcd31e4add6efc2487c7d U drh -Z 68bd4395db7df71bb884bf375d7fe437 +Z 9d51c74e3083ce62441ba344efd87c33 diff --git a/manifest.uuid b/manifest.uuid index e622592ff5..70f8695b85 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7cb718491b5de77d4a73d8484324b66a36815019 \ No newline at end of file +627ea83c26b420088f101801eb8765127f47d2d0 \ No newline at end of file diff --git a/test/fuzzdata1.txt b/test/fuzzdata1.txt new file mode 100644 index 0000000000..592e7cab3a Binary files /dev/null and b/test/fuzzdata1.txt differ diff --git a/test/releasetest.tcl b/test/releasetest.tcl index 95cacf590f..05250a119a 100644 --- a/test/releasetest.tcl +++ b/test/releasetest.tcl @@ -199,6 +199,7 @@ array set ::Configs [strip_comments { Fail2 {-O0} Fail3 {-O0} Fail4 {-O0} + FuzzFail {-O0} }] array set ::Platforms [strip_comments { @@ -255,6 +256,7 @@ array set ::Platforms [strip_comments { Fail2 "TEST_FAILURE=2 valgrindtest" Fail3 "TEST_FAILURE=3 valgrindtest" Fail4 "TEST_FAILURE=4 test" + FuzzFail "TEST_FAILURE=5 test" } }] diff --git a/tool/fuzzershell.c b/tool/fuzzershell.c index 65c8fb78ac..a35ed3aa7a 100644 --- a/tool/fuzzershell.c +++ b/tool/fuzzershell.c @@ -373,6 +373,7 @@ int main(int argc, char **argv){ sqlite3 *dataDb = 0; /* Database holding compacted input data */ sqlite3_stmt *pStmt = 0; /* Statement to insert testcase into dataDb */ const char *zDataOut = 0; /* Write compacted data to this output file */ + int nHeader = 0; /* Bytes of header comment text on input file */ g.zArgv0 = argv[0]; @@ -524,7 +525,12 @@ int main(int argc, char **argv){ abendError("unable to open initialization database \"%s\"", zInitDb); } } - for(i=nTest=0; i****/"); @@ -582,9 +588,10 @@ int main(int argc, char **argv){ printf("INPUT (offset: %d, size: %d): [%s]\n", i, (int)strlen(&zIn[i]), &zIn[i]); }else if( multiTest && !quietFlag ){ - int pct = 100*(i+strlen(zSql))/nIn; + int pct = 10*iNext/nIn; if( pct!=lastPct ){ - printf("%d%%\r", pct); + if( lastPct<0 ) printf("fuzz test:"); + printf(" %d%%", pct*10); fflush(stdout); lastPct = pct; } @@ -621,15 +628,24 @@ int main(int argc, char **argv){ if( sqlite3_memory_used()>0 ){ abendError("memory in use after close: %lld bytes", sqlite3_memory_used()); } + if( nTest==1 ){ + /* Simulate an error if the TEST_FAILURE environment variable is "5" */ + char *zFailCode = getenv("TEST_FAILURE"); + if( zFailCode && zFailCode[0]=='5' && zFailCode[1]==0 ){ + abendError("simulated failure"); + } + } } + if( !verboseFlag && multiTest && !quietFlag ) printf("\n"); if( nTest>1 && !quietFlag ){ - printf("%d tests with no errors\nSQLite %s %s\n", + printf("%d fuzz tests with no errors\nSQLite %s %s\n", nTest, sqlite3_libversion(), sqlite3_sourceid()); } if( zDataOut ){ - FILE *out = fopen(zDataOut, "wb"); int n = 0; + FILE *out = fopen(zDataOut, "wb"); if( out==0 ) abendError("cannot open %s for writing", zDataOut); + if( nHeader>0 ) fwrite(zIn, nHeader, 1, out); sqlite3_finalize(pStmt); rc = sqlite3_prepare_v2(dataDb, "SELECT sql FROM testcase", -1, &pStmt, 0); if( rc ) abendError("%s", sqlite3_errmsg(dataDb));