8000 Let user pass their own CPU_TARGET in test-pre.sh by justuswilhelm · Pull Request #2461 · AFLplusplus/AFLplusplus · GitHub
[go: up one dir, main page]

Skip to content

Let user pass their own CPU_TARGET in test-pre.sh #2461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2025

Conversation

justuswilhelm
Copy link
Contributor

The target system might be different from the host system. For example, you can fuzz Linux binaries compiled for mipsel, while your host is x86_64.

Some of the tests depend on specific platforms to run correctly. For example, the afl-fuzz qemu_mode cmplog test only works on Intel or ARM systems. The SYS variable is populated using uname -m and the test cases then consult this variable to decide whether to run the test or not.

If you want to test afl-fuzz for qemu_mode on mipsel, you might want to make sure that Intel or ARM tests don't run. With this patch, you can supply your own SYS environment variable and skip platform specific tests.

This allows you to add tests for mipsel or other niche platforms in the future as well.

Sample usage:

$ cd qemu_mode && env CPU_TARGET=mipsel ./build_qemu_support.sh
$ cd ../test && env SYS=mipsel ./test-qemu-mode.sh
[*] Using user supplied environment variable SYS=mipsel
[*] starting AFL++ test framework ...
[*] Testing: qemu_mode
...

@domenukk domenukk changed the base branch from stable to dev June 3, 2025 09:55
@domenukk
Copy link
Member
domenukk commented Jun 3, 2025

I wonder if just SYS as env variable might be prone to collisions for some users? Like, maybe use AFL_TEST_SYS instead, or something?

@vanhauser-thc
Copy link
Member

Or use CPU_TARGET?

The target system might be different from the host system. For example,
you can fuzz Linux binaries compiled for *mipsel*, while your host is
*x86_64*.

Some of the tests depend on specific platforms to run correctly.
For example, the afl-fuzz qemu_mode cmplog test only works on Intel or
ARM systems. The `SYS` variable is populated using `uname -m` and the
test cases then consult this variable to decide whether to run the test
or not.

If you want to test afl-fuzz for qemu_mode on mipsel, you might
want to make sure that Intel or ARM tests don't run. With this
patch, you can supply your own `CPU_TARGET` environment variable and skip
platform specific tests. `SYS` then contains the value of `CPU_TARGET`.

This allows you to add tests for *mipsel* or other niche platforms in
the future as well.

Sample usage:

```
$ cd qemu_mode && env CPU_TARGET=mipsel ./build_qemu_support.sh
$ cd ../test && env CPU_TARGET=mipsel ./test-qemu-mode.sh
[*] Using environment variable CPU_TARGET=mipsel for SYS
[*] starting AFL++ test framework ...
[*] Testing: qemu_mode
...
```
shellcheck pointed out a few command substition (backtick vs. $(...))
and quoting issues. This patch fixes them.
@justuswilhelm
Copy link
Contributor Author

Or use CPU_TARGET?

Thanks for getting back so quickly :) CPU_TARGET sounds the most consistent. I've pushed a new version.

@justuswilhelm justuswilhelm changed the title Let user pass their own SYS in test-pre.sh Let user pass their own CPU_TARGET in test-pre.sh Jun 4, 2025
@vanhauser-thc
Copy link
Member

Lgtm thanks

@vanhauser-thc vanhauser-thc merged commit d25efff into AFLplusplus:dev Jun 4, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0