| 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=1000 |
| 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 | |
| 32 | source $TESTDIR/utils/utils.sh |
| 33 | |
| 34 | if [ ! -x "$TESTAPP_BIN" ]; then |
| 35 | BAIL_OUT "No UST $TESTAPP_BIN binary detected." |
| 36 | fi |
| 37 | |
| 38 | # MUST set TESTDIR before calling those functions |
| 39 | |
| 40 | plan_tests $NUM_TESTS |
| 41 | |
| 42 | print_test_banner "$TEST_DESC" |
| 43 | |
| 44 | start_lttng_sessiond |
| 45 | |
| 46 | # Start test for 1000 seconds |
| 47 | |
| 48 | for i in `seq 1 $NUM_PROCESS` |
| 49 | do |
| 50 | $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1 & |
| 51 | done |
| 52 | |
| 53 | reg_app_count=0 |
| 54 | while [ $reg_app_count -ne $NUM_PROCESS ]; do |
| 55 | listing=$($TESTDIR/../src/bin/lttng/$LTTNG_BIN list -u) |
| 56 | reg_app_count=$(echo -n $listing | sed "s#$TESTAPP_BIN#$TESTAPP_BIN\n#g" | grep "$TESTAPP_BIN" | wc -l) |
| 57 | done |
| 58 | |
| 59 | pass "Trace validation" |
| 60 | |
| 61 | TRACE_PATH=$(mktemp -d) |
| 62 | |
| 63 | create_lttng_session $SESSION_NAME $TRACE_PATH |
| 64 | |
| 65 | enable_ust_lttng_event $SESSION_NAME $EVENT_NAME |
| 66 | start_lttng_tracing $SESSION_NAME |
| 67 | |
| 68 | diag "Sleeping $TEST_WAIT_SEC seconds for tracing to start everywhere" |
| 69 | diag "Warning: this arbitrary time can make the test fail on slower system" |
| 70 | |
| 71 | sleep $TEST_WAIT_SEC |
| 72 | |
| 73 | stop_lttng_tracing $SESSION_NAME |
| 74 | destroy_lttng_session $SESSION_NAME |
| 75 | |
| 76 | rm -rf $TRACE_PATH |
| 77 | |
| 78 | while [ -n "$(pidof $TESTAPP_NAME)" ]; do |
| 79 | killall -q $TESTAPP_NAME >/dev/null 2>&1 |
| 80 | sleep 0.5 |
| 81 | done |
| 82 | |
| 83 | |
| 84 | pass "Kill all spawned applications" |
| 85 | |
| 86 | stop_lttng_sessiond |