Skip to content

Commit 1f414d5

Browse files
Make Makefile tests handle optimization more gracefully. (aflnet#33) (aflnet#30)
Make tests using ./test-instr use paths that are less likely to be optimized out.
1 parent ac2b6ac commit 1f414d5

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ ifndef AFL_NO_X86
8989
test_build: afl-gcc afl-as afl-showmap
9090
@echo "[*] Testing the CC wrapper and instrumentation output..."
9191
unset AFL_USE_ASAN AFL_USE_MSAN; AFL_QUIET=1 AFL_INST_RATIO=100 AFL_PATH=. ./$(TEST_CC) $(CFLAGS) test-instr.c -o test-instr $(LDFLAGS)
92-
echo 0 | ./afl-showmap -m none -q -o .test-instr0 ./test-instr
92+
./afl-showmap -m none -q -o .test-instr0 ./test-instr < /dev/null
9393
echo 1 | ./afl-showmap -m none -q -o .test-instr1 ./test-instr
9494
@rm -f test-instr
9595
@cmp -s .test-instr0 .test-instr1; DR="$$?"; rm -f .test-instr0 .test-instr1; if [ "$$DR" = "0" ]; then echo; echo "Oops, the instrumentation does not seem to be behaving correctly!"; echo; echo "Please ping <[email protected]> to troubleshoot the issue."; echo; exit 1; fi

llvm_mode/Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ endif
9797
test_build: $(PROGS)
9898
@echo "[*] Testing the CC wrapper and instrumentation output..."
9999
unset AFL_USE_ASAN AFL_USE_MSAN AFL_INST_RATIO; AFL_QUIET=1 AFL_PATH=. AFL_CC=$(CC) ../afl-clang-fast $(CFLAGS) ../test-instr.c -o test-instr $(LDFLAGS)
100-
echo 0 | ../afl-showmap -m none -q -o .test-instr0 ./test-instr
100+
# Use /dev/null to avoid problems with optimization messing up expected
101+
# branches. See https://github.com/google/AFL/issues/30.
102+
../afl-showmap -m none -q -o .test-instr0 ./test-instr < /dev/null
101103
echo 1 | ../afl-showmap -m none -q -o .test-instr1 ./test-instr
102104
@rm -f test-instr
103105
@cmp -s .test-instr0 .test-instr1; DR="$$?"; rm -f .test-instr0 .test-instr1; if [ "$$DR" = "0" ]; then echo; echo "Oops, the instrumentation does not seem to be behaving correctly!"; echo; echo "Please ping <[email protected]> to troubleshoot the issue."; echo; exit 1; fi

qemu_mode/build_qemu_support.sh

+2
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ if [ "$ORIG_CPU_TARGET" = "" ]; then
178178

179179
unset AFL_INST_RATIO
180180

181+
# We shouldn't need the /dev/null hack because program isn't compiled with any
182+
# optimizations.
181183
echo 0 | ./afl-showmap -m none -Q -q -o .test-instr0 ./test-instr || exit 1
182184
echo 1 | ./afl-showmap -m none -Q -q -o .test-instr1 ./test-instr || exit 1
183185

0 commit comments

Comments
 (0)