diff options
author | Nick Fitzgerald <fitzgen@gmail.com> | 2017-10-09 15:37:38 -0700 |
---|---|---|
committer | Nick Fitzgerald <fitzgen@gmail.com> | 2017-10-10 10:20:41 -0700 |
commit | b70eb51627c86cb1b04c34729ce518e2d55e2ba3 (patch) | |
tree | e0e936ae484f3b759b0022b9ddbff844b9a75507 /csmith-fuzzing/driver.py | |
parent | cfb7e7dfbb3861236b2e2bee1531c9cc9f970ac0 (diff) |
Make the `csmith` driver use `predicate.py` instead of its own half reimplementation
Diffstat (limited to 'csmith-fuzzing/driver.py')
-rwxr-xr-x | csmith-fuzzing/driver.py | 57 |
1 files changed, 13 insertions, 44 deletions
diff --git a/csmith-fuzzing/driver.py b/csmith-fuzzing/driver.py index 38ae9ff3..7dc6086c 100755 --- a/csmith-fuzzing/driver.py +++ b/csmith-fuzzing/driver.py @@ -28,29 +28,12 @@ def run_logged(cmd): cat(stdout.name, title="stderr") return result -def run_bindgen(input, output): - return run_logged([ - "bindgen", - "--with-derive-partialeq", - "--with-derive-eq", - "--with-derive-partialord", - "--with-derive-ord", - "--with-derive-hash", - "--with-derive-default", - "-o", output.name, - input.name, - "--", - "-I", os.path.abspath(os.path.dirname(sys.argv[0])), - ]) - -def run_rustc(output, test): - return run_logged([ - "rustc", - "--crate-type", "lib", - "--test", - output.name, - "-o", test.name, - ]) +BINDGEN_ARGS = "--with-derive-partialeq \ +--with-derive-eq \ +--with-derive-partialord \ +--with-derive-ord \ +--with-derive-hash \ +--with-derive-default" def main(): print("Fuzzing `bindgen` with C-Smith...\n") @@ -65,36 +48,22 @@ def main(): if result.returncode != 0: exit(1) - output = NamedTemporaryFile(delete=False, prefix="output-", suffix=".rs") - output.close() - result = run_bindgen(input, output) - if result.returncode != 0: - cat(input.name) - cat(output.name) - exit(1) - - test = NamedTemporaryFile(delete=False, prefix="test-") - test.close() - result = run_rustc(output, test) - if result.returncode != 0: - cat(input.name) - cat(output.name) - exit(1) - - result = run_logged([test.name]) + result = run_logged([ + "./predicate.py", + "--bindgen-args", + "{} -- -I{}".format(BINDGEN_ARGS, os.path.abspath(os.path.dirname(sys.argv[0]))), + input.name + ]) if result.returncode != 0: cat(input.name) - cat(output.name) exit(1) os.remove(input.name) - os.remove(output.name) - os.remove(test.name) - iterations += 1 if __name__ == "__main__": try: + os.chdir(os.path.abspath(os.path.dirname(sys.argv[0]))) main() except KeyboardInterrupt: exit() |