Convert the unit tests to the TAP format
[babeltrace.git] / tests / runall.sh
index 9e0bdca5a3ed44f42ecd8bbb82d0dac3860fcd6a..c10e88ab5ddbcdb8292a6dd0543e5221da2c3f5e 100755 (executable)
@@ -5,44 +5,20 @@ DIR=$(readlink -f ${TESTDIR})
 BABELTRACE_BIN=${DIR}/../converter/babeltrace
 CTF_TRACES=${DIR}/ctf-traces
 
-function print_ok ()
-{
-       # Check if we are a terminal
-       if [ -t 1 ]; then
-               echo -e "\e[1;32mOK\e[0m"
-       else
-               echo -e "OK"
-       fi
-}
-
-function print_fail ()
-{
-       # Check if we are a terminal
-       if [ -t 1 ]; then
-               echo -e "\e[1;31mFAIL\e[0m"
-       else
-               echo -e "FAIL"
-       fi
-}
-
-function test_check ()
+function test_check_success ()
 {
        if [ $? -ne 0 ] ; then
-               print_fail
                return 1
        else
-               print_ok
                return 0
        fi
 }
 
 function test_check_fail ()
 {
-       if [ $? -ne 1 ] ; then
-               print_fail
+       if [ $? -eq 0 ] ; then
                return 1
        else
-               print_ok
                return 0
        fi
 }
@@ -53,38 +29,48 @@ function run_babeltrace ()
        return $?
 }
 
-#run babeltrace expects success
-echo -e "Running babeltrace without argument..."
-run_babeltrace
-test_check
-if [ $? -ne 0 ]; then
-       exit 1
-fi
-
-for a in ${CTF_TRACES}/succeed/*; do
-       echo -e "Running babeltrace for trace ${a}..."
-       run_babeltrace ${a}
-       test_check
-       if [ $? -ne 0 ]; then
+function print_test_result ()
+{
+       if [ $# -ne 3 ] ; then
+               echo "Invalid arguments provided"
                exit 1
        fi
-done
 
-#run babeltrace expects failure
-echo -e "Running babeltrace with bogus argument..."
+       if [ ${2} -eq 0 ] ; then
+               echo -n "ok"
+       else
+               echo -n "not ok"
+       fi
+       echo -e " "${1}" - "${3}
+}
+
+successTraces=(${CTF_TRACES}/succeed/*)
+failTraces=(${CTF_TRACES}/fail/*)
+testCount=$((2 + ${#successTraces[@]} + ${#failTraces[@]}))
+
+currentTestIndex=1
+echo -e 1..${testCount}
+
+#run babeltrace, expects success
+run_babeltrace
+test_check_success
+print_test_result $((currentTestIndex++)) $? "Running babeltrace without arguments"
+
+#run babeltrace with a bogus argument, expects failure
 run_babeltrace --bogusarg
 test_check_fail
-if [ $? -ne 0 ]; then
-       exit 1
-fi
+print_test_result $((currentTestIndex++)) $? "Running babeltrace with a bogus argument"
+
+for tracePath in ${successTraces[@]}; do
+       run_babeltrace ${tracePath}
+       test_check_success
+       print_test_result $((currentTestIndex++)) $? "Running babeltrace with trace ${tracePath}"
+done
 
-for a in ${CTF_TRACES}/fail/*; do
-       echo -e "Running babeltrace for trace ${a}..."
-       run_babeltrace ${a}
+for tracePath in ${failTraces[@]}; do
+       run_babeltrace ${tracePath}
        test_check_fail
-       if [ $? -ne 0 ]; then
-               exit 1
-       fi
+       print_test_result $((currentTestIndex++)) $? "Running babeltrace with trace ${tracePath}"
 done
 
 exit 0
This page took 0.023427 seconds and 4 git commands to generate.