Tests: Add syscall enable/disable scenarios
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 3 Sep 2020 15:04:46 +0000 (11:04 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 27 Oct 2020 14:06:16 +0000 (10:06 -0400)
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ic3d9e739b01a0cf2bffb7c103911b3b51520010e

tests/regression/kernel/test_syscall

index 487ee668e2a583fef364044b753e64f86afb82e7..9ce40dcc52bf5fc84ae7643090169d87630552ec 100755 (executable)
@@ -10,7 +10,7 @@ TEST_DESC="Kernel tracer - System calls"
 
 CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../..
-NUM_TESTS=183
+NUM_TESTS=214
 
 # `gen-syscall-event` starts and waits for the creation a file passed by
 # arguments to start executing 3 syscalls (open,read,close) and returning.
@@ -329,6 +329,96 @@ function test_syscall_enable_all_disable_all_enable_all()
        rm -rf $TRACE_PATH
 }
 
+function test_syscall_enable_all_enable_one_disable_all()
+{
+       TRACE_PATH=$(mktemp -d)
+       SESSION_NAME="kernel_syscall_enable_all_enable_one_disable_all"
+
+       diag "Syscall trace all events, enable one and disable all"
+
+       create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"
+
+       # enable all syscalls
+       lttng_enable_kernel_syscall_ok $SESSION_NAME
+
+       # enable one specific syscall, "openat"
+       lttng_enable_kernel_syscall_ok $SESSION_NAME openat
+
+       # disable all syscalls
+       lttng_disable_kernel_syscall_ok $SESSION_NAME
+
+       trace_testapp
+
+       # The trace shouldn't contain any syscalls, disable-all should disable
+       # even individually specified syscalls
+       trace_match_only openat 0 "$TRACE_PATH"
+
+       destroy_lttng_session_ok $SESSION_NAME
+
+       rm -rf "$TRACE_PATH"
+}
+
+function test_syscall_enable_one_enable_all_disable_one()
+{
+       TRACE_PATH=$(mktemp -d)
+       SESSION_NAME="kernel_syscall_enable_one_enable_all_disable_one"
+
+       diag "Syscall trace all events and enable/disable one"
+
+       create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"
+
+       # enable one specific syscall, "openat"
+       lttng_enable_kernel_syscall_ok $SESSION_NAME openat
+
+       # enable all syscalls
+       lttng_enable_kernel_syscall_ok $SESSION_NAME
+
+       # disable one specific syscall, "openat"
+       lttng_disable_kernel_syscall_ok $SESSION_NAME openat
+
+       trace_testapp
+
+       # The trace should contain all syscalls, including 'openat' because
+       # enable-all overrides individually disabled syscalls.
+       validate_trace openat "$TRACE_PATH"
+
+       destroy_lttng_session_ok $SESSION_NAME
+
+       rm -rf "$TRACE_PATH"
+}
+
+function test_syscall_enable_one_enable_all_disable_all_disable_one()
+{
+       TRACE_PATH=$(mktemp -d)
+       SESSION_NAME="kernel_syscall_enable_one_enable_all_disable_all_disable_one"
+
+       diag "Syscall trace all events and enable/disable one"
+
+       create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"
+
+       # enable one specific syscall, "openat"
+       lttng_enable_kernel_syscall_ok $SESSION_NAME openat
+
+       # enable all syscalls
+       lttng_enable_kernel_syscall_ok $SESSION_NAME
+
+       # disable all syscalls
+       lttng_disable_kernel_syscall_ok $SESSION_NAME
+
+       # disable one specific syscall, "openat"
+       lttng_disable_kernel_syscall_ok $SESSION_NAME openat
+
+       trace_testapp
+
+       # The trace shouldn't contain any syscalls, disable-all should disable
+       # even individually specified syscalls
+       trace_match_only openat 0 "$TRACE_PATH"
+
+       destroy_lttng_session_ok $SESSION_NAME
+
+       rm -rf "$TRACE_PATH"
+}
+
 function test_syscall_enable_all_disable_all_twice()
 {
        TRACE_PATH=$(mktemp -d)
@@ -596,6 +686,9 @@ skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
        test_syscall_enable_all_disable_all
        test_syscall_enable_all_disable_all_enable_all
        test_syscall_enable_all_disable_all_twice
+       test_syscall_enable_all_enable_one_disable_all
+       test_syscall_enable_one_enable_all_disable_one
+       test_syscall_enable_one_enable_all_disable_all_disable_one
        test_syscall_enable_one_disable_one
        test_syscall_enable_two_disable_two
        test_syscall_enable_two_disable_one
This page took 0.027117 seconds and 4 git commands to generate.