~xnox/upstart/env

« back to all changes in this revision

Viewing changes to util/tests/test_initctl.c

  • Committer: Dmitrijs Ledkovs
  • Date: 2013-11-06 03:35:22 UTC
  • Revision ID: dmitrijs.ledkovs@canonical.com-20131106033522-2tv9f6xln1euxl8m
Similarly provide XDG_RUNTIME_DIR for testing session D-Bus connections.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16884
16884
        pid_t            upstart_pid = 0;
16885
16885
        nih_local char  *cmd = NULL;
16886
16886
        char           **output;
 
16887
        nih_local char  *orig_xdg_runtime_dir = NULL;
16887
16888
        nih_local char  *dbus_session_address = NULL;
16888
16889
        nih_local char  *dbus_session_address2 = NULL;
16889
16890
        nih_local char  *upstart_session = NULL;
16890
16891
        char            *address;
 
16892
        char             dirname[PATH_MAX];
 
16893
 
 
16894
        /* Take care to avoid disrupting users environment by saving and
 
16895
         * restoring this variable (assuming the tests all pass...).
 
16896
         */
 
16897
        orig_xdg_runtime_dir = getenv ("XDG_RUNTIME_DIR");
 
16898
        if (orig_xdg_runtime_dir)
 
16899
                orig_xdg_runtime_dir = NIH_MUST (nih_strdup (NULL, orig_xdg_runtime_dir));
 
16900
        TEST_FILENAME (dirname);
 
16901
        TEST_EQ (mkdir (dirname, 0755), 0);
 
16902
        TEST_EQ (setenv ("XDG_RUNTIME_DIR", dirname, 1), 0);
16891
16903
 
16892
16904
        TEST_GROUP ("D-Bus connection");
16893
16905
 
17082
17094
 
17083
17095
        /* Stop the 2nd daemon */
17084
17096
        TEST_DBUS_END (dbus_pid2);
 
17097
 
 
17098
        /* Restore */
 
17099
        if (orig_xdg_runtime_dir) {
 
17100
                /* restore */
 
17101
                setenv ("XDG_RUNTIME_DIR", orig_xdg_runtime_dir, 1);
 
17102
        } else {
 
17103
                assert0 (unsetenv ("XDG_RUNTIME_DIR"));
 
17104
        }
17085
17105
}
17086
17106
 
17087
17107
int