11 #define TEST(c, ...) ((c) ? 1 : (t_error(#c" failed: " __VA_ARGS__),0))
12 #define TESTVAL(v,op,x) TEST(v op x, "%jd\n", (intmax_t)(v))
21 TEST(utimensat(AT_FDCWD, "/dev/null/invalid", ((struct timespec[2]){{.tv_nsec=UTIME_OMIT},{.tv_nsec=UTIME_OMIT}}), 0)==0 || errno==ENOTDIR,
22 "%s\n", strerror(errno));
23 TEST(futimens(-1, ((struct timespec[2]){{.tv_nsec=UTIME_OMIT},{.tv_nsec=UTIME_OMIT}}))==0 || errno==EBADF,
24 "%s\n", strerror(errno));
26 if (!TEST(f = tmpfile())) return t_status;
29 TEST(futimens(fd, (struct timespec[2]){0}) == 0, "\n");
30 TEST(fstat(fd, &st) == 0, "\n");
31 TESTVAL(st.st_atim.tv_sec,==,0);
32 TESTVAL(st.st_atim.tv_nsec,==,0);
33 TESTVAL(st.st_mtim.tv_sec,==,0);
34 TESTVAL(st.st_mtim.tv_nsec,==,0);
36 TEST(futimens(fd, ((struct timespec[2]){{.tv_sec=1,.tv_nsec=UTIME_OMIT},{.tv_sec=1,.tv_nsec=UTIME_OMIT}})) == 0, "\n");
37 TEST(fstat(fd, &st) == 0, "\n");
38 TESTVAL(st.st_atim.tv_sec,==,0);
39 TESTVAL(st.st_atim.tv_nsec,==,0);
40 TESTVAL(st.st_mtim.tv_sec,==,0);
41 TESTVAL(st.st_mtim.tv_nsec,==,0);
45 TEST(futimens(fd, ((struct timespec[2]){{.tv_nsec=UTIME_NOW},{.tv_nsec=UTIME_OMIT}})) == 0, "\n");
46 TEST(fstat(fd, &st) == 0, "\n");
47 TESTVAL(st.st_atim.tv_sec,>=,t);
48 TESTVAL(st.st_mtim.tv_sec,==,0);
49 TESTVAL(st.st_mtim.tv_nsec,==,0);
51 TEST(futimens(fd, (struct timespec[2]){0}) == 0, "\n");
52 TEST(futimens(fd, ((struct timespec[2]){{.tv_nsec=UTIME_OMIT},{.tv_nsec=UTIME_NOW}})) == 0, "\n");
53 TEST(fstat(fd, &st) == 0, "\n");
54 TESTVAL(st.st_atim.tv_sec,==,0);
55 TESTVAL(st.st_mtim.tv_sec,>=,t);
57 TEST(futimens(fd, ((struct timespec[2]){{.tv_nsec=UTIME_NOW},{.tv_nsec=UTIME_OMIT}})) == 0, "\n");
58 TEST(fstat(fd, &st) == 0, "\n");
59 TESTVAL(st.st_atim.tv_sec,>=,t);
60 TESTVAL(st.st_mtim.tv_sec,>=,t);
62 if (TEST((time_t)(1LL<<32) == (1LL<<32), "implementation has Y2038 EOL\n")) {
63 if (TEST(futimens(fd, ((struct timespec[2]){{.tv_sec=1LL<<32},{.tv_sec=1LL<<32}})) == 0, "%s\n", strerror(errno))) {
64 TEST(fstat(fd, &st) == 0, "\n");
65 TESTVAL(st.st_atim.tv_sec, ==, 1LL<<32);
66 TESTVAL(st.st_mtim.tv_sec, ==, 1LL<<32);