bz2_au.library -> bz2.library
[AROS.git] / test / clib / fcntl.c
blob3a7563dfe645d44ce1a7d5128768fb74a7f6840d
1 #include <fcntl.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <unistd.h>
5 #include "test.h"
7 int fd = -1;
8 int fd2 = -1;
10 int main()
12 fd = mkstemp("T:lseekXXXXXX");
13 TEST((fd != -1));
15 /* Check if F_GETFD and F_SETFD is working */
16 TEST((fcntl(fd, F_GETFD) == 0));
17 TEST((fcntl(fd, F_SETFD, FD_CLOEXEC) == 0));
18 TEST((fcntl(fd, F_GETFD) == FD_CLOEXEC));
19 TEST((fcntl(fd, F_SETFD, 0) == 0));
20 TEST((fcntl(fd, F_GETFD) == 0));
22 int fd2 = dup(fd);
23 TEST((fd2 != -1));
25 /* Check if descriptor flags are independent for duped descriptors */
26 TEST((fcntl(fd2, F_GETFD) == 0));
27 TEST((fcntl(fd2, F_SETFD, FD_CLOEXEC) == 0));
28 TEST((fcntl(fd2, F_GETFD) == FD_CLOEXEC));
29 TEST((fcntl(fd, F_GETFD) == 0));
30 TEST((fcntl(fd, F_SETFD, FD_CLOEXEC) == 0));
31 TEST((fcntl(fd2, F_SETFD, 0) == 0));
32 TEST((fcntl(fd, F_GETFD) == FD_CLOEXEC));
34 cleanup();
35 return OK;
38 void cleanup()
40 if(fd != -1)
41 close(fd);
42 if(fd2 != -1)
43 close(fd2);