From 9c8a396496a28702730192ae1ded06105c54c5dc Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Wed, 28 Mar 2018 15:21:26 -0400 Subject: [PATCH] Tests: use modprobe to test for the presence of lttng-modules MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau --- tests/regression/tools/regen-metadata/test_kernel | 8 ++------ tests/regression/tools/regen-statedump/test_kernel | 7 +------ tests/regression/tools/rotation/test_kernel | 8 ++------ tests/regression/tools/snapshots/test_kernel | 9 +++------ tests/regression/tools/snapshots/test_kernel_streaming | 8 ++------ tests/regression/tools/streaming/test_kernel | 8 ++------ tests/utils/utils.sh | 10 ++++++++++ 7 files changed, 22 insertions(+), 36 deletions(-) diff --git a/tests/regression/tools/regen-metadata/test_kernel b/tests/regression/tools/regen-metadata/test_kernel index fd139aeef..1849b9cd0 100755 --- a/tests/regression/tools/regen-metadata/test_kernel +++ b/tests/regression/tools/regen-metadata/test_kernel @@ -28,12 +28,6 @@ NUM_TESTS=18 source $TESTDIR/utils/utils.sh -# LTTng kernel modules check -out=`ls /lib/modules/$(uname -r)/extra | grep lttng` -if [ -z "$out" ]; then - BAIL_OUT "LTTng modules not detected." -fi - function lttng_create_session_uri { # Create session with default path @@ -91,6 +85,8 @@ fi skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS || { + validate_lttng_modules_present + start_lttng_relayd "-o $TRACE_PATH" start_lttng_sessiond modprobe lttng-test diff --git a/tests/regression/tools/regen-statedump/test_kernel b/tests/regression/tools/regen-statedump/test_kernel index 85afe76a1..50054eb07 100755 --- a/tests/regression/tools/regen-statedump/test_kernel +++ b/tests/regression/tools/regen-statedump/test_kernel @@ -29,12 +29,6 @@ NUM_TESTS=11 source $TESTDIR/utils/utils.sh -# LTTng kernel modules check -out=`ls /lib/modules/$(uname -r)/extra | grep lttng` -if [ -z "$out" ]; then - BAIL_OUT "LTTng modules not detected." -fi - function test_kernel_local () { diag "Test kernel local with statedump regeneration" @@ -64,6 +58,7 @@ fi skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS || { + validate_lttng_modules_present start_lttng_sessiond modprobe lttng-test diff --git a/tests/regression/tools/rotation/test_kernel b/tests/regression/tools/rotation/test_kernel index 3ef3b7dfd..0d72f9eae 100755 --- a/tests/regression/tools/rotation/test_kernel +++ b/tests/regression/tools/rotation/test_kernel @@ -29,12 +29,6 @@ NUM_TESTS=68 source $TESTDIR/utils/utils.sh source $CURDIR/rotate_utils.sh -# LTTng kernel modules check -out=`ls /lib/modules/$(uname -r)/extra | grep lttng` -if [ -z "$out" ]; then - BAIL_OUT "LTTng modules not detected." -fi - function lttng_create_session_uri { # Create session with default path @@ -126,6 +120,8 @@ fi skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS || { + validate_lttng_modules_present + start_lttng_relayd "-o $TRACE_PATH" start_lttng_sessiond modprobe lttng-test diff --git a/tests/regression/tools/snapshots/test_kernel b/tests/regression/tools/snapshots/test_kernel index 886c4557a..ff563100b 100755 --- a/tests/regression/tools/snapshots/test_kernel +++ b/tests/regression/tools/snapshots/test_kernel @@ -29,12 +29,6 @@ NUM_TESTS=2060 source $TESTDIR/utils/utils.sh -# LTTng kernel modules check -out=`ls /lib/modules/$(uname -r)/extra | grep lttng` -if [ -z "$out" ]; then - BAIL_OUT "LTTng modules not detected." -fi - function test_kernel_local_snapshot () { diag "Test local kernel snapshots" @@ -241,6 +235,9 @@ fi skip $isroot "Root access is needed. Skipping all kernel snapshot tests." $NUM_TESTS || { + + validate_lttng_modules_present + start_lttng_sessiond #tests=( test_kernel_1000_local_snapshots ) diff --git a/tests/regression/tools/snapshots/test_kernel_streaming b/tests/regression/tools/snapshots/test_kernel_streaming index 7653bd9f9..bdbcc4929 100755 --- a/tests/regression/tools/snapshots/test_kernel_streaming +++ b/tests/regression/tools/snapshots/test_kernel_streaming @@ -29,12 +29,6 @@ NUM_TESTS=36 source $TESTDIR/utils/utils.sh -# LTTng kernel modules check -out=`ls /lib/modules/$(uname -r)/extra | grep lttng` -if [ -z "$out" ]; then - BAIL_OUT "LTTng modules not detected." -fi - function snapshot_add_output () { local sess_name=$1 @@ -143,6 +137,8 @@ fi skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS || { + validate_lttng_modules_present + start_lttng_relayd "-o $TRACE_PATH" start_lttng_sessiond diff --git a/tests/regression/tools/streaming/test_kernel b/tests/regression/tools/streaming/test_kernel index d54bcedf5..6bb23d9f5 100755 --- a/tests/regression/tools/streaming/test_kernel +++ b/tests/regression/tools/streaming/test_kernel @@ -28,12 +28,6 @@ NUM_TESTS=10 source $TESTDIR/utils/utils.sh -# LTTng kernel modules check -out=`ls /lib/modules/$(uname -r)/extra | grep lttng` -if [ -z "$out" ]; then - BAIL_OUT "LTTng modules not detected." -fi - function lttng_create_session_uri { # Create session with default path @@ -80,6 +74,8 @@ fi skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS || { + validate_lttng_modules_present + start_lttng_relayd "-o $TRACE_PATH" start_lttng_sessiond diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index c88387dc7..92ed7b354 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -125,6 +125,16 @@ function conf_proc_count() echo } +# Check if base lttng-modules are present. +# Bail out on failure +function validate_lttng_modules_present () +{ + modprobe -n lttng-tracer 2>/dev/null + if [ $? -ne 0 ]; then + BAIL_OUT "LTTng modules not detected." + fi +} + function enable_kernel_lttng_event { local withtap="$1" -- 2.34.1