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
=== modified file 'ChangeLog'
--- ChangeLog 2012-02-14 16:47:34 +0000
+++ ChangeLog 2012-02-15 03:29:18 +0000
@@ -1,3 +1,10 @@
12012-02-14 Steve Langasek <steve.langasek@ubuntu.com>
2
3 * init/tests/test_job_process.c:
4 - close_all_files(): helper function to close all fds above 3
5 - test_run(): call close_all_files() so that fds leaked from the
6 testsuite's environment don't cause spurious failures.
7
12012-02-14 James Hunt <james.hunt@ubuntu.com>82012-02-14 James Hunt <james.hunt@ubuntu.com>
29
3 * dbus/com.ubuntu.Upstart.xml:10 * dbus/com.ubuntu.Upstart.xml:
411
=== modified file 'init/tests/test_job_process.c'
--- init/tests/test_job_process.c 2012-02-14 16:47:34 +0000
+++ init/tests/test_job_process.c 2012-02-15 03:29:18 +0000
@@ -391,6 +391,22 @@
391 return max - nr;391 return max - nr;
392}392}
393393
394/* Helper function to close all fds above 2, in case any have been leaked
395 * to us from the environment (and thence to the child process)
396 */
397void
398close_all_files (void)
399{
400 int i;
401 struct rlimit rlim;
402
403 if (getrlimit(RLIMIT_NOFILE, &rlim) < 0)
404 return;
405
406 for (i = 3; i < rlim.rlim_cur; i++)
407 close(i);
408}
409
394/* XXX: Note that none of these tests attempts to test with a Session410/* XXX: Note that none of these tests attempts to test with a Session
395 * passed to job_class_new() since to do so would modify the home411 * passed to job_class_new() since to do so would modify the home
396 * directory of the user running these tests (BAD!!).412 * directory of the user running these tests (BAD!!).
@@ -1106,6 +1122,8 @@
1106 */1122 */
1107 TEST_EQ (setenv ("UPSTART_LOGDIR", dirname, 1), 0);1123 TEST_EQ (setenv ("UPSTART_LOGDIR", dirname, 1), 0);
11081124
1125 close_all_files();
1126
1109 /************************************************************/1127 /************************************************************/
1110 TEST_FEATURE ("ensure sane fds with no console, no script");1128 TEST_FEATURE ("ensure sane fds with no console, no script");
11111129

Subscribers

People subscribed via source and target branches

to all changes: