#!/bin/bash
#
-# Copyright (C) - 2015 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
-# Copyright (C) - 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+# Copyright (C) 2015 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+# Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@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="UST - Blocking mode"
CURDIR=$(dirname $0)/
NUM_TESTS=49
-source $TESTDIR/utils/utils.sh
+# shellcheck source=../utils/utils.sh
+source "$TESTDIR/utils/utils.sh"
# MUST set TESTDIR before calling those functions
-# Run app on CPU 0 to ensure we only write in a single ring buffer.
+# Run app on a single CPU to ensure we only write in a single ring buffer.
function run_app()
{
- taskset 0x00000001 $TESTAPP_BIN $NUM_EVENT
+ taskset --cpu-list "$(get_any_available_cpu)" $TESTAPP_BIN -i $NUM_EVENT
ok $? "Application done"
}
+function check_disk_space()
+{
+ local path
+
+ path="${1:?}"
+ kb_free=$(df -k -P "${path}" | tail -n 1 | awk '{ print $4 }')
+ if [ "${kb_free}" -lt "1048576" ] ; then
+ return 1
+ fi
+
+ return 0
+}
+
function test_ust_implicit_no_blocking()
{
NUM_EVENT=5000000
function test_ust_implicit_no_blocking_with_channel_blocking()
{
NUM_EVENT=5000000
- diag "UST implicit non-blocking mode (default) with blocking-timeout=-1 channel: will hang if fails"
+ diag "UST implicit non-blocking mode (default) with blocking-timeout=inf channel: will hang if fails"
start_lttng_sessiond
# session in no-output mode
create_lttng_session_no_output $SESSION_NAME
- enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=-1"
+ enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=inf"
enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME
start_lttng_tracing_ok $SESSION_NAME
run_app
start_lttng_sessiond
create_lttng_session_ok $SESSION_NAME $TRACE_PATH
# infinite blocking timeout
- enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=-1"
+ enable_ust_lttng_channel_ok $SESSION_NAME $CHANNEL_NAME "--blocking-timeout=inf"
enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME" $CHANNEL_NAME
start_lttng_tracing_ok $SESSION_NAME
LTTNG_UST_ALLOW_BLOCKING=1 run_app
stop_lttng_tracing_ok $SESSION_NAME
+ discarded=$("${XML_EXTRACT}" <("${TESTDIR}/../src/bin/lttng/${LTTNG_BIN}" --mi=xml list --channel="${CHANNEL_NAME}" "${SESSION_NAME}") '//lttng:command/lttng:output/lttng:sessions/lttng:session/lttng:domains/lttng:domain/lttng:channels/lttng:channel/lttng:attributes/lttng:discarded_events')
destroy_lttng_session_ok $SESSION_NAME
stop_lttng_sessiond
- nr_events=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l)
-
- test $nr_events -eq $NUM_EVENT
- ok $? "No event lost with UST blocking mode: found $nr_events expect $NUM_EVENT"
+ test "$(echo "${discarded}" | grep -Eo '[0-9]+')" = "0"
+ ok $? "No event lost with UST blocking mode: ${discarded}"
}
plan_tests $NUM_TESTS
print_test_banner "$TEST_DESC"
+bail_out_if_no_babeltrace
+
+if ! check_disk_space "${TMPDIR:-/tmp}"; then
+ BAIL_OUT "Not enough free space to run blocking tests"
+fi
+
TESTS=(
"test_ust_implicit_no_blocking"
"test_ust_implicit_no_blocking_with_channel_blocking"
while [ "$i" -lt "$TEST_COUNT" ]; do
- TRACE_PATH=$(mktemp -d)
+ TRACE_PATH=$(mktemp -d -t tmp.test_blocking_ust_trace_path.XXXXXX)
# Execute test
${TESTS[$i]}