^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #! /bin/bash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) if ! make >/dev/null; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) echo "Building liblockdep failed."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) echo "FAILED!"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) find tests -name '*.c' | sort | while read -r i; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) testname=$(basename "$i" .c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) echo -ne "$testname... "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) if gcc -o "tests/$testname" -pthread "$i" liblockdep.a -Iinclude -D__USE_LIBLOCKDEP &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) timeout 1 "tests/$testname" 2>&1 | /bin/bash "tests/${testname}.sh"; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) echo "PASSED!"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) echo "FAILED!"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) rm -f "tests/$testname"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) find tests -name '*.c' | sort | while read -r i; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) testname=$(basename "$i" .c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) echo -ne "(PRELOAD) $testname... "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) if gcc -o "tests/$testname" -pthread -Iinclude "$i" &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) timeout 1 ./lockdep "tests/$testname" 2>&1 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) /bin/bash "tests/${testname}.sh"; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) echo "PASSED!"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) echo "FAILED!"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) rm -f "tests/$testname"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) find tests -name '*.c' | sort | while read -r i; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) testname=$(basename "$i" .c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) echo -ne "(PRELOAD + Valgrind) $testname... "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) if gcc -o "tests/$testname" -pthread -Iinclude "$i" &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) { timeout 10 valgrind --read-var-info=yes ./lockdep "./tests/$testname" >& "tests/${testname}.vg.out"; true; } &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /bin/bash "tests/${testname}.sh" < "tests/${testname}.vg.out" &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) ! grep -Eq '(^==[0-9]*== (Invalid |Uninitialised ))|Mismatched free|Source and destination overlap| UME ' "tests/${testname}.vg.out"; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) echo "PASSED!"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) echo "FAILED!"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) rm -f "tests/$testname"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) done