Attachment:
driver.c
Description: Binary data
Attachment:
func.c
Description: Binary data
#!/bin/bash
rm -f out*.txt
rm -f ubsan.txt
rm -f msan.txt
rm -f ./small_O0 ./small_O3 ./small_ubsan_O0 ./small_ubsan_O3 ./small_msan_O0 ./small_msan_O3
COMPILER="" #target compiler
EMULATOR="/usr/bin/qemu-aarch64"
INCLUDE="-I./"
TESTCASE="./driver.c ./func.c "
ulimit -t 60
if
$COMPILER $INCLUDE -pedantic -Wall -Werror=uninitialized -O0 $TESTCASE -o ./small_O0 > /dev/null 2>&1 &&\
test -f "./small_O0" &&\
$EMULATOR ./small_O0 > out_O0.txt &&\
$COMPILER $INCLUDE -pedantic -Wall -Werror=uninitialized -O3 $TESTCASE -o ./small_O3 >out.txt 2>&1 &&\
test -f "./small_O3" &&\
! grep 'undefined behavior' out.txt &&\
! grep 'conversions than data arguments' out.txt &&\
! grep 'incompatible redeclaration' out.txt &&\
! grep 'ordered comparison between pointer' out.txt &&\
! grep 'eliding middle term' out.txt &&\
! grep 'end of non-void function' out.txt &&\
! grep 'invalid in C99' out.txt &&\
! grep 'specifies type' out.txt &&\
! grep 'should return a value' out.txt &&\
! grep 'uninitialized' out.txt &&\
! grep 'incompatible pointer to' out.txt &&\
! grep 'incompatible integer to' out.txt &&\
! grep 'incompatible pointer types' out.txt &&\
! grep 'type specifier missing' out.txt &&\
! grep 'tentative array definition' out.txt &&\
! grep 'implicit conversion' out.txt &&\
! grep 'omitting the parameter' out.txt &&\
$EMULATOR ./small_O3 >out_O3.txt 2>&1 &&\
! diff out_O0.txt out_O3.txt &&\
/usr/bin/clang-17 -I./ -fsanitize=undefined,address -O0 $TESTCASE -o ./small_ubsan_O0 > /dev/null 2>&1 &&\
/usr/bin/clang-17 -I./ -fsanitize=memory -O0 $TESTCASE -o ./small_msan_O0 > /dev/null 2>&1 &&\
/usr/bin/clang-17 -I./ -fsanitize=undefined,address -O3 $TESTCASE -o ./small_ubsan_O3 > /dev/null 2>&1 &&\
/usr/bin/clang-17 -I./ -fsanitize=memory -O3 $TESTCASE -o ./small_msan_O3 > /dev/null 2>&1
then
if
./small_ubsan_O0 > ubsan.txt 2>&1 &&\
! grep 'error' ubsan.txt && \
./small_ubsan_O3 > ubsan.txt 2>&1 &&\
! grep 'error' ubsan.txt && \
./small_msan_O0 > msan.txt 2>&1 && \
! grep -i 'memorysanitizer' msan.txt &&\
./small_msan_O3 > msan.txt 2>&1 && \
! grep -i 'memorysanitizer' msan.txt
then
exit 0
else
exit 1
fi
else
exit 1
fi