Skip to contentSkip to conversation

Fix: test code assumes that child process is schedule to run before parent

PATCH In review Anders Wallin via lttng-dev 1 participant 5 messages Apr 1, 2021 – Apr 8, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix: test code assumes that child process is schedule to run before parent

the following tests fails
- test_event_vpid_tracker ust 0 "${EVENT_NAME}"
- test_event_vpid_track_untrack ust 0 "${EVENT_NAME}"
- test_event_pid_tracker ust 0 "${EVENT_NAME}"
- test_event_pid_track_untrack ust 0 "${EVENT_NAME}"

---
 tests/regression/tools/tracker/test_event_tracker | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
tests/regression/tools/tracker/test_event_tracker +6 -9
index 711690af..78e9310b 100755
@@ -5,7 +5,7 @@
 #
 # SPDX-License-Identifier: GPL-2.0-only
 
-TEST_DESC="LTTng - Event traker test"
+TEST_DESC="LTTng - Event tracker test"
 
 CURDIR=$(dirname "$0")/
 TESTDIR="$CURDIR/../../.."
@@ -30,27 +30,24 @@ SCRIPT_GROUPNAME="$(id -gn)"
 
 CHILD_PID=-1
 WAIT_PATH=
-AFTER_FIRST_PATH=
-BEFORE_LAST_PATH=
+BEFORE_FIRST_PATH=
 
 source $TESTDIR/utils/utils.sh
 
 function prepare_ust_app
 {
-	AFTER_FIRST_PATH=$(mktemp -u)
-	BEFORE_LAST_PATH=$(mktemp -u)
+	BEFORE_FIRST_PATH=$(mktemp -u)
 
-	$TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT -a "$AFTER_FIRST_PATH" -b "$BEFORE_LAST_PATH" &
+	$TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT --sync-before-first-event "$BEFORE_FIRST_PATH" &
 	CHILD_PID=$!
 }
 
 function trace_ust_app
 {
-	touch "$BEFORE_LAST_PATH"
+	touch "$BEFORE_FIRST_PATH"
 	wait
 	ok $? "Traced application stopped."
-	rm "$BEFORE_LAST_PATH"
-	rm "$AFTER_FIRST_PATH"
+	rm "$BEFORE_FIRST_PATH"
 }
 
 function prepare_kernel_app
Signature · 6 lines
2.31.1

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
#1 lore raw
Quoted 5 lines · ----- On Apr 1, 2021, at 12:37 PM, lttng-dev [email protected] wrote:

the following tests fails
- test_event_vpid_tracker ust 0 "${EVENT_NAME}"
- test_event_vpid_track_untrack ust 0 "${EVENT_NAME}"
- test_event_pid_tracker ust 0 "${EVENT_NAME}"
- test_event_pid_track_untrack ust 0 "${EVENT_NAME}"

There is indeed an issue with these tests: there is a missing "untrack all pids" which should be done at the very beginning of each test to have the expected behavior. AFAIU this explains why there is a small window where traced applications can generate events when none are expected.

Fixing this should solve the issues without requiring any addition to the test program.

Thanks,

Mathieu

Quoted 62 lines

---
tests/regression/tools/tracker/test_event_tracker | 15 ++++++---------

1 file changed, 6 insertions(+), 9 deletions(-)
tests/regression/tools/tracker/test_event_tracker +1 -1
index 711690af..78e9310b 100755
@@ -5,7 +5,7 @@
 #
 # SPDX-License-Identifier: GPL-2.0-only
 
-TEST_DESC="LTTng - Event traker test"
+TEST_DESC="LTTng - Event tracker test"
 

CURDIR=$(dirname "$0")/
TESTDIR="$CURDIR/../../.."

tests/regression/tools/tracker/test_event_tracker +0 -0
@@ -30,27 +30,24 @@ SCRIPT_GROUPNAME="$(id -gn)"
 

CHILD_PID=-1
WAIT_PATH=

tests/regression/tools/tracker/test_event_tracker +1 -2
-AFTER_FIRST_PATH=
-BEFORE_LAST_PATH=
+BEFORE_FIRST_PATH=

source $TESTDIR/utils/utils.sh

