usleep tests: Avoid failure due to known Cygwin 3.5.3 bug.
[gnulib.git] / tests / test-dirfd.c
blob132b378a88be47b98e3b0d8ad706b4a6ff9d3318
1 /* Test of dirfd() function.
2 Copyright (C) 2023-2024 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2023. */
19 #include <config.h>
21 #include <dirent.h>
23 #include <stdio.h>
25 #include "macros.h"
27 int
28 main ()
30 #if defined _WIN32 && !defined __CYGWIN__
31 fprintf (stderr, "Skipping test: The DIR type does not contain a file descriptor.\n");
32 return 77;
33 #else
34 /* On all other platforms, we expect to have either
35 - a dirfd() function, or
36 - a dirfd macro, or
37 - a DIR struct with a d_fd member, or
38 - a DIR struct with a dd_fd member.
39 If we don't have this, dirfd.c produces a function that always returns -1.
40 Check here that this does not happen. */
41 DIR *d = opendir (".");
42 int fd = dirfd (d);
43 ASSERT (fd >= 0);
45 return test_exit_status;
46 #endif