Hi Bruno,

On your NetBSD test failures you had these:

> FAIL: test-fdutimensat
> ======================
>
> ../../gltests/test-utimens.h:75: assertion 'func (BASE "file", ts) == -1' 
> failed
> FAIL test-fdutimensat (exit status: 134)
>
> FAIL: test-futimens
> ===================
>
> ../../gltests/test-futimens.h:170: assertion 'ctime_compare (&st3, &st2) < 0' 
> failed
> FAIL test-futimens (exit status: 134)
>
> FAIL: test-utimens
> ==================
>
> ../../gltests/test-utimens.h:149: assertion 'ctime_compare (&st3, &st2) < 0' 
> failed
> FAIL test-utimens (exit status: 134)
>
> FAIL: test-utimensat
> ====================
>
> ../../gltests/test-utimens.h:75: assertion 'func (BASE "file", ts) == -1' 
> failed
> FAIL test-utimensat (exit status: 134)

I started looking into it. The two test cases 'test-utimensat' and
'test-fdutimensat' both fail in test-utimens.h on line 75.

It appears that NetBSD doesn't properly check the tv_nsec like a few
other platforms. This diff seems to be the correct way of handling it:

$ git diff master
diff --git a/lib/utimensat.c b/lib/utimensat.c
index 1321264269..ed7b2c22fc 100644
--- a/lib/utimensat.c
+++ b/lib/utimensat.c
@@ -133,8 +133,9 @@ rpl_utimensat (int fd, char const *file, struct timespec 
const times[2],
         }
 #   endif
 #  endif
-#  if defined __APPLE__ && defined __MACH__
-      /* macOS 10.13 does not reject invalid tv_nsec values either.  */
+#  if (defined __APPLE__ && defined __MACH__) || defined __NetBSD__
+      /* macOS 10.13 and NetBSD 10.0 do not reject invalid tv_nsec values
+         either.  */
       if (times
           && ((times[0].tv_nsec != UTIME_OMIT
                && times[0].tv_nsec != UTIME_NOW
@@ -148,6 +149,8 @@ rpl_utimensat (int fd, char const *file, struct timespec 
const times[2],
           errno = EINVAL;
           return -1;
         }
+      /* macOS 10.13 does not handle trailing slashes correctly.  */
+#   ifndef __NetBSD__
       size_t len = strlen (file);
       if (len > 0 && file[len - 1] == '/')
         {
@@ -160,6 +163,7 @@ rpl_utimensat (int fd, char const *file, struct timespec 
const times[2],
               return -1;
             }
         }
+#   endif
 #  endif
       result = utimensat (fd, file, times, flag);
       /* Linux kernel 2.6.25 has a bug where it returns EINVAL for


With that those two test cases seem to fail for the same reason as the
others:

    $ ./gltests/test-fdutimensat 
    test-utimens.h:149: assertion 'ctime_compare (&st3, &st2) < 0' failed
    $ ./gltests/test-utimensat   
    test-utimens.h:149: assertion 'ctime_compare (&st3, &st2) < 0' failed

It looks like the behavior is different when one argument has
tv_nsec == 0 and the other has tv_nsec == UTIME_OMIT. But I am not
very familiar with these functions.

Collin

Reply via email to