generated from clearbluejar/ghidra-python-vscode-devcontainer-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81cbf34
commit 0cb6775
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import pytest | ||
from pathlib import Path | ||
|
||
import pyhidra | ||
from ghidrecomp import decompile, get_parser | ||
from ghidrecomp.bsim import has_bsim,add_bsim_args_to_parser,add_categories_to_prog | ||
from pyhidra.version import get_ghidra_version | ||
|
||
# check BSIM exists | ||
def test_bsim_should_exist(): | ||
|
||
pyhidra.start() | ||
|
||
# check ghidra version and bail if old | ||
if get_ghidra_version() < '11.0': | ||
assert not has_bsim() | ||
else: | ||
assert has_bsim() | ||
|
||
|
||
def test_bsim_bad_known_arg(shared_datadir: Path): | ||
|
||
parser = get_parser() | ||
|
||
bin_path = shared_datadir / 'ls_aarch64' | ||
|
||
args = parser.parse_args([f"{bin_path.absolute()}", | ||
"--bsim-cat", | ||
"CustomArgNeedsValue", | ||
"--bsim" | ||
]) | ||
|
||
with pytest.raises(ValueError): | ||
|
||
all_funcs, decompilations, output_path, compiler, lang_id, callgraphs = decompile(args) | ||
|
||
|
||
x = 1 / 1 | ||
|
||
# check category + func count | ||
|
||
def test_bsim_args_with_ls(shared_datadir: Path): | ||
|
||
parser = get_parser() | ||
|
||
bin_path = shared_datadir / 'ls_aarch64' | ||
|
||
args = parser.parse_args([f"{bin_path.absolute()}", | ||
"--skip-cache", | ||
"--bsim-cat", | ||
"Executable Location", | ||
"--bsim-cat", | ||
"source:ghidrecomp", | ||
"--bsim" | ||
]) | ||
|
||
expected_output_path = Path(args.output_path) / bin_path.name | ||
|
||
all_funcs, decompilations, output_path, compiler, lang_id, callgraphs = decompile(args) | ||
|
||
assert len(all_funcs) == 532 | ||
assert len(decompilations) == 532 | ||
assert output_path == expected_output_path | ||
assert compiler == 'unknown' | ||
assert lang_id == 'AARCH64:LE:64:v8A' | ||
assert len(callgraphs) == 0 | ||
|