function prepare_ust_app
{

tests/regression/tools/tracker/test_event_tracker +1 -3
-	AFTER_FIRST_PATH=$(mktemp -u)
-	BEFORE_LAST_PATH=$(mktemp -u)
+	BEFORE_FIRST_PATH=$(mktemp -u)
 
-	$TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT -a "$AFTER_FIRST_PATH" -b

"$BEFORE_LAST_PATH" &

tests/regression/tools/tracker/test_event_tracker +1 -0
+	$TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT --sync-before-first-event

"$BEFORE_FIRST_PATH" &

	CHILD_PID=$!
}

function trace_ust_app
{

tests/regression/tools/tracker/test_event_tracker +1 -1
-	touch "$BEFORE_LAST_PATH"
+	touch "$BEFORE_FIRST_PATH"

wait
ok $? "Traced application stopped."

tests/regression/tools/tracker/test_event_tracker +1 -2
-	rm "$BEFORE_LAST_PATH"
-	rm "$AFTER_FIRST_PATH"
+	rm "$BEFORE_FIRST_PATH"

}

function prepare_kernel_app
--
2.31.1

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Signature · 7 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
#2 lore raw

OK,

I tried this and for
- test_event_vpid_track_untrack ust 0 "${EVENT_NAME}"
- test_event_pid_track_untrack ust 0 "${EVENT_NAME}" it works well.

For
- test_event_vpid_tracker ust 0 "${EVENT_NAME}"
- test_event_pid_tracker ust 0 "${EVENT_NAME}" validate_trace_empty fails since there is no data at all in the trace_path

This run is just calling copy of test_event_tracker running only "test_event_vpid_tracker ust 0 ..."
1..747
# LTTng - Event tracker test
ok 1 - Start session daemon
# Test UST tracker
ok 2 - Create session tracker in -o /tmp/tmp.lu5aeCJhQ3 ok 3 - Enable ust event tp:tptest for session tracker ok 4 - Untrack command with opts: -u --all --vpid
ok 5 - Start tracing for session
ok 6 - Track command with opts: -u --vpid 11842
ok 7 - Traced application stopped.
ok 8 - Stop lttng tracing for session
ok 9 - Destroy session tracker

*not ok 10 - Failed to parse trace# Failed test 'Failed to parse trace'*#
in ./regression/tools/tracker//../../../utils/tap/tap.sh:fail() at line
159.
# Killing (signal SIGTERM) lttng-sessiond and lt-lttng-sessiond pids: 11808 11809 11830
ok 11 - Wait after kill session daemon
# Looks like you planned 747 tests but only ran 11.
# Looks like you failed 1 test of 11.

# find /tmp/tmp.lu5aeCJhQ3
/tmp/tmp.lu5aeCJhQ3
/tmp/tmp.lu5aeCJhQ3/ust

Do you want me to add a special version of "validate_trace_empty" not returning
"Failed to parse trace" for this? If so should it be added in "test_event_tracker" or in "utils.sh"

Anders Wallin

Quoted 83 lines · Mathieu Desnoyers

----- On Apr 1, 2021, at 12:37 PM, lttng-dev [email protected]

Quoted 5 lines · wrote:

the following tests fails
- test_event_vpid_tracker ust 0 "${EVENT_NAME}"
- test_event_vpid_track_untrack ust 0 "${EVENT_NAME}"
- test_event_pid_tracker ust 0 "${EVENT_NAME}"
- test_event_pid_track_untrack ust 0 "${EVENT_NAME}"

There is indeed an issue with these tests: there is a missing "untrack all pids"
which should be done at the very beginning of each test to have the expected
behavior. AFAIU this explains why there is a small window where traced applications
can generate events when none are expected.

Fixing this should solve the issues without requiring any addition to the test
program.

Thanks,

Mathieu

Quoted 58 lines

---
tests/regression/tools/tracker/test_event_tracker | 15 ++++++---------

1 file changed, 6 insertions(+), 9 deletions(-)
tests/regression/tools/tracker/test_event_tracker +1 -1
index 711690af..78e9310b 100755
@@ -5,7 +5,7 @@
 #
 # SPDX-License-Identifier: GPL-2.0-only
 
-TEST_DESC="LTTng - Event traker test"
+TEST_DESC="LTTng - Event tracker test"
 

