Merge lp:~xnox/upstart/read-vs-sigchild into lp:upstart

Proposed by Dimitri John Ledkov
Status: Merged
Merged at revision: 1651
Proposed branch: lp:~xnox/upstart/read-vs-sigchild
Merge into: lp:upstart
Diff against target: 101 lines (+65/-2)
1 file modified
init/tests/test_job_process.c (+65/-2)
To merge this branch: bzr merge lp:~xnox/upstart/read-vs-sigchild
Reviewer Review Type Date Requested Status
Dimitri John Ledkov Needs Fixing
Review via email: mp+226560@code.launchpad.net

Description of the change

This should resolve racy test failure as seen on arm64:

not ok 16 - with no such file
 wrong content in file 0x557c0b1480 (output), expected 'test: Failed to spawn test (foo) main process: unable to execute: No such file or directory
' got 'test: test (foo) main process (348) terminated with status 255
'
 at tests/test_job_process.c:1205 (test_start).

To post a comment you must log in.
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Haha, and it didn't:

not ok 16 - with no such file (read error)
 wrong content in file 0x55c91bf480 (output), expected 'test: Failed to spawn test (foo) main process: unable to execute: No such file or directory
' got 'test: test (foo) main process (14635) terminated with status 255
'
 at tests/test_job_process.c:1220 (test_start).
1..153

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'init/tests/test_job_process.c'
2--- init/tests/test_job_process.c 2014-07-11 19:42:48 +0000
3+++ init/tests/test_job_process.c 2014-07-12 00:42:21 +0000
4@@ -145,6 +145,20 @@
5 NIH_MUST (nih_main_loop_add_func (NULL, (NihMainLoopCb)event_poll, \
6 NULL))
7
8+#define TEST_INSTALL_CHILD_HANDLERS_WITHOUT_JOB_PROCESS() \
9+ NIH_MUST (nih_child_add_watch (NULL, \
10+ -1, \
11+ NIH_CHILD_ALL, \
12+ test_job_process_handler,\
13+ NULL)); \
14+ NIH_MUST (nih_child_add_watch (NULL, \
15+ -1, \
16+ NIH_CHILD_ALL, \
17+ job_process_handler, \
18+ NULL)); \
19+ NIH_MUST (nih_main_loop_add_func (NULL, (NihMainLoopCb)event_poll, \
20+ NULL))
21+
22
23 #define TEST_CLEAR_CHILD_STATUS() \
24 do { \
25@@ -506,6 +520,7 @@
26 pid_t pid;
27 int i;
28 siginfo_t siginfo;
29+ NihList *removed_watch;
30
31 log_unflushed_init ();
32 job_class_init ();
33@@ -1165,11 +1180,11 @@
34 * job_process_start() raises a ProcessError and the command doesn't
35 * have any stored process id for it.
36 */
37- TEST_FEATURE ("with no such file");
38+ TEST_FEATURE ("with no such file (read error)");
39 TEST_HASH_EMPTY (job_classes);
40
41 TEST_RESET_MAIN_LOOP ();
42- TEST_INSTALL_CHILD_HANDLERS ();
43+ TEST_INSTALL_CHILD_HANDLERS_WITHOUT_JOB_PROCESS ();
44
45 output = tmpfile ();
46
47@@ -1209,6 +1224,54 @@
48 nih_free (class);
49 }
50
51+ TEST_RESET_MAIN_LOOP ();
52+
53+ TEST_FEATURE ("with no such file (child abort)");
54+ TEST_HASH_EMPTY (job_classes);
55+
56+ TEST_RESET_MAIN_LOOP ();
57+ TEST_INSTALL_CHILD_HANDLERS_WITHOUT_JOB_PROCESS ();
58+
59+ output = tmpfile ();
60+
61+ TEST_ALLOC_FAIL {
62+ TEST_ALLOC_SAFE {
63+ TEST_HASH_EMPTY (job_classes);
64+ class = job_class_new (NULL, "test", NULL);
65+ class->console = CONSOLE_NONE;
66+ class->process[PROCESS_MAIN] = process_new (class);
67+ class->process[PROCESS_MAIN]->script = FALSE;
68+ class->process[PROCESS_MAIN]->command = filename;
69+
70+ job = job_new (class, "foo");
71+ job->goal = JOB_START;
72+ job->state = JOB_SPAWNED;
73+
74+ nih_hash_add (job_classes, &class->entry);
75+ TEST_CLEAR_CHILD_STATUS ();
76+ }
77+
78+ TEST_DIVERT_STDERR (output) {
79+ job_process_start (job, PROCESS_MAIN);
80+ pid = job->pid[PROCESS_MAIN];
81+ TEST_GT (pid, 0);
82+ waitpid (pid, &status, 0);
83+ TEST_TRUE (WIFEXITED (status));
84+ TEST_EQ (WEXITSTATUS (status), 255);
85+ job_process_handler (NULL, pid, NIH_CHILD_EXITED, 255);
86+ event_poll ();
87+ }
88+ rewind (output);
89+
90+ TEST_EQ (job->pid[PROCESS_MAIN], 0);
91+ TEST_GT (sprintf (buffer, "test: test (foo) main process (%i) terminated with status 255\n", pid), 0);
92+ TEST_FILE_EQ (output, buffer);
93+ TEST_FILE_END (output);
94+ TEST_FILE_RESET (output);
95+
96+ nih_free (class);
97+ }
98+
99 TEST_EQ (rmdir (dirname), 0);
100
101 TEST_RESET_MAIN_LOOP ();

Subscribers

People subscribed via source and target branches