uatomic/x86: Remove redundant memory barriers
[urcu.git] / tests / unit / test_get_max_cpuid_from_sysfs
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-later
3
4 if [ "x${URCU_TESTS_SRCDIR:-}" != "x" ]; then
5 UTILSSH="$URCU_TESTS_SRCDIR/utils/utils.sh"
6 else
7 UTILSSH="$(dirname "$0")/../utils/utils.sh"
8 fi
9
10 # shellcheck source=../utils/utils.sh
11 source "$UTILSSH"
12
13 # shellcheck source=../../utils/tap.sh
14 source "$URCU_TESTS_SRCDIR/utils/tap.sh"
15
16 CURDIR="${URCU_TESTS_BUILDDIR}/unit"
17
18 STD_OUTPUT="/dev/null"
19 STD_ERROR="/dev/null"
20
21 NUM_TESTS=13
22
23 TESTDIR=$(mktemp -d)
24
25 populate_testdir() {
26 local cpus=("$@")
27
28 mkdir "$TESTDIR"
29
30 for i in "${cpus[@]}"; do
31 mkdir "$TESTDIR/$i"
32 done
33 }
34
35 test_get_max_cpuid_from_sysfs() {
36 local num_cpus=$1
37 shift
38 local current_cpus=("$@")
39 local result
40
41 populate_testdir "${current_cpus[@]}" >"$STD_OUTPUT" 2>"$STD_ERROR"
42 result=$("${CURDIR}/get_max_cpuid_from_sysfs" "$TESTDIR")
43 is "$result" "$num_cpus" "get_max_cpuid_from_sysfs - cpu set: '${current_cpus[*]}', expected: '$num_cpus', result: '$result'"
44 rm -rf "$TESTDIR"
45 }
46
47 if [ "$URCU_TESTS_OS_TYPE" == "linux" ]; then
48 plan_tests $NUM_TESTS
49
50 diag "get_max_cpuid_from_sysfs"
51
52 test_data=(0 "cpu0")
53 test_get_max_cpuid_from_sysfs "${test_data[@]}"
54
55 test_data=(1 "cpu0" "cpu1")
56 test_get_max_cpuid_from_sysfs "${test_data[@]}"
57
58 test_data=(1 "cpu1" "cpu0")
59 test_get_max_cpuid_from_sysfs "${test_data[@]}"
60
61 test_data=(3 "cpu3")
62 test_get_max_cpuid_from_sysfs "${test_data[@]}"
63
64 test_data=(99 "cpu99")
65 test_get_max_cpuid_from_sysfs "${test_data[@]}"
66
67 test_data=(3 "cpu0" "cpu3")
68 test_get_max_cpuid_from_sysfs "${test_data[@]}"
69
70 test_data=(3 "cpufreq" "cpuidle" "cpu0" "cpu1" "cpu2" "cpu3")
71 test_get_max_cpuid_from_sysfs "${test_data[@]}"
72
73 test_data=(0 "cpu" "cpu0")
74 test_get_max_cpuid_from_sysfs "${test_data[@]}"
75
76 test_data=(5 "cpu" "cpu5")
77 test_get_max_cpuid_from_sysfs "${test_data[@]}"
78
79
80 test_data=(-1 "toto")
81 test_get_max_cpuid_from_sysfs "${test_data[@]}"
82
83 test_data=(-1 "cpu")
84 test_get_max_cpuid_from_sysfs "${test_data[@]}"
85
86 test_data=(-1 "cpua" "cpud")
87 test_get_max_cpuid_from_sysfs "${test_data[@]}"
88
89 test_data=(-1 "cpufreq" "cpuidle")
90 test_get_max_cpuid_from_sysfs "${test_data[@]}"
91 else
92 plan_skip_all "Linux specific tests."
93 fi
This page took 0.031736 seconds and 4 git commands to generate.