From: David Goulet Date: Tue, 27 Aug 2013 21:30:45 +0000 (-0400) Subject: Tests: change buffers UID test to PID X-Git-Tag: v2.3.0-rc3~12 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=f5481aa9adff33804a2003baa1157043c35a1ccd;p=lttng-tools.git Tests: change buffers UID test to PID Signed-off-by: David Goulet --- diff --git a/configure.ac b/configure.ac index 8d42e9019..ba3776230 100644 --- a/configure.ac +++ b/configure.ac @@ -376,7 +376,7 @@ AC_CONFIG_FILES([ tests/regression/ust/high-throughput/Makefile tests/regression/ust/low-throughput/Makefile tests/regression/ust/before-after/Makefile - tests/regression/ust/buffers-uid/Makefile + tests/regression/ust/buffers-pid/Makefile tests/regression/ust/periodical-metadata-flush/Makefile tests/regression/ust/multi-session/Makefile tests/regression/ust/overlap/Makefile diff --git a/tests/fast_regression b/tests/fast_regression index b54d38d0e..92aaff65c 100644 --- a/tests/fast_regression +++ b/tests/fast_regression @@ -7,7 +7,7 @@ regression/tools/tracefile-limits/test_tracefile_size regression/tools/snapshots/test_ust regression/tools/snapshots/test_ust_streaming regression/ust/before-after/test_before_after -regression/ust/buffers-uid/test_buffers_uid +regression/ust/buffers-pid/test_buffers_pid regression/ust/periodical-metadata-flush/test_periodical_metadata_flush regression/ust/multi-session/test_multi_session regression/ust/nprocesses/test_nprocesses diff --git a/tests/long_regression b/tests/long_regression index 246259ab7..b9d6ef8f7 100644 --- a/tests/long_regression +++ b/tests/long_regression @@ -8,7 +8,7 @@ regression/tools/streaming/test_ust regression/tools/tracefile-limits/test_tracefile_count regression/tools/tracefile-limits/test_tracefile_size regression/ust/before-after/test_before_after -regression/ust/buffers-uid/test_buffers_uid +regression/ust/buffers-pid/test_buffers_pid regression/ust/periodical-metadata-flush/test_periodical_metadata_flush regression/ust/high-throughput/test_high_throughput regression/ust/low-throughput/test_low_throughput diff --git a/tests/regression/ust/Makefile.am b/tests/regression/ust/Makefile.am index b3620c008..e7b4cf71b 100644 --- a/tests/regression/ust/Makefile.am +++ b/tests/regression/ust/Makefile.am @@ -1,6 +1,6 @@ if HAVE_LIBLTTNG_UST_CTL SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \ - overlap buffers-uid linking daemon exit-fast fork libc-wrapper \ + overlap buffers-pid linking daemon exit-fast fork libc-wrapper \ periodical-metadata-flush EXTRA_DIST = test_event_basic test_event_wildcard diff --git a/tests/regression/ust/buffers-pid/Makefile.am b/tests/regression/ust/buffers-pid/Makefile.am new file mode 100644 index 000000000..74aacbabb --- /dev/null +++ b/tests/regression/ust/buffers-pid/Makefile.am @@ -0,0 +1,16 @@ +noinst_SCRIPTS = test_buffers_pid +EXTRA_DIST = test_buffers_pid + +all-local: + @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ + for script in $(EXTRA_DIST); do \ + cp -f $(srcdir)/$$script $(builddir); \ + done; \ + fi + +clean-local: + @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ + for script in $(EXTRA_DIST); do \ + rm -f $(builddir)/$$script; \ + done; \ + fi diff --git a/tests/regression/ust/buffers-pid/test_buffers_pid b/tests/regression/ust/buffers-pid/test_buffers_pid new file mode 100755 index 000000000..2d227bf5f --- /dev/null +++ b/tests/regression/ust/buffers-pid/test_buffers_pid @@ -0,0 +1,241 @@ +#!/bin/bash +# +# Copyright (C) - 2012 David Goulet +# +# This library is free software; you can redistribute it and/or modify it under +# the terms of the GNU Lesser General Public License as published by the Free +# Software Foundation; version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +TEST_DESC="UST tracer - Tracing with per PID buffers" + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../../.. +NR_ITER=100 +NR_USEC_WAIT=100000 +SESSION_NAME="buffers-pid" + +TESTAPP_PATH="$TESTDIR/utils/testapp" +TESTAPP_NAME="gen-ust-events" +TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" +EVENT_NAME="tp:tptest" +NUM_TESTS=58 + +source $TESTDIR/utils/utils.sh + +if [ ! -x "$TESTAPP_BIN" ]; then + BAIL_OUT "No UST events binary detected." +fi + +# MUST set TESTDIR before calling those functions + +function enable_channel_per_pid() +{ + sess_name=$1 + channel_name=$2 + + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-pid -u $channel_name -s $sess_name >/dev/null 2>&1 + ok $? "Enable channel $channel_name per PID for session $sess_name" +} + +function wait_apps +{ + diag "Waiting for applications to end..." + while [ -n "$(pidof $TESTAPP_NAME)" ]; do + sleep 1 + done +} + +test_after_multiple_apps() { + local out + local i + + diag "Start multiple applications AFTER tracing is started" + + # BEFORE application is spawned + create_lttng_session $SESSION_NAME $TRACE_PATH + enable_channel_per_pid $SESSION_NAME "channel0" + enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0" + start_lttng_tracing $SESSION_NAME + + for i in `seq 1 5`; do + $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT & >/dev/null 2>&1 + ok $? "Start application $i for tracing" + done + wait_apps + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + trace_matches $EVENT_NAME $[NR_ITER * 5] $TRACE_PATH + + return $? +} + +test_before_multiple_apps() { + local out + local i + + diag "Start multiple applications BEFORE tracing is started" + + for i in `seq 1 5`; do + $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT & >/dev/null 2>&1 + ok $? "Start application $i for tracing" + done + + # BEFORE application is spawned + create_lttng_session $SESSION_NAME $TRACE_PATH + enable_channel_per_pid $SESSION_NAME "channel0" + enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0" + start_lttng_tracing $SESSION_NAME + + # At least hit one event + sleep 2 + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l) + if [ $out -eq 0 ]; then + fail "Trace validation" + diag "No event(s) found. We are supposed to have at least one." + out=1 + else + pass "Trace validation" + diag "Found $out event(s). Coherent." + out=0 + fi + + wait_apps + + return $out +} + +test_after_app() { + local out + + diag "Start application AFTER tracing is started" + + # BEFORE application is spawned + create_lttng_session $SESSION_NAME $TRACE_PATH + enable_channel_per_pid $SESSION_NAME "channel0" + enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0" + start_lttng_tracing $SESSION_NAME + + $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT + ok $? "Start application to trace" + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH + + return $? +} + +test_before_app() { + local out + + diag "Start application BEFORE tracing is started" + + $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT & + ok $? "Start application to trace" + + # BEFORE application is spawned + create_lttng_session $SESSION_NAME $TRACE_PATH + enable_channel_per_pid $SESSION_NAME "channel0" + enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0" + start_lttng_tracing $SESSION_NAME + + # At least hit one event + sleep 2 + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l) + if [ $out -eq 0 ]; then + fail "Trace validation" + diag "No event(s) found. We are supposed to have at least one." + out=1 + else + pass "Trace validation" + diag "Found $out event(s). Coherent." + out=0 + fi + + wait_apps + + return $out +} + +test_multiple_channels() { + local out + + diag "Start with multiple channels" + + # BEFORE application is spawned + create_lttng_session $SESSION_NAME $TRACE_PATH + enable_channel_per_pid $SESSION_NAME "channel0" + enable_channel_per_pid $SESSION_NAME "channel1" + enable_channel_per_pid $SESSION_NAME "channel2" + enable_channel_per_pid $SESSION_NAME "channel3" + enable_channel_per_pid $SESSION_NAME "channel4" + # Enable event in all channels. + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $EVENT_NAME -c channel0 -s $SESSION_NAME -u >/dev/null 2>&1 + ok $? "Enable event $EVENT_NAME for session $SESSION_NAME in channel0" + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $EVENT_NAME -c channel1 -s $SESSION_NAME -u >/dev/null 2>&1 + ok $? "Enable event $EVENT_NAME for session $SESSION_NAME in channel1" + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $EVENT_NAME -c channel2 -s $SESSION_NAME -u >/dev/null 2>&1 + ok $? "Enable event $EVENT_NAME for session $SESSION_NAME in channel2" + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $EVENT_NAME -c channel3 -s $SESSION_NAME -u >/dev/null 2>&1 + ok $? "Enable event $EVENT_NAME for session $SESSION_NAME in channel3" + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $EVENT_NAME -c channel4 -s $SESSION_NAME -u >/dev/null 2>&1 + ok $? "Enable event $EVENT_NAME for session $SESSION_NAME in channel4" + start_lttng_tracing $SESSION_NAME + + $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT + ok $? "Start application to trace" + + stop_lttng_tracing $SESSION_NAME + trace_matches $EVENT_NAME $[NR_ITER * 5] $TRACE_PATH + out=$? + + destroy_lttng_session $SESSION_NAME + + return $out +} + +# MUST set TESTDIR before calling those functions +plan_tests $NUM_TESTS + +print_test_banner "$TEST_DESC" + +TESTS=( + "test_before_app" + "test_after_app" + "test_after_multiple_apps" + "test_before_multiple_apps" + "test_multiple_channels" +) + +TEST_COUNT=${#TESTS[@]} +i=0 + +start_lttng_sessiond + +while [ $i -lt $TEST_COUNT ]; do + TRACE_PATH=$(mktemp -d) + ${TESTS[$i]} + rm -rf $TRACE_PATH + let "i++" +done + +stop_lttng_sessiond diff --git a/tests/regression/ust/buffers-uid/Makefile.am b/tests/regression/ust/buffers-uid/Makefile.am deleted file mode 100644 index 1925768ba..000000000 --- a/tests/regression/ust/buffers-uid/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -noinst_SCRIPTS = test_buffers_uid -EXTRA_DIST = test_buffers_uid - -all-local: - @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ - for script in $(EXTRA_DIST); do \ - cp -f $(srcdir)/$$script $(builddir); \ - done; \ - fi - -clean-local: - @if [ x"$(srcdir)" != x"$(builddir)" ]; then \ - for script in $(EXTRA_DIST); do \ - rm -f $(builddir)/$$script; \ - done; \ - fi diff --git a/tests/regression/ust/buffers-uid/test_buffers_uid b/tests/regression/ust/buffers-uid/test_buffers_uid deleted file mode 100755 index faeec037c..000000000 --- a/tests/regression/ust/buffers-uid/test_buffers_uid +++ /dev/null @@ -1,241 +0,0 @@ -#!/bin/bash -# -# Copyright (C) - 2012 David Goulet -# -# This library is free software; you can redistribute it and/or modify it under -# the terms of the GNU Lesser General Public License as published by the Free -# Software Foundation; version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -# details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this library; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -TEST_DESC="UST tracer - Tracing with per UID buffers" - -CURDIR=$(dirname $0)/ -TESTDIR=$CURDIR/../../.. -NR_ITER=100 -NR_USEC_WAIT=100000 -SESSION_NAME="buffers-uid" - -TESTAPP_PATH="$TESTDIR/utils/testapp" -TESTAPP_NAME="gen-ust-events" -TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME" -EVENT_NAME="tp:tptest" -NUM_TESTS=58 - -source $TESTDIR/utils/utils.sh - -if [ ! -x "$TESTAPP_BIN" ]; then - BAIL_OUT "No UST events binary detected." -fi - -# MUST set TESTDIR before calling those functions - -function enable_channel_per_uid() -{ - sess_name=$1 - channel_name=$2 - - $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-uid -u $channel_name -s $sess_name >/dev/null 2>&1 - ok $? "Enable channel $channel_name per UID for session $sess_name" -} - -function wait_apps -{ - diag "Waiting for applications to end..." - while [ -n "$(pidof $TESTAPP_NAME)" ]; do - sleep 1 - done -} - -test_after_multiple_apps() { - local out - local i - - diag "Start multiple applications AFTER tracing is started" - - # BEFORE application is spawned - create_lttng_session $SESSION_NAME $TRACE_PATH - enable_channel_per_uid $SESSION_NAME "channel0" - enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0" - start_lttng_tracing $SESSION_NAME - - for i in `seq 1 5`; do - $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT & >/dev/null 2>&1 - ok $? "Start application $i for tracing" - done - wait_apps - - stop_lttng_tracing $SESSION_NAME - destroy_lttng_session $SESSION_NAME - - trace_matches $EVENT_NAME $[NR_ITER * 5] $TRACE_PATH - - return $? -} - -test_before_multiple_apps() { - local out - local i - - diag "Start multiple applications BEFORE tracing is started" - - for i in `seq 1 5`; do - $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT & >/dev/null 2>&1 - ok $? "Start application $i for tracing" - done - - # BEFORE application is spawned - create_lttng_session $SESSION_NAME $TRACE_PATH - enable_channel_per_uid $SESSION_NAME "channel0" - enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0" - start_lttng_tracing $SESSION_NAME - - # At least hit one event - sleep 2 - - stop_lttng_tracing $SESSION_NAME - destroy_lttng_session $SESSION_NAME - - out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l) - if [ $out -eq 0 ]; then - fail "Trace validation" - diag "No event(s) found. We are supposed to have at least one." - out=1 - else - pass "Trace validation" - diag "Found $out event(s). Coherent." - out=0 - fi - - wait_apps - - return $out -} - -test_after_app() { - local out - - diag "Start application AFTER tracing is started" - - # BEFORE application is spawned - create_lttng_session $SESSION_NAME $TRACE_PATH - enable_channel_per_uid $SESSION_NAME "channel0" - enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0" - start_lttng_tracing $SESSION_NAME - - $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT - ok $? "Start application to trace" - - stop_lttng_tracing $SESSION_NAME - destroy_lttng_session $SESSION_NAME - - trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH - - return $? -} - -test_before_app() { - local out - - diag "Start application BEFORE tracing is started" - - $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT & - ok $? "Start application to trace" - - # BEFORE application is spawned - create_lttng_session $SESSION_NAME $TRACE_PATH - enable_channel_per_uid $SESSION_NAME "channel0" - enable_ust_lttng_event $SESSION_NAME $EVENT_NAME "channel0" - start_lttng_tracing $SESSION_NAME - - # At least hit one event - sleep 2 - - stop_lttng_tracing $SESSION_NAME - destroy_lttng_session $SESSION_NAME - - out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l) - if [ $out -eq 0 ]; then - fail "Trace validation" - diag "No event(s) found. We are supposed to have at least one." - out=1 - else - pass "Trace validation" - diag "Found $out event(s). Coherent." - out=0 - fi - - wait_apps - - return $out -} - -test_multiple_channels() { - local out - - diag "Start with multiple channels" - - # BEFORE application is spawned - create_lttng_session $SESSION_NAME $TRACE_PATH - enable_channel_per_uid $SESSION_NAME "channel0" - enable_channel_per_uid $SESSION_NAME "channel1" - enable_channel_per_uid $SESSION_NAME "channel2" - enable_channel_per_uid $SESSION_NAME "channel3" - enable_channel_per_uid $SESSION_NAME "channel4" - # Enable event in all channels. - $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $EVENT_NAME -c channel0 -s $SESSION_NAME -u >/dev/null 2>&1 - ok $? "Enable event $EVENT_NAME for session $SESSION_NAME in channel0" - $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $EVENT_NAME -c channel1 -s $SESSION_NAME -u >/dev/null 2>&1 - ok $? "Enable event $EVENT_NAME for session $SESSION_NAME in channel1" - $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $EVENT_NAME -c channel2 -s $SESSION_NAME -u >/dev/null 2>&1 - ok $? "Enable event $EVENT_NAME for session $SESSION_NAME in channel2" - $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $EVENT_NAME -c channel3 -s $SESSION_NAME -u >/dev/null 2>&1 - ok $? "Enable event $EVENT_NAME for session $SESSION_NAME in channel3" - $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $EVENT_NAME -c channel4 -s $SESSION_NAME -u >/dev/null 2>&1 - ok $? "Enable event $EVENT_NAME for session $SESSION_NAME in channel4" - start_lttng_tracing $SESSION_NAME - - $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT - ok $? "Start application to trace" - - stop_lttng_tracing $SESSION_NAME - trace_matches $EVENT_NAME $[NR_ITER * 5] $TRACE_PATH - out=$? - - destroy_lttng_session $SESSION_NAME - - return $out -} - -# MUST set TESTDIR before calling those functions -plan_tests $NUM_TESTS - -print_test_banner "$TEST_DESC" - -TESTS=( - "test_before_app" - "test_after_app" - "test_after_multiple_apps" - "test_before_multiple_apps" - "test_multiple_channels" -) - -TEST_COUNT=${#TESTS[@]} -i=0 - -start_lttng_sessiond - -while [ $i -lt $TEST_COUNT ]; do - TRACE_PATH=$(mktemp -d) - ${TESTS[$i]} - rm -rf $TRACE_PATH - let "i++" -done - -stop_lttng_sessiond