[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20250102064807.404607-2-po-hsu.lin@canonical.com>
Date: Thu, 2 Jan 2025 14:48:07 +0800
From: Po-Hsu Lin <po-hsu.lin@...onical.com>
To: linux-kselftest@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
shuah@...nel.org,
po-hsu.lin@...onical.com
Subject: [PATCH 1/1] selftests/memfd: skip hugetlbfs test if it's not supported
Handle the case that hugetlbfs is not supported. To make it easier
for debugging.
On a system that does not support hugetlbfs. There will be no such
HugePages_Free entry in /proc/meminfo. And consequently freepgs will
be empty. The huge pages availability check will fail and the test
will be started anyway:
./run_hugetlbfs_test.sh: line 47: [: -lt: unary operator expected
./run_hugetlbfs_test.sh: line 60: 12577 Aborted
(core dumped) ./memfd_test hugetlbfs
Aborted (core dumped)
Signed-off-by: Po-Hsu Lin <po-hsu.lin@...onical.com>
---
tools/testing/selftests/memfd/run_hugetlbfs_test.sh | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/memfd/run_hugetlbfs_test.sh b/tools/testing/selftests/memfd/run_hugetlbfs_test.sh
index fb633eeb0290..9bbd30ced9c5 100755
--- a/tools/testing/selftests/memfd/run_hugetlbfs_test.sh
+++ b/tools/testing/selftests/memfd/run_hugetlbfs_test.sh
@@ -19,10 +19,13 @@ while read name size unit; do
fi
done < /proc/meminfo
+if [ -z "$freepgs" ]; then
+ echo "hugetlbfs not supported, test skipped."
+ exit $ksft_skip
#
# If not enough free huge pages for test, attempt to increase
#
-if [ -n "$freepgs" ] && [ $freepgs -lt $hpages_test ]; then
+elif [ -n "$freepgs" ] && [ $freepgs -lt $hpages_test ]; then
nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
hpages_needed=`expr $hpages_test - $freepgs`
--
2.34.1
Powered by blists - more mailing lists