mirror of
https://github.com/mandiant/capa.git
synced 2025-12-12 07:40:38 -08:00
tests: add test demonstrating to/from proto scripts
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -122,3 +122,4 @@ scripts/perf/*.zip
|
||||
.envrc
|
||||
.DS_Store
|
||||
*/.DS_Store
|
||||
.github/binja/binaryninja
|
||||
|
||||
@@ -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": ')
|
||||
|
||||
Reference in New Issue
Block a user