Commit | Line | Data |
---|---|---|
d3e8f6bb DG |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) - 2012 David Goulet <dgoulet@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 | |
21dee66a CB |
17 | NUM_PROCESS=30 |
18 | TEST_DESC="UST tracer - Generate $NUM_PROCESS process" | |
d3e8f6bb | 19 | |
ec8f26de | 20 | CURDIR=$(dirname $0)/ |
9ac429ef | 21 | TESTDIR=$CURDIR/../../.. |
0fc2834c | 22 | NR_ITER=-1 # infinite loop |
21dee66a CB |
23 | NR_USEC_WAIT=1000000 |
24 | TESTAPP_PATH="$TESTDIR/utils/testapp" | |
25 | TESTAPP_NAME="gen-ust-events" | |
26 | TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" | |
4220447f | 27 | SESSION_NAME="ust-nprocesses" |
21dee66a | 28 | EVENT_NAME="tp:tptest" |
4220447f CB |
29 | TEST_WAIT_SEC=5 |
30 | NUM_TESTS=9 | |
0fc2834c | 31 | APPS_PID= |
d3e8f6bb | 32 | |
9ac429ef | 33 | source $TESTDIR/utils/utils.sh |
d3e8f6bb | 34 | |
21dee66a CB |
35 | if [ ! -x "$TESTAPP_BIN" ]; then |
36 | BAIL_OUT "No UST $TESTAPP_BIN binary detected." | |
ec8f26de DG |
37 | fi |
38 | ||
d3e8f6bb DG |
39 | # MUST set TESTDIR before calling those functions |
40 | ||
4220447f CB |
41 | plan_tests $NUM_TESTS |
42 | ||
e3bef725 CB |
43 | print_test_banner "$TEST_DESC" |
44 | ||
fb3268e3 | 45 | start_lttng_sessiond |
d3e8f6bb | 46 | |
0fc2834c | 47 | # Start tests. Each is an infinite tracing loop. |
d3e8f6bb | 48 | |
5fcaccbc MD |
49 | file_sync_after_first=$(mktemp -u) |
50 | file_sync_before_last=$(mktemp -u) | |
51 | ||
0fc2834c | 52 | diag "Starting $NUM_PROCESS test applications" |
21dee66a | 53 | for i in `seq 1 $NUM_PROCESS` |
4220447f | 54 | do |
6c4a91d6 MD |
55 | $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \ |
56 | --sync-after-first-event ${file_sync_after_first} \ | |
57 | --sync-before-last-event ${file_sync_before_last} >/dev/null 2>&1 & | |
0fc2834c | 58 | APPS_PID="${APPS_PID} ${!}" |
4220447f CB |
59 | done |
60 | ||
0fc2834c MD |
61 | diag "Waiting for applications to be registered to sessiond" |
62 | ||
7972aab2 | 63 | reg_app_count=0 |
21dee66a | 64 | while [ $reg_app_count -ne $NUM_PROCESS ]; do |
7972aab2 | 65 | listing=$($TESTDIR/../src/bin/lttng/$LTTNG_BIN list -u) |
21dee66a | 66 | reg_app_count=$(echo -n $listing | sed "s#$TESTAPP_BIN#$TESTAPP_BIN\n#g" | grep "$TESTAPP_BIN" | wc -l) |
7972aab2 | 67 | done |
4220447f | 68 | |
0fc2834c | 69 | pass "All applications are registered to sessiond" |
4220447f CB |
70 | |
71 | TRACE_PATH=$(mktemp -d) | |
72 | ||
bf6ae429 | 73 | create_lttng_session_ok $SESSION_NAME $TRACE_PATH |
4220447f | 74 | |
c4926bb5 | 75 | enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME |
e563bbdb | 76 | start_lttng_tracing_ok $SESSION_NAME |
d3e8f6bb | 77 | |
5fcaccbc MD |
78 | touch ${file_sync_before_last} |
79 | ||
0fc2834c MD |
80 | # We don't validate whether the applications have traced here, rather |
81 | # just that they registered to sessiond (above). | |
4220447f | 82 | |
96340a01 | 83 | stop_lttng_tracing_ok $SESSION_NAME |
67b4c664 | 84 | destroy_lttng_session_ok $SESSION_NAME |
4220447f | 85 | |
5fcaccbc | 86 | #TODO: add trace validation. |
c7613334 | 87 | |
4220447f CB |
88 | rm -rf $TRACE_PATH |
89 | ||
5dca3876 | 90 | diag "Stopping all spawned applications" |
0fc2834c MD |
91 | for p in ${APPS_PID}; do |
92 | kill ${p} | |
93 | wait ${p} 2>/dev/null | |
94 | done | |
c7613334 | 95 | APPS_PID= |
5dca3876 | 96 | pass "Stopped all spawned applications" |
4220447f | 97 | |
5fcaccbc MD |
98 | rm -f ${file_sync_after_first} |
99 | rm -f ${file_sync_before_last} | |
100 | ||
4220447f | 101 | stop_lttng_sessiond |