As fs/Kconfig shows, MEMFD_CREATE depends on TMPFS or HUGETLBFS:
config MEMFD_CREATE
def_bool TMPFS || HUGETLBFS
Let's skip vfprintf test if they are not there.
The /tmp and /hugetlb directories have been created to mount tmpfs and
hugetlbfs respectively, if they are not enabled in kernel configuration,
neither /tmp nor /hugetlb will be created.
Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
---
tools/testing/selftests/nolibc/nolibc-test.c | 11 +++++++++++
1 file changed, 11 insertions(+)
@@ -769,11 +769,22 @@ int run_stdlib(int min, int max)
static int expect_vfprintf(int llen, size_t c, const char *expected, const char *fmt, ...)
{
+ struct stat stat_buf;
int ret, fd, w, r;
+ int tmpfs = 0, hugetlbfs = 0;
char buf[100];
FILE *memfile;
va_list args;
+ /* memfd_create depends on tmpfs or hugetlbfs */
+ tmpfs = stat("/tmp/.", &stat_buf) == 0;
+ hugetlbfs = stat("/hugetlb/.", &stat_buf) == 0;
+
+ if (!tmpfs && !hugetlbfs) {
+ pad_spc(llen, 64, "[SKIPPED]\n");
+ return 0;
+ }
+
/* silence warning for kernel >= v6.2:
*
* "memfd_create() without MFD_EXEC nor MFD_NOEXEC_SEAL, pid=<pid>"