update fuzz

This commit is contained in:
gmlwns2000
2022-03-15 20:26:33 +09:00
committed by Jeehoon Kang
parent d2ecfe629a
commit 7ffd357fde

View File

@@ -121,7 +121,7 @@ def generate(tests_dir, bin_path, seed=None, easy=False):
"--max-struct-fields", "3", "--max-struct-fields", "3",
] ]
args = [bin_path] + options args = [bin_path] + options
try: try:
proc = subprocess.Popen(args, cwd=tests_dir, stdout=subprocess.PIPE) proc = subprocess.Popen(args, cwd=tests_dir, stdout=subprocess.PIPE)
(src, err) = proc.communicate() (src, err) = proc.communicate()
@@ -261,11 +261,10 @@ def fuzz(tests_dir, fuzz_arg, num_iter, easy=False):
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Fuzzing KECC.') parser = argparse.ArgumentParser(description='Fuzzing KECC.')
parser.add_argument('-n', '--num', type=int, help='The number of tests', default=None) parser.add_argument('-n', '--num', type=int, help='The number of tests')
parser.add_argument('-p', '--print', action='store_true', help='Fuzzing C AST printer') parser.add_argument('-p', '--print', action='store_true', help='Fuzzing C AST printer')
parser.add_argument('-i', '--irgen', action='store_true', help='Fuzzing irgen') parser.add_argument('-i', '--irgen', action='store_true', help='Fuzzing irgen')
parser.add_argument('-r', '--reduce', action='store_true', help="Reducing input file") parser.add_argument('-r', '--reduce', action='store_true', help="Reducing input file")
parser.add_argument('--skip-build', action='store_true', help="Skipping cargo build")
parser.add_argument('--easy', action='store_true', help="Generate more easy code by csmith option") parser.add_argument('--easy', action='store_true', help="Generate more easy code by csmith option")
parser.add_argument('--seed', type=int, help="Provide seed of fuzz generation", default=-1) parser.add_argument('--seed', type=int, help="Provide seed of fuzz generation", default=-1)
args = parser.parse_args() args = parser.parse_args()
@@ -288,16 +287,13 @@ if __name__ == "__main__":
tests_dir = os.path.abspath(os.path.dirname(__file__)) tests_dir = os.path.abspath(os.path.dirname(__file__))
if not args.skip_build: print("Building KECC..")
print("Building KECC..") try:
try: proc = subprocess.Popen(["cargo", "build", "--release"], cwd=tests_dir)
proc = subprocess.Popen(["cargo", "build", "--release"], cwd=tests_dir) proc.communicate()
proc.communicate() except subprocess.TimeoutExpired as e:
except subprocess.TimeoutExpired as e: proc.kill()
proc.kill() raise e
raise e
else:
print("Skip building. You should manually build the binary. Please execute `cargo build --release` to build.")
if args.reduce: if args.reduce:
creduce(tests_dir, fuzz_arg) creduce(tests_dir, fuzz_arg)