citrun

watch C/C++ source code execute
Log | Files | Refs | LICENSE

commit aba93ab3e9d90ccb90022bfdc25e31d7f0281959
parent 1575e056d6fc6319a2f3d87a19d45b1ee7781bb0
Author: kyle <kyle@getaddrinfo.net>
Date:   Mon, 26 Oct 2015 22:19:02 -0600

tests: move to directory based layout

Diffstat:
Mrun_tests.sh | 31++++++++++++++++++++-----------
Dtests/fibonacci.c.sh | 14--------------
Rtests/fibonacci.c.instrumented -> tests/fibonacci/instrumented.c | 0
Rtests/fibonacci.c -> tests/fibonacci/prog.c | 0
Atests/fibonacci/test.sh | 14++++++++++++++
5 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/run_tests.sh b/run_tests.sh @@ -10,28 +10,37 @@ if which tput > /dev/null; then RESET=`tput sgr0` fi -echo "starting tests" -for t in `ls tests/*.c`; do +for t in `ls tests/*/prog.c`; do ./instrument $t -- > $temp_file - if ! diff -u ${t}.instrumented $temp_file; then - echo "$t:$RED source compare failed$RESET" - continue + 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 fi + # compile the instrumented file if ! gcc -o /tmp/bin $temp_file; then # /tmp/bin won't be created here - echo "$t:$RED post compilation failed$RESET" - continue - fi + echo "$dirname/instrumented.c:$RED gcc compilation failed$RESET" - if ! sh ${t}.sh /tmp/bin "${t}"; then - echo "$t:$RED tests failed!$RESET" rm /tmp/bin 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 + fi + rm /tmp/bin - echo "$t:$GREEN ok$RESET" + if [ $failed -eq 0 ]; then + echo "$dirname:$GREEN ok$RESET" + fi done rm $temp_file diff --git a/tests/fibonacci.c.sh b/tests/fibonacci.c.sh @@ -1,14 +0,0 @@ -#!/bin/sh - -result="`/tmp/bin 10`" -if [ "$result" != "result: 55" ]; then - echo "${2}.sh: $result != \"result: 55\"" - exit 1 -fi - -result="`/tmp/bin 20`" -expected="result: 6765" -if [ "$result" != "$expected" ]; then - echo "${2}.sh: '$result' != '$expected'" - exit 1 -fi diff --git a/tests/fibonacci.c.instrumented b/tests/fibonacci/instrumented.c diff --git a/tests/fibonacci.c b/tests/fibonacci/prog.c diff --git a/tests/fibonacci/test.sh b/tests/fibonacci/test.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +result="`/tmp/bin 10`" +if [ "$result" != "result: 55" ]; then + echo "${0}: $result != \"result: 55\"" + exit 1 +fi + +result="`/tmp/bin 20`" +expected="result: 6765" +if [ "$result" != "$expected" ]; then + echo "${0}: '$result' != '$expected'" + exit 1 +fi