diff --git a/.gitignore b/.gitignore index 10269009..f4887a52 100644 --- a/.gitignore +++ b/.gitignore @@ -122,3 +122,4 @@ scripts/perf/*.zip .envrc .DS_Store */.DS_Store +.github/binja/binaryninja diff --git a/tests/test_scripts.py b/tests/test_scripts.py index f48a6f99..fb1ce734 100644 --- a/tests/test_scripts.py +++ b/tests/test_scripts.py @@ -63,4 +63,22 @@ def test_bulk_process(tmpdir): def run_program(script_path, args): args = [sys.executable] + [script_path] + args print(f"running: '{args}'") - return subprocess.run(args) + return subprocess.run(args, stdout=subprocess.PIPE) + + +def test_proto_conversion(tmpdir): + t = tmpdir.mkdir("proto-test") + + json = os.path.join(CD, "data", "rd", "Practical Malware Analysis Lab 01-01.dll_.json") + + p = run_program(get_script_path("proto-from-results.py"), [json]) + assert p.returncode == 0 + + pb = os.path.join(t, "pma.pb") + with open(pb, "wb") as f: + f.write(p.stdout) + + p = run_program(get_script_path("proto-to-results.py"), [pb]) + assert p.returncode == 0 + + assert p.stdout.startswith(b'{\n "meta": ')