3 # SPDX-FileCopyrightText: 2023 EfficiOS Inc.
5 # SPDX-License-Identifier: GPL-2.0-or-later
7 if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then
8 UTILSSH
="$URCU_TESTS_SRCDIR/utils/utils.sh"
10 UTILSSH
="$(dirname "$0")/../utils/utils.sh"
13 # shellcheck source=../utils/utils.sh
16 # shellcheck source=../../utils/tap.sh
17 source "$URCU_TESTS_SRCDIR/utils/tap.sh"
19 CURDIR
="${URCU_TESTS_BUILDDIR}/unit"
21 STD_OUTPUT
="/dev/null"
33 for i
in "${cpus[@]}"; do
38 test_get_max_cpuid_from_sysfs_cxx
() {
41 local current_cpus
=("$@")
44 populate_testdir
"${current_cpus[@]}" >"$STD_OUTPUT" 2>"$STD_ERROR"
45 result
=$
("${CURDIR}/get_max_cpuid_from_sysfs_cxx" "$TESTDIR")
46 is
"$result" "$num_cpus" "get_max_cpuid_from_sysfs_cxx - cpu set: '${current_cpus[*]}', expected: '$num_cpus', result: '$result'"
50 if [ "$URCU_TESTS_OS_TYPE" == "linux" ]; then
53 diag
"get_max_cpuid_from_sysfs_cxx"
56 test_get_max_cpuid_from_sysfs_cxx
"${test_data[@]}"
58 test_data
=(1 "cpu0" "cpu1")
59 test_get_max_cpuid_from_sysfs_cxx
"${test_data[@]}"
61 test_data
=(1 "cpu1" "cpu0")
62 test_get_max_cpuid_from_sysfs_cxx
"${test_data[@]}"
65 test_get_max_cpuid_from_sysfs_cxx
"${test_data[@]}"
67 test_data
=(99 "cpu99")
68 test_get_max_cpuid_from_sysfs_cxx
"${test_data[@]}"
70 test_data
=(3 "cpu0" "cpu3")
71 test_get_max_cpuid_from_sysfs_cxx
"${test_data[@]}"
73 test_data
=(3 "cpufreq" "cpuidle" "cpu0" "cpu1" "cpu2" "cpu3")
74 test_get_max_cpuid_from_sysfs_cxx
"${test_data[@]}"
76 test_data
=(0 "cpu" "cpu0")
77 test_get_max_cpuid_from_sysfs_cxx
"${test_data[@]}"
79 test_data
=(5 "cpu" "cpu5")
80 test_get_max_cpuid_from_sysfs_cxx
"${test_data[@]}"
84 test_get_max_cpuid_from_sysfs_cxx
"${test_data[@]}"
87 test_get_max_cpuid_from_sysfs_cxx
"${test_data[@]}"
89 test_data
=(-1 "cpua" "cpud")
90 test_get_max_cpuid_from_sysfs_cxx
"${test_data[@]}"
92 test_data
=(-1 "cpufreq" "cpuidle")
93 test_get_max_cpuid_from_sysfs_cxx
"${test_data[@]}"
95 plan_skip_all
"Linux specific tests."