Skip to content

Commit 31084b0

Browse files
committed
allow test binaries to take args
1 parent cd03e99 commit 31084b0

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

tests/symqemu/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ The purpose of those tests is to automatically run SymQEMU on some known binarie
55
The directory `binaries` contains a directory for each test binary. A test binary directory contains the following:
66

77
- An executable file `binary`
8-
- A file `input` whose name will be given as first argument to `binary` and whose content will be symbolic
9-
- A directory `expected_outputs` : the test cases that SymQEMU should generate when called like this : `<symqemu> <path/to/binary> <path/to/input>`, with the content of `input` being symbolic.
8+
- A file `input` whose path will be given as argument to `binary` and whose content will be symbolic
9+
- A text file `args` that contains the arguments `binary` will be called with. One of the arguments must be `@@` and it will be replaced with the path of the `input` file.
10+
- A directory `expected_outputs` : the test cases that SymQEMU should generate when called like this : `<symqemu> <path/to/binary> <args>`, with the content of `input` being symbolic.
1011

1112
The script `test.py` will automatically run SymQEMU on the binaries and check that it gives the correct output.
1213

tests/symqemu/binaries/printf/args

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@@

tests/symqemu/binaries/simple/args

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@@

tests/symqemu/util.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@
88
def run_symqemu_on_test_binary(binary_name: str, output_dir: pathlib.Path) -> None:
99
binary_dir = BINARIES_DIR / binary_name
1010

11-
command = [
12-
str(SYMQEMU_EXECUTABLE),
13-
str(binary_dir / 'binary'),
14-
str(binary_dir / 'input')
15-
]
11+
with open(binary_dir / 'args', 'r') as f:
12+
binary_args = f.read().strip().split(' ')
13+
14+
def replace_placeholder_with_input(arg: str):
15+
return str(binary_dir / 'input') if arg == '@@' else arg
16+
17+
binary_args = *map(replace_placeholder_with_input, binary_args),
18+
19+
command = (
20+
str(SYMQEMU_EXECUTABLE),
21+
str(binary_dir / 'binary'),
22+
) + binary_args
1623

1724
environment_variables = {
1825
'SYMCC_OUTPUT_DIR': str(output_dir),

0 commit comments

Comments
 (0)