mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-06-05 22:20:54 +02:00
test: Fix closefrom() test on macOS
On macOS we do not close the file descriptors, and instead mark them all as close-on-exec. So checking whether they are not valid does not work.
This commit is contained in:
parent
0f8bcdfd92
commit
ed2eb31da9
@ -55,7 +55,19 @@ main(int argc, char *argv[])
|
|||||||
closefrom(4);
|
closefrom(4);
|
||||||
|
|
||||||
for (i = 4; i < fd_max; i++) {
|
for (i = 4; i < fd_max; i++) {
|
||||||
assert(fcntl(i, F_GETFL) == -1 && errno == EBADF);
|
int rc;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
rc = fcntl(i, F_GETFD);
|
||||||
|
#ifdef __APPLE__
|
||||||
|
/* On macOS we only set close-on-exec. */
|
||||||
|
if ((i & (i - 1)) == 0)
|
||||||
|
assert(rc == FD_CLOEXEC);
|
||||||
|
else
|
||||||
|
assert(rc == -1 && errno == EBADF);
|
||||||
|
#else
|
||||||
|
assert(rc == -1 && errno == EBADF);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
assert(fcntl(fd, F_GETFL) == -1 && errno == EBADF);
|
assert(fcntl(fd, F_GETFL) == -1 && errno == EBADF);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user