public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/1] test_zero_hugepage.sh: Detect errors write to /proc/sys/vm/nr_hugepages
@ 2021-11-04 16:45 Petr Vorel
  2021-11-08  7:31 ` Li Wang
  0 siblings, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2021-11-04 16:45 UTC (permalink / raw)
  To: ltp

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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-09  9:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-04 16:45 [LTP] [PATCH 1/1] test_zero_hugepage.sh: Detect errors write to /proc/sys/vm/nr_hugepages Petr Vorel
2021-11-08  7:31 ` Li Wang
2021-11-08 10:17   ` Petr Vorel
2021-11-08 14:34     ` Cyril Hrubis
2021-11-09  0:51       ` xuyang2018.jy
2021-11-09  9:43         ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox