2 * Tests for the utimes functions
4 * utimes, lutimes, futimes, futimesat
16 char tmpfile1
[] = "/tmp/testutimes1.XXXXXX";
17 int tmpfd1
= mkstemp(tmpfile1
);
19 struct timeval times
[2];
21 times
[0].tv_usec
= 14142;
23 times
[1].tv_usec
= 12345;
24 if (-1 == utimes("utimes.c", NULL
)) {
25 perror("utimes failed: ");
28 if (-1 == utimes("utimes.c", times
)) {
29 perror("utimes failed: ");
33 times
[0].tv_usec
= 70711;
35 times
[1].tv_usec
= 23456;
36 if (-1 == futimes(tmpfd1
, NULL
)) {
37 perror("futimes failed: ");
39 if (-1 == futimes(tmpfd1
, times
)) {
40 perror("futimes failed: ");
43 char tmpsymlink
[] = "/tmp/testutimes2.XXXXXX";
46 DIR* tmpdir
= opendir("/tmp");
48 int tmpdirfd
= dirfd(tmpdir
);
50 if (-1 == symlinkat(tmpfile1
+5, tmpdirfd
, tmpsymlink
+5)) {
51 perror("symlinkat failed");
55 times
[0].tv_usec
= 15708;
57 times
[1].tv_usec
= 34567;
59 if (-1 == lutimes(tmpsymlink
, NULL
)) {
60 perror("lutimes failed: ");
63 if (-1 == lutimes(tmpsymlink
, times
)) {
64 perror("lutimes failed: ");
68 times
[0].tv_usec
= 63662;
70 times
[1].tv_usec
= 31831;
72 if (-1 == futimesat(tmpdirfd
, tmpfile1
+5, NULL
)) {
73 perror("fuutimesat failed: ");
76 if (-1 == futimesat(tmpdirfd
, tmpfile1
+5, times
)) {
77 perror("fuutimesat failed: ");
90 char* badstring
= strdup("foo");
94 utimes(badstring
, (struct timeval
*)badstring
);
95 lutimes(badstring
, (struct timeval
*)badstring
);
96 futimes(badint
, (struct timeval
*)badstring
);
97 futimesat(badint
, badstring
, (struct timeval
*)badstring
);