about summary refs log tree commit diff
diff options
context:
space:
mode:
authorhexcoder- <heiko@hexco.de>2020-02-10 21:52:17 +0100
committerhexcoder- <heiko@hexco.de>2020-02-10 21:52:17 +0100
commit3b9ac30efa4f27978b1d9d82c605ec858f403f59 (patch)
treece19a3b52a4629fee2fcd5daa847c72fc14b8445
parent39be4cd80baf28edc26ebf7e35a84235d442dd99 (diff)
downloadafl++-3b9ac30efa4f27978b1d9d82c605ec858f403f59.tar.gz
test.sh: make grep option '-a' optional. Use when supported
-rwxr-xr-xtest/test.sh12
1 files changed, 9 insertions, 3 deletions
diff --git a/test/test.sh b/test/test.sh
index fde40736..c78297f6 100755
--- a/test/test.sh
+++ b/test/test.sh
@@ -15,6 +15,12 @@ rm -f test.1 test.2
 test -z "$OK" && { echo Error: diff is not working ; exit 1 ; }
 test -z "$LLVM_CONFIG" && LLVM_CONFIG=llvm-config
 
+# check for '-a' option of grep
+if grep -a test test.sh >/dev/null 2>&1; then
+  GREPAOPTION=' -a'
+else
+  GREPAOPTION=
+fi
 
 ECHO="printf %b\\n"
 $ECHO \\101 2>&1 | grep -qE '^A' || {
@@ -122,7 +128,7 @@ test "$SYS" = "i686" -o "$SYS" = "x86_64" -o "$SYS" = "amd64" -o "$SYS" = "i86pc
     CODE=1
   }
   test -e test-compcov.harden && {
-    grep -Eq 'stack_chk_fail|fstack-protector-all|fortified' test-compcov.harden > /dev/null 2>&1 && {
+    grep -Eq$GREPAOPTION 'stack_chk_fail|fstack-protector-all|fortified' test-compcov.harden > /dev/null 2>&1 && {
       $ECHO "$GREEN[+] ${AFL_GCC} hardened mode succeeded and is working"
     } || {
       $ECHO "$RED[!] ${AFL_GCC} hardened mode is not hardened"
@@ -237,7 +243,7 @@ test -e ../afl-clang-fast -a -e ../split-switches-pass.so && {
     CODE=1
   }
   test -e test-compcov.harden && {
-    grep -Eq 'stack_chk_fail|fstack-protector-all|fortified' test-compcov.harden > /dev/null 2>&1 && {
+    grep -Eq$GREPAOPTION 'stack_chk_fail|fstack-protector-all|fortified' test-compcov.harden > /dev/null 2>&1 && {
       $ECHO "$GREEN[+] llvm_mode hardened mode succeeded and is working"
     } || {
       $ECHO "$RED[!] llvm_mode hardened mode is not hardened"
@@ -402,7 +408,7 @@ test -e ../afl-gcc-fast -a -e ../afl-gcc-rt.o && {
   }
 
   test -e test-compcov.harden.gccpi && {
-    grep -Eq 'stack_chk_fail|fstack-protector-all|fortified' test-compcov.harden.gccpi > /dev/null 2>&1 && {
+    grep -Eq$GREPAOPTION 'stack_chk_fail|fstack-protector-all|fortified' test-compcov.harden.gccpi > /dev/null 2>&1 && {
       $ECHO "$GREEN[+] gcc_plugin hardened mode succeeded and is working"
     } || {
       $ECHO "$RED[!] gcc_plugin hardened mode is not hardened"