Revert "[Fuzzer] Afl driver changing iterations handling"
authorMatt Morehouse <mascasa@google.com>
Tue, 10 Jul 2018 19:58:42 +0000 (19:58 +0000)
committerMatt Morehouse <mascasa@google.com>
Tue, 10 Jul 2018 19:58:42 +0000 (19:58 +0000)
This reverts rL334510 due to breakage of afl_driver's command line
interface.

Patch By: Jonathan Metzman

Differential Revision: https://reviews.llvm.org/D49141

llvm-svn: 336719

compiler-rt/lib/fuzzer/afl/afl_driver.cpp
compiler-rt/test/fuzzer/afl-driver.test

index f3435ffd9676b682ed982e8365139c6ca9c268bc..fa494c03bde08c9aca2bf03e11fa57502b097760 100644 (file)
@@ -59,7 +59,6 @@ statistics from the file. If that fails then the process will quit.
 #include <sys/resource.h>
 #include <sys/time.h>
 #include <unistd.h>
-#include <limits.h>
 
 #include <fstream>
 #include <iostream>
@@ -306,18 +305,6 @@ int ExecuteFilesOnyByOne(int argc, char **argv) {
   return 0;
 }
 
-static void set_iterations(int *N, const char *arg) {
-  char *next_char;
-  long NL = strtol(arg, &next_char, 10);
-  if (NL < 1 || NL > INT_MAX || *next_char != '\0') {
-    fprintf(stderr, "WARNING: iterations invalid `%s`\n",
-        arg);
-    ::exit(-1);
-  }
-
-  *N = static_cast<int>(NL);
-}
-
 int main(int argc, char **argv) {
   fprintf(stderr,
       "======================= INFO =========================\n"
@@ -344,12 +331,11 @@ int main(int argc, char **argv) {
 
   int N = 1000;
   if (argc == 2 && argv[1][0] == '-')
-    set_iterations(&N, argv[1] + 1);
-  else if(argc == 2) {
-    fprintf(stderr, "WARNING: using the deprecated call style `%s %d`\n",
-        argv[0], N);
-    set_iterations(&N, argv[1]);
-  } else if (argc > 1)
+      N = atoi(argv[1] + 1);
+  else if(argc == 2 && (N = atoi(argv[1])) > 0)
+      fprintf(stderr, "WARNING: using the deprecated call style `%s %d`\n",
+              argv[0], N);
+  else if (argc > 1)
     return ExecuteFilesOnyByOne(argc, argv);
 
   assert(N > 0);
index d617117cda1698bb0c1e13678d12e554444559aa..552bafb0bf3469930ed0de4c25efb0a1f3a068a9 100644 (file)
@@ -21,16 +21,9 @@ CHECK3: __afl_persistent_loop calle, Count = 666
 CHECK3: LLVMFuzzerTestOneInput called; Size = 3
 
 
-RUN: not %run %t-AFLDriverTest %t.file3 2>&1 | FileCheck %s --check-prefix=CHECK4
-CHECK4: WARNING: using the deprecated call style `{{.*}} 1000`
-CHECK4: WARNING: iterations invalid `{{.*}}`
+RUN: %run %t-AFLDriverTest %t.file3 2>&1 | FileCheck %s --check-prefix=CHECK4
+CHECK4: LLVMFuzzerTestOneInput called; Size = 3
 
 RUN: %run %t-AFLDriverTest %t.file3 %t.file4  2>&1 | FileCheck %s --check-prefix=CHECK5
 CHECK5: LLVMFuzzerTestOneInput called; Size = 3
 CHECK5: LLVMFuzzerTestOneInput called; Size = 4
-
-RUN: not %run %t-AFLDriverTest < %t.file3 --1 2>&1 | FileCheck %s --check-prefix=CHECK6
-CHECK6: WARNING: iterations invalid `-1`
-
-RUN: not %run %t-AFLDriverTest < %t.file3 -Invalid 2>&1 | FileCheck %s --check-prefix=CHECK7
-CHECK7: WARNING: iterations invalid `Invalid`