CURDIR=$(dirname "$0")/
TESTDIR="$CURDIR/../../.."

tests/regression/tools/tracker/test_event_tracker +0 -0
@@ -30,27 +30,24 @@ SCRIPT_GROUPNAME="$(id -gn)"
 

CHILD_PID=-1
WAIT_PATH=

tests/regression/tools/tracker/test_event_tracker +1 -2
-AFTER_FIRST_PATH=
-BEFORE_LAST_PATH=
+BEFORE_FIRST_PATH=

source $TESTDIR/utils/utils.sh

function prepare_ust_app
{

tests/regression/tools/tracker/test_event_tracker +1 -3
-     AFTER_FIRST_PATH=$(mktemp -u)
-     BEFORE_LAST_PATH=$(mktemp -u)
+     BEFORE_FIRST_PATH=$(mktemp -u)
 
-     $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT -a "$AFTER_FIRST_PATH" -b

"$BEFORE_LAST_PATH" &
+ $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT --sync-before-first-event
"$BEFORE_FIRST_PATH" &

      CHILD_PID=$!
}

function trace_ust_app
{

tests/regression/tools/tracker/test_event_tracker +2 -3
-     touch "$BEFORE_LAST_PATH"
+     touch "$BEFORE_FIRST_PATH"
      wait
      ok $? "Traced application stopped."
-     rm "$BEFORE_LAST_PATH"
-     rm "$AFTER_FIRST_PATH"
+     rm "$BEFORE_FIRST_PATH"

}

function prepare_kernel_app
--
2.31.1

Quoted 10 lines
Quoted 4 lines

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

#3 lore raw
Quoted 35 lines · Anders Wallin

OK,

I tried this and for
- test_event_vpid_track_untrack ust 0 "${EVENT_NAME}"
- test_event_pid_track_untrack ust 0 "${EVENT_NAME}" it works well.

For
- test_event_vpid_tracker ust 0 "${EVENT_NAME}"
- test_event_pid_tracker ust 0 "${EVENT_NAME}" validate_trace_empty fails since there is no data at all in the trace_path

This run is just calling copy of test_event_tracker running only "test_event_vpid_tracker ust 0 ..."
1..747
# LTTng - Event tracker test
ok 1 - Start session daemon
# Test UST tracker
ok 2 - Create session tracker in -o /tmp/tmp.lu5aeCJhQ3 ok 3 - Enable ust event tp:tptest for session tracker ok 4 - Untrack command with opts: -u --all --vpid
ok 5 - Start tracing for session
ok 6 - Track command with opts: -u --vpid 11842
ok 7 - Traced application stopped.
ok 8 - Stop lttng tracing for session
ok 9 - Destroy session tracker
not ok 10 - Failed to parse trace
# Failed test 'Failed to parse trace'

# in ./regression/tools/tracker//../../../utils/tap/tap.sh:fail() at line 159.
# Killing (signal SIGTERM) lttng-sessiond and lt-lttng-sessiond pids: 11808
11809 11830
ok 11 - Wait after kill session daemon
# Looks like you planned 747 tests but only ran 11.
# Looks like you failed 1 test of 11.
Quoted 7 lines
# find /tmp/tmp.lu5aeCJhQ3
/tmp/tmp.lu5aeCJhQ3
/tmp/tmp.lu5aeCJhQ3/ust

Do you want me to add a special version of "validate_trace_empty" not returning "Failed to parse trace" for this? If so should it be added in "test_event_tracker" or in "utils.sh"

Actually, this helper already exists in utils.sh: validate_trace_session_ust_empty (), which internally uses validate_directory_empty (). As you point out, we should use validate_trace_session_ust_empty for the validation of those test cases which populate no trace whatsoever.

Thanks,

Mathieu

Quoted 97 lines

Anders Wallin

Quoted 91 lines · Mathieu Desnoyers

----- On Apr 1, 2021, at 12:37 PM, lttng-dev [ mailto:[email protected]

Quoted 5 lines · | [email protected] ] wrote:

the following tests fails
- test_event_vpid_tracker ust 0 "${EVENT_NAME}"
- test_event_vpid_track_untrack ust 0 "${EVENT_NAME}"
- test_event_pid_tracker ust 0 "${EVENT_NAME}"
- test_event_pid_track_untrack ust 0 "${EVENT_NAME}"

