various warning/errorwarning fixes for gcc47
[minix3.git] / test / test14.c
blob1765239af7c8aa982b31453a0a5ebb3b4293b919
1 /* Test 14. unlinking an open file. */
3 #include <sys/types.h>
4 #include <errno.h>
5 #include <fcntl.h>
6 #include <stdlib.h>
7 #include <unistd.h>
8 #include <stdio.h>
10 #define TRIALS 100
11 #define MAX_ERROR 4
13 char name[20] = {"TMP14."};
14 int subtest = 1;
16 #include "common.c"
18 int main(void);
19 void e(int n);
20 void quit(void);
22 int main()
24 int fd0, i, pid;
26 start(14);
28 pid = getpid();
29 sprintf(&name[6], "%x", pid);
31 for (i = 0; i < TRIALS; i++) {
32 if ( (fd0 = creat(name, 0777)) < 0) e(1);
33 if (write(fd0, name, 20) != 20) e(2);
34 if (unlink(name) != 0) e(3);
35 if (close(fd0) != 0) e(4);
38 fd0 = creat(name, 0777);
39 write(fd0, name, 20);
40 unlink(name);
41 quit();
42 return(-1); /* impossible */