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