runtests: assert the test logs contain no errors or warnings
[ust.git] / tests / runtests
CommitLineData
1518fa0f
PMF
1#!/bin/bash
2
1518fa0f
PMF
3function 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
53bd45cf
PMF
13function starttest() {
14 echo "------------------------------------"
15 echo "Starting test: $1"
16 echo "------------------------------------"
17}
18
68d19739
PMF
19function 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
1518fa0f
PMF
32TESTDIR=$(dirname $0)
33MATCHES="$TESTDIR/trace_matches"
34
53bd45cf 35starttest "Test-nevents"
1518fa0f 36NOFAIL usttrace $TESTDIR/test-nevents/prog
68d19739
PMF
37trace_loc=$(usttrace -W)
38NOFAIL $MATCHES -N "an_event (100000)" -n 100000 "^ust.an_event:" $trace_loc
39NOFAIL $MATCHES -N "another_event (100000)" -n 100000 "^ust.another_event:" $trace_loc
40NOFAIL check_trace_logs "$trace_loc"
1518fa0f 41
53bd45cf 42starttest "fork()/exec() test"
1518fa0f 43NOFAIL usttrace -f $TESTDIR/fork/.libs/fork $TESTDIR/fork/.libs/fork2
68d19739
PMF
44trace_loc=$(usttrace -W)
45NOFAIL $MATCHES -N "fork - before_fork" "^ust.before_fork:" $trace_loc
46NOFAIL $MATCHES -N "fork - after_fork_parent" "^ust.after_fork_parent:" $trace_loc
47NOFAIL $MATCHES -N "fork - after_fork_child" "^ust.after_fork_child:" $trace_loc
48NOFAIL $MATCHES -N "fork - before_exec" "^ust.before_exec:" $trace_loc
49NOFAIL $MATCHES -N "fork - potential_exec" "^ust.potential_exec:" $trace_loc
50NOFAIL $MATCHES -N "fork - after_exec" "^ust.after_exec:" $trace_loc
51NOFAIL check_trace_logs "$trace_loc"
1518fa0f 52
53bd45cf 53starttest "libmallocwrap"
24232db7 54NOFAIL usttrace -lm $TESTDIR/test-libmallocwrap/.libs/prog
68d19739
PMF
55trace_loc=$(usttrace -W)
56NOFAIL $MATCHES -N "mallocwrap - malloc" -n 1000 "^ust.malloc:.*{ size = 1[0-9][0-9][0-9]," $trace_loc
57NOFAIL check_trace_logs "$trace_loc"
1518fa0f
PMF
58
59### Manual mode test
53bd45cf 60starttest "Manual mode tracing"
1518fa0f
PMF
61TRACE_DIR="/tmp/ust-testsuite-manual-trace"
62rm -rf "$TRACE_DIR"
63mkdir "$TRACE_DIR"
64
65NOFAIL ustd -o "$TRACE_DIR" >/dev/null 2>&1 &
66USTD_PID=$!
67
68LD_PRELOAD=/usr/local/lib/libust.so.0.0.0:/usr/local/lib/libmallocwrap.so find / >/dev/null 2>&1 &
69PID=$!
70sleep 0.1
71NOFAIL ustctl --list-markers "$PID" >/dev/null
72NOFAIL ustctl --enable-marker ust/malloc $PID
73NOFAIL ustctl --enable-marker ust/free $PID
74NOFAIL ustctl --create-trace $PID
75NOFAIL ustctl --alloc-trace $PID
76NOFAIL ustctl --start-trace $PID
77sleep 0.5
78NOFAIL ustctl --stop-trace $PID
79NOFAIL ustctl --destroy-trace $PID
80kill $PID
81kill $USTD_PID
82
83NOFAIL $MATCHES -N "manual - find - ust.malloc" "^ust.malloc:" "$TRACE_DIR"
84
85echo "************************************"
86echo "$0: All passed"
87echo "************************************"
88exit 0
This page took 0.025752 seconds and 4 git commands to generate.