X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=tests%2Futils%2Futils.sh;h=2752b0f7a76c84eec8ad2f70db5c9340c7162022;hb=HEAD;hp=44b3f167a8bb54a078c25370018eeee1533878e8;hpb=d2456f81866aea50e79ce64ecd5c889d054717b7;p=lttng-tools.git diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index 44b3f167a..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 () @@ -633,7 +668,7 @@ function start_lttng_relayd_opt() if [ -z $(lttng_pgrep "$RELAYD_MATCH") ]; then # shellcheck disable=SC2086 $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $process_mode $opt 1> $OUTPUT_DEST 2> $ERROR_OUTPUT_DEST - #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 & + #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $process_mode $opt -vvv >>/tmp/relayd.log 2>&1 & if [ $? -eq 1 ]; then if [ $withtap -eq "1" ]; then fail "Start lttng-relayd (process mode: $process_mode opt: $opt)" @@ -675,8 +710,9 @@ function stop_lttng_relayd_opt() # Multiply time by 2 to simplify integer arithmetic + # Multiply time by 5 to adjust for sleeping every 0.1s if [ -n "$timeout_s" ]; then - dtimeleft_s=$((timeout_s * 2)) + dtimeleft_s=$((timeout_s * 2 * 5)) fi @@ -711,7 +747,7 @@ function stop_lttng_relayd_opt() fi dtimeleft_s=$((dtimeleft_s - 1)) fi - sleep 0.5 + sleep 0.1 done if [ "$withtap" -eq "1" ]; then if [ "$retval" -eq "0" ]; then @@ -835,8 +871,9 @@ function stop_lttng_sessiond_opt() fi # Multiply time by 2 to simplify integer arithmetic + # Multiply time by 5 to adjust for sleeping every 0.1s if [ -n "$timeout_s" ]; then - dtimeleft_s=$((timeout_s * 2)) + dtimeleft_s=$((timeout_s * 2 * 5)) fi if [ -n "$TEST_NO_SESSIOND" ] && [ "$TEST_NO_SESSIOND" == "1" ]; then @@ -881,7 +918,7 @@ function stop_lttng_sessiond_opt() fi dtimeleft_s=$((dtimeleft_s - 1)) fi - sleep 0.5 + sleep 0.1 done out=1 while [ -n "$out" ]; do @@ -893,7 +930,7 @@ function stop_lttng_sessiond_opt() fi dtimeleft_s=$((dtimeleft_s - 1)) fi - sleep 0.5 + sleep 0.1 done if [ "$withtap" -eq "1" ]; then @@ -1003,8 +1040,9 @@ function stop_lttng_consumerd_opt() fi # Multiply time by 2 to simplify integer arithmetic + # Multiply time by 5 to adjust for sleeping every 0.1s if [ -n "$timeout_s" ]; then - dtimeleft_s=$((timeout_s * 2)) + dtimeleft_s=$((timeout_s * 2 * 5)) fi pids="$(lttng_pgrep "$CONSUMERD_MATCH")" @@ -1049,7 +1087,7 @@ function stop_lttng_consumerd_opt() fi dtimeleft_s=$((dtimeleft_s - 1)) fi - sleep 0.5 + sleep 0.1 done if [ "$withtap" -eq "1" ]; then if [ "$retval" -eq "0" ]; then @@ -1299,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() @@ -1688,9 +1726,10 @@ function destroy_lttng_session () local withtap=$1 local expected_to_fail=$2 local sess_name=$3 + shift 3 _run_lttng_cmd "$OUTPUT_DEST" "$ERROR_OUTPUT_DEST" \ - destroy $sess_name + destroy $sess_name $@ ret=$? if [[ $expected_to_fail -eq "1" ]]; then test "$ret" -ne "0" @@ -1995,7 +2034,7 @@ function wait_live_trace_ready () diag "Waiting for live trace at url: $url" while [ $zero_client_match -eq 0 ]; do zero_client_match=$($BABELTRACE_BIN -i lttng-live $url | grep "0 client(s) connected" | wc -l) - sleep 0.5 + sleep 0.1 done pass "Waiting for live trace at url: $url" } @@ -2008,7 +2047,7 @@ function wait_live_viewer_connect () diag "Waiting for live viewers on url: $url" while [ $one_client_match -eq 0 ]; do one_client_match=$($BABELTRACE_BIN -i lttng-live $url | grep "1 client(s) connected" | wc -l) - sleep 0.5 + sleep 0.1 done pass "Waiting for live viewers on url: $url" }