Commit | Line | Data |
---|---|---|
ebaaaf5e JD |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) - 2013 Julien Desfossez <jdesfossez@efficios.com> | |
4 | # | |
5 | # This library is free software; you can redistribute it and/or modify it under | |
6 | # the terms of the GNU Lesser General Public License as published by the Free | |
7 | # Software Foundation; version 2.1 of the License. | |
8 | # | |
9 | # This library is distributed in the hope that it will be useful, but WITHOUT | |
10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
11 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | |
12 | # details. | |
13 | # | |
14 | # You should have received a copy of the GNU Lesser General Public License | |
15 | # along with this library; if not, write to the Free Software Foundation, Inc., | |
16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | TEST_DESC="Snapshots - UST tracing" | |
18 | ||
19 | CURDIR=$(dirname $0)/ | |
20 | TESTDIR=$CURDIR/../../.. | |
21 | EVENT_NAME="tp:tptest" | |
22 | BIN_NAME="gen-nevents" | |
23 | PID_RELAYD=0 | |
24 | SESSION_NAME="" | |
25 | CHANNEL_NAME="snapchan" | |
26 | TESTAPP_PATH="$TESTDIR/utils/testapp" | |
27 | TESTAPP_NAME="gen-ust-events" | |
28 | TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" | |
29 | NR_ITER=2000000 | |
30 | NR_USEC_WAIT=100 | |
31 | ||
32 | TRACE_PATH=$(mktemp -d) | |
33 | ||
34 | NUM_TESTS=2019 | |
35 | ||
36 | source $TESTDIR/utils/utils.sh | |
37 | ||
38 | if [ ! -x "$TESTAPP_BIN" ]; then | |
39 | BAIL_OUT "No UST events binary detected." | |
40 | fi | |
41 | ||
42 | function test_ust_local_snapshot () | |
43 | { | |
44 | diag "Test local UST snapshots" | |
45 | create_lttng_session_no_output $SESSION_NAME | |
46 | enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME | |
47 | enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME | |
48 | start_lttng_tracing $SESSION_NAME | |
49 | lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH | |
50 | $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT & | |
51 | ok $? "Start application to trace" | |
52 | lttng_snapshot_record $SESSION_NAME | |
53 | stop_lttng_tracing $SESSION_NAME | |
54 | destroy_lttng_session $SESSION_NAME | |
55 | ||
56 | # Validate test | |
57 | validate_trace $EVENT_NAME $TRACE_PATH/ | |
58 | if [ $? -eq 0 ]; then | |
59 | # Only delete if successful | |
60 | rm -rf $TRACE_PATH | |
61 | else | |
62 | break | |
63 | fi | |
64 | diag "Killing $TESTAPP_NAME" | |
65 | PID_APP=`pidof $TESTAPP_NAME` | |
66 | kill $PID_APP >/dev/null 2>&1 | |
67 | } | |
68 | ||
69 | function test_ust_1000_local_snapshots () | |
70 | { | |
71 | NB_SNAP=1000 | |
72 | ||
73 | diag "Test $NB_SNAP local UST snapshots" | |
74 | create_lttng_session_no_output $SESSION_NAME | |
75 | enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME | |
76 | enable_ust_lttng_event $SESSION_NAME $EVENT_NAME $CHANNEL_NAME | |
77 | start_lttng_tracing $SESSION_NAME | |
78 | lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH | |
79 | $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT & | |
80 | for i in $(seq 1 $NB_SNAP); do | |
81 | diag "Snapshot $i/$NB_SNAP" | |
82 | rm -rf $TRACE_PATH/snapshot/* 2>/dev/null | |
83 | lttng_snapshot_record $SESSION_NAME | |
84 | # Validate test | |
85 | validate_trace $EVENT_NAME $TRACE_PATH/ | |
86 | if [ $? -eq 0 ]; then | |
87 | # Only delete if successful | |
88 | rm -rf $TRACE_PATH | |
89 | else | |
90 | break | |
91 | fi | |
92 | done | |
93 | stop_lttng_tracing $SESSION_NAME | |
94 | destroy_lttng_session $SESSION_NAME | |
95 | diag "Killing $TESTAPP_NAME" | |
96 | PID_APP=`pidof $TESTAPP_NAME` | |
97 | # kill $PID_APP >/dev/null 2>&1 | |
98 | } | |
99 | ||
100 | plan_tests $NUM_TESTS | |
101 | ||
102 | print_test_banner "$TEST_DESC" | |
103 | ||
104 | if [ "$(id -u)" == "0" ]; then | |
105 | isroot=1 | |
106 | else | |
107 | isroot=0 | |
108 | fi | |
109 | ||
110 | start_lttng_sessiond | |
111 | ||
112 | tests=( test_ust_local_snapshot test_ust_1000_local_snapshots ) | |
113 | ||
114 | for fct_test in ${tests[@]}; | |
115 | do | |
116 | SESSION_NAME=$(randstring 16 0) | |
117 | ${fct_test} | |
118 | ||
119 | done | |
120 | ||
121 | stop_lttng_sessiond |