There is indeed an issue with these tests: there is a missing "untrack all pids" which should be done at the very beginning of each test to have the expected behavior. AFAIU this explains why there is a small window where traced applications
can generate events when none are expected.

Fixing this should solve the issues without requiring any addition to the test program.

Thanks,

Mathieu

Quoted 58 lines

] >
---
tests/regression/tools/tracker/test_event_tracker | 15 ++++++---------

1 file changed, 6 insertions(+), 9 deletions(-)
tests/regression/tools/tracker/test_event_tracker +1 -1
index 711690af..78e9310b 100755
@@ -5,7 +5,7 @@
 #
 # SPDX-License-Identifier: GPL-2.0-only
 
-TEST_DESC="LTTng - Event traker test"
+TEST_DESC="LTTng - Event tracker test"
 

CURDIR=$(dirname "$0")/
TESTDIR="$CURDIR/../../.."

tests/regression/tools/tracker/test_event_tracker +0 -0
@@ -30,27 +30,24 @@ SCRIPT_GROUPNAME="$(id -gn)"
 

CHILD_PID=-1
WAIT_PATH=

tests/regression/tools/tracker/test_event_tracker +1 -2
-AFTER_FIRST_PATH=
-BEFORE_LAST_PATH=
+BEFORE_FIRST_PATH=

source $TESTDIR/utils/utils.sh

function prepare_ust_app
{
- AFTER_FIRST_PATH=$(mktemp -u)
- BEFORE_LAST_PATH=$(mktemp -u)
+ BEFORE_FIRST_PATH=$(mktemp -u)

- $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT -a "$AFTER_FIRST_PATH" -b "$BEFORE_LAST_PATH" &
+ $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT --sync-before-first-event "$BEFORE_FIRST_PATH" &
CHILD_PID=$!
}

function trace_ust_app
{
- touch "$BEFORE_LAST_PATH"
+ touch "$BEFORE_FIRST_PATH"
wait
ok $? "Traced application stopped."
- rm "$BEFORE_LAST_PATH"
- rm "$AFTER_FIRST_PATH"
+ rm "$BEFORE_FIRST_PATH"
}

function prepare_kernel_app
--
2.31.1

Quoted 5 lines

_______________________________________________
lttng-dev mailing list
[ mailto:[email protected] | [email protected] ] [ https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev |
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev ]

