mirror of
https://github.com/vee1e/flare-floss.git
synced 2026-09-01 09:49:59 +00:00
--no only works today via argparse abbreviation of --no-string-type. The PR's planned --no-section/--no-structure/--no-tag flags will make --no an ambiguous prefix and break these call sites. Use the canonical spelling.
68 lines
2.5 KiB
Python
68 lines
2.5 KiB
Python
# Copyright 2022 Google LLC
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at: [package root]/LICENSE.txt
|
|
# Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and limitations under the License.
|
|
|
|
import sys
|
|
import subprocess
|
|
from pathlib import Path
|
|
from functools import lru_cache
|
|
|
|
import pytest
|
|
|
|
CD = Path(__file__).resolve().parent
|
|
|
|
|
|
def get_disassembler_script_path(s) -> Path:
|
|
return CD / ".." / "scripts" / "disassemblers" / s
|
|
|
|
|
|
def get_file_path() -> Path:
|
|
return CD / "data" / "test-decode-to-stack.exe"
|
|
|
|
|
|
def run_program(script_path: Path, args):
|
|
args = [sys.executable] + [str(script_path)] + args
|
|
print("running: '%s'" % args)
|
|
return subprocess.run(args, capture_output=True)
|
|
|
|
|
|
@lru_cache()
|
|
def get_results_file_path():
|
|
res_path = Path("results.json")
|
|
p = run_program(Path("floss/main.py"), ["--no-string-type", "static", "-j", str(get_file_path())])
|
|
with res_path.open("w") as f:
|
|
f.write(p.stdout.decode("utf-8"))
|
|
return str(res_path)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"script,args",
|
|
[
|
|
pytest.param("render-binja-import-script.py", [get_results_file_path()]),
|
|
pytest.param("render-ghidra-import-script.py", [get_results_file_path()]),
|
|
pytest.param("render-ida-import-script.py", [get_results_file_path()]),
|
|
pytest.param("render-r2-import-script.py", [get_results_file_path()]),
|
|
pytest.param("render-x64dbg-database.py", [get_results_file_path()]),
|
|
],
|
|
)
|
|
def test_disassembler_scripts(script, args):
|
|
script_path = get_disassembler_script_path(script)
|
|
p = run_program(script_path, args)
|
|
assert p.returncode == 0
|