Merge authors:
  Dmitrijs Ledkovs (xnox)
  James Hunt (jamesodhunt)
  Stéphane Graber (stgraber)
Related merge proposals:
  
https://code.launchpad.net/~stgraber/upstart/upstart-udev-bridge-man/+merge/140673
  proposed by: Stéphane Graber (stgraber)
  review: Approve - James Hunt (jamesodhunt)
  https://code.launchpad.net/~xnox/upstart/test-static/+merge/140655
  proposed by: Dmitrijs Ledkovs (xnox)
  review: Approve - James Hunt (jamesodhunt)
  https://code.launchpad.net/~xnox/upstart/utmp-usleep/+merge/140490
  proposed by: Dmitrijs Ledkovs (xnox)
  review: Approve - James Hunt (jamesodhunt)
------------------------------------------------------------
revno: 1409 [merge]
committer: James Hunt <[email protected]>
branch nick: upstart-setenv+getenv
timestamp: Wed 2012-12-19 16:26:47 +0000
message:
  * Sync with lp:upstart.
added:
  init/tests/test_conf_static.c
modified:
  extra/man/upstart-udev-bridge.8
  init/Makefile.am
  init/conf.c
  init/conf.h
  init/tests/test_conf.c
  init/tests/test_job_process.c
  util/tests/test_sysv.c
  util/tests/test_utmp.c


--
lp:upstart
https://code.launchpad.net/~upstart-devel/upstart/trunk

Your team Upstart Reviewers is subscribed to branch lp:upstart.
To unsubscribe from this branch go to 
https://code.launchpad.net/~upstart-devel/upstart/trunk/+edit-subscription
=== modified file 'extra/man/upstart-udev-bridge.8'
--- extra/man/upstart-udev-bridge.8	2012-11-14 14:47:19 +0000
+++ extra/man/upstart-udev-bridge.8	2012-12-19 13:55:12 +0000
@@ -71,12 +71,6 @@
 .IP graphics\-card\-added
 Event emitted when a graphics device is available to the system.
 .\"
-.SH NOTES
-This is a temporary tool until
-.BR init (8)
-itself gains the functionality to read them directly; you should not
-rely on its behaviour.
-.\"
 .SH AUTHOR
 Written by Scott James Remnant
 .RB < [email protected] >

=== modified file 'init/Makefile.am'
--- init/Makefile.am	2012-12-14 15:54:35 +0000
+++ init/Makefile.am	2012-12-19 12:46:46 +0000
@@ -154,6 +154,7 @@
 	test_parse_job \
 	test_parse_conf \
 	test_conf \
+	test_conf_static \
 	test_xdg \
 	test_control
 
@@ -339,6 +340,20 @@
 	$(JSON_LIBS) \
 	-lrt
 
+test_conf_static_SOURCES = tests/test_conf_static.c
+test_conf_static_LDADD = \
+	system.o environ.o process.o \
+	job_class.o job_process.o job.o event.o event_operator.o blocked.o \
+	parse_job.o parse_conf.o control.o \
+	session.o log.o state.o \
+	com.ubuntu.Upstart.o \
+	com.ubuntu.Upstart.Job.o com.ubuntu.Upstart.Instance.o \
+	$(NIH_LIBS) \
+	$(NIH_DBUS_LIBS) \
+	$(DBUS_LIBS) \
+	$(JSON_LIBS) \
+	-lrt
+
 test_xdg_SOURCES = tests/test_xdg.c
 test_xdg_LDADD = \
 	xdg.o \

=== modified file 'init/conf.c'
--- init/conf.c	2012-09-09 20:01:22 +0000
+++ init/conf.c	2012-12-19 12:46:46 +0000
@@ -83,6 +83,9 @@
 static inline int is_conf_file_override(const char *path)
 	__attribute__ ((warn_unused_result));
 
+static inline char *toggle_conf_name   (const void *parent, const char *path)
+	__attribute__ ((warn_unused_result, malloc));
+
 /**
  * conf_sources:
  *
@@ -167,15 +170,12 @@
  * "foo.override", whereas if @path is "foo.override", it will return
  * "foo.conf".
  *
- * Note that this function should be static, but isn't to allow the
- * tests to access it.
- *
  * @parent: parent of returned path,
  * @path: path to a configuration file.
  *
  * Returns: newly allocated toggled path, or NULL on error.
  **/
