Tests: Split lib tests in multiple standalone test scripts
[babeltrace.git] / tests / runall.sh
1 #!/bin/bash
2
3 TESTDIR=$(dirname $0)
4 DIR=$(readlink -f ${TESTDIR})
5 BABELTRACE_BIN=${DIR}/../converter/babeltrace
6 CTF_TRACES=${DIR}/ctf-traces
7
8 function test_check_success ()
9 {
10 if [ $? -ne 0 ] ; then
11 return 1
12 else
13 return 0
14 fi
15 }
16
17 function test_check_fail ()
18 {
19 if [ $? -eq 0 ] ; then
20 return 1
21 else
22 return 0
23 fi
24 }
25
26 function run_babeltrace ()
27 {
28 ${BABELTRACE_BIN} $* > /dev/null 2>&1
29 return $?
30 }
31
32 function print_test_result ()
33 {
34 if [ $# -ne 3 ] ; then
35 echo "Invalid arguments provided"
36 exit 1
37 fi
38
39 if [ ${2} -eq 0 ] ; then
40 echo -n "ok"
41 else
42 echo -n "not ok"
43 fi
44 echo -e " "${1}" - "${3}
45 }
46
47 successTraces=(${CTF_TRACES}/succeed/*)
48 failTraces=(${CTF_TRACES}/fail/*)
49 testCount=$((2 + ${#successTraces[@]} + ${#failTraces[@]}))
50
51 currentTestIndex=1
52 echo -e 1..${testCount}
53
54 #run babeltrace, expects success
55 run_babeltrace
56 test_check_success
57 print_test_result $((currentTestIndex++)) $? "Running babeltrace without arguments"
58
59 #run babeltrace with a bogus argument, expects failure
60 run_babeltrace --bogusarg
61 test_check_fail
62 print_test_result $((currentTestIndex++)) $? "Running babeltrace with a bogus argument"
63
64 for tracePath in ${successTraces[@]}; do
65 run_babeltrace ${tracePath}
66 test_check_success
67 print_test_result $((currentTestIndex++)) $? "Running babeltrace with trace ${tracePath}"
68 done
69
70 for tracePath in ${failTraces[@]}; do
71 run_babeltrace ${tracePath}
72 test_check_fail
73 print_test_result $((currentTestIndex++)) $? "Running babeltrace with trace ${tracePath}"
74 done
75
76 exit 0
This page took 0.029881 seconds and 4 git commands to generate.