From 065069191cae60edb076eb71624ec7cf5b78153e Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 14 Aug 2023 09:27:07 +0100 Subject: [PATCH] tests: Disable use of ptrace() in tests on BSD and macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit cf55c31170a5d79beb1119164c6f5ea3c4ea06a9 added a new test which uses `ptrace()` to check some `GSubprocess` behaviour. FreeBSD uses different symbol names for ptrace symbols, and we haven’t tested whether the test works (and reproduces the failure) on FreeBSD, so skip the test for now. Signed-off-by: Philip Withnall --- gio/tests/gsubprocess.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/gio/tests/gsubprocess.c b/gio/tests/gsubprocess.c index c7f2ea489..695012c7d 100644 --- a/gio/tests/gsubprocess.c +++ b/gio/tests/gsubprocess.c @@ -2,7 +2,6 @@ #include #ifdef G_OS_UNIX -#include #include #include #include @@ -12,6 +11,10 @@ #include #endif +#ifdef __linux__ +#include +#endif + /* We write 2^1 + 2^2 ... + 2^10 or 2047 copies of "Hello World!\n" * ultimately */ @@ -1990,6 +1993,8 @@ test_fd_conflation_child_err_report_fd (void) do_test_fd_conflation (G_SUBPROCESS_FLAGS_NONE, empty_child_setup, TRUE); } +#ifdef __linux__ + /* Handle ptrace events on @main_child, and assert that when it exits, it does * so with status %EXIT_SUCCESS, rather than signalling. Other than that, this * just calls %PTRACE_CONT for all trace events. */ @@ -2061,15 +2066,20 @@ trace_children (pid_t main_child) } } +#endif /* __linux__ */ + static void test_exit_status_trapped (void) { +#ifdef __linux__ GPtrArray *args = NULL; pid_t test_child; +#endif g_test_summary ("Test that exit status is reported correctly for ptrace()d child processes"); g_test_bug ("https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3433"); +#ifdef __linux__ /* Call fork() directly here, rather than using #GSubprocess, so that we can * safely call waitpid() on it ourselves without interfering with the internals * of #GSubprocess. @@ -2088,6 +2098,9 @@ test_exit_status_trapped (void) trace_children (test_child); g_clear_pointer (&args, g_ptr_array_unref); +#else + g_test_skip ("ptrace() support for this test is only tested on Linux"); +#endif } #endif /* G_OS_UNIX */