Fix: tools/snapshots/test_kernel flaky test
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 24 Feb 2022 17:24:45 +0000 (12:24 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 28 Feb 2022 21:51:46 +0000 (16:51 -0500)
When tracing all system calls, nothing guarantees that the first system
call won't come from some _other_ program on the system, on a CPU != 0,
and stay invariant between the two snapshots (when it should not be).

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iba45664f10eea0a757f8ac4eb9a7c7c75c305eef

tests/regression/tools/snapshots/test_kernel

index 8cac901e7dff69d0da3e6fc9fc5d651becbcdd55..a2a4db06d6a84e87bab2f1c5ddf8ef7dd3d3b157 100755 (executable)
@@ -100,25 +100,27 @@ function test_kernel_local_snapshot_append_to_metadata ()
        destroy_lttng_session_ok $SESSION_NAME
 }
 
-function true_loop_cpu0()
+function generate_filter_events_cpu0()
 {
-       # Generate many system call events (fill buffers) on CPU 0
-       for a in $(seq 1 $1); do
-               taskset 0x00000001 /bin/true;
-       done
+       # Generate many events (fill buffers) on CPU 0
+       taskset 0x00000001 /bin/echo -n "$1" > /proc/lttng-test-filter-event 2> /dev/null
 }
 
 function test_kernel_local_snapshot_discard ()
 {
        diag "Test local kernel snapshots with small discard buffers"
+
+       local event_name="lttng_test_filter_event"
+
+       modprobe lttng-test
        create_lttng_session_no_output $SESSION_NAME
        enable_lttng_mmap_discard_small_kernel_channel $SESSION_NAME \
                        $CHANNEL_NAME
-       lttng_enable_kernel_syscall_ok $SESSION_NAME -a $CHANNEL_NAME
+       enable_kernel_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
 
-       true_loop_cpu0 10000
+       generate_filter_events_cpu0 10000
 
        # Take first snapshot, remember first line.
        lttng_snapshot_record $SESSION_NAME
@@ -127,7 +129,7 @@ function test_kernel_local_snapshot_discard ()
 
        rm -rf $TRACE_PATH
 
-       true_loop_cpu0 10000
+       generate_filter_events_cpu0 10000
 
        # Take 2nd snapshot, compare first line. In discard mode, they
        # should still be the same.
@@ -144,19 +146,24 @@ function test_kernel_local_snapshot_discard ()
 
        stop_lttng_tracing_ok $SESSION_NAME
        destroy_lttng_session_ok $SESSION_NAME
+       modprobe --remove lttng-test
 }
 
 function test_kernel_local_snapshot_overwrite_small_buffers ()
 {
        diag "Test local kernel snapshot with small overwrite buffers"
+
+       local event_name="lttng_test_filter_event"
+
+       modprobe lttng-test
        create_lttng_session_no_output $SESSION_NAME
        enable_lttng_mmap_overwrite_small_kernel_channel $SESSION_NAME \
                        $CHANNEL_NAME
-       lttng_enable_kernel_syscall_ok $SESSION_NAME -a $CHANNEL_NAME
+       enable_kernel_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
 
-       true_loop_cpu0 10000
+       generate_filter_events_cpu0 10000
 
        # Take first snapshot, remember first line.
        lttng_snapshot_record $SESSION_NAME
@@ -165,7 +172,7 @@ function test_kernel_local_snapshot_overwrite_small_buffers ()
 
        rm -rf $TRACE_PATH
 
-       true_loop_cpu0 10000
+       generate_filter_events_cpu0 10000
 
        # Take 2nd snapshot, compare first line. In overwrite mode, they
        # WILL be different.
@@ -182,6 +189,7 @@ function test_kernel_local_snapshot_overwrite_small_buffers ()
 
        stop_lttng_tracing_ok $SESSION_NAME
        destroy_lttng_session_ok $SESSION_NAME
+       modprobe --remove lttng-test
 }
 
 function test_kernel_1000_local_snapshots ()
This page took 0.027327 seconds and 4 git commands to generate.