summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
4f00273)
Background
==========
The `test_event_tracker` file contains test cases when the event
generating app in executed in two distinct steps. Those two steps are
preparation and execution.
1. the preparation is the launching the app in the background, and
2. the execution is actually generating the event that should or
should not be traced depending on the test case.
This is useful to test the tracker feature since we want to ensure that
already running apps are notified properly when changing their tracking
status.
Issue
=====
The `test_event_vpid_track_untrack` test case suffers from a race
condition that is easy to reproduce on Yocto.
The issue is that sometimes events are end up the trace when none is
expected.
This is due to the absence of synchronization point at the launch of the
app which leads to the app being scheduled in-between the track-untrack
calls leading to events being recorded to the trace.
It's easy to reproduce this issue on my machine by adding a `sleep 5`
between the track and untrack calls and setting the `NR_USEC_WAIT`
variable to 1.
Fix
===
Using the testapp `--sync-before-last-event-touch` flag to make the app
create a file when all but the last event are executed. We then have the
app wait until we create a file (`--sync-before-last-event`) to generate
that last event. This way, we are sure no event will be generated when
running the track and untrack commands.
Notes
=====
- This issue affects other test cases in this file.
- This commit fixes a typo in the test header.
- This commit adds `diag` calls to help tracking to what test the output
relates to when reading the log.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia2b68128dc9a805526f9748f31ec2c2d95566f31
#
# SPDX-License-Identifier: GPL-2.0-only
#
# SPDX-License-Identifier: GPL-2.0-only
-TEST_DESC="LTTng - Event traker test"
+TEST_DESC="LTTng - Event tracker test"
CURDIR=$(dirname "$0")/
TESTDIR="$CURDIR/../../.."
CURDIR=$(dirname "$0")/
TESTDIR="$CURDIR/../../.."
TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
TESTAPP_KERNEL_BIN="$TESTAPP_PATH/$TESTAPP_KERNEL_NAME/$TESTAPP_KERNEL_NAME"
SESSION_NAME="tracker"
TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
TESTAPP_KERNEL_BIN="$TESTAPP_PATH/$TESTAPP_KERNEL_NAME/$TESTAPP_KERNEL_NAME"
SESSION_NAME="tracker"
NUM_GLOBAL_TESTS=2
NUM_UST_TESTS=283
NUM_KERNEL_TESTS=462
NUM_GLOBAL_TESTS=2
NUM_UST_TESTS=283
NUM_KERNEL_TESTS=462
-AFTER_FIRST_PATH=
-BEFORE_LAST_PATH=
+TOUCH_BEFORE_LAST_PATH=
+SYNC_BEFORE_LAST_PATH=
source $TESTDIR/utils/utils.sh
source $TESTDIR/utils/utils.sh
+# Launch the testapp and execute it up until right before the last event. It is
+# useful to do it in two seperate steps in order to test tracking and
+# untracking on an active app.
function prepare_ust_app
{
function prepare_ust_app
{
- AFTER_FIRST_PATH=$(mktemp --tmpdir -u tmp.${FUNCNAME[0]}_sync_after_first.XXXXXX)
- BEFORE_LAST_PATH=$(mktemp --tmpdir -u tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX)
+ TOUCH_BEFORE_LAST_PATH=$(mktemp --tmpdir -u tmp.${FUNCNAME[0]}_touch_before_last.XXXXXX)
+ SYNC_BEFORE_LAST_PATH=$(mktemp --tmpdir -u tmp.${FUNCNAME[0]}_sync_before_last.XXXXXX)
+
+ $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT \
+ --sync-before-last-event-touch "$TOUCH_BEFORE_LAST_PATH" \
+ --sync-before-last-event "$SYNC_BEFORE_LAST_PATH" &
- $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT -a "$AFTER_FIRST_PATH" -b "$BEFORE_LAST_PATH" &
+
+ # Wait for the app to execute all the way to right before the last
+ # event.
+ while [ ! -f "${TOUCH_BEFORE_LAST_PATH}" ]; do
+ sleep 0.5
+ done
+# Generate the last event.
- touch "$BEFORE_LAST_PATH"
- wait
+ # Ask the test app to generate the last event.
+ touch "$SYNC_BEFORE_LAST_PATH"
+ wait "$CHILD_PID"
ok $? "Traced application stopped."
ok $? "Traced application stopped."
- rm "$BEFORE_LAST_PATH"
- rm "$AFTER_FIRST_PATH"
+ rm "$SYNC_BEFORE_LAST_PATH"
+ rm "$TOUCH_BEFORE_LAST_PATH"
}
function prepare_kernel_app
}
function prepare_kernel_app
function trace_kernel_app
{
touch "$WAIT_PATH"
function trace_kernel_app
{
touch "$WAIT_PATH"
ok $? "Traced application stopped."
rm "$WAIT_PATH"
}
ok $? "Traced application stopped."
rm "$WAIT_PATH"
}
local tracker="$4"
local channel=''
local tracker="$4"
local channel=''
+ diag "${FUNCNAME[0]} $*"
+
trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX)
create_lttng_session_ok $SESSION_NAME "$trace_path"
trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX)
create_lttng_session_ok $SESSION_NAME "$trace_path"
local wildcard="$3"
local channel=''
local wildcard="$3"
local channel=''
+ diag "${FUNCNAME[0]} $*"
+
trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX)
create_lttng_session_ok $SESSION_NAME "$trace_path"
trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX)
create_lttng_session_ok $SESSION_NAME "$trace_path"
local wildcard="$3"
local channel=''
local wildcard="$3"
local channel=''
+ diag "${FUNCNAME[0]} $*"
+
trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX)
create_lttng_session_ok $SESSION_NAME "$trace_path"
trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX)
create_lttng_session_ok $SESSION_NAME "$trace_path"
local wildcard="$2"
local tracker="$3"
local wildcard="$2"
local tracker="$3"
+ diag "${FUNCNAME[0]} $*"
+
trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX)
create_lttng_session_ok $SESSION_NAME "$trace_path"
trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX)
create_lttng_session_ok $SESSION_NAME "$trace_path"
local tracker="$4"
local channel=''
local tracker="$4"
local channel=''
+ diag "${FUNCNAME[0]} $*"
+
trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX)
create_lttng_session_ok $SESSION_NAME "$trace_path"
trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX)
create_lttng_session_ok $SESSION_NAME "$trace_path"
local wildcard="$3"
local channel=''
local wildcard="$3"
local channel=''
+ diag "${FUNCNAME[0]} $*"
+
trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX)
create_lttng_session_ok $SESSION_NAME "$trace_path"
trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX)
create_lttng_session_ok $SESSION_NAME "$trace_path"
local wildcard="$3"
local channel=''
local wildcard="$3"
local channel=''
+ diag "${FUNCNAME[0]} $*"
+
trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX)
create_lttng_session_ok $SESSION_NAME "$trace_path"
trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX)
create_lttng_session_ok $SESSION_NAME "$trace_path"
function test_event_ust_vpid_untrack_snapshot()
{
function test_event_ust_vpid_untrack_snapshot()
{
- local trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX)
+ diag "${FUNCNAME[0]} $*"
- diag "Test_event_ust_vpid_untrack_snapshot"
+ local trace_path=$(mktemp --tmpdir -d tmp.${FUNCNAME[0]}_trace_path.XXXXXX)
create_lttng_session_ok $SESSION_NAME "$trace_path" "--snapshot"
create_lttng_session_ok $SESSION_NAME "$trace_path" "--snapshot"