Merge lp:~xnox/upstart/missing-errors into lp:upstart/async

Proposed by Dimitri John Ledkov on 2014-06-03
Status: Merged
Merged at revision: 1661
Proposed branch: lp:~xnox/upstart/missing-errors
Merge into: lp:upstart/async
Diff against target: 71 lines (+50/-0)
2 files modified
init/job_process.c (+16/-0)
init/tests/test_cgroup.c (+34/-0)
To merge this branch: bzr merge lp:~xnox/upstart/missing-errors
Reviewer Review Type Date Requested Status
James Hunt 2014-06-03 Approve on 2014-06-03
Review via email: mp+221897@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 'init/job_process.c'
2--- init/job_process.c 2014-06-02 20:29:33 +0000
3+++ init/job_process.c 2014-06-03 14:53:11 +0000
4@@ -1236,6 +1236,22 @@
5 err, _("unable to switch security profile: %s"),
6 strerror (err->errnum)));
7 break;
8+ case JOB_PROCESS_ERROR_CGROUP_MGR_CONNECT:
9+ err->error.message = NIH_MUST (nih_sprintf (
10+ err, _("unable to connect to CGManager: %s"),
11+ strerror (err->errnum)));
12+ break;
13+ case JOB_PROCESS_ERROR_CGROUP_SETUP:
14+ err->error.message = NIH_MUST (nih_sprintf (
15+ err, _("unable to setup cgroup: %s"),
16+ strerror (err->errnum)));
17+ break;
18+ case JOB_PROCESS_ERROR_CGROUP_ENTER:
19+ err->error.message = NIH_MUST (nih_sprintf (
20+ err, _("unable to enter cgroup: %s"),
21+ strerror (err->errnum)));
22+ break;
23+
24 default:
25 nih_assert_not_reached ();
26 }
27
28=== modified file 'init/tests/test_cgroup.c'
29--- init/tests/test_cgroup.c 2014-05-13 09:03:14 +0000
30+++ init/tests/test_cgroup.c 2014-06-03 14:53:11 +0000
31@@ -330,6 +330,40 @@
32 assert0 (unlink (logfile_name));
33
34 /*******************************************************************/
35+ TEST_FEATURE ("Ensure bogus cgroups don't crash init");
36+
37+ contents = nih_sprintf (NULL,
38+ "cgroup name\n"
39+ "\n"
40+ "exec echo hello\n");
41+ TEST_NE_P (contents, NULL);
42+
43+ CREATE_FILE (confdir, "cgroup-name.conf", contents);
44+
45+ logfile_name = NIH_MUST (nih_sprintf (NULL, "%s/%s",
46+ logdir,
47+ "cgroup-name.log"));
48+
49+ cmd = nih_sprintf (NULL, "%s status %s 2>&1", get_initctl (), "cgroup-name");
50+ TEST_NE_P (cmd, NULL);
51+ RUN_COMMAND (NULL, cmd, &output, &lines);
52+ TEST_EQ (lines, 1);
53+
54+ /* job is not running yet */
55+ TEST_EQ_STR (output[0], "cgroup-name stop/waiting");
56+ nih_free (output);
57+
58+ TEST_FALSE (file_exists (logfile_name));
59+
60+ cmd = nih_sprintf (NULL, "%s start %s 2>&1", get_initctl (), "cgroup-name");
61+ TEST_NE_P (cmd, NULL);
62+ RUN_COMMAND (NULL, cmd, &output, &lines);
63+ TEST_EQ (lines, 1);
64+
65+ TEST_EQ_STR (output[0], "initctl: Job failed to start");
66+
67+ DELETE_FILE (confdir, "cgroup-name.conf");
68+ /*******************************************************************/
69
70 STOP_UPSTART (upstart_pid);
71 TEST_DBUS_END (dbus_pid);

Subscribers

People subscribed via source and target branches