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>
# All file must be relative to the test directory.
files=(
meta/test_shellcheck
+ regression/tools/notification/util_event_generator.sh
run.sh
)
NUM_TESTS=837
-source $TESTDIR/utils/utils.sh
+# shellcheck source=../utils/utils.sh
+source "$TESTDIR/utils/utils.sh"
function signal_cleanup ()
{
--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
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
PAGE_SIZE=$(getconf PAGE_SIZE)
TRACE_PATH=$(mktemp -d -t tmp.test_clear_ust_trace_path.XXXXXX)
-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."
--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
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
USERSPACE_PROBE_ELF_TESTAPP_NAME=${USERSPACE_PROBE_ELF_TESTAPP_NAME:-"userspace-probe-elf-binary"}
USERSPACE_PROBE_ELF_TESTAPP_BIN=${USERSPACE_PROBE_ELF_TESTAPP_BIN:-"$TESTAPP_PATH/$USERSPACE_PROBE_ELF_TESTAPP_NAME/.libs/$USERSPACE_PROBE_ELF_TESTAPP_NAME"}
+# shellcheck source=../utils/utils.sh
+source "$GENERATOR_TESTDIR/utils/utils.sh"
+
function generate_filter_events
{
local nr=$1
local nr=$1
shift
- for i in $(seq 1 "$nr"); do
+ for _ in $(seq 1 "$nr"); do
# Pass /dev/null so to generate the syscall right away.
$SYSCALL_TESTAPP_BIN /dev/null "$@"
done
local nr=$1
shift
- for i in $(seq 1 "$nr"); do
+ for _ in $(seq 1 "$nr"); do
# This userspace probe test has to instrument the actual elf
# binary and not the generated libtool wrapper. However, we
# can't invoke the wrapper either since it will re-link the test
run=true
sleep 0.5
elif [ "$run" = true ]; then
- taskset -c 0 "$test_app" -i "$nr_iter" -w "$nr_usec_wait" "$@"> /dev/null 2>&1
+ taskset -c "$(get_any_available_cpu)" "$test_app" -i "$nr_iter" -w "$nr_usec_wait" "$@"> /dev/null 2>&1
run=false;
if [[ -f $state_file ]]; then
rm -rf "$state_file" 2> /dev/null
# Reset the "run" state
sleep 0.5
else
- taskset -c 0 "$test_app" -i $nr_iter -w $nr_usec_wait "$@" > /dev/null 2>&1
+ taskset -c "$(get_any_available_cpu)" "$test_app" -i $nr_iter -w $nr_usec_wait "$@" > /dev/null 2>&1
if [[ -f $state_file ]]; then
rm -rf "$state_file" 2> /dev/null
fi
function generate_filter_events_cpu0()
{
- # Generate many events (fill buffers) on CPU 0
- taskset 0x00000001 /bin/echo -n "$1" > /proc/lttng-test-filter-event 2> /dev/null
+ # Generate many events (fill buffers) on a single CPU
+ taskset --cpu-list "$(get_any_available_cpu)" /bin/echo -n "$1" > /proc/lttng-test-filter-event 2> /dev/null
}
function test_kernel_local_snapshot_discard ()
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"
}
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()
{