Skip to content

Commit dae1d8a

Browse files
cris-mashuahkh
authored andcommitted
selftests: skip mincore.check_file_mmap when fs lacks needed support
Report mincore.check_file_mmap as SKIP instead of FAIL if the underlying filesystem lacks support of O_TMPFILE or fallocate since such failures are not really related to mincore functionality. Cc: Ricardo Cañuelo <ricardo.canuelo@collabora.com> Signed-off-by: Cristian Marussi <cristian.marussi@arm.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent ac9e0a2 commit dae1d8a

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

tools/testing/selftests/mincore/mincore_selftest.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,21 @@ TEST(check_file_mmap)
207207

208208
errno = 0;
209209
fd = open(".", O_TMPFILE | O_RDWR, 0600);
210-
ASSERT_NE(-1, fd) {
211-
TH_LOG("Can't create temporary file: %s",
212-
strerror(errno));
210+
if (fd < 0) {
211+
ASSERT_EQ(errno, EOPNOTSUPP) {
212+
TH_LOG("Can't create temporary file: %s",
213+
strerror(errno));
214+
}
215+
SKIP(goto out_free, "O_TMPFILE not supported by filesystem.");
213216
}
214217
errno = 0;
215218
retval = fallocate(fd, 0, 0, FILE_SIZE);
216-
ASSERT_EQ(0, retval) {
217-
TH_LOG("Error allocating space for the temporary file: %s",
218-
strerror(errno));
219+
if (retval) {
220+
ASSERT_EQ(errno, EOPNOTSUPP) {
221+
TH_LOG("Error allocating space for the temporary file: %s",
222+
strerror(errno));
223+
}
224+
SKIP(goto out_close, "fallocate not supported by filesystem.");
219225
}
220226

221227
/*
@@ -271,7 +277,9 @@ TEST(check_file_mmap)
271277
}
272278

273279
munmap(addr, FILE_SIZE);
280+
out_close:
274281
close(fd);
282+
out_free:
275283
free(vec);
276284
}
277285

0 commit comments

Comments
 (0)