#!/bin/bash
#
-# Copyright (C) - 2015 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+# Copyright (C) 2015 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
#
-# This library is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation; version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+# SPDX-License-Identifier: LGPL-2.1-only
+
TEST_DESC="UST - Getcpu override plugin"
CURDIR=$(dirname $0)/
TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
TESTAPP_WRAPPER="run-getcpu-override"
NUM_EVENT=256
+EVENT_WAIT_USEC=1
EVENT_NAME="tp:tptest"
NUM_TESTS=20
89 13 63 6 136 153 23 16 47 130 75 62
)
-# Equivalent to the syconf(_SC_NPROCESSORS_CONF) call.
-NPROC=`nproc --all`
-
source $TESTDIR/utils/utils.sh
-if [ ! -x "$CURDIR/.libs/lttng-ust-getcpu-override-test.so" ]; then
- BAIL_OUT "No shared object generated"
-fi
+# Equivalent to the syconf(_SC_NPROCESSORS_CONF) call.
+num_cpus=$(conf_proc_count)
# MUST set TESTDIR before calling those functions
run_app()
{
diag "Launching app without getcpu-plugin wrapper"
- $TESTAPP_BIN $NUM_EVENT
+ $TESTAPP_BIN -i $NUM_EVENT -w $EVENT_WAIT_USEC
ok $? "Application without wrapper done"
}
run_getcpu_plugin_app()
{
diag "Launching app with getcpu-plugin wrapper"
- $CURDIR/$TESTAPP_WRAPPER $TESTAPP_BIN $NUM_EVENT
+ $CURDIR/$TESTAPP_WRAPPER $TESTAPP_BIN -i $NUM_EVENT -w $EVENT_WAIT_USEC
ok $? "Application with wrapper done"
}
ok $? "Sequence seed and cpuid sequence have the same size ${#SEQUENCE_SEED[*]}/${#array_to_compare[*]}"
for (( i = 0; i < ${#SEQUENCE_SEED[*]}; i++ )); do
- if [ "${array_to_compare[$i]}" -ne "$(( ${SEQUENCE_SEED[$i]} % $NPROC))" ]; then
+ if [ "${array_to_compare[$i]}" -ne "$(( ${SEQUENCE_SEED[$i]} % $num_cpus))" ]; then
valid=1
break
fi
echo -n "# array value is "
echo -n "${array_to_compare[$i]}"
echo -n " expected "
- echo "$(( ${SEQUENCE_SEED[$i]} % $NPROC))"
+ echo "$(( ${SEQUENCE_SEED[$i]} % $num_cpus))"
done
diag "Dumping trace"
$BABELTRACE_BIN $TRACE_PATH | awk '{print "# " $0}'
print_test_banner "$TEST_DESC"
+if [ ! -x "$CURDIR/.libs/lttng-ust-getcpu-override-test.so" ]; then
+ skip 0 "No shared object generated. Skipping all tests." $NUM_TESTS && exit 0
+fi
+
+if [ "$num_cpus" -eq "1" ]; then
+ # Skip the test since we cannot perform it as designed since N mod 1
+ # is always equals to zero. There is no point testing this on a system
+ # with a single configured core. LTTng-UST limits the get_cpu function
+ # to return value inside the [0, NUM_CPU - 1] range for a valid event
+ # (present in trace).
+ skip 0 "Test system only have a single thread. Skipping all tests." $NUM_TESTS && exit 0
+fi
+
+
TESTS=(
test_getcpu_override_fail
test_getcpu_override