tests: add test demonstrating to/from proto scripts

This commit is contained in:
Willi Ballenthin
2023-03-23 15:42:43 +01:00
parent b1f4035530
commit e8082173ad
2 changed files with 20 additions and 1 deletions

1
.gitignore vendored
View File

@@ -122,3 +122,4 @@ scripts/perf/*.zip
.envrc
.DS_Store
*/.DS_Store
.github/binja/binaryninja

View File

@@ -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": ')