commit 98ca5359ce0a3be907ec05da64126eb63d805468
parent 32df9e3bd527276c455acc9b996a7ab55a03ea76
Author: kyle <kyle@getaddrinfo.net>
Date: Sat, 31 Oct 2015 16:50:04 -0600
tests: make use of instrument changes
- instrument can do more on its own now, remove duplicated functionality
- we are now in good shape to hook up multi file tests
Diffstat:
8 files changed, 41 insertions(+), 29 deletions(-)
diff --git a/run_tests.sh b/run_tests.sh
@@ -1,8 +1,5 @@
#!/bin/sh
-# make sure we have a .c extension
-temp_file=$(mktemp).c
-
if which tput > /dev/null; then
RED=`tput setaf 1 0 0`
GREEN=`tput setaf 2 0 0`
@@ -10,36 +7,31 @@ if which tput > /dev/null; then
fi
export LD_LIBRARY_PATH="runtime"
+export SCV_PATH="$HOME/src/scv/instrument"
+export PATH="$SCV_PATH:$PATH"
+which cc
for t in `ls tests/*/prog.c`; do
- ./instrument/instrument $t -- > $temp_file
dirname=`dirname ${t}`
- failed=0
-
- # diff against the last known good instrumented source
- if ! diff -u "$dirname/instrumented.c" $temp_file; then
- echo "$dirname/instrumented.c:$RED source compare failed$RESET"
- failed=1
+ if ! make -C $dirname prog; then
+ echo "$dirname: make failed!"
+ make -C $dirname clean > /dev/null
+ continue
fi
- # try to compile the instrumented file
- if ! gcc -o /tmp/bin -pthread -Lruntime/ $temp_file -lruntime ; then
- echo "$dirname/instrumented.c:$RED gcc compilation failed$RESET"
-
- # /tmp/bin won't be created here
+ # diff against the last known good instrumented source
+ if ! diff -u $dirname/instrumented.c $dirname/prog_inst.c; then
+ echo "$dirname:$RED source compare failed$RESET"
+ make -C $dirname clean > /dev/null
continue
fi
# test that the instrumented binary works properly
- if ! sh "$dirname/test.sh" /tmp/bin; then
- echo "$dirname/test.sh:$RED failed!$RESET"
- failed=1
+ if ! make -C $dirname "test" > /dev/null; then
+ echo "$dirname:$RED test failed!$RESET"
+ make -C $dirname clean > /dev/null
+ continue
fi
- rm /tmp/bin
-
- if [ $failed -eq 0 ]; then
- echo "$dirname:$GREEN ok$RESET"
- fi
+ make -C $dirname clean > /dev/null
+ echo "$dirname:$GREEN ok$RESET"
done
-
-rm $temp_file
diff --git a/tests/fibonacci/Makefile b/tests/fibonacci/Makefile
@@ -0,0 +1,5 @@
+test:
+ sh test.sh
+
+clean:
+ rm -f prog prog_inst.c
diff --git a/tests/fibonacci/test.sh b/tests/fibonacci/test.sh
@@ -1,12 +1,12 @@
#!/bin/sh
-result="`/tmp/bin 10`"
+result="`./prog 10`"
if [ "$result" != "result: 55" ]; then
echo "${0}: '$result' != 'result: 55'"
exit 1
fi
-result="`/tmp/bin 20`"
+result="`./prog 20`"
expected="result: 6765"
if [ "$result" != "$expected" ]; then
echo "${0}: '$result' != '$expected'"
diff --git a/tests/hello_world/Makefile b/tests/hello_world/Makefile
@@ -0,0 +1,5 @@
+test:
+ sh test.sh
+
+clean:
+ rm -f prog prog_inst.c
diff --git a/tests/hello_world/test.sh b/tests/hello_world/test.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-result="`${1}`"
+result="`prog`"
expected="hello, world"
if [ "$result" != "$expected" ]; then
echo "${0}: '$result' != '$expected'"
diff --git a/tests/if_statement/Makefile b/tests/if_statement/Makefile
@@ -0,0 +1,5 @@
+test:
+ sh test.sh
+
+clean:
+ rm -f prog prog_inst.c
diff --git a/tests/while_loops/Makefile b/tests/while_loops/Makefile
@@ -0,0 +1,5 @@
+test:
+ sh test.sh
+
+clean:
+ rm -f prog prog_inst.c
diff --git a/tests/while_loops/test.sh b/tests/while_loops/test.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-${1}
+prog
if [ $? -ne 10 ]; then
echo "${0}: basic while loops broken"
exit 1