Dimitri John Ledkov has proposed merging lp:~xnox/upstart/read-vs-sigchild into
lp:upstart.
Requested reviews:
Upstart Reviewers (upstart-reviewers)
For more details, see:
https://code.launchpad.net/~xnox/upstart/read-vs-sigchild/+merge/226560
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).
--
https://code.launchpad.net/~xnox/upstart/read-vs-sigchild/+merge/226560
Your team Upstart Reviewers is requested to review the proposed merge of
lp:~xnox/upstart/read-vs-sigchild into lp:upstart.
=== modified file 'init/tests/test_job_process.c'
--- init/tests/test_job_process.c 2014-07-11 19:42:48 +0000
+++ init/tests/test_job_process.c 2014-07-12 00:42:21 +0000
@@ -145,6 +145,20 @@
NIH_MUST (nih_main_loop_add_func (NULL, (NihMainLoopCb)event_poll, \
NULL))
+#define TEST_INSTALL_CHILD_HANDLERS_WITHOUT_JOB_PROCESS() \
+ NIH_MUST (nih_child_add_watch (NULL, \
+ -1, \
+ NIH_CHILD_ALL, \
+ test_job_process_handler,\
+ NULL)); \
+ NIH_MUST (nih_child_add_watch (NULL, \
+ -1, \
+ NIH_CHILD_ALL, \
+ job_process_handler, \
+ NULL)); \
+ NIH_MUST (nih_main_loop_add_func (NULL, (NihMainLoopCb)event_poll, \
+ NULL))
+
#define TEST_CLEAR_CHILD_STATUS() \
do { \
@@ -506,6 +520,7 @@
pid_t pid;
int i;
siginfo_t siginfo;
+ NihList *removed_watch;
log_unflushed_init ();
job_class_init ();
@@ -1165,11 +1180,11 @@
* job_process_start() raises a ProcessError and the command doesn't
* have any stored process id for it.
*/
- TEST_FEATURE ("with no such file");
+ TEST_FEATURE ("with no such file (read error)");
TEST_HASH_EMPTY (job_classes);
TEST_RESET_MAIN_LOOP ();
- TEST_INSTALL_CHILD_HANDLERS ();
+ TEST_INSTALL_CHILD_HANDLERS_WITHOUT_JOB_PROCESS ();
output = tmpfile ();
@@ -1209,6 +1224,54 @@
nih_free (class);
}
+ TEST_RESET_MAIN_LOOP ();
+
+ TEST_FEATURE ("with no such file (child abort)");
+ TEST_HASH_EMPTY (job_classes);
+
+ TEST_RESET_MAIN_LOOP ();
+ TEST_INSTALL_CHILD_HANDLERS_WITHOUT_JOB_PROCESS ();
+
+ output = tmpfile ();
+
+ TEST_ALLOC_FAIL {
+ TEST_ALLOC_SAFE {
+ TEST_HASH_EMPTY (job_classes);
+ class = job_class_new (NULL, "test", NULL);
+ class->console = CONSOLE_NONE;
+ class->process[PROCESS_MAIN] = process_new (class);
+ class->process[PROCESS_MAIN]->script = FALSE;
+ class->process[PROCESS_MAIN]->command = filename;
+
+ job = job_new (class, "foo");
+ job->goal = JOB_START;
+ job->state = JOB_SPAWNED;
+
+ nih_hash_add (job_classes, &class->entry);
+ TEST_CLEAR_CHILD_STATUS ();
+ }
+
+ TEST_DIVERT_STDERR (output) {
+ job_process_start (job, PROCESS_MAIN);
+ pid = job->pid[PROCESS_MAIN];
+ TEST_GT (pid, 0);
+ waitpid (pid, &status, 0);
+ TEST_TRUE (WIFEXITED (status));
+ TEST_EQ (WEXITSTATUS (status), 255);
+ job_process_handler (NULL, pid, NIH_CHILD_EXITED, 255);
+ event_poll ();
+ }
+ rewind (output);
+
+ TEST_EQ (job->pid[PROCESS_MAIN], 0);
+ TEST_GT (sprintf (buffer, "test: test (foo) main process (%i) terminated with status 255\n", pid), 0);
+ TEST_FILE_EQ (output, buffer);
+ TEST_FILE_END (output);
+ TEST_FILE_RESET (output);
+
+ nih_free (class);
+ }
+
TEST_EQ (rmdir (dirname), 0);
TEST_RESET_MAIN_LOOP ();
--
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/upstart-devel