X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=tests%2Futils%2Futils.sh;h=18b673b11452491bc3946abda5aa0225d53be587;hb=HEAD;hp=c1d702e823c33120f96b256df93bd35044a73d8e;hpb=cdcf8972424da5cba4c0210d7fdfa2e7123aa748;p=lttng-tools.git diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index c1d702e82..55c821d60 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -323,6 +323,41 @@ function conf_proc_count() echo } +# Usage: +# check_skip_kernel_test [NB_TESTS] [SKIP_MESSAGE] +# Return 0 if LTTNG_TOOLS_DISABLE_KERNEL_TESTS was set or the current user is not a root user +# If NB_TESTS is set, call skip() to skip number of tests. +# If NB_TESTS is empty, just output a reason with diag. +# An optional message can be added. + +function check_skip_kernel_test () +{ + local num_tests="$1" + local skip_message="$2" + + # Check for skip test kernel flag + if [ "$LTTNG_TOOLS_DISABLE_KERNEL_TESTS" == "1" ]; then + if ! test -z "$num_tests"; then + skip 0 "LTTNG_TOOLS_DISABLE_KERNEL_TESTS was set.${skip_message+ }${skip_message}" "$num_tests" + else + diag "LTTNG_TOOLS_DISABLE_KERNEL_TESTS was set.${skip_message+ }${skip_message}" + fi + return 0 + fi + + # Check if we are running as root + if [ "$(id -u)" != "0" ]; then + if ! test -z "$num_tests"; then + skip 0 "Root access is needed for kernel testing.${skip_message+ }${skip_message}" "$num_tests" + else + diag "Root access is needed for kernel testing.${skip_message+ }${skip_message}" + fi + return 0 + fi + + return 1 +} + # Check if base lttng-modules are present. # Bail out on failure function validate_lttng_modules_present () @@ -1302,7 +1337,7 @@ function enable_lttng_mmap_overwrite_small_kernel_channel() _run_lttng_cmd "$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \ enable-channel -s $sess_name $channel_name -k --output mmap --overwrite --subbuf-size=$(getconf PAGE_SIZE) --num-subbuf=2 - ok $? "Enable small discard channel $channel_name for session $sess_name" + ok $? "Enable small overwrite channel $channel_name for session $sess_name" } function enable_lttng_mmap_overwrite_ust_channel()