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