Merge lp:~xnox/upstart/xdg-runtime-dir-fixes into lp:upstart

Proposed by Dimitri John Ledkov on 2013-11-13
Status: Merged
Merged at revision: 1569
Proposed branch: lp:~xnox/upstart/xdg-runtime-dir-fixes
Merge into: lp:upstart
Diff against target: 162 lines (+42/-20)
1 file modified
util/tests/test_initctl.c (+42/-20)
To merge this branch: bzr merge lp:~xnox/upstart/xdg-runtime-dir-fixes
Reviewer Review Type Date Requested Status
James Hunt 2013-11-13 Approve on 2013-11-13
Review via email: mp+194974@code.launchpad.net
To post a comment you must log in.
James Hunt (jamesodhunt) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'util/tests/test_initctl.c'
2--- util/tests/test_initctl.c 2013-11-12 12:17:30 +0000
3+++ util/tests/test_initctl.c 2013-11-13 02:53:47 +0000
4@@ -10997,7 +10997,7 @@
5 "start on startup\n"
6 "\n"
7 "pre-start script\n"
8- "initctl set-env foo=bar\n"
9+ "%s set-env foo=bar\n"
10 "\n"
11 "# create flag file\n"
12 "touch \"%s\"\n"
13@@ -11016,10 +11016,10 @@
14 "done\n"
15 "\n"
16 "# query value post-re-exec\n"
17- "initctl get-env foo\n"
18+ "%s get-env foo\n"
19 "\n"
20 "end script\n",
21- flagfile, flagfile);
22+ get_initctl_binary(), flagfile, flagfile, get_initctl_binary());
23 TEST_NE_P (contents, NULL);
24
25 CREATE_FILE (confdir, "foo.conf", contents);
26@@ -11107,16 +11107,20 @@
27 nih_local char *session_file = NULL;
28 nih_local char *path = NULL;
29 nih_local char *expected = NULL;
30+ nih_local char *original_runtime = NULL;
31 size_t len;
32 char *value;
33
34 TEST_GROUP ("list-sessions");
35
36- TEST_FILENAME (dirname);
37- TEST_EQ (mkdir (dirname, 0755), 0);
38-
39- TEST_FILENAME (confdir);
40- TEST_EQ (mkdir (confdir, 0755), 0);
41+ original_runtime = nih_strdup (NULL, getenv("XDG_RUNTIME_DIR"));
42+ TEST_NE_P (original_runtime, NULL);
43+
44+ TEST_FILENAME (dirname);
45+ TEST_EQ (mkdir (dirname, 0755), 0);
46+
47+ TEST_FILENAME (confdir);
48+ TEST_EQ (mkdir (confdir, 0755), 0);
49
50 /*******************************************************************/
51 TEST_FEATURE ("with no instances and XDG_RUNTIME_DIR unset");
52@@ -11200,6 +11204,8 @@
53 TEST_EQ (rmdir (dirname), 0);
54 TEST_EQ (rmdir (confdir), 0);
55
56+ TEST_EQ (setenv ("XDG_RUNTIME_DIR", original_runtime, 1), 0);
57+
58 /*******************************************************************/
59 }
60
61@@ -11272,7 +11278,7 @@
62 char confdir[PATH_MAX];
63 char logdir[PATH_MAX];
64 char pid_file[PATH_MAX];
65- char sessiondir[PATH_MAX];
66+ nih_local char *sessiondir;
67 nih_local char *cmd = NULL;
68 pid_t upstart_pid = 0;
69 nih_local char *logfile = NULL;
70@@ -11286,19 +11292,21 @@
71
72 TEST_GROUP ("Session Init quiesce");
73
74- TEST_FILENAME (confdir);
75- TEST_EQ (mkdir (confdir, 0755), 0);
76-
77- TEST_FILENAME (logdir);
78- TEST_EQ (mkdir (logdir, 0755), 0);
79-
80- TEST_FILENAME (sessiondir);
81- TEST_EQ (mkdir (sessiondir, 0755), 0);
82+ TEST_FILENAME (confdir);
83+ TEST_EQ (mkdir (confdir, 0755), 0);
84+
85+ TEST_FILENAME (logdir);
86+ TEST_EQ (mkdir (logdir, 0755), 0);
87+
88+ sessiondir = nih_strdup (NULL, getenv ("XDG_RUNTIME_DIR"));
89+ TEST_NE_P (sessiondir, NULL);
90+
91+ cmd = nih_sprintf (NULL, "rm %s/upstart/sessions/*.session 2>/dev/null", sessiondir);
92+ system (cmd);
93
94 /* Use the "secret" interface */
95 TEST_EQ (setenv ("UPSTART_CONFDIR", confdir, 1), 0);
96 TEST_EQ (setenv ("UPSTART_LOGDIR", logdir, 1), 0);
97- TEST_EQ (setenv ("XDG_RUNTIME_DIR", sessiondir, 1), 0);
98
99 /* Reset initctl global from previous tests */
100 dest_name = NULL;
101@@ -12031,7 +12039,6 @@
102 TEST_EQ (rmdir (session_file), 0);
103 session_file = NIH_MUST (nih_sprintf (NULL, "%s/upstart", sessiondir));
104 TEST_EQ (rmdir (session_file), 0);
105- TEST_EQ (rmdir (sessiondir), 0);
106
107 /*******************************************************************/
108 }
109@@ -12044,6 +12051,7 @@
110 char logdir[PATH_MAX];
111 pid_t upstart_pid = 0;
112 nih_local char *logfile = NULL;
113+ nih_local char *original_runtime = NULL;
114 mode_t job_umask;
115 nih_local char *job_umask_str = NULL;
116 size_t length;
117@@ -12052,6 +12060,9 @@
118 mode_t test_umask = 0077;
119 mode_t default_umask = 022;
120
121+ original_runtime = nih_strdup (NULL, getenv ("XDG_RUNTIME_DIR"));
122+ TEST_NE_P (original_runtime, NULL);
123+
124 TEST_FILENAME (dirname);
125 TEST_EQ (mkdir (dirname, 0755), 0);
126 TEST_EQ (setenv ("XDG_RUNTIME_DIR", dirname, 1), 0);
127@@ -12129,6 +12140,7 @@
128
129 /* Restore */
130 (void)umask (original_umask);
131+ TEST_EQ (setenv ("XDG_RUNTIME_DIR", original_runtime, 1), 0);
132
133 assert0 (rmdir (confdir));
134 assert0 (rmdir (logdir));
135@@ -16917,9 +16929,17 @@
136 nih_local char *dbus_session_address = NULL;
137 nih_local char *dbus_session_address2 = NULL;
138 nih_local char *upstart_session = NULL;
139+ nih_local char *original_runtime = NULL;
140+ char dirname[PATH_MAX];
141 char *address;
142
143- TEST_TRUE (getenv ("XDG_RUNTIME_DIR"));
144+ original_runtime = nih_strdup (NULL, getenv("XDG_RUNTIME_DIR"));
145+ TEST_NE_P (original_runtime, NULL);
146+
147+ TEST_FILENAME (dirname);
148+ TEST_EQ (mkdir (dirname, 0755), 0);
149+
150+ TEST_EQ (setenv ("XDG_RUNTIME_DIR", dirname, 1), 0);
151
152 TEST_GROUP ("D-Bus connection");
153
154@@ -17114,6 +17134,8 @@
155
156 /* Stop the 2nd daemon */
157 TEST_DBUS_END (dbus_pid2);
158+
159+ TEST_EQ (setenv ("XDG_RUNTIME_DIR", original_runtime, 1), 0);
160 }
161
162 int

Subscribers

People subscribed via source and target branches