Fix: tests: don't use pidof to wait for test apps
[lttng-tools.git] / tests / regression / ust / nprocesses / test_nprocesses
CommitLineData
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
17NUM_PROCESS=30
18TEST_DESC="UST tracer - Generate $NUM_PROCESS process"
d3e8f6bb 19
ec8f26de 20CURDIR=$(dirname $0)/
9ac429ef 21TESTDIR=$CURDIR/../../..
21dee66a
CB
22NR_ITER=1000
23NR_USEC_WAIT=1000000
24TESTAPP_PATH="$TESTDIR/utils/testapp"
25TESTAPP_NAME="gen-ust-events"
26TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
4220447f 27SESSION_NAME="ust-nprocesses"
21dee66a 28EVENT_NAME="tp:tptest"
4220447f
CB
29TEST_WAIT_SEC=5
30NUM_TESTS=9
d3e8f6bb 31
9ac429ef 32source $TESTDIR/utils/utils.sh
d3e8f6bb 33
21dee66a
CB
34if [ ! -x "$TESTAPP_BIN" ]; then
35 BAIL_OUT "No UST $TESTAPP_BIN binary detected."
ec8f26de
DG
36fi
37
d3e8f6bb
DG
38# MUST set TESTDIR before calling those functions
39
4220447f
CB
40plan_tests $NUM_TESTS
41
e3bef725
CB
42print_test_banner "$TEST_DESC"
43
fb3268e3 44start_lttng_sessiond
d3e8f6bb 45
4220447f 46# Start test for 1000 seconds
d3e8f6bb 47
21dee66a 48for i in `seq 1 $NUM_PROCESS`
4220447f 49do
21dee66a 50 $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 &
4220447f
CB
51done
52
7972aab2 53reg_app_count=0
21dee66a 54while [ $reg_app_count -ne $NUM_PROCESS ]; do
7972aab2 55 listing=$($TESTDIR/../src/bin/lttng/$LTTNG_BIN list -u)
21dee66a 56 reg_app_count=$(echo -n $listing | sed "s#$TESTAPP_BIN#$TESTAPP_BIN\n#g" | grep "$TESTAPP_BIN" | wc -l)
7972aab2 57done
4220447f 58
7972aab2 59pass "Trace validation"
4220447f
CB
60
61TRACE_PATH=$(mktemp -d)
62
63create_lttng_session $SESSION_NAME $TRACE_PATH
64
65enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
66start_lttng_tracing $SESSION_NAME
d3e8f6bb 67
4220447f
CB
68diag "Sleeping $TEST_WAIT_SEC seconds for tracing to start everywhere"
69diag "Warning: this arbitrary time can make the test fail on slower system"
70
71sleep $TEST_WAIT_SEC
72
73stop_lttng_tracing $SESSION_NAME
74destroy_lttng_session $SESSION_NAME
75
76rm -rf $TRACE_PATH
77
5dca3876
MD
78diag "Stopping all spawned applications"
79killall -q $TESTAPP_NAME >/dev/null 2>&1
80wait
81pass "Stopped all spawned applications"
4220447f
CB
82
83stop_lttng_sessiond
This page took 0.043155 seconds and 5 git commands to generate.