#!/bin/bash
#
-# Copyright (C) - 2013 Julien Desfossez <jdesfossez@efficios.com>
+# Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
#
-# 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
+# SPDX-License-Identifier: LGPL-2.1-only
+
TEST_DESC="Snapshots - UST tracing"
CURDIR=$(dirname $0)/
TESTDIR=$CURDIR/../../..
EVENT_NAME="tp:tptest"
-PID_RELAYD=0
SESSION_NAME=""
CHANNEL_NAME="snapchan"
TESTAPP_PATH="$TESTDIR/utils/testapp"
TESTAPP_NAME="gen-ust-events"
TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
-NR_ITER=2000000
-NR_USEC_WAIT=100
APPS_PID=
-NUM_TESTS=76
+NUM_TESTS=100
TRACE_PATH=$(mktemp -d)
source $TESTDIR/utils/utils.sh
if [ ! -x "$TESTAPP_BIN" ]; then
- BAIL_OUT "No UST events binary detected."
+ BAIL_OUT "No UST events binary detected"
fi
# Need the number of snapshot to do.
if [ -z $1 ]; then
- BAIL_OUT "A number of snapshot is needed."
+ BAIL_OUT "A number of snapshot is needed"
fi
NR_SNAPSHOT=$1
local tmp_file=$(mktemp -u)
# Start application with a temporary file.
- $TESTAPP_BIN $NR_ITER $NR_USEC_WAIT $tmp_file &
+ $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT --sync-after-first-event $tmp_file &
ret=$?
APPS_PID="${APPS_PID} ${!}"
ok $ret "Start application to trace"
rm -f $tmp_file
}
+function wait_test_apps()
+{
+ diag "Waiting for $TESTAPP_NAME"
+ for p in ${APPS_PID}; do
+ wait ${p} 2>/dev/null
+ done
+}
+
function stop_test_apps()
{
diag "Stopping $TESTAPP_NAME"
ok $? "Enable channel $channel_name for session $sess_name with subbuf size $subbuf_size"
}
+function enable_mmap_small_discard_ust_channel ()
+{
+ local sess_name=$1
+ local chan_name=$2
+
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name \
+ $chan_name -u --output mmap --discard \
+ --subbuf-size $(getconf PAGE_SIZE) --num-subbuf 2 \
+ > /dev/null 2>&1
+
+ ok $? "Enable channel $channel_name for session $sess_name with small discard buffers"
+}
+
+function enable_mmap_small_overwrite_ust_channel ()
+{
+ local sess_name=$1
+ local chan_name=$2
+
+ $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name \
+ $chan_name -u --output mmap --overwrite \
+ --subbuf-size $(getconf PAGE_SIZE) --num-subbuf 2 \
+ > /dev/null 2>&1
+
+ ok $? "Enable channel $channel_name for session $sess_name with small discard buffers"
+}
function test_ust_list_output ()
{
function test_ust_local_snapshot ()
{
+ NR_ITER=-1
+ NR_USEC_WAIT=100
+
diag "Test local UST snapshots"
create_lttng_session_no_output $SESSION_NAME
enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
start_lttng_tracing_ok $SESSION_NAME
- lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
+ lttng_snapshot_add_output_ok $SESSION_NAME file://$TRACE_PATH
# Returns once the application has at least fired ONE tracepoint.
start_test_app
stop_test_apps
}
+function test_ust_local_snapshot_small_discard_buffers ()
+{
+ NR_ITER=10000
+ NR_USEC_WAIT=0
+ OLDCPUSET=$(taskset -p $$)
+
+ diag "Test local UST snapshots with small discard buffers"
+ taskset -p 0x1 $$ 1>/dev/null 2>&1 # CPU 0 only
+ create_lttng_session_no_output $SESSION_NAME
+ enable_mmap_small_discard_ust_channel $SESSION_NAME $CHANNEL_NAME
+ enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
+ start_lttng_tracing_ok $SESSION_NAME
+ lttng_snapshot_add_output_ok $SESSION_NAME file://$TRACE_PATH
+
+ # Run test apps, wait for them to complete.
+ start_test_app
+ wait_test_apps
+
+ # Take first snapshot, remember first line.
+ lttng_snapshot_record $SESSION_NAME
+ FIRST_LINE="$(trace_first_line $TRACE_PATH/)"
+ diag "First line (1st snapshot): $FIRST_LINE"
+ rm -rf $TRACE_PATH/
+
+ # Run test apps, wait for them to complete.
+ start_test_app
+ wait_test_apps
+
+ # Take second snapshot, remember first line.
+ lttng_snapshot_record $SESSION_NAME
+ FIRST_LINE_2="$(trace_first_line $TRACE_PATH/)"
+ diag "First line (2nd snapshot): $FIRST_LINE_2"
+ rm -rf $TRACE_PATH/
+
+ if [ x"$FIRST_LINE" != x"$FIRST_LINE_2" ]; then
+ fail "First snapshot event do not match"
+ else
+ pass "First snapshot event match"
+ fi
+
+ stop_lttng_tracing_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME
+ taskset -p $OLDCPUSET $$ 1>/dev/null 2>&1
+}
+
+function test_ust_local_snapshot_small_overwrite_buffers ()
+{
+ NR_ITER=10000
+ NR_USEC_WAIT=0
+ OLDCPUSET=$(taskset -p $$)
+
+ diag "Test local UST snapshots with small overwrite buffers"
+ taskset -p 0x1 $$ 1>/dev/null 2>&1 # CPU 0 only
+ create_lttng_session_no_output $SESSION_NAME
+ enable_mmap_small_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
+ enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
+ start_lttng_tracing_ok $SESSION_NAME
+ lttng_snapshot_add_output_ok $SESSION_NAME file://$TRACE_PATH
+
+ # Run test apps, wait for them to complete.
+ start_test_app
+ wait_test_apps
+
+ # Take first snapshot, remember first line.
+ lttng_snapshot_record $SESSION_NAME
+ FIRST_LINE="$(trace_first_line $TRACE_PATH/)"
+ diag "First line (1st snapshot): $FIRST_LINE"
+ rm -rf $TRACE_PATH/
+
+ # Run test apps, wait for them to complete.
+ start_test_app
+ wait_test_apps
+
+ # Take second snapshot, remember first line.
+ lttng_snapshot_record $SESSION_NAME
+ FIRST_LINE_2="$(trace_first_line $TRACE_PATH/)"
+ diag "First line (2nd snapshot): $FIRST_LINE_2"
+ rm -rf $TRACE_PATH/
+
+ if [ x"$FIRST_LINE" != x"$FIRST_LINE_2" ]; then
+ pass "First snapshot event do not match"
+ else
+ fail "First snapshot event match"
+ fi
+
+ stop_lttng_tracing_ok $SESSION_NAME
+ destroy_lttng_session_ok $SESSION_NAME
+ taskset -p $OLDCPUSET $$ 1>/dev/null 2>&1
+}
+
function test_ust_local_snapshot_max_size ()
{
- subbuf_size=8192
- num_cpus=`nproc`
+ NR_ITER=-1
+ NR_USEC_WAIT=100
+ page_size=`getconf PAGE_SIZE`
+ num_cpus=$(conf_proc_count)
+
+ # The minimum subbuf size is the platform PAGE_SIZE
+ subbuf_size=$(($page_size*2))
# The minimum size limit is min(subbuf_size) * nb_streams
max_size=$(($subbuf_size*$num_cpus))
if [ "$sum_size_tracefiles" -gt "$max_size" ]; then
fail "Tracefiles size sum validation"
diag "Tracefiles size sum: $sum_size_tracefiles Expected max: $max_size"
+ else
+ pass "Tracefiles size sum validation"
fi
- pass "Tracefiles size sum validation"
-
stop_lttng_tracing_ok $SESSION_NAME
destroy_lttng_session_ok $SESSION_NAME
enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
enable_ust_lttng_event_ok $SESSION_NAME $LM_EVENT $CHANNEL_NAME
start_lttng_tracing_ok $SESSION_NAME
- lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
- $LM_BIN 1 1
+ lttng_snapshot_add_output_ok $SESSION_NAME file://$TRACE_PATH
+ $LM_BIN --iter 1 --wait 1
ok $? "Start application to trace"
lttng_snapshot_record $SESSION_NAME
stop_lttng_tracing_ok $SESSION_NAME
function test_ust_per_uid_local_snapshot ()
{
- diag "Test local UST snapshots"
+ NR_ITER=-1
+ NR_USEC_WAIT=100
+ diag "Test per-uid local UST snapshots"
create_lttng_session_no_output $SESSION_NAME
enable_channel_per_uid_mmap_overwrite $SESSION_NAME $CHANNEL_NAME
enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
start_lttng_tracing_ok $SESSION_NAME
- lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
+ lttng_snapshot_add_output_ok $SESSION_NAME file://$TRACE_PATH
# Returns once the application has at least fired ONE tracepoint.
start_test_app
function test_ust_per_uid_local_snapshot_post_mortem ()
{
+ NR_ITER=-1
+ NR_USEC_WAIT=100
+
diag "Test local UST snapshots post-mortem"
create_lttng_session_no_output $SESSION_NAME
enable_channel_per_uid_mmap_overwrite $SESSION_NAME $CHANNEL_NAME
enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
start_lttng_tracing_ok $SESSION_NAME
- lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
+ lttng_snapshot_add_output_ok $SESSION_NAME file://$TRACE_PATH
# Returns once the application has at least fired ONE tracepoint.
start_test_app
function test_ust_local_snapshots ()
{
+ NR_ITER=-1
+ NR_USEC_WAIT=100
+
diag "Test $NR_SNAPSHOT local UST snapshots"
create_lttng_session_no_output $SESSION_NAME
enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
start_lttng_tracing_ok $SESSION_NAME
- lttng_snapshot_add_output $SESSION_NAME $TRACE_PATH
+ lttng_snapshot_add_output_ok $SESSION_NAME file://$TRACE_PATH
# Returns once the application has at least fired ONE tracepoint.
start_test_app
print_test_banner "$TEST_DESC"
start_lttng_sessiond
-
tests=( test_ust_list_output
test_ust_local_snapshot
test_ust_local_snapshot_max_size
test_ust_per_uid_local_snapshot
test_ust_per_uid_local_snapshot_post_mortem
test_ust_local_snapshot_large_metadata
- test_ust_local_snapshots)
+ test_ust_local_snapshots
+ test_ust_local_snapshot_small_discard_buffers
+ test_ust_local_snapshot_small_overwrite_buffers
+)
for fct_test in ${tests[@]};
do