The tmpfile-backed COW cases allocate a one-page file with fallocate()
before exercising private and shared mappings.  When the filesystem
backing tmpfile() does not implement fallocate(), setup fails with
EOPNOTSUPP and no COW behavior is exercised.

This occurs when the temporary directory resides on a filesystem with
limited allocation support, such as NFSv3.  Reporting a failure adds
noise because the test prerequisite is absent rather than the COW
implementation being broken.

Report EOPNOTSUPP as a skip.  Continue treating every other fallocate()
error as a failure so unexpected setup regressions remain visible.

Signed-off-by: Muhammad Usama Anjum <[email protected]>
---
 tools/testing/selftests/mm/cow.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c
index 0c627ea89ff7b..c1b8920e29342 100644
--- a/tools/testing/selftests/mm/cow.c
+++ b/tools/testing/selftests/mm/cow.c
@@ -1718,8 +1718,13 @@ static void run_with_tmpfile(non_anon_test_fn fn, const 
char *desc)
 
        /* File consists of a single page filled with zeroes. */
        if (fallocate(fd, 0, 0, pagesize)) {
-               ksft_perror("fallocate() failed");
-               log_test_result(KSFT_FAIL);
+               if (errno == EOPNOTSUPP) {
+                       ksft_print_msg("fallocate() not supported by 
filesystem\n");
+                       log_test_result(KSFT_SKIP);
+               } else {
+                       ksft_perror("fallocate() failed");
+                       log_test_result(KSFT_FAIL);
+               }
                goto close;
        }
 
-- 
2.47.3


Reply via email to