[LTP] [PATCH 1/1] test_zero_hugepage.sh: Detect errors write to /proc/sys/vm/nr_hugepages
Petr Vorel
pvorel@suse.cz
Thu Nov 4 17:45:28 CET 2021
Fix running make test-c as non-root.
Fixes: 057d6b046 ("lib/tst_hugepage: Fix .request_hugepages = 0 bug")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi,
maybe echo "128" would not have to be checked.
Kind regards,
Petr
lib/newlib_tests/test_zero_hugepage.sh | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/lib/newlib_tests/test_zero_hugepage.sh b/lib/newlib_tests/test_zero_hugepage.sh
index d270e686c..663bd2316 100755
--- a/lib/newlib_tests/test_zero_hugepage.sh
+++ b/lib/newlib_tests/test_zero_hugepage.sh
@@ -3,16 +3,31 @@
# Copyright (c) 2021 Yang Xu <xuyang2018.jy@fujitsu.com>
# Copyright (c) 2021 Petr Vorel <pvorel@suse.cz>
+tconf()
+{
+ echo "TCONF: $1"
+ exit 32
+}
+
echo "Testing .request_hugepages = TST_NO_HUGEPAGES"
orig_value=`cat /proc/sys/vm/nr_hugepages`
if grep -q -E '^proc /proc(/sys)? proc ro' /proc/mounts; then
- echo "TCONF: /proc or /proc/sys mounted as read-only"
- exit 32
+ tconf "/proc or /proc/sys mounted as read-only"
+fi
+
+if [ ! -f /proc/sys/vm/nr_hugepages ]; then
+ tconf "/proc/sys/vm/nr_hugepages does not exist"
+fi
+
+if [ ! -w /proc/sys/vm/nr_hugepages ]; then
+ tconf "no write permission to /proc/sys/vm/nr_hugepages (run as root)"
fi
-echo "128" > /proc/sys/vm/nr_hugepages
+if ! echo "128" > /proc/sys/vm/nr_hugepages; then
+ tconf "Failed to write /proc/sys/vm/nr_hugepages"
+fi
./test_zero_hugepage
--
2.33.1
More information about the ltp
mailing list