Skip to content

Commit 1151559

Browse files
x-y-zakpm00
authored andcommitted
selftests/mm: skip hugevm test if kernel config file is not present
When running hugevm tests in a machine without kernel config present, e.g., a VM running a kernel without CONFIG_IKCONFIG_PROC nor /boot/config-*, skip hugevm tests, which reads kernel config to get page table level information. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Zi Yan <[email protected]> Acked-by: Lorenzo Stoakes <[email protected]> Cc: Adam Sindelar <[email protected]> Cc: Lorenzo Stoakes <[email protected]> Cc: Pedro Falcato <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 6d21130 commit 1151559

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

tools/testing/selftests/mm/va_high_addr_switch.sh

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,20 @@
77
# real test to check that the kernel is configured to support at least 5
88
# pagetable levels.
99

10-
# 1 means the test failed
11-
exitcode=1
12-
1310
# Kselftest framework requirement - SKIP code is 4.
1411
ksft_skip=4
1512

16-
fail()
13+
skip()
1714
{
1815
echo "$1"
19-
exit $exitcode
16+
exit $ksft_skip
2017
}
2118

2219
check_supported_x86_64()
2320
{
2421
local config="/proc/config.gz"
2522
[[ -f "${config}" ]] || config="/boot/config-$(uname -r)"
26-
[[ -f "${config}" ]] || fail "Cannot find kernel config in /proc or /boot"
23+
[[ -f "${config}" ]] || skip "Cannot find kernel config in /proc or /boot"
2724

2825
# gzip -dcfq automatically handles both compressed and plaintext input.
2926
# See man 1 gzip under '-f'.
@@ -33,36 +30,31 @@ check_supported_x86_64()
3330
else {print 1}; exit}' /proc/cpuinfo 2>/dev/null)
3431

3532
if [[ "${pg_table_levels}" -lt 5 ]]; then
36-
echo "$0: PGTABLE_LEVELS=${pg_table_levels}, must be >= 5 to run this test"
37-
exit $ksft_skip
33+
skip "$0: PGTABLE_LEVELS=${pg_table_levels}, must be >= 5 to run this test"
3834
elif [[ "${cpu_supports_pl5}" -ne 0 ]]; then
39-
echo "$0: CPU does not have the necessary la57 flag to support page table level 5"
40-
exit $ksft_skip
35+
skip "$0: CPU does not have the necessary la57 flag to support page table level 5"
4136
fi
4237
}
4338

4439
check_supported_ppc64()
4540
{
4641
local config="/proc/config.gz"
4742
[[ -f "${config}" ]] || config="/boot/config-$(uname -r)"
48-
[[ -f "${config}" ]] || fail "Cannot find kernel config in /proc or /boot"
43+
[[ -f "${config}" ]] || skip "Cannot find kernel config in /proc or /boot"
4944

5045
local pg_table_levels=$(gzip -dcfq "${config}" | grep PGTABLE_LEVELS | cut -d'=' -f 2)
5146
if [[ "${pg_table_levels}" -lt 5 ]]; then
52-
echo "$0: PGTABLE_LEVELS=${pg_table_levels}, must be >= 5 to run this test"
53-
exit $ksft_skip
47+
skip "$0: PGTABLE_LEVELS=${pg_table_levels}, must be >= 5 to run this test"
5448
fi
5549

5650
local mmu_support=$(grep -m1 "mmu" /proc/cpuinfo | awk '{print $3}')
5751
if [[ "$mmu_support" != "radix" ]]; then
58-
echo "$0: System does not use Radix MMU, required for 5-level paging"
59-
exit $ksft_skip
52+
skip "$0: System does not use Radix MMU, required for 5-level paging"
6053
fi
6154

6255
local hugepages_total=$(awk '/HugePages_Total/ {print $2}' /proc/meminfo)
6356
if [[ "${hugepages_total}" -eq 0 ]]; then
64-
echo "$0: HugePages are not enabled, required for some tests"
65-
exit $ksft_skip
57+
skip "$0: HugePages are not enabled, required for some tests"
6658
fi
6759
}
6860

0 commit comments

Comments
 (0)