blob: 11f425662b432c00e00d4a8bfb10fef632c3f00b [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001#! /bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
David Brazdil0f672f62019-12-10 10:32:29 +00004if ! make >/dev/null; then
5 echo "Building liblockdep failed."
6 echo "FAILED!"
7 exit 1
8fi
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00009
David Brazdil0f672f62019-12-10 10:32:29 +000010find tests -name '*.c' | sort | while read -r i; do
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000011 testname=$(basename "$i" .c)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000012 echo -ne "$testname... "
David Brazdil0f672f62019-12-10 10:32:29 +000013 if gcc -o "tests/$testname" -pthread "$i" liblockdep.a -Iinclude -D__USE_LIBLOCKDEP &&
14 timeout 1 "tests/$testname" 2>&1 | /bin/bash "tests/${testname}.sh"; then
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000015 echo "PASSED!"
16 else
17 echo "FAILED!"
18 fi
David Brazdil0f672f62019-12-10 10:32:29 +000019 rm -f "tests/$testname"
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000020done
21
David Brazdil0f672f62019-12-10 10:32:29 +000022find tests -name '*.c' | sort | while read -r i; do
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000023 testname=$(basename "$i" .c)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000024 echo -ne "(PRELOAD) $testname... "
David Brazdil0f672f62019-12-10 10:32:29 +000025 if gcc -o "tests/$testname" -pthread -Iinclude "$i" &&
26 timeout 1 ./lockdep "tests/$testname" 2>&1 |
27 /bin/bash "tests/${testname}.sh"; then
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000028 echo "PASSED!"
29 else
30 echo "FAILED!"
31 fi
David Brazdil0f672f62019-12-10 10:32:29 +000032 rm -f "tests/$testname"
33done
34
35find tests -name '*.c' | sort | while read -r i; do
36 testname=$(basename "$i" .c)
37 echo -ne "(PRELOAD + Valgrind) $testname... "
38 if gcc -o "tests/$testname" -pthread -Iinclude "$i" &&
39 { timeout 10 valgrind --read-var-info=yes ./lockdep "./tests/$testname" >& "tests/${testname}.vg.out"; true; } &&
40 /bin/bash "tests/${testname}.sh" < "tests/${testname}.vg.out" &&
41 ! grep -Eq '(^==[0-9]*== (Invalid |Uninitialised ))|Mismatched free|Source and destination overlap| UME ' "tests/${testname}.vg.out"; then
42 echo "PASSED!"
43 else
44 echo "FAILED!"
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000045 fi
David Brazdil0f672f62019-12-10 10:32:29 +000046 rm -f "tests/$testname"
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000047done