+2009-10-14 Eric Blake <ebb9@byu.net>
+
+ test-stat-time: port to mingw
+ * tests/test-stat-time.c (force_unlink): Return a value.
+ (test_ctime) [W32]: Fix compilation error.
+ (nap): Don't call usleep with too large an argument. Use
+ force_unlink.
+ * doc/pastposix-functions/usleep.texi (usleep): Document the
+ portability issue.
+
2009-10-13 Jim Meyering <meyering@redhat.com>
use AC_CHECK_FUNCS_ONCE, not AC_CHECK_FUNCS in modules/*
@itemize
@item
This function is missing on some platforms:
-IRIX 5.3, Solaris 2.4, mingw, BeOS.
+IRIX 5.3, Solaris 2.4, older mingw, BeOS.
@item
According to POSIX, the @code{usleep} function may interfere with the program's
use of the @code{SIGALRM} signal. On Linux, it doesn't; on other platforms,
it may.
+@item
+On some systems, @code{usleep} rejects attempts to sleep longer than 1
+second, as allowed by POSIX:
+mingw.
@end itemize
enum { NFILES = 4 };
-static void
+static int
force_unlink (const char *filename)
{
/* This chmod is necessary on mingw, where unlink() of a read-only file
fails with EPERM. */
chmod (filename, 0600);
- unlink (filename);
+ return unlink (filename);
}
static void
differ, repeat the test one more time (in case we crossed a
quantization boundary on a file system with 1 second
resolution). If we can't observe a difference in only the
- nanoseconds, then fall back to 2 seconds. */
+ nanoseconds, then fall back to 2 seconds. However, note that
+ usleep (2000000) is allowed to fail with EINVAL. */
struct stat st1;
struct stat st2;
ASSERT (stat ("t-stt-stamp1", &st1) == 0);
- ASSERT (unlink ("t-stt-stamp1") == 0);
+ ASSERT (force_unlink ("t-stt-stamp1") == 0);
delay = 15000;
usleep (delay);
create_file ("t-stt-stamp1");
{
/* Seconds differ, give it one more shot. */
st1 = st2;
- ASSERT (unlink ("t-stt-stamp1") == 0);
+ ASSERT (force_unlink ("t-stt-stamp1") == 0);
usleep (delay);
create_file ("t-stt-stamp1");
ASSERT (stat ("t-stt-stamp1", &st2) == 0);
&& get_stat_mtime_ns (&st1) < get_stat_mtime_ns (&st2)))
delay = 2000000;
}
- usleep (delay);
+ if (delay == 2000000)
+ sleep (2);
+ else
+ usleep (delay);
#endif /* HAVE_USLEEP */
}
st_ctime is either the same as st_mtime (plus or minus an offset)
or set to the file _creation_ time, and is not influenced by rename
or chmod. */
-# define test_ctime ((void) 0)
+# define test_ctime(ignored) ((void) 0)
#else
static void
test_ctime (const struct stat *statinfo)
{
int i;
- /* Collect the birth times.. */
+ /* Collect the birth times. */
for (i = 0; i < NFILES; ++i)
{
birthtimes[i] = get_stat_birthtime (&statinfo[i]);