summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2018-07-16 17:01:13 +0200
committerJonas Ådahl <jadahl@gmail.com>2018-11-06 17:17:36 +0100
commit32f3bb02e12ffd754d049c8823ec7bf8a75a278f (patch)
treef885809047e872cdcadd5e49508a6b3d2134352c
parentd21022f5625ae3c32fa70d3784a1386872666524 (diff)
downloadmutter-32f3bb02e12ffd754d049c8823ec7bf8a75a278f.tar.gz
tests: Move out test client path init into helper function
Makes the common test init function simpler to read.
-rw-r--r--src/tests/test-utils.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/tests/test-utils.c b/src/tests/test-utils.c
index 5faaaa781..ceac34e9d 100644
--- a/src/tests/test-utils.c
+++ b/src/tests/test-utils.c
@@ -57,24 +57,41 @@ G_DEFINE_QUARK (test-runner-error-quark, test_runner_error)
static char *test_client_path;
+static void
+ensure_test_client_path (int argc,
+ char **argv)
+{
+ test_client_path = g_test_build_filename (G_TEST_BUILT,
+ "src",
+ "tests",
+ "mutter-test-client",
+ NULL);
+ if (!g_file_test (test_client_path,
+ G_FILE_TEST_EXISTS | G_FILE_TEST_IS_EXECUTABLE))
+ {
+ g_autofree char *basename;
+ g_autofree char *dirname = NULL;
+
+ basename = g_path_get_basename (argv[0]);
+
+ dirname = g_path_get_dirname (argv[0]);
+ test_client_path = g_build_filename (dirname,
+ "mutter-test-client", NULL);
+ }
+
+ if (!g_file_test (test_client_path,
+ G_FILE_TEST_EXISTS | G_FILE_TEST_IS_EXECUTABLE))
+ g_error ("mutter-test-client executable not found");
+}
+
void
test_init (int *argc,
char ***argv)
{
- char *basename = g_path_get_basename (argv[0]);
- char *dirname = g_path_get_dirname (argv[0]);
-
g_test_init (argc, argv, NULL);
g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=");
- if (g_str_has_prefix (basename, "lt-"))
- test_client_path = g_build_filename (dirname,
- "../mutter-test-client", NULL);
- else
- test_client_path = g_build_filename (dirname,
- "mutter-test-client", NULL);
- g_free (basename);
- g_free (dirname);
+ ensure_test_client_path (*argc, *argv);
}
AsyncWaiter *