--
Mathieu Desnoyers
EfficiOS Inc.
[ http://www.efficios.com/ | http://www.efficios.com ]

Signature · 3 lines
Mathieu Desnoyers 
EfficiOS Inc. 
http://www.efficios.com 

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

#4 lore raw

Is it OK that validate_trace_session_ust_empty
and validate_trace_session_kernel_empty calls different functions? Or is it cp/paste error?

function validate_trace_session_ust_empty()
{
validate_directory_empty "$1"/ust
}

function validate_trace_session_kernel_empty()
{
* validate_trace_empty "$1"/kernel*
}

Anders Wallin

Quoted 167 lines · Mathieu Desnoyers

----- On Apr 8, 2021, at 5:22 AM, Anders Wallin <[email protected]> wrote:

OK,

I tried this and for
- test_event_vpid_track_untrack ust 0 "${EVENT_NAME}"
- test_event_pid_track_untrack ust 0 "${EVENT_NAME}" it works well.

For
- test_event_vpid_tracker ust 0 "${EVENT_NAME}"
- test_event_pid_tracker ust 0 "${EVENT_NAME}" validate_trace_empty fails since there is no data at all in the trace_path

This run is just calling copy of test_event_tracker running only "test_event_vpid_tracker ust 0 ..."
1..747
# LTTng - Event tracker test
ok 1 - Start session daemon
# Test UST tracker
ok 2 - Create session tracker in -o /tmp/tmp.lu5aeCJhQ3 ok 3 - Enable ust event tp:tptest for session tracker ok 4 - Untrack command with opts: -u --all --vpid
ok 5 - Start tracing for session
ok 6 - Track command with opts: -u --vpid 11842
ok 7 - Traced application stopped.
ok 8 - Stop lttng tracing for session
ok 9 - Destroy session tracker

*not ok 10 - Failed to parse trace# Failed test 'Failed to parse trace'*#
in ./regression/tools/tracker//../../../utils/tap/tap.sh:fail() at line
159.
# Killing (signal SIGTERM) lttng-sessiond and lt-lttng-sessiond pids:
11808 11809 11830
ok 11 - Wait after kill session daemon
# Looks like you planned 747 tests but only ran 11.
# Looks like you failed 1 test of 11.

# find /tmp/tmp.lu5aeCJhQ3
/tmp/tmp.lu5aeCJhQ3
/tmp/tmp.lu5aeCJhQ3/ust

Do you want me to add a special version of "validate_trace_empty" not returning
"Failed to parse trace" for this? If so should it be added in "test_event_tracker" or in "utils.sh"

Actually, this helper already exists in utils.sh:
validate_trace_session_ust_empty (), which
internally uses validate_directory_empty (). As you point out, we should use
validate_trace_session_ust_empty for the validation of those test cases which populate no
trace whatsoever.

Thanks,

Mathieu

Anders Wallin

Quoted 90 lines · Mathieu Desnoyers

----- On Apr 1, 2021, at 12:37 PM, lttng-dev [email protected]

Quoted 5 lines · wrote:

the following tests fails
- test_event_vpid_tracker ust 0 "${EVENT_NAME}"
- test_event_vpid_track_untrack ust 0 "${EVENT_NAME}"
- test_event_pid_tracker ust 0 "${EVENT_NAME}"
- test_event_pid_track_untrack ust 0 "${EVENT_NAME}"

There is indeed an issue with these tests: there is a missing "untrack all pids"
which should be done at the very beginning of each test to have the expected
behavior. AFAIU this explains why there is a small window where traced applications
can generate events when none are expected.

Fixing this should solve the issues without requiring any addition to the test
program.

Thanks,

Mathieu

Quoted 32 lines

---
tests/regression/tools/tracker/test_event_tracker | 15 ++++++---------

1 file changed, 6 insertions(+), 9 deletions(-)
tests/regression/tools/tracker/test_event_tracker +1 -1
index 711690af..78e9310b 100755
@@ -5,7 +5,7 @@
 #
 # SPDX-License-Identifier: GPL-2.0-only
 
-TEST_DESC="LTTng - Event traker test"
+TEST_DESC="LTTng - Event tracker test"
 

CURDIR=$(dirname "$0")/
TESTDIR="$CURDIR/../../.."

tests/regression/tools/tracker/test_event_tracker +0 -0
@@ -30,27 +30,24 @@ SCRIPT_GROUPNAME="$(id -gn)"
 

CHILD_PID=-1
WAIT_PATH=

tests/regression/tools/tracker/test_event_tracker +1 -2
-AFTER_FIRST_PATH=
-BEFORE_LAST_PATH=
+BEFORE_FIRST_PATH=

source $TESTDIR/utils/utils.sh

function prepare_ust_app
{

tests/regression/tools/tracker/test_event_tracker SCRIPT_GROUPNAME="$(id -gn)"

Quoted 5 lines
tests/regression/tools/tracker/test_event_tracker +1 -3
-     AFTER_FIRST_PATH=$(mktemp -u)
-     BEFORE_LAST_PATH=$(mktemp -u)
+     BEFORE_FIRST_PATH=$(mktemp -u)
 
-     $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT -a "$AFTER_FIRST_PATH"

-b

Quoted 2 lines

"$BEFORE_LAST_PATH" &
+ $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT

--sync-before-first-event

Quoted 15 lines

"$BEFORE_FIRST_PATH" &

      CHILD_PID=$!
}

function trace_ust_app
{

tests/regression/tools/tracker/test_event_tracker +2 -3
-     touch "$BEFORE_LAST_PATH"
+     touch "$BEFORE_FIRST_PATH"
      wait
      ok $? "Traced application stopped."
-     rm "$BEFORE_LAST_PATH"
-     rm "$AFTER_FIRST_PATH"
+     rm "$BEFORE_FIRST_PATH"

}

Quoted 8 lines

function prepare_kernel_app
--
2.31.1

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Quoted 5 lines

--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

Quoted 5 lines

--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev