mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-18 12:48:06 +00:00
expanded test-instr to also work with input files via "-f @@" and changed the test.sh values
This commit is contained in:
25
test-instr.c
25
test-instr.c
@ -18,22 +18,39 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
|
||||||
|
int fd = 0;
|
||||||
char buff[8];
|
char buff[8];
|
||||||
char* buf = buff;
|
char* buf = buff;
|
||||||
|
|
||||||
// we support command line parameter and stdin
|
// we support command line parameter and stdin
|
||||||
if (argc > 1) {
|
if (argc == 2) {
|
||||||
|
|
||||||
buf = argv[1];
|
buf = argv[1];
|
||||||
printf("Input %s - ", buf);
|
printf("Input %s - ", buf);
|
||||||
|
|
||||||
} else if (read(0, buf, sizeof(buf)) < 1) {
|
} else {
|
||||||
|
|
||||||
printf("Hum?\n");
|
if (argc >= 3 && strcmp(argv[1], "-f") == 0)
|
||||||
return 1;
|
if ((fd = open(argv[2], O_RDONLY)) < 0) {
|
||||||
|
|
||||||
|
fprintf(stderr, "Error: unable to open %s\n", argv[2]);
|
||||||
|
exit(-1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (read(fd, buf, sizeof(buf)) < 1) {
|
||||||
|
|
||||||
|
printf("Hum?\n");
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
test/test.sh
19
test/test.sh
@ -120,7 +120,7 @@ test "$SYS" = "i686" -o "$SYS" = "x86_64" -o "$SYS" = "amd64" -o "$SYS" = "i86pc
|
|||||||
}
|
}
|
||||||
rm -f test-instr.plain.0 test-instr.plain.1
|
rm -f test-instr.plain.0 test-instr.plain.1
|
||||||
TUPLES=`echo 0|../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain 2>&1 | grep Captur | awk '{print$3}'`
|
TUPLES=`echo 0|../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain 2>&1 | grep Captur | awk '{print$3}'`
|
||||||
test "$TUPLES" -gt 3 -a "$TUPLES" -lt 8 && {
|
test "$TUPLES" -gt 3 -a "$TUPLES" -lt 10 && {
|
||||||
$ECHO "$GREEN[+] ${AFL_GCC} run reported $TUPLES instrumented locations which is fine"
|
$ECHO "$GREEN[+] ${AFL_GCC} run reported $TUPLES instrumented locations which is fine"
|
||||||
} || {
|
} || {
|
||||||
$ECHO "$RED[!] ${AFL_GCC} produces weird instrumentation numbers: $TUPLES"
|
$ECHO "$RED[!] ${AFL_GCC} produces weird instrumentation numbers: $TUPLES"
|
||||||
@ -324,19 +324,20 @@ test -e ../afl-clang-fast -a -e ../split-switches-pass.so && {
|
|||||||
rm -f test-instr.plain
|
rm -f test-instr.plain
|
||||||
|
|
||||||
# now for the special llvm_mode things
|
# now for the special llvm_mode things
|
||||||
AFL_LLVM_INSTRIM=1 AFL_LLVM_INSTRIM_LOOPHEAD=1 ../afl-clang-fast -o test-compcov.instrim test-compcov.c > /dev/null 2> test.out
|
AFL_LLVM_INSTRIM=1 AFL_LLVM_INSTRIM_LOOPHEAD=1 ../afl-clang-fast -o test-instr.instrim ../test-instr.c > /dev/null 2> test.out
|
||||||
test -e test-compcov.instrim && {
|
test -e test-instr.instrim && {
|
||||||
grep -Eq " [1-3] location" test.out && {
|
TUPLES=`echo 0|../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.instrim 2>&1 | grep Captur | awk '{print$3}'`
|
||||||
$ECHO "$GREEN[+] llvm_mode InsTrim feature works correctly"
|
test "$TUPLES" -gt 2 -a "$TUPLES" -lt 5 && {
|
||||||
|
$ECHO "$GREEN[+] llvm_mode Instrim reported $TUPLES instrumented locations which is fine"
|
||||||
} || {
|
} || {
|
||||||
$ECHO "$RED[!] llvm_mode InsTrim feature failed"
|
$ECHO "$RED[!] llvm_mode Instrim produces weird numbers: $TUPLES"
|
||||||
CODE=1
|
CODE=1
|
||||||
}
|
}
|
||||||
|
rm -f test-instr.instrim test.out
|
||||||
} || {
|
} || {
|
||||||
$ECHO "$RED[!] llvm_mode InsTrim feature compilation failed"
|
$ECHO "$RED[!] llvm_mode InsTrim compilation failed"
|
||||||
CODE=1
|
CODE=1
|
||||||
}
|
}
|
||||||
rm -f test-compcov.instrim test.out
|
|
||||||
AFL_DEBUG=1 AFL_LLVM_LAF_SPLIT_SWITCHES=1 AFL_LLVM_LAF_TRANSFORM_COMPARES=1 AFL_LLVM_LAF_SPLIT_COMPARES=1 ../afl-clang-fast -o test-compcov.compcov test-compcov.c > /dev/null 2> test.out
|
AFL_DEBUG=1 AFL_LLVM_LAF_SPLIT_SWITCHES=1 AFL_LLVM_LAF_TRANSFORM_COMPARES=1 AFL_LLVM_LAF_SPLIT_COMPARES=1 ../afl-clang-fast -o test-compcov.compcov test-compcov.c > /dev/null 2> test.out
|
||||||
test -e test-compcov.compcov && {
|
test -e test-compcov.compcov && {
|
||||||
grep -Eq " [3-9][0-9] location" test.out && {
|
grep -Eq " [3-9][0-9] location" test.out && {
|
||||||
@ -405,7 +406,7 @@ test -e ../afl-clang-lto -a -e ../afl-llvm-lto-instrumentation.so && {
|
|||||||
} || {
|
} || {
|
||||||
$ECHO "$GREEN[+] llvm_mode LTO instrumentation present and working correctly"
|
$ECHO "$GREEN[+] llvm_mode LTO instrumentation present and working correctly"
|
||||||
TUPLES=`echo 0|../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain 2>&1 | grep Captur | awk '{print$3}'`
|
TUPLES=`echo 0|../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain 2>&1 | grep Captur | awk '{print$3}'`
|
||||||
test "$TUPLES" -gt 3 -a "$TUPLES" -lt 6 && {
|
test "$TUPLES" -gt 3 -a "$TUPLES" -lt 7 && {
|
||||||
$ECHO "$GREEN[+] llvm_mode LTO run reported $TUPLES instrumented locations which is fine"
|
$ECHO "$GREEN[+] llvm_mode LTO run reported $TUPLES instrumented locations which is fine"
|
||||||
} || {
|
} || {
|
||||||
$ECHO "$RED[!] llvm_mode LTO instrumentation produces weird numbers: $TUPLES"
|
$ECHO "$RED[!] llvm_mode LTO instrumentation produces weird numbers: $TUPLES"
|
||||||
|
Reference in New Issue
Block a user