Add tests to make check
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 27 Oct 2012 15:09:36 +0000 (11:09 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 27 Oct 2012 15:09:36 +0000 (11:09 -0400)
Fixes #361

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tests/Makefile.am
tests/runall.sh [new file with mode: 0755]

index 642dd983de46de4edf3a82c1bcfe73242ce6184c..ffb41343ed1385a769c4f4b9c358cecd2e2f6792 100644 (file)
@@ -3,3 +3,8 @@ AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include
 noinst_PROGRAMS = test-bitfield
 
 test_bitfield_SOURCES = test-bitfield.c
+
+EXTRA_DIST = runall.sh
+
+check-am:
+       ./runall.sh
diff --git a/tests/runall.sh b/tests/runall.sh
new file mode 100755 (executable)
index 0000000..b2af656
--- /dev/null
@@ -0,0 +1,97 @@
+#!/bin/bash
+
+TESTDIR=$(dirname $0)
+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 ()
+{
+       if [ $? -ne 0 ] ; then
+               print_fail
+               return 1
+       else
+               print_ok
+               return 0
+       fi
+}
+
+function test_check_fail ()
+{
+       if [ $? -ne 1 ] ; then
+               print_fail
+               return 1
+       else
+               print_ok
+               return 0
+       fi
+}
+
+function run_babeltrace ()
+{
+       ${BABELTRACE_BIN} $* > /dev/null 2>&1
+       return $?
+}
+
+echo -e "Running test-bitfield..."
+./test-bitfield
+test_check
+if [ $? -ne 0 ]; then
+       exit 1
+fi
+
+#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
+               exit 1
+       fi
+done
+
+#run babeltrace expects failure
+echo -e "Running babeltrace with bogus argument..."
+run_babeltrace --bogusarg
+test_check_fail
+if [ $? -ne 0 ]; then
+       exit 1
+fi
+
+for a in ${CTF_TRACES}/fail/*; do
+       echo -e "Running babeltrace for trace ${a}..."
+       run_babeltrace ${a}
+       test_check_fail
+       if [ $? -ne 0 ]; then
+               exit 1
+       fi
+done
+
+exit 0
This page took 0.037495 seconds and 4 git commands to generate.