[glib/halfline/test-case-pipe-confusion: 14/15] tests/desktop-app-info: Use named pipe instead of /proc
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/halfline/test-case-pipe-confusion: 14/15] tests/desktop-app-info: Use named pipe instead of /proc
- Date: Tue, 18 Oct 2022 14:09:40 +0000 (UTC)
commit d8f4b065e7c72b7f009e9bd912256beeaebcbab0
Author: Ray Strode <rstrode redhat com>
Date: Mon Oct 17 14:44:14 2022 -0400
tests/desktop-app-info: Use named pipe instead of /proc
Freebsd doesn't always have /proc mounted, so relying on
/proc for the tests isn't ideal.
This commit changes the desktop-app-info tests to use
mkfifo instead of /proc/../fd/.. to relay terminal
arguments.
Might help with this error message I'm seeing in CI:
/tmp/bin-path-H1UQT1/gnome-terminal: cannot create /proc/38961/fd/6: No such file or directory
gio/tests/desktop-app-info.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/gio/tests/desktop-app-info.c b/gio/tests/desktop-app-info.c
index 81804a8160..0609a36418 100644
--- a/gio/tests/desktop-app-info.c
+++ b/gio/tests/desktop-app-info.c
@@ -30,6 +30,8 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
static GAppInfo *
create_command_line_app_info (const char *name,
@@ -1218,7 +1220,8 @@ test_launch_uris_with_terminal (gconstpointer data)
/* FIXME: https://gitlab.gnome.org/GNOME/glib/-/issues/2781 */
g_test_skip ("/proc pipe sharing currently doesn’t work reliably on FreeBSD CI");
#else
- int fds[2];
+ int fd;
+ int ret;
const char *terminal_exec = data;
char *old_path;
char *command_line;
@@ -1245,17 +1248,18 @@ test_launch_uris_with_terminal (gconstpointer data)
old_path = g_strdup (g_getenv ("PATH"));
g_assert_true (g_setenv ("PATH", bin_path, TRUE));
- g_unix_open_pipe (fds, FD_CLOEXEC, &error);
- g_assert_no_error (error);
-
terminal_path = g_build_filename (bin_path, terminal_exec, NULL);
- output_fd_path = g_strdup_printf (G_DIR_SEPARATOR_S "proc"
- G_DIR_SEPARATOR_S "%" G_PID_FORMAT
- G_DIR_SEPARATOR_S "fd"
- G_DIR_SEPARATOR_S "%d",
- getpid (), fds[0]);
+ output_fd_path = g_build_filename (bin_path, "fifo", NULL);
+
+ ret = mkfifo (output_fd_path, 0666);
+
+ g_assert (ret == 0);
+
+ fd = g_open (output_fd_path, O_RDONLY | O_CLOEXEC | O_NONBLOCK, 0);
+
+ g_assert (fd >= 0);
- input_stream = g_unix_input_stream_new (fds[0], TRUE);
+ input_stream = g_unix_input_stream_new (fd, TRUE);
data_input_stream = g_data_input_stream_new (input_stream);
script_contents = g_strdup_printf ("#!%s\n" \
"out='%s'\n"
@@ -1325,7 +1329,7 @@ test_launch_uris_with_terminal (gconstpointer data)
g_assert_null (paths);
g_assert_true (g_setenv ("PATH", old_path, TRUE));
- g_close (fds[1], &error);
+ g_close (fd, &error);
g_assert_no_error (error);
g_free (sh);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]