diff mbox series

[1/5] selftests: skip mincore.check_file_mmap when fs lacks needed support

Message ID 20220126102723.23300-2-cristian.marussi@arm.com (mailing list archive)
State Accepted
Headers show
Series Miscellaneous trivial fixes | expand

Commit Message

Cristian Marussi Jan. 26, 2022, 10:27 a.m. UTC
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>
---
This can happen especially on test-automation systems where rootfs can
be configured as being on NFS or virtual disks.
---
 .../selftests/mincore/mincore_selftest.c      | 20 +++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

Comments

Shuah Khan Jan. 27, 2022, 11:23 p.m. UTC | #1
On 1/26/22 3:27 AM, Cristian Marussi wrote:
> 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>
> ---

Thanks. Will apply to linux-kselftest fixes for rc3

thanks,
-- Shuah
diff mbox series

Patch

diff --git a/tools/testing/selftests/mincore/mincore_selftest.c b/tools/testing/selftests/mincore/mincore_selftest.c
index e54106643337..4c88238fc8f0 100644
--- a/tools/testing/selftests/mincore/mincore_selftest.c
+++ b/tools/testing/selftests/mincore/mincore_selftest.c
@@ -207,15 +207,21 @@  TEST(check_file_mmap)
 
 	errno = 0;
 	fd = open(".", O_TMPFILE | O_RDWR, 0600);
-	ASSERT_NE(-1, fd) {
-		TH_LOG("Can't create temporary file: %s",
-			strerror(errno));
+	if (fd < 0) {
+		ASSERT_EQ(errno, EOPNOTSUPP) {
+			TH_LOG("Can't create temporary file: %s",
+			       strerror(errno));
+		}
+		SKIP(goto out_free, "O_TMPFILE not supported by filesystem.");
 	}
 	errno = 0;
 	retval = fallocate(fd, 0, 0, FILE_SIZE);
-	ASSERT_EQ(0, retval) {
-		TH_LOG("Error allocating space for the temporary file: %s",
-			strerror(errno));
+	if (retval) {
+		ASSERT_EQ(errno, EOPNOTSUPP) {
+			TH_LOG("Error allocating space for the temporary file: %s",
+			       strerror(errno));
+		}
+		SKIP(goto out_close, "fallocate not supported by filesystem.");
 	}
 
 	/*
@@ -271,7 +277,9 @@  TEST(check_file_mmap)
 	}
 
 	munmap(addr, FILE_SIZE);
+out_close:
 	close(fd);
+out_free:
 	free(vec);
 }