------------------------------------------------------------
revno: 1492
committer: James Hunt <[email protected]>
branch nick: upstart
timestamp: Thu 2013-06-27 16:14:30 +0100
message:
  * lib/tests/test_libupstart.c: test_libupstart():
    - Ensure XDG_RUNTIME_DIR is available, required for 'initctl list-sessions'.
modified:
  ChangeLog
  lib/tests/test_libupstart.c


--
lp:upstart
https://code.launchpad.net/~upstart-devel/upstart/trunk

Your team Upstart Reviewers is subscribed to branch lp:upstart.
To unsubscribe from this branch go to 
https://code.launchpad.net/~upstart-devel/upstart/trunk/+edit-subscription
=== modified file 'ChangeLog'
--- ChangeLog	2013-06-27 10:16:35 +0000
+++ ChangeLog	2013-06-27 15:14:30 +0000
@@ -6,6 +6,8 @@
 	  - test_libupstart():
 	    - Start a private D-Bus server and Session Init to handle possibility
 	      of building on systems not using Upstart as PID 1.
+	    - Ensure XDG_RUNTIME_DIR is available, required for
+	      'initctl list-sessions'.
 	  - main(): Disable tests if required environment not available (as done
 	    for test_initctl).
 	* test/test_util_common.c:

=== modified file 'lib/tests/test_libupstart.c'
--- lib/tests/test_libupstart.c	2013-06-27 10:16:35 +0000
+++ lib/tests/test_libupstart.c	2013-06-27 15:14:30 +0000
@@ -97,11 +97,29 @@
 	int                      ret;
 	pid_t                    upstart_pid;
 	pid_t                    dbus_pid;
+	char                     xdg_runtime_dir[PATH_MAX];
+	nih_local char          *orig_xdg_runtime_dir = NULL;
+	nih_local char          *session_file = NULL;
+	nih_local char          *path = NULL;
 
 	TEST_GROUP ("libupstart");
 
 	TEST_FEATURE ("version");
 
+        TEST_FILENAME (xdg_runtime_dir);
+        TEST_EQ (mkdir (xdg_runtime_dir, 0755), 0);
+
+	/* Take care to avoid disrupting users environment by saving and
+	 * restoring this variable (assuming the tests all pass...).
+	 */
+	orig_xdg_runtime_dir = getenv ("XDG_RUNTIME_DIR");
+	if (orig_xdg_runtime_dir)
+		orig_xdg_runtime_dir = NIH_MUST (nih_strdup (NULL, orig_xdg_runtime_dir));
+
+	assert0 (setenv ("XDG_RUNTIME_DIR", xdg_runtime_dir, 1));
+
+	/*******************************************************************/
+
 	/* Create a private Session Init instance to connect to */
 	TEST_DBUS (dbus_pid);
 	START_UPSTART (upstart_pid, TRUE);
@@ -121,6 +139,26 @@
 
 	STOP_UPSTART (upstart_pid);
 	TEST_DBUS_END (dbus_pid);
+
+	/*******************************************************************/
+
+	if (orig_xdg_runtime_dir) {
+		/* restore */
+		setenv ("XDG_RUNTIME_DIR", orig_xdg_runtime_dir, 1);
+	} else {
+		assert0 (unsetenv ("XDG_RUNTIME_DIR"));
+	}
+
+	session_file = get_session_file (xdg_runtime_dir, upstart_pid);
+	unlink (session_file);
+
+	/* Remove the directory tree the Session Init created */
+	path = NIH_MUST (nih_sprintf (NULL, "%s/upstart/sessions", xdg_runtime_dir));
+        assert0 (rmdir (path));
+	path = NIH_MUST (nih_sprintf (NULL, "%s/upstart", xdg_runtime_dir));
+        assert0 (rmdir (path));
+
+        assert0 (rmdir (xdg_runtime_dir));
 }
 
 int

-- 
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/upstart-devel

Reply via email to