-char *
+static inline char *
 toggle_conf_name (const void     *parent,
 		 const char     *path)
 {

=== modified file 'init/conf.h'
--- init/conf.h	2012-09-09 19:24:49 +0000
+++ init/conf.h	2012-12-19 12:46:46 +0000
@@ -127,9 +127,6 @@
 
 JobClass *  conf_select_job    (const char *name, const Session *session);
 
-char *toggle_conf_name         (const void *parent, const char *path)
-	__attribute__ ((warn_unused_result, malloc));
-
 #ifdef DEBUG
 
 /* used for debugging only */

=== modified file 'init/tests/test_conf.c'
--- init/tests/test_conf.c	2012-09-20 08:12:05 +0000
+++ init/tests/test_conf.c	2012-12-19 12:46:46 +0000
@@ -2417,53 +2417,6 @@
 }
 
 void
-test_toggle_conf_name (void)
-{
-	char override_ext[] = ".override";
-	char dirname[PATH_MAX];
-	char filename[PATH_MAX];
-	JobClass *job;
-	char *f;
-	char *p;
-
-	TEST_FUNCTION_FEATURE ("toggle_conf_name",
-			"changing conf to override");
-
-	TEST_FILENAME (dirname);
-	strcpy (filename, dirname);
-	strcat (filename, "/foo.conf");
-	f = toggle_conf_name (NULL, filename);
-	TEST_NE_P (f, NULL);
-
-	p = strstr (f, ".override");
-	TEST_NE_P (p, NULL);
-	TEST_EQ_P (p, f+strlen (f) - strlen (override_ext));
-	nih_free (f);
-
-	TEST_FEATURE ("changing override to conf");
-	strcpy (filename, dirname);
-	strcat (filename, "/bar.override");
-	f = toggle_conf_name (NULL, filename);
-	TEST_NE_P (f, NULL);
-
-	p = strstr (f, ".conf");
-	TEST_NE_P (p, NULL);
-	TEST_EQ_P (p, f+strlen (f) - strlen (".conf"));
-	nih_free (f);
-
-	/* test parent param */
-	job = job_class_new (NULL, "foo", NULL);
-	TEST_NE_P (job, NULL);
-
-	f = toggle_conf_name (job, filename);
-	TEST_NE_P (f, NULL);
-
-	TEST_EQ (TRUE, nih_alloc_parent (f, job));
-
-	nih_free (job);
-}
-
-void
 test_override (void)
 {
 	ConfSource *source;
@@ -4708,7 +4661,6 @@
 	test_source_reload_conf_dir ();
 	test_source_reload_file ();
 	test_source_reload ();
-	test_toggle_conf_name ();
 	test_override ();
 	test_file_destroy ();
 	test_select_job ();

=== added file 'init/tests/test_conf_static.c'
--- init/tests/test_conf_static.c	1970-01-01 00:00:00 +0000
+++ init/tests/test_conf_static.c	2012-12-19 12:46:46 +0000
@@ -0,0 +1,81 @@
+/* upstart
+ *
+ * test_conf.c - test suite for init/conf.c
+ *
+ * Copyright © 2012 Canonical Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <limits.h>
+
+#include <nih/test.h>
+
+#include "conf.c"
+
+void
+test_toggle_conf_name (void)
+{
+	char override_ext[] = ".override";
+	char dirname[PATH_MAX];
+	char filename[PATH_MAX];
+	JobClass *job;
+	char *f;
+	char *p;
+
+	TEST_FUNCTION_FEATURE ("toggle_conf_name",
+			"changing conf to override");
+
+	TEST_FILENAME (dirname);
+	strcpy (filename, dirname);
+	strcat (filename, "/foo.conf");
+	f = toggle_conf_name (NULL, filename);
+	TEST_NE_P (f, NULL);
+
+	p = strstr (f, ".override");
+	TEST_NE_P (p, NULL);
+	TEST_EQ_P (p, f+strlen (f) - strlen (override_ext));
+	nih_free (f);
+
+	TEST_FEATURE ("changing override to conf");
+	strcpy (filename, dirname);
+	strcat (filename, "/bar.override");
+	f = toggle_conf_name (NULL, filename);
+	TEST_NE_P (f, NULL);
+
+	p = strstr (f, ".conf");
+	TEST_NE_P (p, NULL);
+	TEST_EQ_P (p, f+strlen (f) - strlen (".conf"));
+	nih_free (f);
+
+	/* test parent param */
+	job = job_class_new (NULL, "foo", NULL);
+	TEST_NE_P (job, NULL);
+
+	f = toggle_conf_name (job, filename);
+	TEST_NE_P (f, NULL);
+
+	TEST_EQ (TRUE, nih_alloc_parent (f, job));
+
+	nih_free (job);
+}
+
+int
+main (int   argc,
+      char *argv[])
+{
+	test_toggle_conf_name ();
+
+	return 0;
+}

