Commit | Line | Data |
---|---|---|
1518fa0f PMF |
1 | #!/bin/bash |
2 | ||
3 | function check_no_fail() { | |
4 | if [ "$?" -ne "0" ]; then | |
5 | echo "$0: Stopping because of error" | |
6 | exit 1; | |
7 | fi | |
8 | } | |
9 | ||
10 | function 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 | ||
20 | TESTDIR=$(dirname $0) | |
21 | MATCHES="$TESTDIR/trace_matches" | |
22 | ||
23 | NOFAIL usttrace $TESTDIR/test-nevents/prog | |
24 | NOFAIL $MATCHES -N "an_event (100000)" -n 100000 "^ust.an_event:" $(usttrace -W) | |
25 | NOFAIL $MATCHES -N "another_event (100000)" -n 100000 "^ust.another_event:" $(usttrace -W) | |
26 | ||
27 | NOFAIL usttrace -f $TESTDIR/fork/.libs/fork $TESTDIR/fork/.libs/fork2 | |
28 | NOFAIL $MATCHES -N "fork - before_fork" "^ust.before_fork:" $(usttrace -W) | |
29 | NOFAIL $MATCHES -N "fork - after_fork_parent" "^ust.after_fork_parent:" $(usttrace -W) | |
30 | NOFAIL $MATCHES -N "fork - after_fork_child" "^ust.after_fork_child:" $(usttrace -W) | |
31 | NOFAIL $MATCHES -N "fork - before_exec" "^ust.before_exec:" $(usttrace -W) | |
32 | NOFAIL $MATCHES -N "fork - potential_exec" "^ust.potential_exec:" $(usttrace -W) | |
33 | NOFAIL $MATCHES -N "fork - after_exec" "^ust.after_exec:" $(usttrace -W) | |
34 | ||
35 | NOFAIL usttrace -lm $TESTDIR/test-libmallocwrap/prog | |
36 | NOFAIL $MATCHES -N "mallocwrap - malloc" -n 1000 "^ust.malloc:.*{ size = 1[0-9][0-9][0-9]," $(usttrace -W) | |
37 | ||
38 | ### Manual mode test | |
39 | TRACE_DIR="/tmp/ust-testsuite-manual-trace" | |
40 | rm -rf "$TRACE_DIR" | |
41 | mkdir "$TRACE_DIR" | |
42 | ||
43 | NOFAIL ustd -o "$TRACE_DIR" >/dev/null 2>&1 & | |
44 | USTD_PID=$! | |
45 | ||
46 | LD_PRELOAD=/usr/local/lib/libust.so.0.0.0:/usr/local/lib/libmallocwrap.so find / >/dev/null 2>&1 & | |
47 | PID=$! | |
48 | sleep 0.1 | |
49 | NOFAIL ustctl --list-markers "$PID" >/dev/null | |
50 | NOFAIL ustctl --enable-marker ust/malloc $PID | |
51 | NOFAIL ustctl --enable-marker ust/free $PID | |
52 | NOFAIL ustctl --create-trace $PID | |
53 | NOFAIL ustctl --alloc-trace $PID | |
54 | NOFAIL ustctl --start-trace $PID | |
55 | sleep 0.5 | |
56 | NOFAIL ustctl --stop-trace $PID | |
57 | NOFAIL ustctl --destroy-trace $PID | |
58 | kill $PID | |
59 | kill $USTD_PID | |
60 | ||
61 | NOFAIL $MATCHES -N "manual - find - ust.malloc" "^ust.malloc:" "$TRACE_DIR" | |
62 | ||
63 | echo "************************************" | |
64 | echo "$0: All passed" | |
65 | echo "************************************" | |
66 | exit 0 |