Fix: Tests that assume CPU 0 is present
authorOlivier Dion <odion@efficios.com>
Thu, 16 Feb 2023 20:34:26 +0000 (15:34 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 6 Jun 2023 18:46:41 +0000 (14:46 -0400)
Add util_event_generator.sh to shellcheck test while at it.

Change-Id: I261452496827a5b9fc08b39a1132b13a39d0a7f5
Signed-off-by: Olivier Dion <odion@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/regression/tools/clear/test_kernel
tests/regression/tools/clear/test_ust
tests/regression/tools/notification/test_notification_multi_app
tests/regression/tools/notification/test_notification_ust
tests/regression/tools/snapshots/test_kernel
tests/regression/ust/blocking/test_blocking
tests/utils/utils.sh

index 2fbddb84cc78de4f3a258f1b14a178b9ce3c9d34..3386ebc4263c098bd8ba6e19022b7036d57c6441 100755 (executable)
@@ -15,7 +15,8 @@ TRACE_PATH=$(mktemp -d)
 
 NUM_TESTS=837
 
-source $TESTDIR/utils/utils.sh
+# shellcheck source=../utils/utils.sh
+source "$TESTDIR/utils/utils.sh"
 
 function signal_cleanup ()
 {
@@ -488,7 +489,7 @@ function test_kernel_streaming_tracefile_rotation_overwrite_files ()
                --tracefile-size=$PAGE_SIZE --tracefile-count=2
        enable_kernel_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
        start_lttng_tracing_ok $SESSION_NAME
-       taskset -c 0 echo -n "200000" > /proc/lttng-test-filter-event
+       taskset -c "$(get_any_available_cpu)" echo -n "200000" > /proc/lttng-test-filter-event
        do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
        stop_lttng_tracing_ok $SESSION_NAME
 
@@ -499,7 +500,7 @@ function test_kernel_streaming_tracefile_rotation_overwrite_files ()
        fi
 
        start_lttng_tracing_ok $SESSION_NAME
-       taskset -c 0 echo -n "400000" > /proc/lttng-test-filter-event
+       taskset -c "$(get_any_available_cpu)" echo -n "400000" > /proc/lttng-test-filter-event
        stop_lttng_tracing_ok
 
        if [[ $rotate_before -eq 1 ]]; then
index 04b713909c7a664e28ec46839424e35d05839ff2..f825e6321017ac6314e11bbe5796b50c25a69732 100755 (executable)
@@ -21,7 +21,8 @@ NUM_TESTS=2071
 PAGE_SIZE=$(getconf PAGE_SIZE)
 TRACE_PATH=$(mktemp -d)
 
-source $TESTDIR/utils/utils.sh
+# shellcheck source=../utils/utils.sh
+source "$TESTDIR/utils/utils.sh"
 
 if [ ! -x "$TESTAPP_BIN" ]; then
        BAIL_OUT "No UST events binary detected."
@@ -754,7 +755,7 @@ function test_ust_streaming_tracefile_rotation_overwrite_files ()
                --tracefile-size=$PAGE_SIZE --tracefile-count=2 --buffers-$buffer_type
        enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
        start_lttng_tracing_ok $SESSION_NAME
-       taskset -c 0 $TESTAPP_BIN -i 200000
+       taskset -c "$(get_any_available_cpu)" $TESTAPP_BIN -i 200000
        do_clear_session $SESSION_NAME $tracing_active $clear_twice $rotate_before $rotate_after
        stop_lttng_tracing_ok $SESSION_NAME
 
@@ -769,7 +770,7 @@ function test_ust_streaming_tracefile_rotation_overwrite_files ()
        fi
 
        start_lttng_tracing_ok $SESSION_NAME
-       taskset -c 0 $TESTAPP_BIN -i 400000
+       taskset -c "$(get_any_available_cpu)" $TESTAPP_BIN -i 400000
        stop_lttng_tracing_ok
 
        if [[ $rotate_before -eq 1 ]]; then
index 9468d0a0db19c8aeb66486cc2a3352a850eb3c8a..1e94f44416d32815cea771ee03a30d978c481b98 100755 (executable)
@@ -86,7 +86,7 @@ function ust_event_generator
                        if [[ -f $state_file ]]; then
                                rm $state_file 2> /dev/null
                        fi
-                       taskset  -c 0 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT > /dev/null 2>&1
+                       taskset -c "$(get_any_available_cpu)" $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT > /dev/null 2>&1
                fi
        done
 }
index 57ae52cbd8f6df9c1ec9003804ac2923c6ef4bef..f963bd0ced741b4ab907edad09cc1cc950164ece 100755 (executable)
@@ -53,7 +53,7 @@ function ust_event_generator
                        if [[ -f $state_file ]]; then
                                rm -rf $state_file 2> /dev/null
                        fi
-                       taskset  -c 0 $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT > /dev/null 2>&1
+                       taskset -c "$(get_any_available_cpu)" $TESTAPP_BIN -i $NR_ITER -w $NR_USEC_WAIT > /dev/null 2>&1
                fi
        done
 }
index 75de4ed45a89624e6b8bf0bf6ea142de395c789b..892784e6164d8bb099aca14b7adce6ba27e7550f 100755 (executable)
@@ -104,7 +104,7 @@ function true_loop_cpu0()
 {
        # Generate many system call events (fill buffers) on CPU 0
        for a in $(seq 1 $1); do
-               taskset 0x00000001 /bin/true;
+               taskset --cpu-list "$(get_any_available_cpu)" /bin/true;
        done
 }
 
index abd50d45938ee2625746211bc38291b056d6e170..fcf1ad94d016445c58b273772469f963976f1728 100755 (executable)
@@ -19,13 +19,14 @@ EVENT_NAME="tp:tptest"
 
 NUM_TESTS=49
 
-source $TESTDIR/utils/utils.sh
+# shellcheck source=../utils/utils.sh
+source "$TESTDIR/utils/utils.sh"
 
 # MUST set TESTDIR before calling those functions
-# Run app on CPU 0 to ensure we only write in a single ring buffer.
+# Run app on a single CPU to ensure we only write in a single ring buffer.
 function run_app()
 {
-       taskset 0x00000001 $TESTAPP_BIN -i $NUM_EVENT
+       taskset --cpu-list "$(get_any_available_cpu)" $TESTAPP_BIN -i $NUM_EVENT
        ok $? "Application done"
 }
 
index 09c4ae28d502ea8459a9ea13c57431657b8f4f54..89624a4216f952095d8b42be4b754e7a791a886f 100644 (file)
@@ -198,6 +198,16 @@ function get_exposed_cpus_list()
        echo "${list[@]}"
 }
 
+# Return any available CPU found. Do not make assumption about the returned
+# value, e.g. that it could be 0.
+function get_any_available_cpu()
+{
+       for cpu in /sys/devices/system/cpu/cpu[0-9]*; do
+               echo "${cpu#/sys/devices/system/cpu/cpu}"
+               break;
+       done
+}
+
 # Return the number of _configured_ CPUs.
 function conf_proc_count()
 {
This page took 0.030237 seconds and 4 git commands to generate.