Steve Langasek has proposed merging lp:~vorlon/upstart/upstart-fix-racy-tests 
into lp:upstart.

Requested reviews:
  Martin Pitt (pitti)
  Upstart Reviewers (upstart-reviewers)

For more details, see:
https://code.launchpad.net/~vorlon/upstart/upstart-fix-racy-tests/+merge/293563

Adjust the script-oriented logging tests to use read from a fifo instead of
sleep 999, for clearer process handling; and fix the descriptions of a
couple of tests to match what they're actually doing.
-- 
Your team Upstart Reviewers is requested to review the proposed merge of 
lp:~vorlon/upstart/upstart-fix-racy-tests into lp:upstart.
=== modified file 'ChangeLog'
--- ChangeLog	2015-05-12 15:46:47 +0000
+++ ChangeLog	2016-05-02 19:59:01 +0000
@@ -1,3 +1,10 @@
+2016-05-02  Steve Langasek  <steve.langa...@ubuntu.com>
+
+	* init/tests/test_job_process.c: Adjust the script-oriented logging
+	  tests to use read from a fifo instead of sleep 999, for clearer
+	  process handling; and fix the descriptions of a couple of tests to
+	  match what they're actually doing.
+
 2015-05-12  James Hunt  <james.h...@ubuntu.com>
 
 	* init/log.c:

=== modified file 'init/tests/test_job_process.c'
--- init/tests/test_job_process.c	2014-07-14 12:06:30 +0000
+++ init/tests/test_job_process.c	2016-05-02 19:59:01 +0000
@@ -494,6 +494,7 @@
 	FILE            *output;
 	struct stat      statbuf;
 	char             filename[PATH_MAX], buf[80];
+	char             fifoname[PATH_MAX];
 	char             function[PATH_MAX];
 	int              status;
 	siginfo_t        info;
@@ -1729,6 +1730,13 @@
 	TEST_FEATURE ("with single-line script that is killed");
 	TEST_HASH_EMPTY (job_classes);
 
+	/* Create a fifo that we can use to read from in our scripts,
+	 * so we have a sensible way to block in shell without spawning
+	 * a separate process.
+	 */
+	TEST_GT (sprintf (fifoname, "%s/pipe", dirname), 0);
+	TEST_EQ (mknod (fifoname, S_IFIFO|S_IRUSR|S_IWUSR, 0), 0);
+
 	class = job_class_new (NULL, "test", NULL);
 	TEST_NE_P (class, NULL);
 
@@ -1738,7 +1746,7 @@
 	class->process[PROCESS_MAIN] = process_new (class);
 	class->process[PROCESS_MAIN]->command = nih_sprintf (
 			class->process[PROCESS_MAIN],
-			"%s hello world;sleep 999", TEST_CMD_ECHO);
+			"%s hello world;read <%s", TEST_CMD_ECHO, fifoname);
 	class->process[PROCESS_MAIN]->script = TRUE;
 
 	job = job_new (class, "");
@@ -1807,6 +1815,7 @@
 	fclose (output);
 
 	TEST_EQ (unlink (filename), 0);
+	TEST_EQ (unlink (fifoname), 0);
 	nih_free (class);
 
 	/************************************************************/
@@ -1913,6 +1922,13 @@
 	TEST_FEATURE ("with multi-line script that is killed");
 	TEST_HASH_EMPTY (job_classes);
 
+	/* Create a fifo that we can use to read from in our scripts,
+	 * so we have a sensible way to block in shell without spawning
+	 * a separate process.
+	 */
+	TEST_GT (sprintf (fifoname, "%s/pipe", dirname), 0);
+	TEST_EQ (mknod (fifoname, S_IFIFO|S_IRUSR|S_IWUSR, 0), 0);
+
 	/* Note we can't use TEST_ALLOC_FAIL() for this test since on
 	 * the ENOMEM loop all we could do is discard the error and
 	 * continue since job_process_start() calls job_process_spawn()
@@ -1932,7 +1948,7 @@
 	class->process[PROCESS_MAIN] = process_new (class);
 	class->process[PROCESS_MAIN]->command = nih_sprintf (
 			class->process[PROCESS_MAIN],
-			"%s hello world\nsleep 999", TEST_CMD_ECHO);
+			"%s hello world\nread <%s", TEST_CMD_ECHO, fifoname);
 	class->process[PROCESS_MAIN]->script = TRUE;
 
 	job = job_new (class, "");
@@ -1982,12 +1998,20 @@
 	fclose (output);
 
 	TEST_EQ (unlink (filename), 0);
+	TEST_EQ (unlink (fifoname), 0);
 	nih_free (class);
 
 	/************************************************************/
 	TEST_FEATURE ("with single-line script that writes 1 byte and is killed");
 	TEST_HASH_EMPTY (job_classes);
 
+	/* Create a fifo that we can use to read from in our scripts,
+	 * so we have a sensible way to block in shell without spawning
+	 * a separate process.
+	 */
+	TEST_GT (sprintf (fifoname, "%s/pipe", dirname), 0);
+	TEST_EQ (mknod (fifoname, S_IFIFO|S_IRUSR|S_IWUSR, 0), 0);
+
 	class = job_class_new (NULL, "test", NULL);
 	TEST_NE_P (class, NULL);
 
@@ -1997,7 +2021,7 @@
 	class->process[PROCESS_MAIN] = process_new (class);
 	class->process[PROCESS_MAIN]->command = nih_sprintf (
 			class->process[PROCESS_MAIN],
-			"%s -ne X;sleep 999", TEST_CMD_ECHO);
+			"%s -ne X; read <%s", TEST_CMD_ECHO, fifoname);
 	class->process[PROCESS_MAIN]->script = TRUE;
 
 	job = job_new (class, "");
@@ -2043,6 +2067,7 @@
 	fclose (output);
 
 	TEST_EQ (unlink (filename), 0);
+	TEST_EQ (unlink (fifoname), 0);
 	nih_free (class);
 
 	/************************************************************/
@@ -2055,7 +2080,7 @@
 	 */
 
 	/************************************************************/
-	TEST_FEATURE ("with multi-line script that writes 1 byte and is killed");
+	TEST_FEATURE ("with multi-line script that writes 1 byte");
 	TEST_HASH_EMPTY (job_classes);
 
 	class = job_class_new (NULL, "multiline", NULL);
@@ -2588,7 +2613,7 @@
 	class->process[PROCESS_MAIN]->command = nih_sprintf (
 			class->process[PROCESS_MAIN],
 			"%s if=/dev/zero of=/dev/null bs=1 count=0", TEST_CMD_DD);
-	class->process[PROCESS_MAIN]->script = TRUE;
+	class->process[PROCESS_MAIN]->script = FALSE;
 
 	job = job_new (class, "");
 	job->goal = JOB_START;

-- 
upstart-devel mailing list
upstart-devel@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/upstart-devel

Reply via email to