trace_matches: fix return value bug
[ust.git] / tests / runtests
CommitLineData
1518fa0f
PMF
1#!/bin/bash
2
3function check_no_fail() {
4 if [ "$?" -ne "0" ]; then
5 echo "$0: Stopping because of error"
6 exit 1;
7 fi
8}
9
10function NOFAIL() {
11 "$@"
12 if [ "$?" -ne "0" ]; then
13 echo "!!!!!!!!!!!!!!!!!!!!!!!!"
14 echo "$0: Stopping because of error"
15 echo "!!!!!!!!!!!!!!!!!!!!!!!!"
16 exit 1;
17 fi
18}
19
53bd45cf
PMF
20function starttest() {
21 echo "------------------------------------"
22 echo "Starting test: $1"
23 echo "------------------------------------"
24}
25
1518fa0f
PMF
26TESTDIR=$(dirname $0)
27MATCHES="$TESTDIR/trace_matches"
28
53bd45cf 29starttest "Test-nevents"
1518fa0f
PMF
30NOFAIL usttrace $TESTDIR/test-nevents/prog
31NOFAIL $MATCHES -N "an_event (100000)" -n 100000 "^ust.an_event:" $(usttrace -W)
32NOFAIL $MATCHES -N "another_event (100000)" -n 100000 "^ust.another_event:" $(usttrace -W)
33
53bd45cf 34starttest "fork()/exec() test"
1518fa0f
PMF
35NOFAIL usttrace -f $TESTDIR/fork/.libs/fork $TESTDIR/fork/.libs/fork2
36NOFAIL $MATCHES -N "fork - before_fork" "^ust.before_fork:" $(usttrace -W)
37NOFAIL $MATCHES -N "fork - after_fork_parent" "^ust.after_fork_parent:" $(usttrace -W)
38NOFAIL $MATCHES -N "fork - after_fork_child" "^ust.after_fork_child:" $(usttrace -W)
39NOFAIL $MATCHES -N "fork - before_exec" "^ust.before_exec:" $(usttrace -W)
40NOFAIL $MATCHES -N "fork - potential_exec" "^ust.potential_exec:" $(usttrace -W)
41NOFAIL $MATCHES -N "fork - after_exec" "^ust.after_exec:" $(usttrace -W)
42
53bd45cf 43starttest "libmallocwrap"
24232db7 44NOFAIL usttrace -lm $TESTDIR/test-libmallocwrap/.libs/prog
1518fa0f
PMF
45NOFAIL $MATCHES -N "mallocwrap - malloc" -n 1000 "^ust.malloc:.*{ size = 1[0-9][0-9][0-9]," $(usttrace -W)
46
47### Manual mode test
53bd45cf 48starttest "Manual mode tracing"
1518fa0f
PMF
49TRACE_DIR="/tmp/ust-testsuite-manual-trace"
50rm -rf "$TRACE_DIR"
51mkdir "$TRACE_DIR"
52
53NOFAIL ustd -o "$TRACE_DIR" >/dev/null 2>&1 &
54USTD_PID=$!
55
56LD_PRELOAD=/usr/local/lib/libust.so.0.0.0:/usr/local/lib/libmallocwrap.so find / >/dev/null 2>&1 &
57PID=$!
58sleep 0.1
59NOFAIL ustctl --list-markers "$PID" >/dev/null
60NOFAIL ustctl --enable-marker ust/malloc $PID
61NOFAIL ustctl --enable-marker ust/free $PID
62NOFAIL ustctl --create-trace $PID
63NOFAIL ustctl --alloc-trace $PID
64NOFAIL ustctl --start-trace $PID
65sleep 0.5
66NOFAIL ustctl --stop-trace $PID
67NOFAIL ustctl --destroy-trace $PID
68kill $PID
69kill $USTD_PID
70
71NOFAIL $MATCHES -N "manual - find - ust.malloc" "^ust.malloc:" "$TRACE_DIR"
72
73echo "************************************"
74echo "$0: All passed"
75echo "************************************"
76exit 0
This page took 0.024377 seconds and 4 git commands to generate.