alsa.audio: add debug logs
[AROS.git] / test / clib / fcntl.c
blob06130445c65ce4cac75123fb02a02a9ee645d3ee
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <fcntl.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <unistd.h>
10 #include "test.h"
12 int fd = -1;
13 int fd2 = -1;
15 int main()
17 fd = mkstemp("T:lseekXXXXXX");
18 TEST((fd != -1));
20 /* Check if F_GETFD and F_SETFD is working */
21 TEST((fcntl(fd, F_GETFD) == 0));
22 TEST((fcntl(fd, F_SETFD, FD_CLOEXEC) == 0));
23 TEST((fcntl(fd, F_GETFD) == FD_CLOEXEC));
24 TEST((fcntl(fd, F_SETFD, 0) == 0));
25 TEST((fcntl(fd, F_GETFD) == 0));
27 int fd2 = dup(fd);
28 TEST((fd2 != -1));
30 /* Check if descriptor flags are independent for duped descriptors */
31 TEST((fcntl(fd2, F_GETFD) == 0));
32 TEST((fcntl(fd2, F_SETFD, FD_CLOEXEC) == 0));
33 TEST((fcntl(fd2, F_GETFD) == FD_CLOEXEC));
34 TEST((fcntl(fd, F_GETFD) == 0));
35 TEST((fcntl(fd, F_SETFD, FD_CLOEXEC) == 0));
36 TEST((fcntl(fd2, F_SETFD, 0) == 0));
37 TEST((fcntl(fd, F_GETFD) == FD_CLOEXEC));
39 cleanup();
40 return OK;
43 void cleanup()
45 if(fd != -1)
46 close(fd);
47 if(fd2 != -1)
48 close(fd2);