Commit | Line | Data |
---|---|---|
607c826c MD |
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 print_ok () | |
9 | { | |
10 | # Check if we are a terminal | |
11 | if [ -t 1 ]; then | |
12 | echo -e "\e[1;32mOK\e[0m" | |
13 | else | |
14 | echo -e "OK" | |
15 | fi | |
16 | } | |
17 | ||
18 | function print_fail () | |
19 | { | |
20 | # Check if we are a terminal | |
21 | if [ -t 1 ]; then | |
22 | echo -e "\e[1;31mFAIL\e[0m" | |
23 | else | |
24 | echo -e "FAIL" | |
25 | fi | |
26 | } | |
27 | ||
28 | function test_check () | |
29 | { | |
30 | if [ $? -ne 0 ] ; then | |
31 | print_fail | |
32 | return 1 | |
33 | else | |
34 | print_ok | |
35 | return 0 | |
36 | fi | |
37 | } | |
38 | ||
39 | function test_check_fail () | |
40 | { | |
41 | if [ $? -ne 1 ] ; then | |
42 | print_fail | |
43 | return 1 | |
44 | else | |
45 | print_ok | |
46 | return 0 | |
47 | fi | |
48 | } | |
49 | ||
50 | function run_babeltrace () | |
51 | { | |
52 | ${BABELTRACE_BIN} $* > /dev/null 2>&1 | |
53 | return $? | |
54 | } | |
55 | ||
607c826c MD |
56 | #run babeltrace expects success |
57 | echo -e "Running babeltrace without argument..." | |
58 | run_babeltrace | |
59 | test_check | |
60 | if [ $? -ne 0 ]; then | |
61 | exit 1 | |
62 | fi | |
63 | ||
64 | for a in ${CTF_TRACES}/succeed/*; do | |
65 | echo -e "Running babeltrace for trace ${a}..." | |
66 | run_babeltrace ${a} | |
67 | test_check | |
68 | if [ $? -ne 0 ]; then | |
69 | exit 1 | |
70 | fi | |
71 | done | |
72 | ||
73 | #run babeltrace expects failure | |
74 | echo -e "Running babeltrace with bogus argument..." | |
75 | run_babeltrace --bogusarg | |
76 | test_check_fail | |
77 | if [ $? -ne 0 ]; then | |
78 | exit 1 | |
79 | fi | |
80 | ||
81 | for a in ${CTF_TRACES}/fail/*; do | |
82 | echo -e "Running babeltrace for trace ${a}..." | |
83 | run_babeltrace ${a} | |
84 | test_check_fail | |
85 | if [ $? -ne 0 ]; then | |
86 | exit 1 | |
87 | fi | |
88 | done | |
89 | ||
90 | exit 0 |