Skip to content

Commit

Permalink
Add fflush() calls to fuzzershell to keep stderr and stdout synchroni…
Browse files Browse the repository at this point in the history
…zed.
  • Loading branch information
D. Richard Hipp committed Apr 25, 2015
1 parent 9b3bce9 commit 65420d5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tool/fuzzershell.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ static void sqlexec(sqlite3 *db, const char *zFormat, ...){
*/
static void shellLog(void *pNotUsed, int iErrCode, const char *zMsg){
printf("LOG: (%d) %s\n", iErrCode, zMsg);
fflush(stdout);
}

/*
Expand All @@ -181,6 +182,7 @@ static int execCallback(void *NotUsed, int argc, char **argv, char **colv){
printf("NULL\n");
}
}
fflush(stdout);
return 0;
}
static int execNoop(void *NotUsed, int argc, char **argv, char **colv){
Expand All @@ -194,6 +196,7 @@ static int execNoop(void *NotUsed, int argc, char **argv, char **colv){
*/
static void traceCallback(void *NotUsed, const char *zMsg){
printf("TRACE: %s\n", zMsg);
fflush(stdout);
}
#endif

Expand Down Expand Up @@ -594,7 +597,10 @@ int main(int argc, char **argv){
char *z = strstr(&zIn[i], ">****/");
if( z ){
z += 6;
if( verboseFlag ) printf("%.*s\n", (int)(z-&zIn[i]), &zIn[i]);
if( verboseFlag ){
printf("%.*s\n", (int)(z-&zIn[i]), &zIn[i]);
fflush(stdout);
}
i += (int)(z-&zIn[i]);
multiTest = 1;
}
Expand All @@ -617,6 +623,7 @@ int main(int argc, char **argv){
if( verboseFlag ){
printf("INPUT (offset: %d, size: %d): [%s]\n",
i, (int)strlen(&zIn[i]), &zIn[i]);
fflush(stdout);
}else if( multiTest && !quietFlag ){
int pct = oomFlag ? 100*iNext/nIn : ((10*iNext)/nIn)*10;
if( pct!=lastPct ){
Expand All @@ -641,7 +648,10 @@ int main(int argc, char **argv){
oomCnt = g.iOomCntdown = 1;
g.nOomFault = 0;
g.bOomOnce = 1;
if( verboseFlag ) printf("Once.%d\n", oomCnt);
if( verboseFlag ){
printf("Once.%d\n", oomCnt);
fflush(stdout);
}
}else{
oomCnt = 0;
}
Expand Down Expand Up @@ -710,6 +720,7 @@ int main(int argc, char **argv){
if( oomCnt ){
if( verboseFlag ){
printf("%s.%d\n", g.bOomOnce ? "Once" : "Multi", oomCnt);
fflush(stdout);
}
nTest++;
}
Expand All @@ -725,6 +736,7 @@ int main(int argc, char **argv){
if( zErrMsg ){
printf("ERROR-MSG: [%s]\n", zErrBuf);
}
fflush(stdout);
}
/* Simulate an error if the TEST_FAILURE environment variable is "5" */
if( zFailCode ){
Expand Down

0 comments on commit 65420d5

Please sign in to comment.