[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <52c056a4d319070d2f36b59a8ef0b739ee84fdbc.1687344643.git.falcon@tinylab.org>
Date: Wed, 21 Jun 2023 21:21:12 +0800
From: Zhangjin Wu <falcon@...ylab.org>
To: w@....eu
Cc: thomas@...ch.de, arnd@...db.de, falcon@...ylab.org,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org
Subject: [PATCH v1 17/17] selftests/nolibc: vfprintf: support tmpfs and hugetlbfs
When CONFIG_TMPFS not enabled, kernel will use the ramfs based tmpfs
instead, but memfd_create doesn't work with such tmpfs, for this type of
tmpfs, let's use it instead of memfd_create.
At the same time, let's support hugetlbfs too if there is one.
Signed-off-by: Zhangjin Wu <falcon@...ylab.org>
---
tools/testing/selftests/nolibc/nolibc-test.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index 85fa64746cde..bff72365a158 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -796,6 +796,14 @@ static int expect_vfprintf(int llen, size_t c, const char *expected, const char
if (fd == -1)
fd = memfd_create("vfprintf", 0);
+ /* memfd_create not work with ramfs based tmpfs, try tmpfs and hugetlbfs in order instead */
+ if (fd == -1) {
+ if (tmpfs)
+ fd = open("/tmp/vfprintf", O_CREAT | O_TRUNC | O_RDWR);
+ else if (hugetlbfs)
+ fd = open("/hugetlb/vfprintf", O_CREAT | O_TRUNC | O_RDWR);
+ }
+
if (fd == -1) {
pad_spc(llen, 64, "[FAIL]\n");
return 1;
--
2.25.1
Powered by blists - more mailing lists