Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fuzzershell enhancements: (1) Add the --verbose and --quiet flags (2) Show percentage complete and final test count for multi-test inputs (3) Omit trace and result logs unless the --verbose flag is used. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ed202ffac2eb85be9a18dca2a051ea3b |
User & Date: | drh 2015-04-24 13:00:59.981 |
Context
2015-04-24
| ||
14:47 | Add the --unique-cases option to fuzzershell. (check-in: 7cb718491b user: drh tags: trunk) | |
13:00 | Fuzzershell enhancements: (1) Add the --verbose and --quiet flags (2) Show percentage complete and final test count for multi-test inputs (3) Omit trace and result logs unless the --verbose flag is used. (check-in: ed202ffac2 user: drh tags: trunk) | |
2015-04-23
| ||
13:37 | Fix a faulty assert() in the "AS" alias resolution logic of the parser. (check-in: b5e4360283 user: drh tags: trunk) | |
Changes
Changes to tool/fuzzershell.c.
︙ | ︙ | |||
134 135 136 137 138 139 140 141 142 143 144 145 146 147 | printf("[%s]\n", argv[i]); }else{ printf("NULL\n"); } } return 0; } /* ** This callback is invoked by sqlite3_trace() as each SQL statement ** starts. */ static void traceCallback(void *NotUsed, const char *zMsg){ printf("TRACE: %s\n", zMsg); | > > > | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | printf("[%s]\n", argv[i]); }else{ printf("NULL\n"); } } return 0; } static int execNoop(void *NotUsed, int argc, char **argv, char **colv){ return 0; } /* ** This callback is invoked by sqlite3_trace() as each SQL statement ** starts. */ static void traceCallback(void *NotUsed, const char *zMsg){ printf("TRACE: %s\n", zMsg); |
︙ | ︙ | |||
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | " -f FILE Read SQL text from FILE instead of standard input\n" " --heap SZ MIN Memory allocator uses SZ bytes & min allocation MIN\n" " --help Show this help text\n" " --initdb DBFILE Initialize the in-memory database using template DBFILE\n" " --lookaside N SZ Configure lookaside for N slots of SZ bytes each\n" " --pagesize N Set the page size to N\n" " --pcache N SZ Configure N pages of pagecache each of size SZ bytes\n" " --scratch N SZ Configure scratch memory for N slots of SZ bytes each\n" " --utf16be Set text encoding to UTF-16BE\n" " --utf16le Set text encoding to UTF-16LE\n" ); } /* ** Return the value of a hexadecimal digit. Return -1 if the input ** is not a hex digit. */ | > > > > | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | " -f FILE Read SQL text from FILE instead of standard input\n" " --heap SZ MIN Memory allocator uses SZ bytes & min allocation MIN\n" " --help Show this help text\n" " --initdb DBFILE Initialize the in-memory database using template DBFILE\n" " --lookaside N SZ Configure lookaside for N slots of SZ bytes each\n" " --pagesize N Set the page size to N\n" " --pcache N SZ Configure N pages of pagecache each of size SZ bytes\n" " -q Reduced output\n" " --quiet Reduced output\n" " --scratch N SZ Configure scratch memory for N slots of SZ bytes each\n" " --utf16be Set text encoding to UTF-16BE\n" " --utf16le Set text encoding to UTF-16LE\n" " -v Increased output\n" " --verbose Increased output\n" ); } /* ** Return the value of a hexadecimal digit. Return -1 if the input ** is not a hex digit. */ |
︙ | ︙ | |||
348 349 350 351 352 353 354 355 356 357 358 359 360 361 | void *pPCache = 0; /* Allocated storage for pcache */ void *pScratch = 0; /* Allocated storage for scratch */ int doAutovac = 0; /* True for --autovacuum */ char *zSql; /* SQL to run */ char *zToFree = 0; /* Call sqlite3_free() on this afte running zSql */ int iMode = FZMODE_Generic; /* Operating mode */ const char *zCkGlob = 0; /* Inputs must match this glob */ g.zArgv0 = argv[0]; for(i=1; i<argc; i++){ const char *z = argv[i]; if( z[0]=='-' ){ z++; | > > > > > | 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | void *pPCache = 0; /* Allocated storage for pcache */ void *pScratch = 0; /* Allocated storage for scratch */ int doAutovac = 0; /* True for --autovacuum */ char *zSql; /* SQL to run */ char *zToFree = 0; /* Call sqlite3_free() on this afte running zSql */ int iMode = FZMODE_Generic; /* Operating mode */ const char *zCkGlob = 0; /* Inputs must match this glob */ int verboseFlag = 0; /* --verbose or -v flag */ int quietFlag = 0; /* --quiet or -q flag */ int nTest = 0; /* Number of test cases run */ int multiTest = 0; /* True if there will be multiple test cases */ int lastPct = -1; /* Previous percentage done output */ g.zArgv0 = argv[0]; for(i=1; i<argc; i++){ const char *z = argv[i]; if( z[0]=='-' ){ z++; |
︙ | ︙ | |||
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 | pageSize = integerValue(argv[++i]); }else if( strcmp(z,"pcache")==0 ){ if( i>=argc-2 ) abendError("missing arguments on %s", argv[i]); nPCache = integerValue(argv[i+1]); szPCache = integerValue(argv[i+2]); i += 2; }else if( strcmp(z,"scratch")==0 ){ if( i>=argc-2 ) abendError("missing arguments on %s", argv[i]); nScratch = integerValue(argv[i+1]); szScratch = integerValue(argv[i+2]); i += 2; }else if( strcmp(z,"utf16le")==0 ){ zEncoding = "utf16le"; }else if( strcmp(z,"utf16be")==0 ){ zEncoding = "utf16be"; }else { abendError("unknown option: %s", argv[i]); } }else{ abendError("unknown argument: %s", argv[i]); } } | > > > > > > > > | | 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | pageSize = integerValue(argv[++i]); }else if( strcmp(z,"pcache")==0 ){ if( i>=argc-2 ) abendError("missing arguments on %s", argv[i]); nPCache = integerValue(argv[i+1]); szPCache = integerValue(argv[i+2]); i += 2; }else if( strcmp(z,"quiet")==0 || strcmp(z,"q")==0 ){ quietFlag = 1; verboseFlag = 0; }else if( strcmp(z,"scratch")==0 ){ if( i>=argc-2 ) abendError("missing arguments on %s", argv[i]); nScratch = integerValue(argv[i+1]); szScratch = integerValue(argv[i+2]); i += 2; }else if( strcmp(z,"utf16le")==0 ){ zEncoding = "utf16le"; }else if( strcmp(z,"utf16be")==0 ){ zEncoding = "utf16be"; }else if( strcmp(z,"verbose")==0 || strcmp(z,"v")==0 ){ quietFlag = 0; verboseFlag = 1; }else { abendError("unknown option: %s", argv[i]); } }else{ abendError("unknown argument: %s", argv[i]); } } if( verboseFlag ) sqlite3_config(SQLITE_CONFIG_LOG, shellLog, 0); if( nHeap>0 ){ pHeap = malloc( nHeap ); if( pHeap==0 ) fatalError("cannot allocate %d-byte heap\n", nHeap); rc = sqlite3_config(SQLITE_CONFIG_HEAP, pHeap, nHeap, mnHeap); if( rc ) abendError("heap configuration failed: %d\n", rc); } if( nLook>0 ){ |
︙ | ︙ | |||
475 476 477 478 479 480 481 | } if( zInitDb ){ rc = sqlite3_open_v2(zInitDb, &dbInit, SQLITE_OPEN_READONLY, 0); if( rc!=SQLITE_OK ){ abendError("unable to open initialization database \"%s\"", zInitDb); } } | | | > | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 | } if( zInitDb ){ rc = sqlite3_open_v2(zInitDb, &dbInit, SQLITE_OPEN_READONLY, 0); if( rc!=SQLITE_OK ){ abendError("unable to open initialization database \"%s\"", zInitDb); } } for(i=nTest=0; i<nIn; i=iNext, nTest++){ char cSaved; if( strncmp(&zIn[i], "/****<",6)==0 ){ char *z = strstr(&zIn[i], ">****/"); if( z ){ z += 6; if( verboseFlag ) printf("%.*s\n", (int)(z-&zIn[i]), &zIn[i]); i += (int)(z-&zIn[i]); multiTest = 1; } } for(iNext=i; iNext<nIn && strncmp(&zIn[iNext],"/****<",6)!=0; iNext++){} cSaved = zIn[iNext]; zIn[iNext] = 0; if( zCkGlob && sqlite3_strglob(zCkGlob,&zIn[i])!=0 ){ zIn[iNext] = cSaved; |
︙ | ︙ | |||
513 514 515 516 517 518 519 | rc = sqlite3_backup_step(pBackup, -1); if( rc!=SQLITE_DONE ){ abendError("attempt to initialize the in-memory database failed (rc=%d)", rc); } sqlite3_backup_finish(pBackup); } | | > > | | > > > > > | > > > | | | | | < | > > > > > | 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 | rc = sqlite3_backup_step(pBackup, -1); if( rc!=SQLITE_DONE ){ abendError("attempt to initialize the in-memory database failed (rc=%d)", rc); } sqlite3_backup_finish(pBackup); } if( verboseFlag ) sqlite3_trace(db, traceCallback, 0); sqlite3_create_function(db, "eval", 1, SQLITE_UTF8, 0, sqlEvalFunc, 0, 0); sqlite3_create_function(db, "eval", 2, SQLITE_UTF8, 0, sqlEvalFunc, 0, 0); sqlite3_limit(db, SQLITE_LIMIT_LENGTH, 1000000); if( zEncoding ) sqlexec(db, "PRAGMA encoding=%s", zEncoding); if( pageSize ) sqlexec(db, "PRAGMA pagesize=%d", pageSize); if( doAutovac ) sqlexec(db, "PRAGMA auto_vacuum=FULL"); zSql = &zIn[i]; if( verboseFlag ){ 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; if( pct!=lastPct ){ printf("%d%%\r", pct); fflush(stdout); lastPct = pct; } } switch( iMode ){ case FZMODE_Glob: zSql = zToFree = sqlite3_mprintf("SELECT glob(%s);", zSql); break; case FZMODE_Printf: zSql = zToFree = sqlite3_mprintf("SELECT printf(%s);", zSql); break; case FZMODE_Strftime: zSql = zToFree = sqlite3_mprintf("SELECT strftime(%s);", zSql); break; } zErrMsg = 0; rc = sqlite3_exec(db, zSql, verboseFlag ? execCallback : execNoop, 0, &zErrMsg); if( zToFree ){ sqlite3_free(zToFree); zToFree = 0; } zIn[iNext] = cSaved; if( verboseFlag ){ printf("RESULT-CODE: %d\n", rc); if( zErrMsg ){ printf("ERROR-MSG: [%s]\n", zErrMsg); } } sqlite3_free(zErrMsg); rc = sqlite3_close(db); if( rc ){ abendError("sqlite3_close() failed with rc=%d", rc); } if( sqlite3_memory_used()>0 ){ abendError("memory in use after close: %lld bytes", sqlite3_memory_used()); } } if( nTest>1 && !quietFlag ){ printf("%d tests with no errors\n", nTest); } free(zIn); free(pHeap); free(pLook); free(pScratch); free(pPCache); return 0; } |