ca0f9d416cba74e08eafecf04d598d867474fa46
[lttng-tools.git] / tests / regression / ust / nprocesses / test_nprocesses
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
17 NUM_PROCESS=30
18 TEST_DESC="UST tracer - Generate $NUM_PROCESS process"
19
20 CURDIR=$(dirname $0)/
21 TESTDIR=$CURDIR/../../..
22 NR_ITER=-1 # infinite loop
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"
27 SESSION_NAME="ust-nprocesses"
28 EVENT_NAME="tp:tptest"
29 TEST_WAIT_SEC=5
30 NUM_TESTS=9
31 APPS_PID=
32
33 source $TESTDIR/utils/utils.sh
34
35 if [ ! -x "$TESTAPP_BIN" ]; then
36 BAIL_OUT "No UST $TESTAPP_BIN binary detected."
37 fi
38
39 # MUST set TESTDIR before calling those functions
40
41 plan_tests $NUM_TESTS
42
43 print_test_banner "$TEST_DESC"
44
45 start_lttng_sessiond
46
47 # Start tests. Each is an infinite tracing loop.
48
49 diag "Starting $NUM_PROCESS test applications"
50 for i in `seq 1 $NUM_PROCESS`
51 do
52 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 &
53 APPS_PID="${APPS_PID} ${!}"
54 done
55
56 #FIXME: racy missing synchronization
57
58 diag "Waiting for applications to be registered to sessiond"
59
60 reg_app_count=0
61 while [ $reg_app_count -ne $NUM_PROCESS ]; do
62 listing=$($TESTDIR/../src/bin/lttng/$LTTNG_BIN list -u)
63 reg_app_count=$(echo -n $listing | sed "s#$TESTAPP_BIN#$TESTAPP_BIN\n#g" | grep "$TESTAPP_BIN" | wc -l)
64 done
65
66 pass "All applications are registered to sessiond"
67
68 TRACE_PATH=$(mktemp -d)
69
70 create_lttng_session $SESSION_NAME $TRACE_PATH
71
72 enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
73 start_lttng_tracing $SESSION_NAME
74
75 # We don't validate whether the applications have traced here, rather
76 # just that they registered to sessiond (above).
77
78 stop_lttng_tracing $SESSION_NAME
79 destroy_lttng_session $SESSION_NAME
80
81 #FIXME/TODO: add validation after fixing racy synchroniaation
82
83 rm -rf $TRACE_PATH
84
85 diag "Stopping all spawned applications"
86 for p in ${APPS_PID}; do
87 kill ${p}
88 wait ${p} 2>/dev/null
89 done
90 APPS_PID=
91 pass "Stopped all spawned applications"
92
93 stop_lttng_sessiond
This page took 0.030657 seconds and 3 git commands to generate.