James Hunt has proposed merging lp:~jamesodhunt/upstart/cleanup-test-xdg-dirs into lp:upstart.
Requested reviews: Upstart Reviewers (upstart-reviewers) Related bugs: Bug #1250126 in upstart : "upstart tests no longer run unless NIH supports TAP" https://bugs.launchpad.net/upstart/+bug/1250126 For more details, see: https://code.launchpad.net/~jamesodhunt/upstart/cleanup-test-xdg-dirs/+merge/194848 -- https://code.launchpad.net/~jamesodhunt/upstart/cleanup-test-xdg-dirs/+merge/194848 Your team Upstart Reviewers is requested to review the proposed merge of lp:~jamesodhunt/upstart/cleanup-test-xdg-dirs into lp:upstart.
=== modified file 'ChangeLog' --- ChangeLog 2013-11-07 03:35:14 +0000 +++ ChangeLog 2013-11-12 12:19:03 +0000 @@ -1,3 +1,26 @@ +2013-11-12 James Hunt <james.h...@ubuntu.com> + + * extra/man/socket-event.7: PATH => SOCKET_PATH. + * init/Makefile.am: + - Unset DBUS_SYSTEM_BUS_ADDRESS + - Explain unsetting vars. + - test_xdg: link to libtest_util_common. + * init/tests/test_main.c: + - Include config.h to avoid local NIH test run failure. + - Remove test-specific XDG_CONFIG_HOME/XDG_RUNTIME_DIR handling and + call test_common_setup() and test_common_cleanup() instead. + * init/tests/test_xdg.c: Remove test-specific + XDG_CONFIG_HOME/XDG_RUNTIME_DIR handling and call test_common_setup() + and test_common_cleanup() instead. + * test/test_util_common.c: Added test_common_setup() and + test_common_cleanup(). + * util/Makefile.am: + - Unset DBUS_SYSTEM_BUS_ADDRESS + - Explain unsetting vars. + * util/tests/test_initctl.c: Remove test-specific + XDG_CONFIG_HOME/XDG_RUNTIME_DIR handling and call test_common_setup() + and test_common_cleanup() instead. + 2013-11-04 James Hunt <james.h...@ubuntu.com> * test/test_util_common.h: WAIT_FOR_FILE(): Check @path not === modified file 'extra/man/socket-event.7' --- extra/man/socket-event.7 2013-10-23 16:33:09 +0000 +++ extra/man/socket-event.7 2013-11-12 12:19:03 +0000 @@ -52,7 +52,7 @@ .P .RS .nf -start on socket PROTO=unix PATH=/var/run/.s.pgsql.1234 +start on socket PROTO=unix SOCKET_PATH=/var/run/.s.pgsql.1234 .fi .RE .\" @@ -60,7 +60,7 @@ .P .RS .nf -start on socket PROTO=unix PATH=@/at/upstart/example +start on socket PROTO=unix SOCKET_PATH=@/at/upstart/example .fi .RE .\" === modified file 'init/Makefile.am' --- init/Makefile.am 2013-11-11 16:15:52 +0000 +++ init/Makefile.am 2013-11-12 12:19:03 +0000 @@ -172,10 +172,14 @@ LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver endif +# Ensure a clean test environment (that will not touch the running users +# one). Tests that need the variables listed below are expected to set +# them to appropriate temporary values as needed. AM_TESTS_ENVIRONMENT= \ unset -v \ XDG_RUNTIME_DIR \ DBUS_SESSION_BUS_ADDRESS \ + DBUS_SYSTEM_BUS_ADDRESS \ UPSTART_SESSION \ UPSTART_INSTANCE \ UPSTART_EVENTS \ @@ -408,6 +412,10 @@ xdg.o \ environ.o \ $(NIH_LIBS) \ + $(top_builddir)/test/libtest_util_common.a \ + $(NIH_LIBS) \ + $(NIH_DBUS_LIBS) \ + $(DBUS_LIBS) \ -lrt test_control_SOURCES = tests/test_control.c === modified file 'init/tests/test_main.c' --- init/tests/test_main.c 2013-10-18 09:13:36 +0000 +++ init/tests/test_main.c 2013-11-12 12:19:03 +0000 @@ -19,6 +19,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ + #include <nih/string.h> #include <nih/main.h> #include <nih/test.h> @@ -42,16 +46,14 @@ { char confdir_a[PATH_MAX]; char confdir_b[PATH_MAX]; - char xdg_config_home[PATH_MAX]; - char xdg_runtime_dir[PATH_MAX]; + char *xdg_config_home; + char *xdg_runtime_dir; char logdir[PATH_MAX]; pid_t upstart_pid = 0; pid_t dbus_pid = 0; char **output; size_t lines; nih_local char *cmd = NULL; - nih_local char *orig_xdg_config_home = NULL; - nih_local char *orig_xdg_runtime_dir = NULL; nih_local char *xdg_conf_dir = NULL; nih_local char *session_file = NULL; nih_local char *path = NULL; @@ -59,6 +61,12 @@ /* space for 2 sets of confdir options and a terminator */ char *extra[5]; + xdg_config_home = getenv ("XDG_CONFIG_HOME"); + TEST_NE_P (xdg_config_home, NULL); + + xdg_runtime_dir = getenv ("XDG_RUNTIME_DIR"); + TEST_NE_P (xdg_runtime_dir, NULL); + TEST_GROUP ("--confdir command-line option handling"); TEST_FILENAME (confdir_a); @@ -67,12 +75,6 @@ TEST_FILENAME (confdir_b); assert0 (mkdir (confdir_b, 0755)); - TEST_FILENAME (xdg_config_home); - assert0 (mkdir (xdg_config_home, 0755)); - - TEST_FILENAME (xdg_runtime_dir); - assert0 (mkdir (xdg_runtime_dir, 0755)); - xdg_conf_dir = nih_sprintf (NULL, "%s/%s", xdg_config_home, "upstart"); TEST_NE_P (xdg_conf_dir, NULL); assert0 (mkdir (xdg_conf_dir, 0755)); @@ -80,21 +82,6 @@ TEST_FILENAME (logdir); assert0 (mkdir (logdir, 0755)); - /* Take care to avoid disrupting users environment by saving and - * restoring these variable (assuming the tests all pass...). - */ - orig_xdg_config_home = getenv ("XDG_CONFIG_HOME"); - if (orig_xdg_config_home) - orig_xdg_config_home = NIH_MUST (nih_strdup (NULL, orig_xdg_config_home)); - - assert0 (setenv ("XDG_CONFIG_HOME", xdg_config_home, 1)); - - 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)); - /* disable system default job dir */ assert0 (setenv ("UPSTART_NO_SYSTEM_USERCONFDIR", "1", 1)); @@ -412,32 +399,9 @@ TEST_DBUS_END (dbus_pid); - if (orig_xdg_config_home) { - /* restore */ - setenv ("XDG_CONFIG_HOME", orig_xdg_config_home, 1); - } else { - assert0 (unsetenv ("XDG_CONFIG_HOME")); - } - - if (orig_xdg_runtime_dir) { - /* restore */ - setenv ("XDG_RUNTIME_DIR", orig_xdg_runtime_dir, 1); - } else { - assert0 (unsetenv ("XDG_RUNTIME_DIR")); - } - assert0 (rmdir (confdir_a)); assert0 (rmdir (confdir_b)); assert0 (rmdir (xdg_conf_dir)); - assert0 (rmdir (xdg_config_home)); - - /* Remove the directory tree the first Session Init created */ - path = NIH_MUST (nih_sprintf (NULL, "%s/upstart/sessions", xdg_runtime_dir)); - TEST_EQ (rmdir (path), 0); - path = NIH_MUST (nih_sprintf (NULL, "%s/upstart", xdg_runtime_dir)); - TEST_EQ (rmdir (path), 0); - assert0 (rmdir (xdg_runtime_dir)); - assert0 (rmdir (logdir)); assert0 (unsetenv ("UPSTART_CONFDIR")); } @@ -446,7 +410,11 @@ main (int argc, char *argv[]) { + test_common_setup (); + test_confdir (); + test_common_cleanup (); + return 0; } === modified file 'init/tests/test_xdg.c' --- init/tests/test_xdg.c 2013-01-25 09:59:44 +0000 +++ init/tests/test_xdg.c 2013-11-12 12:19:03 +0000 @@ -30,6 +30,8 @@ #include "xdg.h" +#include "test_util_common.h" + void _test_dir_created (char * dirname) { struct stat statbuf; @@ -438,9 +440,12 @@ void test_get_session_dir (void) { - char dirname[PATH_MAX]; - char *expected; - char *path; + char dirname[PATH_MAX]; + char *expected; + char *path; + char *orig_xdg_runtime_dir; + + orig_xdg_runtime_dir = getenv ("XDG_RUNTIME_DIR"); TEST_FUNCTION ("get_session_dir"); @@ -463,6 +468,9 @@ } } + if (orig_xdg_runtime_dir) + setenv ("XDG_RUNTIME_DIR", orig_xdg_runtime_dir, 1); + TEST_FEATURE ("with XDG_RUNTIME_DIR unset"); assert0 (unsetenv ("XDG_RUNTIME_DIR")); @@ -476,12 +484,17 @@ rmdir (path); nih_free (path); rmdir (dirname); + + if (orig_xdg_runtime_dir) + setenv ("XDG_RUNTIME_DIR", orig_xdg_runtime_dir, 1); } int main (int argc, char *argv[]) { + test_common_setup (); + test_get_home_subdir (); test_get_config_home (); test_get_config_dirs (); @@ -490,5 +503,7 @@ test_get_user_log_dir (); test_get_session_dir (); + test_common_cleanup (); + return 0; } === modified file 'test/test_util_common.c' --- test/test_util_common.c 2013-11-07 03:35:14 +0000 +++ test/test_util_common.c 2013-11-12 12:19:03 +0000 @@ -58,6 +58,18 @@ #error unable to find initctl binary as INITCTL_BINARY not defined #endif /* INITCTL_BINARY */ +static char *saved_xdg_config_home = NULL; +static char *saved_xdg_runtime_dir = NULL; +static char test_xdg_config_home[PATH_MAX]; +static char test_xdg_runtime_dir[PATH_MAX]; + +/** + * test_setup_called: + * + * Set to TRUE if test_setup() called. + **/ +static int test_setup_called = FALSE; + static void selfpipe_write (int n); static void selfpipe_setup (void); @@ -849,3 +861,144 @@ return ! stat (path, &st); } + +/** + * test_common_setup: + * + * Perform test setup. + * + * Currently, only needed for those tests which require unique xdg + * directories. + * + * If called, test must call test_common_cleanup() to cleanup. + **/ +void +test_common_setup (void) +{ + char *xdg_config_home; + char *xdg_runtime_dir; + + /* Take care to avoid disrupting users environment by saving and + * restoring these variable (assuming the tests all pass...). + */ + + xdg_config_home = getenv ("XDG_CONFIG_HOME"); + if (xdg_config_home) { + nih_info ("Existing XDG_CONFIG_HOME found ('%s') - " + "saving for later restore", + xdg_config_home); + + saved_xdg_config_home = NIH_MUST (nih_strdup (NULL, xdg_config_home)); + } + + TEST_FILENAME (test_xdg_config_home); + assert0 (mkdir (test_xdg_config_home, TEST_DIR_MODE)); + assert0 (setenv ("XDG_CONFIG_HOME", test_xdg_config_home, 1)); + + nih_info ("Using test XDG_CONFIG_HOME='%s'", test_xdg_config_home); + + xdg_runtime_dir = getenv ("XDG_RUNTIME_DIR"); + if (xdg_runtime_dir) { + nih_info ("Existing XDG_RUNTIME_DIR found ('%s') - " + "saving for later restore", + xdg_runtime_dir); + + saved_xdg_runtime_dir = NIH_MUST (nih_strdup (NULL, xdg_runtime_dir)); + } + + TEST_FILENAME (test_xdg_runtime_dir); + assert0 (mkdir (test_xdg_runtime_dir, TEST_DIR_MODE)); + assert0 (setenv ("XDG_RUNTIME_DIR", test_xdg_runtime_dir, 1)); + + nih_info ("Using test XDG_RUNTIME_DIR='%s'", test_xdg_runtime_dir); + + test_setup_called = TRUE; +} + +/** + * test_common_cleanup: + * + * Perform cleanup of test setup. + * + * Currently, only needed for those tests which require unique xdg + * directories. + * + * If called, test must already have called test_common_setup(). + **/ +void +test_common_cleanup (void) +{ + nih_local char *path = NULL; + char *xdg_config_home; + char *xdg_runtime_dir; + struct stat statbuf; + + if (! test_setup_called) { + nih_error ("BUG: Called %s without first calling %s", + __func__, "test_common_setup()"); + abort (); + } + + xdg_config_home = getenv ("XDG_CONFIG_HOME"); + xdg_runtime_dir = getenv ("XDG_RUNTIME_DIR"); + + if (saved_xdg_config_home) { + nih_assert (test_xdg_config_home[0]); + TEST_EQ_STR (test_xdg_config_home, xdg_config_home); + + if (stat (test_xdg_config_home, &statbuf)) { + nih_error ("A test has removed XDG_CONFIG_HOME '%s'", test_xdg_config_home); + abort (); + } + + if (! S_ISDIR (statbuf.st_mode)) { + nih_error ("XDG_CONFIG_HOME '%s' no longer a directory", test_xdg_config_home); + abort (); + } + + assert0 (rmdir (test_xdg_config_home)); + + assert0 (setenv ("XDG_CONFIG_HOME", saved_xdg_config_home, 1)); + nih_info ("Restoring XDG_RUNTIME_DIR='%s'", saved_xdg_config_home); + nih_free (saved_xdg_config_home); + saved_xdg_config_home = NULL; + } + + if (saved_xdg_runtime_dir) { + nih_assert (test_xdg_runtime_dir[0]); + TEST_EQ_STR (test_xdg_runtime_dir, xdg_runtime_dir); + + if (stat (test_xdg_runtime_dir, &statbuf)) { + nih_error ("A test has removed XDG_RUNTIME_DIR '%s'", test_xdg_runtime_dir); + abort (); + } + + if (! S_ISDIR (statbuf.st_mode)) { + nih_error ("XDG_RUNTIME_DIR '%s' no longer a directory", test_xdg_runtime_dir); + abort (); + } + + path = NIH_MUST (nih_sprintf (NULL, "%s/upstart/sessions", xdg_runtime_dir)); + + if (! stat (path, &statbuf)) { + nih_local char *cmd = NULL; + + /* Clean up if tests forgot to */ + cmd = NIH_MUST (nih_sprintf (NULL, "rm %s/*.session 2>/dev/null", path)); + system (cmd); + + /* Remove the directory tree the first Session Init created */ + assert0 (rmdir (path)); + path = NIH_MUST (nih_sprintf (NULL, "%s/upstart", xdg_runtime_dir)); + assert0 (rmdir (path)); + } + + assert0 (rmdir (test_xdg_runtime_dir)); + + assert0 (setenv ("XDG_RUNTIME_DIR", saved_xdg_runtime_dir, 1)); + nih_info ("Restoring XDG_RUNTIME_DIR='%s'", saved_xdg_config_home); + nih_free (saved_xdg_runtime_dir); + saved_xdg_runtime_dir = NULL; + + } +} === modified file 'test/test_util_common.h' --- test/test_util_common.h 2013-11-07 03:35:14 +0000 +++ test/test_util_common.h 2013-11-12 12:19:03 +0000 @@ -7,6 +7,13 @@ #include <nih-dbus/test_dbus.h> +/** + * TEST_DIR_MODE: + * + * Mode to use when creating test directories. + **/ +#define TEST_DIR_MODE 0750 + #define BUFFER_SIZE 1024 /** @@ -745,4 +752,8 @@ int file_exists (const char *path) __attribute__ ((warn_unused_result)); +void test_common_setup (void); + +void test_common_cleanup (void); + #endif /* TEST_UTIL_COMMON_H */ === modified file 'util/Makefile.am' --- util/Makefile.am 2013-11-11 16:15:52 +0000 +++ util/Makefile.am 2013-11-12 12:19:03 +0000 @@ -182,10 +182,14 @@ rm -f "$(DESTDIR)$(sbindir)/$$file"; \ done +# Ensure a clean test environment (that will not touch the running users +# one). Tests that need the variables listed below are expected to set +# them to appropriate temporary values as needed. AM_TESTS_ENVIRONMENT= \ unset -v \ XDG_RUNTIME_DIR \ DBUS_SESSION_BUS_ADDRESS \ + DBUS_SYSTEM_BUS_ADDRESS \ UPSTART_SESSION \ UPSTART_INSTANCE \ UPSTART_EVENTS \ === modified file 'util/tests/test_initctl.c' --- util/tests/test_initctl.c 2013-11-11 10:13:08 +0000 +++ util/tests/test_initctl.c 2013-11-12 12:19:03 +0000 @@ -10988,16 +10988,11 @@ TEST_EQ (unsetenv ("UPSTART_CONFDIR"), 0); TEST_EQ (unsetenv ("UPSTART_LOGDIR"), 0); - - if (! getenv ("XDG_RUNTIME_DIR")) { - TEST_GROUP ("set-env rexec # TODO fails without XDG_RUNTIME_DIR set"); - TEST_FAILED (); - return; - } else { - /*******************************************************************/ TEST_FEATURE ("ensure 'set-env' persists across session-init re-exec"); + TEST_TRUE (getenv ("XDG_RUNTIME_DIR")); + contents = nih_sprintf (NULL, "start on startup\n" "\n" @@ -11056,8 +11051,6 @@ assert0 (unlink (logfile)); DELETE_FILE (confdir, "foo.conf"); - } - /*******************************************************************/ TEST_FEATURE ("ensure 'set-env --global' persists across session-init re-exec"); @@ -11114,7 +11107,6 @@ nih_local char *session_file = NULL; nih_local char *path = NULL; nih_local char *expected = NULL; - nih_local char *orig_xdg_runtime_dir = NULL; size_t len; char *value; @@ -11126,13 +11118,6 @@ TEST_FILENAME (confdir); TEST_EQ (mkdir (confdir, 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)); - /*******************************************************************/ TEST_FEATURE ("with no instances and XDG_RUNTIME_DIR unset"); @@ -11210,13 +11195,6 @@ /*******************************************************************/ - if (orig_xdg_runtime_dir) { - /* restore */ - setenv ("XDG_RUNTIME_DIR", orig_xdg_runtime_dir, 1); - } else { - assert0 (unsetenv ("XDG_RUNTIME_DIR")); - } - assert0 (unsetenv ("UPSTART_CONFDIR")); TEST_EQ (rmdir (dirname), 0); @@ -11302,7 +11280,6 @@ char **output; size_t lines; nih_local NihDBusProxy *upstart = NULL; - nih_local char *orig_xdg_runtime_dir = NULL; nih_local char *session_file = NULL; nih_local char *job = NULL; pid_t job_pid; @@ -11318,13 +11295,6 @@ TEST_FILENAME (sessiondir); TEST_EQ (mkdir (sessiondir, 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)); - /* Use the "secret" interface */ TEST_EQ (setenv ("UPSTART_CONFDIR", confdir, 1), 0); TEST_EQ (setenv ("UPSTART_LOGDIR", logdir, 1), 0); @@ -12054,13 +12024,6 @@ assert0 (unsetenv ("UPSTART_CONFDIR")); assert0 (unsetenv ("UPSTART_LOGDIR")); - if (orig_xdg_runtime_dir) { - /* restore */ - setenv ("XDG_RUNTIME_DIR", orig_xdg_runtime_dir, 1); - } else { - assert0 (unsetenv ("XDG_RUNTIME_DIR")); - } - TEST_EQ (rmdir (logdir), 0); TEST_EQ (rmdir (confdir), 0); @@ -12078,7 +12041,6 @@ { char confdir[PATH_MAX]; char dirname[PATH_MAX]; - nih_local char *orig_xdg_runtime_dir = NULL; char logdir[PATH_MAX]; pid_t upstart_pid = 0; nih_local char *logfile = NULL; @@ -12090,14 +12052,6 @@ mode_t test_umask = 0077; mode_t default_umask = 022; - - /* 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)); - TEST_FILENAME (dirname); TEST_EQ (mkdir (dirname, 0755), 0); TEST_EQ (setenv ("XDG_RUNTIME_DIR", dirname, 1), 0); @@ -12176,13 +12130,6 @@ /* Restore */ (void)umask (original_umask); - if (orig_xdg_runtime_dir) { - /* restore */ - setenv ("XDG_RUNTIME_DIR", orig_xdg_runtime_dir, 1); - } else { - assert0 (unsetenv ("XDG_RUNTIME_DIR")); - } - assert0 (rmdir (confdir)); assert0 (rmdir (logdir)); } @@ -15794,11 +15741,7 @@ char *args[2]; int ret = 0; - if (! getenv ("XDG_RUNTIME_DIR")) { - TEST_GROUP ("usage # TODO fails without XDG_RUNTIME_DIR set"); - TEST_FAILED (); - return; - } + TEST_TRUE (getenv ("XDG_RUNTIME_DIR")); TEST_GROUP ("usage"); @@ -16870,15 +16813,17 @@ { char confdir[PATH_MAX]; char logdir[PATH_MAX]; - char runtimedir[PATH_MAX]; size_t lines; pid_t dbus_pid = 0; pid_t upstart_pid = 0; char *value; - nih_local char *orig_xdg_runtime_dir = NULL; nih_local char *cmd = NULL; char **output; nih_local char *session_file = NULL; + char *xdg_runtime_dir; + + xdg_runtime_dir = getenv ("XDG_RUNTIME_DIR"); + TEST_TRUE (xdg_runtime_dir); TEST_GROUP ("job process table commands"); @@ -16888,22 +16833,10 @@ TEST_FILENAME (logdir); TEST_EQ (mkdir (logdir, 0755), 0); - TEST_FILENAME (runtimedir); - TEST_EQ (mkdir (runtimedir, 0755), 0); - /* Use the "secret" interface */ TEST_EQ (setenv ("UPSTART_CONFDIR", confdir, 1), 0); TEST_EQ (setenv ("UPSTART_LOGDIR", logdir, 1), 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)); - - TEST_EQ (setenv ("XDG_RUNTIME_DIR", runtimedir, 1), 0); - /*******************************************************************/ /* Ensure basic variables are set in the current environment */ @@ -16954,12 +16887,12 @@ STOP_UPSTART (upstart_pid); session_file = NIH_MUST (nih_sprintf (NULL, "%s/upstart/sessions/%d.session", - runtimedir, (int)upstart_pid)); + xdg_runtime_dir, (int)upstart_pid)); unlink (session_file); /*******************************************************************/ - test_no_inherit_job_env (runtimedir, confdir, logdir); + test_no_inherit_job_env (xdg_runtime_dir, confdir, logdir); /*******************************************************************/ @@ -16968,19 +16901,6 @@ assert0 (unsetenv ("UPSTART_LOGDIR")); assert0 (unsetenv ("UPSTART_SESSION")); - session_file = NIH_MUST (nih_sprintf (NULL, "%s/upstart/sessions", runtimedir)); - TEST_EQ (rmdir (session_file), 0); - session_file = NIH_MUST (nih_sprintf (NULL, "%s/upstart", runtimedir)); - TEST_EQ (rmdir (session_file), 0); - TEST_EQ (rmdir (runtimedir), 0); - - if (orig_xdg_runtime_dir) { - /* restore */ - setenv ("XDG_RUNTIME_DIR", orig_xdg_runtime_dir, 1); - } else { - assert0 (unsetenv ("XDG_RUNTIME_DIR")); - } - TEST_EQ (rmdir (confdir), 0); TEST_EQ (rmdir (logdir), 0); } @@ -16994,22 +16914,12 @@ pid_t upstart_pid = 0; nih_local char *cmd = NULL; char **output; - nih_local char *orig_xdg_runtime_dir = NULL; nih_local char *dbus_session_address = NULL; nih_local char *dbus_session_address2 = NULL; nih_local char *upstart_session = NULL; char *address; - char dirname[PATH_MAX]; - /* 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)); - TEST_FILENAME (dirname); - TEST_EQ (mkdir (dirname, 0755), 0); - TEST_EQ (setenv ("XDG_RUNTIME_DIR", dirname, 1), 0); + TEST_TRUE (getenv ("XDG_RUNTIME_DIR")); TEST_GROUP ("D-Bus connection"); @@ -17204,14 +17114,6 @@ /* Stop the 2nd daemon */ TEST_DBUS_END (dbus_pid2); - - /* Restore */ - if (orig_xdg_runtime_dir) { - /* restore */ - setenv ("XDG_RUNTIME_DIR", orig_xdg_runtime_dir, 1); - } else { - assert0 (unsetenv ("XDG_RUNTIME_DIR")); - } } int @@ -17225,6 +17127,8 @@ nih_main_loop_init (); program_name = "test"; + test_common_setup (); + test_upstart_open (); test_job_status (); @@ -17269,5 +17173,7 @@ test_dbus_connection (); + test_common_cleanup (); + return 0; }
-- upstart-devel mailing list upstart-devel@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/upstart-devel