xref: /minix3/minix/tests/test16.c (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1*433d6423SLionel Sambuc /* test 16 */
2*433d6423SLionel Sambuc 
3*433d6423SLionel Sambuc #include <sys/types.h>
4*433d6423SLionel Sambuc #include <sys/stat.h>
5*433d6423SLionel Sambuc #include <errno.h>
6*433d6423SLionel Sambuc #include <fcntl.h>
7*433d6423SLionel Sambuc #include <stdlib.h>
8*433d6423SLionel Sambuc #include <unistd.h>
9*433d6423SLionel Sambuc #include <utime.h>
10*433d6423SLionel Sambuc #include <stdio.h>
11*433d6423SLionel Sambuc 
12*433d6423SLionel Sambuc int max_error = 4;
13*433d6423SLionel Sambuc #include "common.h"
14*433d6423SLionel Sambuc 
15*433d6423SLionel Sambuc 
16*433d6423SLionel Sambuc int subtest, passes;
17*433d6423SLionel Sambuc int V1filesystem = 0;
18*433d6423SLionel Sambuc 
19*433d6423SLionel Sambuc 
20*433d6423SLionel Sambuc int main(int argc, char *argv []);
21*433d6423SLionel Sambuc void test16init(void);
22*433d6423SLionel Sambuc void test16a(void);
23*433d6423SLionel Sambuc void test16b(void);
24*433d6423SLionel Sambuc void test16c(void);
25*433d6423SLionel Sambuc void test16d(void);
26*433d6423SLionel Sambuc void test16e(void);
27*433d6423SLionel Sambuc void test16f(void);
28*433d6423SLionel Sambuc void test16g(void);
29*433d6423SLionel Sambuc void test16h(void);
30*433d6423SLionel Sambuc void get_times(char *name, time_t *a, time_t *c, time_t *m);
31*433d6423SLionel Sambuc 
main(argc,argv)32*433d6423SLionel Sambuc int main(argc, argv)
33*433d6423SLionel Sambuc int argc;
34*433d6423SLionel Sambuc char *argv[];
35*433d6423SLionel Sambuc {
36*433d6423SLionel Sambuc   int i, m;
37*433d6423SLionel Sambuc 
38*433d6423SLionel Sambuc   start(16);
39*433d6423SLionel Sambuc 
40*433d6423SLionel Sambuc   m = (argc == 2 ? atoi(argv[1]) : 0xFFFF);
41*433d6423SLionel Sambuc 
42*433d6423SLionel Sambuc 
43*433d6423SLionel Sambuc   for (i = 0; i < 4; i++) {
44*433d6423SLionel Sambuc 	test16init();
45*433d6423SLionel Sambuc 	if (m & 0001) test16a();
46*433d6423SLionel Sambuc 	if (m & 0002) test16b();
47*433d6423SLionel Sambuc 	if (m & 0004) test16c();
48*433d6423SLionel Sambuc 	if (m & 0010) test16d();
49*433d6423SLionel Sambuc 	if (m & 0020) test16e();
50*433d6423SLionel Sambuc 	if (m & 0040) test16f();
51*433d6423SLionel Sambuc 	if (m & 0100) test16g();
52*433d6423SLionel Sambuc 	if (m & 0200) test16h();
53*433d6423SLionel Sambuc 	passes++;
54*433d6423SLionel Sambuc   }
55*433d6423SLionel Sambuc   quit();
56*433d6423SLionel Sambuc   return(-1);			/* impossible */
57*433d6423SLionel Sambuc }
58*433d6423SLionel Sambuc 
test16init()59*433d6423SLionel Sambuc void test16init()
60*433d6423SLionel Sambuc {
61*433d6423SLionel Sambuc /* Test atime, ctime, and mtime. */
62*433d6423SLionel Sambuc 
63*433d6423SLionel Sambuc   int fd;
64*433d6423SLionel Sambuc   char buf[1024];
65*433d6423SLionel Sambuc   struct stat s;
66*433d6423SLionel Sambuc 
67*433d6423SLionel Sambuc   subtest = 0;
68*433d6423SLionel Sambuc   if (passes > 0) return;	/* takes too long to repeat this test */
69*433d6423SLionel Sambuc   if (V1filesystem) return;	/* no need to spend time testing lacking features */
70*433d6423SLionel Sambuc 
71*433d6423SLionel Sambuc   if ( (fd = creat("T16.a", 0666)) < 0) e(1);
72*433d6423SLionel Sambuc   if (write(fd, buf, 1024) != 1024) e(2);
73*433d6423SLionel Sambuc   if (close(fd) < 0) e(3);
74*433d6423SLionel Sambuc   sleep(1);			/* wait 1 sec before continuing */
75*433d6423SLionel Sambuc   if ( (fd = open("T16.a", O_RDONLY)) < 0) e(4);
76*433d6423SLionel Sambuc   if (read(fd, buf, 3) != 3) e(5);
77*433d6423SLionel Sambuc   if (close(fd) != 0) e(6);
78*433d6423SLionel Sambuc   if (stat("T16.a", &s) != 0) e(7);
79*433d6423SLionel Sambuc   if (s.st_atime == 0) {
80*433d6423SLionel Sambuc 	/* Almost certainly means we are running a V1 file system. */
81*433d6423SLionel Sambuc 	printf(" (atime = 0. Probably V1 file system.  V2+ tests skipped.) ");
82*433d6423SLionel Sambuc 	V1filesystem = 1;
83*433d6423SLionel Sambuc   }
84*433d6423SLionel Sambuc }
85*433d6423SLionel Sambuc 
86*433d6423SLionel Sambuc   /* Many system calls affect atime, ctime, and mtime.  Test them.  They
87*433d6423SLionel Sambuc    * fall into several groups.  The members of each group can be tested
88*433d6423SLionel Sambuc    * together.  Start with creat(), mkdir(), and mkfifo, all of which
89*433d6423SLionel Sambuc    * set all 3 times on the created object, and ctime and mtime of the dir.
90*433d6423SLionel Sambuc    */
91*433d6423SLionel Sambuc 
test16a()92*433d6423SLionel Sambuc void test16a()
93*433d6423SLionel Sambuc {
94*433d6423SLionel Sambuc /* Test creat(). */
95*433d6423SLionel Sambuc 
96*433d6423SLionel Sambuc   int fd;
97*433d6423SLionel Sambuc   time_t a, c, m, pa, pc, pm;
98*433d6423SLionel Sambuc 
99*433d6423SLionel Sambuc   subtest = 1;
100*433d6423SLionel Sambuc   if (passes > 0) return;	/* takes too long to repeat this test */
101*433d6423SLionel Sambuc   if (V1filesystem) return;	/* no need to spend time testing lacking features */
102*433d6423SLionel Sambuc 
103*433d6423SLionel Sambuc   if ( (fd = creat("T16.b", 0666)) < 0) e(8);
104*433d6423SLionel Sambuc   if (close(fd) != 0) e(9);
105*433d6423SLionel Sambuc   get_times("T16.b", &a, &c, &m);
106*433d6423SLionel Sambuc   get_times(".", &pa, &pc, &pm);
107*433d6423SLionel Sambuc   if (a != c) e(10);
108*433d6423SLionel Sambuc   if (a != m) e(11);
109*433d6423SLionel Sambuc   if (a != pc) e(12);
110*433d6423SLionel Sambuc   if (a != pm) e(13);
111*433d6423SLionel Sambuc   if (unlink("T16.b") < 0) e(14);
112*433d6423SLionel Sambuc }
113*433d6423SLionel Sambuc 
test16b()114*433d6423SLionel Sambuc void test16b()
115*433d6423SLionel Sambuc {
116*433d6423SLionel Sambuc   /* Test the times for mkfifo. */
117*433d6423SLionel Sambuc   int fd;
118*433d6423SLionel Sambuc   time_t a, c, m, pa, pc, pm;
119*433d6423SLionel Sambuc 
120*433d6423SLionel Sambuc   subtest = 2;
121*433d6423SLionel Sambuc   if (passes > 0) return;	/* takes too long to repeat this test */
122*433d6423SLionel Sambuc   if (V1filesystem) return;	/* no need to spend time testing lacking features */
123*433d6423SLionel Sambuc 
124*433d6423SLionel Sambuc   if  ( (fd = mkfifo("T16.c", 0666)) != 0) e(15);
125*433d6423SLionel Sambuc   if (access("T16.c", R_OK | W_OK) != 0) e(16);
126*433d6423SLionel Sambuc   get_times("T16.c", &a, &c, &m);
127*433d6423SLionel Sambuc   get_times(".", &pa, &pc, &pm);
128*433d6423SLionel Sambuc   if (a != c) e(17);
129*433d6423SLionel Sambuc   if (a != m) e(18);
130*433d6423SLionel Sambuc   if (a != pc) e(19);
131*433d6423SLionel Sambuc   if (a != pm) e(20);
132*433d6423SLionel Sambuc   if (unlink("T16.c") < 0) e(21);
133*433d6423SLionel Sambuc }
134*433d6423SLionel Sambuc 
test16c()135*433d6423SLionel Sambuc void test16c()
136*433d6423SLionel Sambuc {
137*433d6423SLionel Sambuc   /* Test the times for mkdir. */
138*433d6423SLionel Sambuc   time_t a, c, m, pa, pc, pm, xa, xc, xm;
139*433d6423SLionel Sambuc 
140*433d6423SLionel Sambuc   subtest = 3;
141*433d6423SLionel Sambuc   if (passes > 0) return;	/* takes too long to repeat this test */
142*433d6423SLionel Sambuc   if (V1filesystem) return;	/* no need to spend time testing lacking features */
143*433d6423SLionel Sambuc 
144*433d6423SLionel Sambuc   if (mkdir("T16.d", 0666) < 0) e(22);
145*433d6423SLionel Sambuc   get_times("T16.d", &a, &c, &m);
146*433d6423SLionel Sambuc   get_times(".", &pa, &pc, &pm);
147*433d6423SLionel Sambuc   if (a != c) e(23);
148*433d6423SLionel Sambuc   if (a != m) e(24);
149*433d6423SLionel Sambuc   if (a != pc) e(25);
150*433d6423SLionel Sambuc   if (a != pm) e(26);
151*433d6423SLionel Sambuc   sleep(1);
152*433d6423SLionel Sambuc   if (rmdir("T16.d") < 0) e(27);
153*433d6423SLionel Sambuc   get_times(".", &xa, &xc, &xm);
154*433d6423SLionel Sambuc   if (c == xc) e(28);
155*433d6423SLionel Sambuc   if (m == xm) e(29);
156*433d6423SLionel Sambuc   if (xc != xm) e(30);
157*433d6423SLionel Sambuc }
158*433d6423SLionel Sambuc 
test16d()159*433d6423SLionel Sambuc void test16d()
160*433d6423SLionel Sambuc {
161*433d6423SLionel Sambuc   /* Test open(file, O_TRUNC). */
162*433d6423SLionel Sambuc   int fd;
163*433d6423SLionel Sambuc   time_t a, c, m, pa, pc, pm, xa, xc, xm, ya, yc, ym;
164*433d6423SLionel Sambuc   char buf[1024];
165*433d6423SLionel Sambuc 
166*433d6423SLionel Sambuc   subtest = 4;
167*433d6423SLionel Sambuc   if (passes > 0) return;	/* takes too long to repeat this test */
168*433d6423SLionel Sambuc   if (V1filesystem) return;	/* no need to spend time testing lacking features */
169*433d6423SLionel Sambuc 
170*433d6423SLionel Sambuc   if ( (fd = open("T16.e", O_WRONLY|O_CREAT, 0666)) < 0) e(31);
171*433d6423SLionel Sambuc   if (write(fd, buf, 1024) != 1024) e(32);
172*433d6423SLionel Sambuc   if (close(fd) != 0) e(33);
173*433d6423SLionel Sambuc   get_times("T16.e", &a, &c, &m);
174*433d6423SLionel Sambuc   get_times(".", &pa, &pc, &pm);
175*433d6423SLionel Sambuc   sleep(1);
176*433d6423SLionel Sambuc   if ( (fd = open("T16.e", O_WRONLY|O_TRUNC)) < 0) e(34);
177*433d6423SLionel Sambuc   get_times("T16.e", &xa, &xc, &xm);
178*433d6423SLionel Sambuc   get_times(".", &ya, &yc, &ym);
179*433d6423SLionel Sambuc   if (c != m) e(35);
180*433d6423SLionel Sambuc   if (pc != pm) e(36);
181*433d6423SLionel Sambuc   if (c == xc) e(37);
182*433d6423SLionel Sambuc   if (m == xm) e(38);
183*433d6423SLionel Sambuc   if (yc != pc) e(39);
184*433d6423SLionel Sambuc   if (ym != pm) e(40);
185*433d6423SLionel Sambuc   if (close(fd) != 0) e(41);
186*433d6423SLionel Sambuc   /* Try once more, now without changing the file size. */
187*433d6423SLionel Sambuc   sleep(1);
188*433d6423SLionel Sambuc   if ( (fd = open("T16.e", O_WRONLY|O_TRUNC)) < 0) e(89);
189*433d6423SLionel Sambuc   get_times("T16.e", &a, &c, &m);
190*433d6423SLionel Sambuc   if (c != m) e(90);
191*433d6423SLionel Sambuc   if (c == xc) e(91);
192*433d6423SLionel Sambuc   if (m == xm) e(92);
193*433d6423SLionel Sambuc   if (close(fd) != 0) e(93);
194*433d6423SLionel Sambuc }
195*433d6423SLionel Sambuc 
test16e()196*433d6423SLionel Sambuc void test16e()
197*433d6423SLionel Sambuc {
198*433d6423SLionel Sambuc   /* Test the times for link/unlink. */
199*433d6423SLionel Sambuc   time_t a, c, m, pa, pc, pm, xa, xc, xm, ya, yc, ym;
200*433d6423SLionel Sambuc 
201*433d6423SLionel Sambuc   subtest = 5;
202*433d6423SLionel Sambuc   if (passes > 0) return;	/* takes too long to repeat this test */
203*433d6423SLionel Sambuc   if (V1filesystem) return;	/* no need to spend time testing lacking features */
204*433d6423SLionel Sambuc 
205*433d6423SLionel Sambuc   get_times("T16.e", &a, &c, &m);
206*433d6423SLionel Sambuc   get_times(".", &ya, &yc, &ym);
207*433d6423SLionel Sambuc   sleep(1);
208*433d6423SLionel Sambuc   if (link("T16.e", "T16.f") != 0) e(42);	/* second link */
209*433d6423SLionel Sambuc   get_times("T16.e", &xa, &xc, &xm);
210*433d6423SLionel Sambuc   get_times(".", &pa, &pc, &pm);
211*433d6423SLionel Sambuc   if (a != xa) e(43);
212*433d6423SLionel Sambuc   if (m != xm) e(44);
213*433d6423SLionel Sambuc #ifndef V1_FILESYSTEM
214*433d6423SLionel Sambuc   if (c == xc) e(45);
215*433d6423SLionel Sambuc #endif
216*433d6423SLionel Sambuc   if (ya != pa) e(46);
217*433d6423SLionel Sambuc   if (yc == pc) e(47);
218*433d6423SLionel Sambuc   if (ym == pm) e(48);
219*433d6423SLionel Sambuc   if (yc != ym) e(49);
220*433d6423SLionel Sambuc   if (pc != pm) e(50);
221*433d6423SLionel Sambuc   sleep(1);
222*433d6423SLionel Sambuc   if (unlink("T16.f") != 0) e(46);
223*433d6423SLionel Sambuc   get_times("T16.e", &a, &c, &m);
224*433d6423SLionel Sambuc   get_times(".", &ya, &yc, &ym);
225*433d6423SLionel Sambuc   if (a != xa) e(51);
226*433d6423SLionel Sambuc   if (m != xm) e(52);
227*433d6423SLionel Sambuc #ifndef V1_FILESYSTEM
228*433d6423SLionel Sambuc   if (c == xc) e(53);
229*433d6423SLionel Sambuc #endif
230*433d6423SLionel Sambuc   if (pa != ya) e(54);
231*433d6423SLionel Sambuc   if (pc == yc) e(55);
232*433d6423SLionel Sambuc   if (pm == ym) e(56);
233*433d6423SLionel Sambuc   if (yc != ym) e(57);
234*433d6423SLionel Sambuc   if (unlink("T16.e") != 0) e(58);
235*433d6423SLionel Sambuc }
236*433d6423SLionel Sambuc 
test16f()237*433d6423SLionel Sambuc void test16f()
238*433d6423SLionel Sambuc {
239*433d6423SLionel Sambuc   /* Test rename, read, write, chmod, utime. */
240*433d6423SLionel Sambuc   int fd, fd1, fd2, fd3, fd4;
241*433d6423SLionel Sambuc   time_t a, c, m, pa, pc, pm, xa, xc, xm, ya, yc, ym, za, zc, zm, ta, tc, tm;
242*433d6423SLionel Sambuc   time_t wa, wc, wm;
243*433d6423SLionel Sambuc   char buf[1024];
244*433d6423SLionel Sambuc 
245*433d6423SLionel Sambuc   subtest = 6;
246*433d6423SLionel Sambuc   if (passes > 0) return;	/* takes too long to repeat this test */
247*433d6423SLionel Sambuc   if (V1filesystem) return;	/* no need to spend time testing lacking features */
248*433d6423SLionel Sambuc 
249*433d6423SLionel Sambuc   get_times(".", &pa, &pc, &pm);
250*433d6423SLionel Sambuc   if ( (fd  = open("T16.g", O_RDWR|O_CREAT)) < 0) e(59);
251*433d6423SLionel Sambuc   if ( (fd1 = open("T16.h", O_WRONLY|O_CREAT, 0666)) < 0) e(60);
252*433d6423SLionel Sambuc   if ( (fd2 = open("T16.i", O_WRONLY|O_CREAT, 0666)) < 0) e(61);
253*433d6423SLionel Sambuc   if ( (fd3 = open("T16.j", O_WRONLY|O_CREAT, 0666)) < 0) e(62);
254*433d6423SLionel Sambuc   if ( (fd4 = open("T16.k", O_RDWR|O_CREAT, 0666)) < 0) e(63);
255*433d6423SLionel Sambuc   if (write(fd, buf, 1024) != 1024) e(64);
256*433d6423SLionel Sambuc   get_times("T16.g", &a, &c, &m);
257*433d6423SLionel Sambuc   get_times("T16.h", &pa, &pc, &pm);
258*433d6423SLionel Sambuc   get_times("T16.i", &xa, &xc, &xm);
259*433d6423SLionel Sambuc   get_times("T16.j", &ya, &yc, &ym);
260*433d6423SLionel Sambuc   get_times("T16.k", &za, &zc, &zm);
261*433d6423SLionel Sambuc   get_times(".", &wa, &wc, &wm);
262*433d6423SLionel Sambuc   sleep(1);
263*433d6423SLionel Sambuc   lseek(fd, 0L, SEEK_SET);
264*433d6423SLionel Sambuc   if (read(fd, buf, 35) != 35) e(65);
265*433d6423SLionel Sambuc   get_times("T16.g", &ta, &tc, &tm);
266*433d6423SLionel Sambuc   if (a == ta || c != tc || m != tm) e(66);
267*433d6423SLionel Sambuc   if (write(fd1, buf, 35) != 35) e(67);
268*433d6423SLionel Sambuc   get_times("T16.h", &ta, &tc, &tm);
269*433d6423SLionel Sambuc   if (pa != ta || pc == tc || pm == tm) e(69);
270*433d6423SLionel Sambuc   if (rename("T16.i", "T16.i1") != 0) e(70);
271*433d6423SLionel Sambuc   get_times("T16.i1", &ta, &tc, &tm);
272*433d6423SLionel Sambuc   if (xa != ta || xc != tc || xm != tm) e(71);
273*433d6423SLionel Sambuc   get_times(".", &a, &c, &m);
274*433d6423SLionel Sambuc   if (a != wa || c == wc || m == wm || wc != wm) e(72);
275*433d6423SLionel Sambuc   if (chmod("T16.j", 0777) != 0) e(73);
276*433d6423SLionel Sambuc   get_times("T16.j", &ta, &tc, &tm);
277*433d6423SLionel Sambuc   if (ya != ta || yc == tc || ym != tm) e(74);
278*433d6423SLionel Sambuc   if (utime("T16.k", (void *) 0) != 0) e(75);
279*433d6423SLionel Sambuc   get_times("T16.k", &ta, &tc, &tm);
280*433d6423SLionel Sambuc   if (za == ta || zc == tc) e(76);
281*433d6423SLionel Sambuc   if (close(fd) != 0) e(77);
282*433d6423SLionel Sambuc   if (close(fd1) != 0) e(78);
283*433d6423SLionel Sambuc   if (close(fd2) != 0) e(79);
284*433d6423SLionel Sambuc   if (close(fd3) != 0) e(80);
285*433d6423SLionel Sambuc   if (close(fd4) != 0) e(81);
286*433d6423SLionel Sambuc   if (unlink("T16.g") != 0) e(82);
287*433d6423SLionel Sambuc   if (unlink("T16.h") != 0) e(83);
288*433d6423SLionel Sambuc   if (unlink("T16.i1") != 0) e(84);
289*433d6423SLionel Sambuc   if (unlink("T16.j") != 0) e(85);
290*433d6423SLionel Sambuc   if (unlink("T16.k") != 0) e(86);
291*433d6423SLionel Sambuc }
292*433d6423SLionel Sambuc 
test16g()293*433d6423SLionel Sambuc void test16g()
294*433d6423SLionel Sambuc {
295*433d6423SLionel Sambuc   /* Test the times for truncate. */
296*433d6423SLionel Sambuc   time_t a, c, m, ta, tc, tm;
297*433d6423SLionel Sambuc   struct stat s;
298*433d6423SLionel Sambuc 
299*433d6423SLionel Sambuc   subtest = 7;
300*433d6423SLionel Sambuc   if (passes > 0) return;	/* takes too long to repeat this test */
301*433d6423SLionel Sambuc   if (V1filesystem) return;	/* no need to spend time testing lacking features */
302*433d6423SLionel Sambuc 
303*433d6423SLionel Sambuc   if (system("echo 1 > T16.l") != 0) e(87);
304*433d6423SLionel Sambuc   stat("T16.l", &s);
305*433d6423SLionel Sambuc   get_times("T16.l", &a, &c, &m);
306*433d6423SLionel Sambuc   sleep(1);
307*433d6423SLionel Sambuc   truncate("T16.l", s.st_size);
308*433d6423SLionel Sambuc   get_times("T16.l", &ta, &tc, &tm);
309*433d6423SLionel Sambuc   if (a != ta || c != tc || m != tm) e(88);
310*433d6423SLionel Sambuc 
311*433d6423SLionel Sambuc }
312*433d6423SLionel Sambuc 
test16h()313*433d6423SLionel Sambuc void test16h()
314*433d6423SLionel Sambuc {
315*433d6423SLionel Sambuc   /* Test utimes, futimes, lutimes, futimens, utimensat. */
316*433d6423SLionel Sambuc   int fd, fd1, fd2, fd3, fd4;
317*433d6423SLionel Sambuc   time_t a, c, m, pa, pc, pm;
318*433d6423SLionel Sambuc   time_t ta, tc, tm, wa, wc, wm, xa, xc, xm, ya, yc, ym, za, zc, zm;
319*433d6423SLionel Sambuc 
320*433d6423SLionel Sambuc   subtest = 8;
321*433d6423SLionel Sambuc   if (passes > 0) return;	/* takes too long to repeat this test */
322*433d6423SLionel Sambuc   if (V1filesystem) return;	/* no need to spend time testing lacking features */
323*433d6423SLionel Sambuc 
324*433d6423SLionel Sambuc   get_times(".", &pa, &pc, &pm);
325*433d6423SLionel Sambuc   if ( (fd  = open("T16.m", O_RDWR|O_CREAT, 0666)) < 0) e(89);
326*433d6423SLionel Sambuc   if ( (fd1 = open("T16.n", O_RDWR|O_CREAT, 0666)) < 0) e(90);
327*433d6423SLionel Sambuc   if ( (fd2 = open("T16.o", O_RDWR|O_CREAT, 0666)) < 0) e(91);
328*433d6423SLionel Sambuc   if ( (fd3 = open("T16.p", O_RDWR|O_CREAT, 0666)) < 0) e(92);
329*433d6423SLionel Sambuc   if ( (fd4 = open("T16.q", O_RDWR|O_CREAT, 0666)) < 0) e(93);
330*433d6423SLionel Sambuc   get_times("T16.m", &ta, &tc, &tm);
331*433d6423SLionel Sambuc   get_times("T16.n", &wa, &wc, &wm);
332*433d6423SLionel Sambuc   get_times("T16.o", &xa, &xc, &xm);
333*433d6423SLionel Sambuc   get_times("T16.p", &ya, &yc, &ym);
334*433d6423SLionel Sambuc   get_times("T16.q", &za, &zc, &zm);
335*433d6423SLionel Sambuc   get_times(".", &pa, &pc, &pm);
336*433d6423SLionel Sambuc   sleep(1);
337*433d6423SLionel Sambuc   if (utimes("T16.m", (void *) 0) != 0) e(94);
338*433d6423SLionel Sambuc   get_times("T16.m", &a, &c, &m);
339*433d6423SLionel Sambuc   if (a == ta || c == tc) e(95);
340*433d6423SLionel Sambuc   if (futimes(fd1, (void *) 0) != 0) e(96);
341*433d6423SLionel Sambuc   get_times("T16.n", &a, &c, &m);
342*433d6423SLionel Sambuc   if (a == wa || c == wc) e(97);
343*433d6423SLionel Sambuc   if (lutimes("T16.o", (void *) 0) != 0) e(98);
344*433d6423SLionel Sambuc   get_times("T16.o", &a, &c, &m);
345*433d6423SLionel Sambuc   if (a == xa || c == xc) e(99);
346*433d6423SLionel Sambuc   if (utimensat(AT_FDCWD, "T16.p", (void *) 0, 0) != 0) e(100);
347*433d6423SLionel Sambuc   get_times("T16.p", &a, &c, &m);
348*433d6423SLionel Sambuc   if (a == ya || c == yc) e(101);
349*433d6423SLionel Sambuc   if (futimens(fd4, (void *) 0) != 0) e(102);
350*433d6423SLionel Sambuc   get_times("T16.q", &a, &c, &m);
351*433d6423SLionel Sambuc   if (a == za || c == zc) e(103);
352*433d6423SLionel Sambuc   if (close(fd) != 0) e(104);
353*433d6423SLionel Sambuc   if (close(fd1) != 0) e(105);
354*433d6423SLionel Sambuc   if (close(fd2) != 0) e(106);
355*433d6423SLionel Sambuc   if (close(fd3) != 0) e(107);
356*433d6423SLionel Sambuc   if (close(fd4) != 0) e(108);
357*433d6423SLionel Sambuc   if (unlink("T16.m") != 0) e(109);
358*433d6423SLionel Sambuc   if (unlink("T16.n") != 0) e(110);
359*433d6423SLionel Sambuc   if (unlink("T16.o") != 0) e(111);
360*433d6423SLionel Sambuc   if (unlink("T16.p") != 0) e(112);
361*433d6423SLionel Sambuc   if (unlink("T16.q") != 0) e(113);
362*433d6423SLionel Sambuc }
363*433d6423SLionel Sambuc 
get_times(name,a,c,m)364*433d6423SLionel Sambuc void get_times(name, a, c, m)
365*433d6423SLionel Sambuc char *name;
366*433d6423SLionel Sambuc time_t *a, *c, *m;
367*433d6423SLionel Sambuc {
368*433d6423SLionel Sambuc   struct stat s;
369*433d6423SLionel Sambuc 
370*433d6423SLionel Sambuc   if (stat(name, &s) != 0) e(500);
371*433d6423SLionel Sambuc   *a = s.st_atime;
372*433d6423SLionel Sambuc   *c = s.st_ctime;
373*433d6423SLionel Sambuc   *m = s.st_mtime;
374*433d6423SLionel Sambuc }
375*433d6423SLionel Sambuc 
376