rm -f "${file_sync_before_last}"
}
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
if ! destructive_tests_enabled ; then
echo 'Please make sure that ntp is not running while executing this test'
skip 0 "You need to set the LTTNG_ENABLE_DESTRUCTIVE_TESTS environment variable to \"will-break-my-system\" to run this test" $NUM_TESTS
exit 0
fi
-skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
+check_skip_kernel_test $NUM_TESTS "Skipping all tests." ||
{
original_date=$(date)
start_lttng_relayd "-o $TRACE_PATH"
rm -rf $TRACE_PATH
}
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
# MUST set TESTDIR before calling those functions
plan_tests $NUM_TESTS
test_ust_raw
-skip $isroot "Root access is needed for kernel testing, skipping." 9 ||
+check_skip_kernel_test 9 ||
{
modprobe lttng-test
test_kernel_raw
print_test_banner "$TEST_DESC"
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
{
validate_lttng_modules_present
start_lttng_sessiond
bail_out_if_no_babeltrace
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all tests." "$NUM_TESTS" ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
{
validate_lttng_modules_present
start_lttng_sessiond
plan_tests $NUM_TESTS
print_test_banner "$TEST_DESC"
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
{
start_lttng_sessiond
TEST_COUNT=${#TESTS[@]}
i=0
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
{
validate_lttng_modules_present
trap signal_cleanup SIGTERM SIGINT
print_test_banner "$TEST_DESC"
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
+check_skip_kernel_test $NUM_TESTS "Skipping all tests." ||
{
validate_lttng_modules_present
start_lttng_sessiond
print_test_banner "$TEST_DESC"
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
{
start_lttng_sessiond_notap
validate_lttng_modules_present
print_test_banner "$TEST_DESC"
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
{
validate_lttng_modules_present
start_lttng_sessiond
print_test_banner "$TEST_DESC"
-isroot=0
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-fi
-
-skip $isroot "Root access is needed. Skipping all tests." "$NUM_TESTS" && exit 0
-
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." && exit 0
system_has_ns=0
if [ -d "/proc/$$/ns" ]; then
print_test_banner "$TEST_DESC"
-
-isroot=0
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-fi
-
-skip $isroot "Root access is needed. Skipping all tests." "$NUM_TESTS" && exit 0
-
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." && exit 0
system_has_ns=0
if [ -d "/proc/$$/ns" ]; then
TEST_COUNT=${#TESTS[@]}
i=0
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
{
validate_lttng_modules_present
trap signal_cleanup SIGTERM SIGINT
exit 0
fi
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
diag "Supported syscalls are $SUPPORTED_SYSCALLS_LIST"
-skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
{
validate_lttng_modules_present
print_test_banner "$TEST_DESC"
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
{
validate_lttng_modules_present
start_lttng_sessiond
plan_tests $NUM_TESTS
print_test_banner "$TEST_DESC"
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
{
validate_lttng_modules_present
start_lttng_sessiond
bail_out_if_no_babeltrace
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
streaming_tests=(test_kernel_streaming
test_kernel_streaming_rotate_clear
test_kernel_streaming_clear_rotate
test_kernel_local_snapshot
)
-skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping kernel streaming tests." ||
{
trap signal_cleanup SIGTERM SIGINT
test_bytecode_limit -u
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all kernel invalid filter tests." $NUM_KERNEL_TESTS ||
+check_skip_kernel_test "$NUM_KERNEL_TESTS" "Skipping kernel invalid filter tests." ||
{
diag "Test kernel filters"
i=0
let "i++"
done
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all kernel unsupported filter operations tests." $NUM_KERNEL_TESTS ||
+check_skip_kernel_test $NUM_KERNEL_TESTS "Skipping kernel unsupported filter operations tests." ||
{
diag "Test kernel unsupported filter operations"
IFS=$OLDIFS
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all kernel valid filter tests." $NUM_KERNEL_TESTS ||
+check_skip_kernel_test "$NUM_KERNEL_TESTS" "Skipping kernel valid filter tests." ||
{
diag "Test kernel valid filters"
diag "With UST consumer daemons"
enable_ust_lttng_event_ok $SESSION_NAME $UST_EVENT_NAME $CHANNEL_NAME
- skip $isroot "Root access is needed. Skipping kernel consumer health check test." "1" ||
+ check_skip_kernel_test "1" "Skipping kernel consumer health check test." ||
{
diag "With kernel consumer daemon"
lttng_enable_kernel_event $SESSION_NAME $KERNEL_EVENT_NAME $CHANNEL_NAME
if [ ${test_needs_root} -eq 1 ]; then
- skip ${isroot} "Root access needed for test \"${test_thread_name}\"." "1" ||
+ check_skip_kernel_test "1" "Skipping \"${test_thread_name}\"." ||
{
report_errors "${test_thread_error_string}" "${test_relayd}"
}
TRACE_PATH=$(mktemp -d -t tmp.test_health_trace_path.XXXXXX)
HEALTH_PATH=$(mktemp -d -t tmp.test_health_trace_path.XXXXXX)
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
THREAD_COUNT=${#THREAD[@]}
i=0
while [ "$i" -lt "$THREAD_COUNT" ]; do
$CURDIR/$HEALTH_CHECK_BIN > ${STDOUT_PATH} 2> ${STDERR_PATH}
report_errors
- skip $isroot "Root access is needed. Skipping kernel consumer health check test." "5" ||
+ check_skip_kernel_test "5" "Skipping kernel consumer health check test." ||
{
diag "With kernel consumer daemon"
create_lttng_session_no_output $SESSION_NAME
TRACE_PATH=$(mktemp -d -t tmp.test_thread_ok_trace_path.XXXXXX)
HEALTH_PATH=$(mktemp -d -t tmp.test_thread_ok_trace_path.XXXXXX)
-# The manage kernel thread is only spawned if we are root
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
test_thread_ok
rm -rf ${HEALTH_PATH}
rm -rf $TRACE_PATH
}
-# Need root access for kernel tracing.
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- plan_skip_all "Root access is needed. Skipping all tests."
+check_skip_kernel_test &&
+{
+ plan_skip_all "Skipping all tests."
exit 0
-fi
+}
modprobe lttng-test
}
# Need root access for kernel tracing.
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
{
modprobe lttng-test
bail_out_if_no_babeltrace
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all kernel metadata tests." $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping kernel metadata tests." ||
{
validate_lttng_modules_present
modprobe lttng-test
wait $APP_PID 2> /dev/null
}
-if [ "$(id -u)" == "0" ]; then
-
- validate_lttng_modules_present
-
+check_skip_kernel_test &&
+{
+ plan_skip_all "Skipping all tests."
+ rm -rf "$TEST_TMPDIR"
+ exit 0
+}
- modprobe lttng-test
+validate_lttng_modules_present
- # Used on sessiond launch.
- LTTNG_SESSIOND_ENV_VARS="LTTNG_TESTPOINT_ENABLE=1 \
- CONSUMER_PAUSE_PIPE_PATH=${TESTPOINT_PIPE_PATH} \
- LD_PRELOAD=${TESTPOINT}"
- start_lttng_sessiond_notap
+modprobe lttng-test
- test_buffer_usage_notification
+# Used on sessiond launch.
+LTTNG_SESSIOND_ENV_VARS="LTTNG_TESTPOINT_ENABLE=1 \
+ CONSUMER_PAUSE_PIPE_PATH=${TESTPOINT_PIPE_PATH} \
+ LD_PRELOAD=${TESTPOINT}"
+start_lttng_sessiond_notap
- stop_lttng_sessiond_notap
- rmmod lttng-test
+test_buffer_usage_notification
- rm -rf "${consumerd_pipe[@]}" 2> /dev/null
-else
- # Kernel tests are skipped.
- plan_tests $NUM_TESTS
- skip 0 "Root access is needed. Skipping all kernel notification tests." $NUM_TESTS
-fi
+stop_lttng_sessiond_notap
+rmmod lttng-test
+rm -rf "${consumerd_pipe[@]}" 2> /dev/null
rm -rf "$TEST_TMPDIR"
}
-if [ "$(id -u)" == "0" ]; then
- validate_lttng_modules_present
+check_skip_kernel_test &&
+{
+ plan_skip_all "Skipping all tests."
+ exit 0
+}
- modprobe lttng-test
+validate_lttng_modules_present
- start_lttng_sessiond_notap
+modprobe lttng-test
- test_basic_error_path
+start_lttng_sessiond_notap
- stop_lttng_sessiond_notap
- rmmod lttng-test
+test_basic_error_path
-else
- # Kernel tests are skipped.
- plan_tests $NUM_TESTS
- skip 0 "Root access is needed. Skipping all kernel notification tests." $NUM_TESTS
-fi
+stop_lttng_sessiond_notap
+rmmod lttng-test
rm -f "$TESTAPP_STATE_PATH"
wait $APP_PID 2> /dev/null
}
+check_skip_kernel_test &&
+{
+ plan_skip_all "Skipping all tests."
+ exit 0
+}
-if [ "$(id -u)" == "0" ]; then
- validate_lttng_modules_present
+validate_lttng_modules_present
- modprobe lttng-test
+modprobe lttng-test
- start_lttng_sessiond_notap
+start_lttng_sessiond_notap
- test_basic_error_path
+test_basic_error_path
- stop_lttng_sessiond_notap
- rmmod lttng-test
+stop_lttng_sessiond_notap
+rmmod lttng-test
-else
- # Kernel tests are skipped.
- plan_tests $NUM_TESTS
- skip 0 "Root access is needed. Skipping all kernel notification tests." $NUM_TESTS
-fi
rm -f "$TESTAPP_STATE_PATH"
wait $APP_PID 2> /dev/null
}
-if [ "$(id -u)" == "0" ]; then
- validate_lttng_modules_present
+check_skip_kernel_test &&
+{
+ plan_skip_all "Skipping all tests."
+ exit 0
+}
- modprobe lttng-test
+validate_lttng_modules_present
- start_lttng_sessiond_notap
+modprobe lttng-test
- test_kernel_instrumentation_notification
+start_lttng_sessiond_notap
- stop_lttng_sessiond_notap
- rmmod lttng-test
+test_kernel_instrumentation_notification
-else
- # Kernel tests are skipped.
- plan_tests $NUM_TESTS
- skip 0 "Root access is needed. Skipping all kernel notification tests." $NUM_TESTS
-fi
+stop_lttng_sessiond_notap
+rmmod lttng-test
rm -f "$TESTAPP_STATE_PATH"
wait $APP_PID 2> /dev/null
}
-if [ "$(id -u)" == "0" ]; then
- validate_lttng_modules_present
+check_skip_kernel_test &&
+{
+ plan_skip_all "Skipping all tests."
+ exit 0
+}
- start_lttng_sessiond_notap
+validate_lttng_modules_present
- test_kernel_syscall_notification
+start_lttng_sessiond_notap
- stop_lttng_sessiond_notap
+test_kernel_syscall_notification
-else
- # Kernel tests are skipped.
- plan_tests $NUM_TESTS
- skip 0 "Root access is needed. Skipping all kernel notification tests." $NUM_TESTS
-fi
+stop_lttng_sessiond_notap
rm -f "$TESTAPP_STATE_PATH"
wait $APP_PID 2> /dev/null
}
-if [ "$(id -u)" == "0" ]; then
- validate_lttng_modules_present
+check_skip_kernel_test &&
+{
+ plan_skip_all "Skipping all tests."
+ exit 0
+}
+
+validate_lttng_modules_present
- start_lttng_sessiond_notap
+start_lttng_sessiond_notap
- test_kernel_userspace_probe_notification
+test_kernel_userspace_probe_notification
- stop_lttng_sessiond_notap
-else
- # Kernel tests are skipped.
- plan_tests $NUM_TESTS
- skip 0 "Root access is needed. Skipping all kernel notification tests." $NUM_TESTS
-fi
+stop_lttng_sessiond_notap
rm -f "$TESTAPP_STATE_PATH"
rm -rf "$output_dir"
}
-
TESTS=(
test_multi_app_ust
test_on_register_evaluation_ust
)
-if [ "$(id -u)" == "0" ]; then
+check_skip_kernel_test "$NUM_TEST_KERNEL" "Skipping kernel multi-app notification tests." || {
validate_lttng_modules_present
TESTS+=(
- test_multi_app_kernel
- test_on_register_evaluation_kernel
-)
-else
- skip 0 "Root access is needed. Skipping all kernel multi-app notification tests." $NUM_TEST_KERNEL
-fi
-
+ test_multi_app_kernel
+ test_on_register_evaluation_kernel
+ )
+}
for fct_test in ${TESTS[@]};
do
test_ust_notifier_discarded_count
test_ust_notifier_discarded_count_max_bucket
-if [ "$(id -u)" == "0" ]; then
+check_skip_kernel_test "$KERNEL_NUM_TESTS" "Skipping kernel notification tests." ||
+{
validate_lttng_modules_present
modprobe --remove lttng-test
rm -rf "${sessiond_pipe[@]}" 2> /dev/null
-else
- # Kernel tests are skipped.
- skip 0 "Root access is needed. Skipping all kernel notification tests." $KERNEL_NUM_TESTS
-fi
+
+}
rm -rf "$TEST_TMPDIR"
print_test_banner "$TEST_DESC"
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
{
validate_lttng_modules_present
print_test_banner "$TEST_DESC"
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
{
validate_lttng_modules_present
start_lttng_sessiond
print_test_banner "$TEST_DESC"
bail_out_if_no_babeltrace
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
{
validate_lttng_modules_present
print_test_banner "$TEST_DESC"
bail_out_if_no_babeltrace
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
{
validate_lttng_modules_present
bail_out_if_no_babeltrace
-
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all kernel snapshot tests" $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
{
validate_lttng_modules_present
print_test_banner "$TEST_DESC"
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all kernel streaming tests" $NUM_TESTS ||
+check_skip_kernel_test $NUM_TESTS "Skipping all tests." ||
{
validate_lttng_modules_present
bail_out_if_no_babeltrace
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed to set bandwith limits. Skipping all tests." $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
{
# Catch sigint and try to cleanup limits
print_test_banner "$TEST_DESC"
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_TESTS ||
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." ||
{
validate_lttng_modules_present
test_event_tracker ust 1 "${EVENT_NAME}" "--pid --all" # backward compat
test_event_pid_tracker ust 1 "${EVENT_NAME}"
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all kernel tracker tests." $NUM_KERNEL_TESTS ||
+check_skip_kernel_test "$NUM_KERNEL_TESTS" "Skipping kernel tracker tests." ||
{
diag "Test kernel tracker"
tmp_stderr=$(mktemp -t test_parse_cli_trigger_stderr.XXXXXX)
uprobe_elf_binary="${TESTDIR}/utils/testapp/userspace-probe-elf-binary/.libs/userspace-probe-elf-binary"
-if [ "$(id -u)" == "0" ]; then
- ist_root=1
-else
- ist_root=0
-fi
-
function test_success ()
{
local test_name="$1"
--condition event-rule-matches --type=user --name='jean-*' --exclude-name jean-chretien -x jean-charest \
--action notify
-skip $ist_root "non-root user: skipping kprobe tests" 18 || {
+check_skip_kernel_test 18 "Skipping kprobe tests." || {
i=0
for type in kprobe kernel:kprobe; do
done
}
-skip $ist_root "non-root user: skipping uprobe tests" 6 || {
+check_skip_kernel_test 6 "Skipping uprobe tests." || {
test_success "--condition event-rule-matches uprobe" "uprobe-trigger-0" \
--name="uprobe-trigger-0" \
--condition event-rule-matches --type=kernel:uprobe --location=${uprobe_elf_binary}:test_function --event-name=ma-probe \
--action notify
}
-skip $ist_root "non-root user: skipping syscall tests" 30 || {
+check_skip_kernel_test 30 "Skipping syscall tests." || {
test_success "--condition event-rule-matches one syscall" "syscall-trigger-0" \
--name="syscall-trigger-0" \
--condition event-rule-matches --type=syscall --name=open \
register_some_triggers_bin=$(realpath "${CURDIR}/utils/register-some-triggers")
uid=$(id --user)
-gid=$(id --group)
-if [ "$uid" == "0" ]; then
- ist_root=1
- ls "$uprobe_sdt_binary" >/dev/null 2>&1
- if test $? == 0; then
- hast_sdt_binary=1
- else
- hast_sdt_binary=0
- fi
-else
- ist_root=0
- hast_sdt_binary=0
+sdt_binary_present=0
+if [ -f "$uprobe_sdt_binary" ]; then
+ sdt_binary_present=1
fi
-
test_top_level_options ()
{
diag "Listing top level options"
test_top_level_options
test_event_rule_matches_tracepoint
-skip $ist_root "non-root user: skipping kprobe tests" 13 || test_event_rule_matches_probe
-skip $ist_root "non-root user: skipping uprobe tests" 9 || test_event_rule_matches_userspace_probe_elf
-skip $(($ist_root && $hast_sdt_binary)) "skipping userspace probe SDT tests" 9 || test_event_rule_matches_userspace_probe_sdt
-skip $ist_root "non-root user: skipping syscall tests" 17 || test_event_rule_matches_syscall
+check_skip_kernel_test 48 "Skipping kprobe, uprobe, SDT and syscall tests." || {
+ test_event_rule_matches_probe
+ test_event_rule_matches_userspace_probe_elf
+ skip $sdt_binary_present "No SDT binary. Skipping userspace probe SDT tests" 9 || test_event_rule_matches_userspace_probe_sdt
+ test_event_rule_matches_syscall
+}
test_session_consumed_size_condition
test_buffer_usage_conditions
test_session_rotation_conditions
test_event_wildcard ust 1 'tp**tptest'
test_event_wildcard ust 1 'tp*test'
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
-skip $isroot "Root access is needed. Skipping all kernel wildcard tests." $NUM_KERNEL_TESTS ||
+check_skip_kernel_test "$NUM_KERNEL_TESTS" "Skipping kernel wildcard tests." ||
{
diag "Test kernel wildcards"
diag "Test lttng-relayd change working directory on non writable directory"
if [ "$(id -u)" == "0" ]; then
- is_user=0
+ is_user=0
else
- is_user=1
+ is_user=1
fi
skip $is_user "Skipping permission debug output test; operation can't fail as root" 6 ||
bail_out_if_no_babeltrace
-isroot=0
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-fi
-
-skip $isroot "Root access is needed. Skipping all tests." "$NUM_TESTS" && exit 0
+check_skip_kernel_test "$NUM_TESTS" "Skipping all tests." && exit 0
system_has_ns=0
if [ -d "/proc/$$/ns" ]; then
bail_out_if_no_babeltrace
-if [ "$(id -u)" == "0" ]; then
- isroot=1
-else
- isroot=0
-fi
-
start_lttng_sessiond
test_parsing_raw
-skip $isroot "Root access is needed. Skipping UST perf tests." 8 ||
+check_skip_kernel_test 8 "Skipping UST perf tests." ||
{
test_event_basic
}
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 ()