[glib: 2/7] glib/tests: make fd-assignment-clash run on win32
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/7] glib/tests: make fd-assignment-clash run on win32
- Date: Wed, 9 Feb 2022 11:19:17 +0000 (UTC)
commit 10b450eaf6c3c244dd20c64d00f1370ca67927d5
Author: Marc-André Lureau <marcandre lureau redhat com>
Date: Wed Jan 26 14:35:43 2022 +0400
glib/tests: make fd-assignment-clash run on win32
This is a minimal test for g_spawn_async_with_pipes_and_fds()
Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>
glib/tests/spawn-singlethread.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/glib/tests/spawn-singlethread.c b/glib/tests/spawn-singlethread.c
index 8dca847fa..7711ba8fe 100644
--- a/glib/tests/spawn-singlethread.c
+++ b/glib/tests/spawn-singlethread.c
@@ -27,10 +27,10 @@
#include <locale.h>
#include <string.h>
#include <fcntl.h>
+#include <glib/gstdio.h>
#ifdef G_OS_UNIX
#include <glib-unix.h>
-#include <glib/gstdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -433,7 +433,6 @@ test_spawn_nonexistent (void)
static void
test_spawn_fd_assignment_clash (void)
{
-#if defined(G_OS_UNIX) && defined(F_DUPFD_CLOEXEC)
int tmp_fd;
guint i;
#define N_FDS 10
@@ -451,7 +450,12 @@ test_spawn_fd_assignment_clash (void)
for (i = 0; i < (N_FDS - 1); ++i)
{
- int source = fcntl (tmp_fd, F_DUPFD_CLOEXEC, 3);
+ int source;
+#ifdef F_DUPFD_CLOEXEC
+ source = fcntl (tmp_fd, F_DUPFD_CLOEXEC, 3);
+#else
+ source = dup (tmp_fd);
+#endif
g_assert_cmpint (source, >=, 0);
source_fds[i] = source;
target_fds[i] = source + N_FDS;
@@ -486,9 +490,6 @@ test_spawn_fd_assignment_clash (void)
/* Clean up. */
for (i = 0; i < N_FDS; i++)
g_close (source_fds[i], NULL);
-#else /* !G_OS_UNIX */
- g_test_skip ("FD redirection only supported on Unix with F_DUPFD_CLOEXEC");
-#endif /* !G_OS_UNIX */
}
int
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]