=== modified file 'init/tests/test_job_process.c'
--- init/tests/test_job_process.c	2012-12-18 11:02:00 +0000
+++ init/tests/test_job_process.c	2012-12-19 12:16:59 +0000
@@ -131,6 +131,9 @@
 	TEST_FDS
 };
 
+
+pid_t pty_child_pid;
+
 static char *argv0;
 
 static int get_available_pty_count (void) __attribute__((unused));
@@ -9124,8 +9127,20 @@
 	nih_free (err);
 
 	nih_free (io);
-	nih_main_loop_exit (EXIT_SUCCESS);
-}
+}
+
+/* Grab child exit status and ask main loop to exit */
+void
+process_handler (void          *data,
+		pid_t           pid,
+		NihChildEvents  event,
+		int             status)
+{
+	nih_assert (pid == pty_child_pid);
+
+	nih_main_loop_exit (status);
+}
+
 
 /**
  * run_tests_in_pty:
@@ -9146,21 +9161,18 @@
 void
 run_tests_in_pty (void)
 {
-	pid_t             pid;
 	int               pty_master;
 	int               pty_slave;
 	nih_local NihIo  *io = NULL;
 	int               ret;
-	int               status;
-	int               exit_status = 0;
 
 	ret = openpty (&pty_master, &pty_slave, NULL, NULL, NULL);
 	TEST_NE (ret, -1);
 
-	pid = fork ();
-	TEST_NE (pid, (pid_t)-1);
+	pty_child_pid = fork ();
+	TEST_NE (pty_child_pid, (pid_t)-1);
 
-	if (! pid) {
+	if (! pty_child_pid) {
 		int   i;
 		pid_t self;
 
@@ -9176,7 +9188,7 @@
 
 		/* connect standard streams to the child end of the pty */
 		for (i = 0; i < 3; i++)
-			while (dup2(pty_slave, i) == -1 && errno == EBUSY)
+			while (dup2 (pty_slave, i) == -1 && errno == EBUSY)
 				;
 
 		/* clean up */
@@ -9198,18 +9210,14 @@
 			io_error_handler, NULL);
 	TEST_NE_P (io, NULL);
 
+	/* Watch child for events */
+	NIH_MUST (nih_child_add_watch (NULL, pty_child_pid,
+				(NIH_CHILD_EXITED|NIH_CHILD_KILLED|NIH_CHILD_DUMPED),
+				process_handler, NULL)); 
+
 	ret = nih_main_loop ();
 
-	/* wait for child to finish */
-	TEST_EQ (waitpid (pid, &status, 0), pid);
-
-	/* catch exit status if it failed and return it via parent */
-	exit_status = WIFEXITED (status) ? WEXITSTATUS (status) :
-		      WIFSIGNALED (status) ? WTERMSIG (status) :
-		      WIFSTOPPED (status) ?  WSTOPSIG (status) :
-		      EXIT_FAILURE;
-
-	exit (exit_status ? exit_status : ret);
+	exit (ret ? EXIT_FAILURE : EXIT_SUCCESS);
 }
 
 /**

=== modified file 'util/tests/test_sysv.c'
--- util/tests/test_sysv.c	2009-07-09 11:50:19 +0000
+++ util/tests/test_sysv.c	2012-12-18 16:37:38 +0000
@@ -203,6 +203,8 @@
 		gettimeofday (&tv, NULL);
 		record.ut_tv.tv_sec = tv.tv_sec;
 		record.ut_tv.tv_usec = tv.tv_usec;
+		/* See comment in test_utmp */
+		usleep(200);
 
 		utmpxname (utmp_file);
 
@@ -806,6 +808,8 @@
 		gettimeofday (&tv, NULL);
 		record.ut_tv.tv_sec = tv.tv_sec;
 		record.ut_tv.tv_usec = tv.tv_usec;
+		/* See comment in test_utmp */
+		usleep(200);
 
 		utmpxname (utmp_file);
 

=== modified file 'util/tests/test_utmp.c'
--- util/tests/test_utmp.c	2009-07-14 11:04:34 +0000
+++ util/tests/test_utmp.c	2012-12-18 16:37:38 +0000
@@ -857,6 +857,13 @@
 		gettimeofday (&tv, NULL);
 		record.ut_tv.tv_sec = tv.tv_sec;
 		record.ut_tv.tv_usec = tv.tv_usec;
+		/* utmp/wtmp records do not have nanosecond resolution
+		 * yet the tests expect time to lapse, but it might not
+		 * on very, very fast machines.
+		 * https://jenkins.qa.ubuntu.com/view/Raring/view/AutoPkgTest/job/raring-adt-upstart/
+		 * Is there a better way to fix the tests?
+		 */
+		usleep(200);
 
 		utmpxname (utmp_file);
 

-- 
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/upstart-devel

Reply via email to