Merge lp:~vorlon/upstart/lp.926473 into lp:~jamesodhunt/upstart/early-job-log-flush

Proposed by Steve Langasek
Status: Needs review
Proposed branch: lp:~vorlon/upstart/lp.926473
Merge into: lp:~jamesodhunt/upstart/early-job-log-flush
Diff against target: 49 lines (+25/-0)
2 files modified
ChangeLog (+7/-0)
init/tests/test_job_process.c (+18/-0)
To merge this branch: bzr merge lp:~vorlon/upstart/lp.926473
Reviewer Review Type Date Requested Status
James Hunt Pending
Review via email: mp+93124@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

1359. By Steve Langasek

don't let leaked file descriptors from the environment cause the test suite to
fail

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2012-02-14 16:47:34 +0000
3+++ ChangeLog 2012-02-15 03:29:18 +0000
4@@ -1,3 +1,10 @@
5+2012-02-14 Steve Langasek <steve.langasek@ubuntu.com>
6+
7+ * init/tests/test_job_process.c:
8+ - close_all_files(): helper function to close all fds above 3
9+ - test_run(): call close_all_files() so that fds leaked from the
10+ testsuite's environment don't cause spurious failures.
11+
12 2012-02-14 James Hunt <james.hunt@ubuntu.com>
13
14 * dbus/com.ubuntu.Upstart.xml:
15
16=== modified file 'init/tests/test_job_process.c'
17--- init/tests/test_job_process.c 2012-02-14 16:47:34 +0000
18+++ init/tests/test_job_process.c 2012-02-15 03:29:18 +0000
19@@ -391,6 +391,22 @@
20 return max - nr;
21 }
22
23+/* Helper function to close all fds above 2, in case any have been leaked
24+ * to us from the environment (and thence to the child process)
25+ */
26+void
27+close_all_files (void)
28+{
29+ int i;
30+ struct rlimit rlim;
31+
32+ if (getrlimit(RLIMIT_NOFILE, &rlim) < 0)
33+ return;
34+
35+ for (i = 3; i < rlim.rlim_cur; i++)
36+ close(i);
37+}
38+
39 /* XXX: Note that none of these tests attempts to test with a Session
40 * passed to job_class_new() since to do so would modify the home
41 * directory of the user running these tests (BAD!!).
42@@ -1106,6 +1122,8 @@
43 */
44 TEST_EQ (setenv ("UPSTART_LOGDIR", dirname, 1), 0);
45
46+ close_all_files();
47+
48 /************************************************************/
49 TEST_FEATURE ("ensure sane fds with no console, no script");
50

Subscribers

People subscribed via source and target branches

to all changes: