tests: test kernel snapshot with discard buffers
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 20 Apr 2016 15:19:59 +0000 (11:19 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 16 Jun 2016 14:31:11 +0000 (10:31 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/regression/tools/snapshots/test_kernel
tests/utils/utils.sh

index a590fb4d02178bba2175e8f8b809afae81c484b4..886c4557a513732b093f53c61f5f6992ca016445 100755 (executable)
@@ -25,7 +25,7 @@ CHANNEL_NAME="snapchan"
 
 TRACE_PATH=$(mktemp -d)
 
 
 TRACE_PATH=$(mktemp -d)
 
-NUM_TESTS=2040
+NUM_TESTS=2060
 
 source $TESTDIR/utils/utils.sh
 
 
 source $TESTDIR/utils/utils.sh
 
@@ -118,6 +118,90 @@ function test_kernel_local_snapshot_append_to_metadata ()
        destroy_lttng_session_ok $SESSION_NAME
 }
 
        destroy_lttng_session_ok $SESSION_NAME
 }
 
+function true_loop_cpu0()
+{
+       # Generate many system call events (fill buffers) on CPU 0
+       for a in $(seq 1 $1); do
+               taskset 0x00000001 /bin/true;
+       done
+}
+
+function test_kernel_local_snapshot_discard ()
+{
+       diag "Test local kernel snapshots with small discard buffers"
+       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
+       start_lttng_tracing_ok $SESSION_NAME
+       lttng_snapshot_add_output_ok $SESSION_NAME $TRACE_PATH
+
+       true_loop_cpu0 10000
+
+       # 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
+
+       true_loop_cpu0 10000
+
+       # Take 2nd snapshot, compare first line. In discard mode, they
+       # should still be the same.
+       lttng_snapshot_record $SESSION_NAME
+       FIRST_LINE_2="$(trace_first_line $TRACE_PATH/)"
+       diag "First line (2nd snapshot): $FIRST_LINE"
+       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
+}
+
+function test_kernel_local_snapshot_overwrite_small_buffers ()
+{
+       diag "Test local kernel snapshot with small overwrite buffers"
+       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
+       start_lttng_tracing_ok $SESSION_NAME
+       lttng_snapshot_add_output_ok $SESSION_NAME $TRACE_PATH
+
+       true_loop_cpu0 10000
+
+       # 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
+
+       true_loop_cpu0 10000
+
+       # Take 2nd snapshot, compare first line. In overwrite mode, they
+       # WILL be different.
+       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
+}
+
 function test_kernel_1000_local_snapshots ()
 {
        NB_SNAP=1000
 function test_kernel_1000_local_snapshots ()
 {
        NB_SNAP=1000
@@ -160,7 +244,13 @@ skip $isroot "Root access is needed. Skipping all kernel snapshot tests." $NUM_T
        start_lttng_sessiond
 
        #tests=( test_kernel_1000_local_snapshots )
        start_lttng_sessiond
 
        #tests=( test_kernel_1000_local_snapshots )
-       tests=( test_kernel_local_snapshot test_kernel_local_snapshot_after_stop test_kernel_local_snapshot_append_to_metadata test_kernel_1000_local_snapshots )
+       tests=( test_kernel_local_snapshot
+               test_kernel_local_snapshot_after_stop
+               test_kernel_local_snapshot_append_to_metadata
+               test_kernel_local_snapshot_discard
+               test_kernel_local_snapshot_overwrite_small_buffers
+               test_kernel_1000_local_snapshots
+       )
 
        for fct_test in ${tests[@]};
        do
 
        for fct_test in ${tests[@]};
        do
index c59442b22c09cc45db2c5118a46aa75a30c25cc1..da2efe91a72264b93cd5c67b8d46cf28c53408d2 100644 (file)
@@ -735,6 +735,24 @@ function enable_lttng_mmap_overwrite_kernel_channel()
        ok $? "Enable channel $channel_name for session $sess_name"
 }
 
        ok $? "Enable channel $channel_name for session $sess_name"
 }
 
+function enable_lttng_mmap_discard_small_kernel_channel()
+{
+       local sess_name=$1
+       local channel_name=$2
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name $channel_name -k --output mmap --discard --subbuf-size=$(getconf PAGE_SIZE) --num-subbuf=2 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
+       ok $? "Enable small discard channel $channel_name for session $sess_name"
+}
+
+function enable_lttng_mmap_overwrite_small_kernel_channel()
+{
+       local sess_name=$1
+       local channel_name=$2
+
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel -s $sess_name $channel_name -k --output mmap --overwrite --subbuf-size=$(getconf PAGE_SIZE) --num-subbuf=2 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST
+       ok $? "Enable small discard channel $channel_name for session $sess_name"
+}
+
 function enable_lttng_mmap_overwrite_ust_channel()
 {
        local sess_name=$1
 function enable_lttng_mmap_overwrite_ust_channel()
 {
        local sess_name=$1
@@ -1276,6 +1294,18 @@ function validate_trace
        return $ret
 }
 
        return $ret
 }
 
+function trace_first_line
+{
+       local trace_path=$1
+
+       which $BABELTRACE_BIN >/dev/null
+       if [ $? -ne 0 ]; then
+           skip 0 "Babeltrace binary not found. Skipping trace validation"
+       fi
+
+       $BABELTRACE_BIN $trace_path 2>/dev/null | head -n 1
+}
+
 function validate_trace_exp()
 {
        local event_exp=$1
 function validate_trace_exp()
 {
        local event_exp=$1
This page took 0.032875 seconds and 5 git commands to generate.