summaryrefslogtreecommitdiff
blob: efc47df7f2e6cbff310f33e0b2bae93a77ab846c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
From ffbaa40603ed33646de10822983c9445d6c70d3a Mon Sep 17 00:00:00 2001
From: Stef Walter <stef@memberwebs.com>
Date: Wed, 19 Jan 2011 19:44:50 +0000
Subject: Don't run tests if a testing enabled gnome-keyring-daemon is not enabled.

This uses the 'gnome-keyring-daemon --version' output to determine
whether testing is enabled or not.
---
diff --git a/tests/gtest-helpers.c b/tests/gtest-helpers.c
index fbdb5d7..e984f64 100644
--- a/tests/gtest-helpers.c
+++ b/tests/gtest-helpers.c
@@ -160,16 +160,17 @@ chdir_base_dir (char* argv0)
 	g_free (dir);
 }
 
-#ifdef TEST_WITH_DAEMON
-
 static pid_t daemon_pid = 0;
 
 static gboolean
-daemon_start ()
+daemon_start (void)
 {
 	GError *err = NULL;
 	gchar *args[5];
 	const gchar *path, *service, *address;
+	gchar *output = NULL;
+	gint exit_status = 1;
+	GError *error = NULL;
 
 	/* Need to have DBUS running */
 	address = g_getenv ("DBUS_SESSION_BUS_ADDRESS");
@@ -178,6 +179,23 @@ daemon_start ()
 		return FALSE;
 	}
 
+	/* Check if gnome-keyring-daemon has testing enabled */
+	if (!g_spawn_command_line_sync (GNOME_KEYRING_DAEMON_PATH " --version",
+	                                &output, NULL, &exit_status, &error)) {
+		g_printerr ("Couldn't launch '%s': %s", GNOME_KEYRING_DAEMON_PATH,
+		            error->message);
+		return FALSE;
+	}
+
+	/* For some reason --version failed */
+	if (exit_status != 0 || strstr (output, "testing: enabled") == NULL) {
+		g_printerr ("Skipping tests since no testing enabled gnome-keyring-daemin is available\n");
+		g_free (output);
+		return FALSE;
+	}
+
+	g_free (output);
+
 	path = g_getenv ("GNOME_KEYRING_TEST_PATH");
 	if (path && !path[0])
 		path = NULL;
@@ -221,8 +239,6 @@ daemon_stop (void)
 	daemon_pid = 0;
 }
 
-#endif /* TEST_WITH_DAEMON */
-
 int
 main (int argc, char* argv[])
 {
@@ -239,18 +255,12 @@ main (int argc, char* argv[])
 
 	initialize_tests ();
 
-#ifdef TEST_WITH_DAEMON
 	if (daemon_start ()) {
-#endif
-
 		start_tests ();
 		ret = g_test_run ();
 		stop_tests();
-
-#ifdef TEST_WITH_DAEMON
 		daemon_stop();
 	}
-#endif
 
 	return ret;
 }
--
cgit v0.9.0.2