10000 Let user pass their own CPU_TARGET in test-pre.sh · AFLplusplus/AFLplusplus@8618fbc · GitHub
[go: up one dir, main page]

Skip to content

Commit 8618fbc

Browse files
committed
Let user pass their own CPU_TARGET in test-pre.sh
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 ... ```
1 parent a9900f0 commit 8618fbc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/test-pre.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,20 @@ test -e /usr/local/bin/opt && {
113113
}
114114
AFL_COMPILER=afl-clang-fast
115115

116-
SYS=`uname -m`
117-
118116
GREY="\\033[1;90m"
119117
BLUE="\\033[1;94m"
120118
GREEN="\\033[0;32m"
121119
RED="\\033[0;31m"
122120
YELLOW="\\033[1;93m"
123121
RESET="\\033[0m"
124122

123+
if test -n "$CPU_TARGET"; then
124+
$ECHO "${RESET}${GREY}[*] Using environment variable CPU_TARGET=$CPU_TARGET for SYS"
125+
SYS="$CPU_TARGET"
126+
else
127+
SYS=`uname -m`
128+
fi
129+
125130
MEM_LIMIT=none
126131

127132
export PATH="${PATH}:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"

0 commit comments

Comments
 (0)
0