runtests: assert the test logs contain no errors or warnings
[ust.git] / tests / runtests
1 #!/bin/bash
2
3 function NOFAIL() {
4 "$@"
5 if [ "$?" -ne "0" ]; then
6 echo "!!!!!!!!!!!!!!!!!!!!!!!!"
7 echo "$0: Stopping because of error"
8 echo "!!!!!!!!!!!!!!!!!!!!!!!!"
9 exit 1;
10 fi
11 }
12
13 function starttest() {
14 echo "------------------------------------"
15 echo "Starting test: $1"
16 echo "------------------------------------"
17 }
18
19 function check_trace_logs() {
20 TRACE=$1
21
22 for f in $(ls $1/*.log); do
23 NLINES=$(egrep "Warning|Error" $f | wc -l)
24 if [ "$NLINES" -ne "0" ]; then
25 echo "Errors/warnings found in $f"
26 return 1;
27 fi
28 done
29 return 0;
30 }
31
32 TESTDIR=$(dirname $0)
33 MATCHES="$TESTDIR/trace_matches"
34
35 starttest "Test-nevents"
36 NOFAIL usttrace $TESTDIR/test-nevents/prog
37 trace_loc=$(usttrace -W)
38 NOFAIL $MATCHES -N "an_event (100000)" -n 100000 "^ust.an_event:" $trace_loc
39 NOFAIL $MATCHES -N "another_event (100000)" -n 100000 "^ust.another_event:" $trace_loc
40 NOFAIL check_trace_logs "$trace_loc"
41
42 starttest "fork()/exec() test"
43 NOFAIL usttrace -f $TESTDIR/fork/.libs/fork $TESTDIR/fork/.libs/fork2
44 trace_loc=$(usttrace -W)
45 NOFAIL $MATCHES -N "fork - before_fork" "^ust.before_fork:" $trace_loc
46 NOFAIL $MATCHES -N "fork - after_fork_parent" "^ust.after_fork_parent:" $trace_loc
47 NOFAIL $MATCHES -N "fork - after_fork_child" "^ust.after_fork_child:" $trace_loc
48 NOFAIL $MATCHES -N "fork - before_exec" "^ust.before_exec:" $trace_loc
49 NOFAIL $MATCHES -N "fork - potential_exec" "^ust.potential_exec:" $trace_loc
50 NOFAIL $MATCHES -N "fork - after_exec" "^ust.after_exec:" $trace_loc
51 NOFAIL check_trace_logs "$trace_loc"
52
53 starttest "libmallocwrap"
54 NOFAIL usttrace -lm $TESTDIR/test-libmallocwrap/.libs/prog
55 trace_loc=$(usttrace -W)
56 NOFAIL $MATCHES -N "mallocwrap - malloc" -n 1000 "^ust.malloc:.*{ size = 1[0-9][0-9][0-9]," $trace_loc
57 NOFAIL check_trace_logs "$trace_loc"
58
59 ### Manual mode test
60 starttest "Manual mode tracing"
61 TRACE_DIR="/tmp/ust-testsuite-manual-trace"
62 rm -rf "$TRACE_DIR"
63 mkdir "$TRACE_DIR"
64
65 NOFAIL ustd -o "$TRACE_DIR" >/dev/null 2>&1 &
66 USTD_PID=$!
67
68 LD_PRELOAD=/usr/local/lib/libust.so.0.0.0:/usr/local/lib/libmallocwrap.so find / >/dev/null 2>&1 &
69 PID=$!
70 sleep 0.1
71 NOFAIL ustctl --list-markers "$PID" >/dev/null
72 NOFAIL ustctl --enable-marker ust/malloc $PID
73 NOFAIL ustctl --enable-marker ust/free $PID
74 NOFAIL ustctl --create-trace $PID
75 NOFAIL ustctl --alloc-trace $PID
76 NOFAIL ustctl --start-trace $PID
77 sleep 0.5
78 NOFAIL ustctl --stop-trace $PID
79 NOFAIL ustctl --destroy-trace $PID
80 kill $PID
81 kill $USTD_PID
82
83 NOFAIL $MATCHES -N "manual - find - ust.malloc" "^ust.malloc:" "$TRACE_DIR"
84
85 echo "************************************"
86 echo "$0: All passed"
87 echo "************************************"
88 exit 0
This page took 0.030926 seconds and 4 git commands to generate.