diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2017-01-11 10:32:50 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2017-01-11 10:32:50 +0100 |
commit | 86ea1ab023d05943c90e46fc597798e599ce31a2 (patch) | |
tree | 3460d59b351e262ce1f41cc9954d28f6abed9205 /mtests.sh | |
parent | 67defaf0521dce0ac2dc4e2af2813ff8090b8619 (diff) | |
download | bin-86ea1ab023d05943c90e46fc597798e599ce31a2.zip bin-86ea1ab023d05943c90e46fc597798e599ce31a2.tar.gz |
mtests: clean up
Diffstat (limited to 'mtests.sh')
-rwxr-xr-x | mtests.sh | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -4,7 +4,6 @@ # TODO # - support test specific subdir test_xxx.d/*.[ch] -# - integrate with autofoos (SRC_D BUILD_D CC CFLAGS ...) SCRIPT_DIR=${0%/*} SCRIPT_FILE=${0##*/} @@ -93,7 +92,7 @@ while [ $# -ge 1 ]; do QUIET=1 ;; -h|--help) - echo "Usage: $SCRIPT_FILE [options]" + echo "Usage: $SCRIPT_FILE [options] [tests]" echo echo "Options:" echo " -b, --abort Abort on test failure" @@ -122,8 +121,8 @@ fi [ -d "$SRC_D" -a -r "$SRC_D" ] || fatal "$SRC_D is not a valid directory" [ -d "$BUILD_D" -a -r "$BUILD_D" ] || fatal "$BUILD_D is not a valid directory" +rm -fr $TEST_D 2 > /dev/null mkdir -p $TEST_D || fatal "cannot create $TEST_D directory" -rm $TEST_D/* function load_main { @@ -178,15 +177,17 @@ function run_test { TEST=$(basename $test_c .c) TEST_C="$TEST.c" - TEST_O="$TEST_D/$TEST.o" + TEST_O="$TEST_D/$TEST" sayn " ${BROWN}run ${PURPLE}${test_c##*/}${RESET} " - $CC $dir/$MAIN_C -o $TEST_O -DTESTC=$TEST_C -DCALL=$TEST -DFUNC="void $TEST(void)" $CFLAGS $INCLUDE $LDP $LDF || fatal " compilation of $test_c failed" + $CC $dir/$MAIN_C -o $TEST_O \ + -DTESTC=$TEST_C -DCALL=$TEST -DFUNC="void $TEST(void)" \ + $CFLAGS $INCLUDE $LDP $LDF || fatal " compilation of $test_c failed" TEST_N=$((TEST_N + 1)) $TEST_O && rm $TEST_O && say "${GREEN}PASS${RESET}" && PASS_N=$((PASS_N + 1)) && return say "${RED}FAIL${RESET}" say_anyway " $test_c" [ $ABORT -ne 1 ] && return - say " see $TEST_C" + say " see $BROWN$TEST_O$RESET" exit 1 } @@ -195,7 +196,7 @@ function report [ $QUIET -eq 1 ] && exit 0 say "\n$PASS_N/$TEST_N tests passed" FAIL_N=$(ls -1 $TEST_D | wc -l) - [ $FAIL_N -gt 0 ] && say "see $TEST_D" + [ $FAIL_N -gt 0 ] && say "see $BROWN$TEST_O$RESET" exit 0 } |