From 6eb1c2cd53d6f38f769964b3e4f509a4ef957ab3 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 31 Oct 2018 15:22:26 +0000 Subject: [PATCH] test_get_helper_executable: Add function This is basically the same as get_test_exec() in dbus-spawn-test.c, but GLib-flavoured. Signed-off-by: Simon McVittie --- test/test-utils-glib.c | 20 ++++++++++++++++++++ test/test-utils-glib.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/test/test-utils-glib.c b/test/test-utils-glib.c index 930b87dfc..04d98aa54 100644 --- a/test/test-utils-glib.c +++ b/test/test-utils-glib.c @@ -890,3 +890,23 @@ test_incomplete (const gchar *message) g_test_skip (message); } } + +/* + * Return location of @exe test helper executable, or NULL if unknown. + * + * @exe must already include %DBUS_EXEEXT if appropriate. + * + * Returns: (transfer full) (nullable): an absolute path or NULL. + */ +gchar * +test_get_helper_executable (const gchar *exe) +{ + const char *dbus_test_exec; + + dbus_test_exec = _dbus_getenv ("DBUS_TEST_EXEC"); + + if (dbus_test_exec == NULL) + return NULL; + + return g_build_filename (dbus_test_exec, exe, NULL); +} diff --git a/test/test-utils-glib.h b/test/test-utils-glib.h index 7cfc87856..93b52b74f 100644 --- a/test/test-utils-glib.h +++ b/test/test-utils-glib.h @@ -129,4 +129,6 @@ void test_store_result_cb (GObject *source_object, void test_incomplete (const gchar *message); +gchar *test_get_helper_executable (const gchar *exe); + #endif -- 2.47.3