You have been requested to review the proposed merge of 
lp:~xnox/upstart/reload-signal into lp:upstart.

For more details, see:
https://code.launchpad.net/~xnox/upstart/reload-signal/+merge/176099

This branch adds "reload signal" stanza.

Instead of initctl calling kill on the main process, it now calls an instance 
dbus method Reload.

Reload method, looks up reload_signal and calls kill on the main process with 
it.

Tests added:
* serialisation/deserialisation
* job configuration parsing
* job_reload() function in init/job.c

Broken tests:
* test_initctl reload_action test currently hangs, and thus is commented out. 
Help with testing it is appreciated, I guess it now needs to simply test that 
dbus calls are done in the right order without actually testing that signals 
were sent to a process, as this is now done in the job_reload() test.

-- 
https://code.launchpad.net/~xnox/upstart/reload-signal/+merge/176099
Your team Upstart Reviewers is requested to review the proposed merge of 
lp:~xnox/upstart/reload-signal into lp:upstart.
=== modified file 'dbus/com.ubuntu.Upstart.Instance.xml'
--- dbus/com.ubuntu.Upstart.Instance.xml	2010-12-14 15:32:41 +0000
+++ dbus/com.ubuntu.Upstart.Instance.xml	2013-08-21 11:08:31 +0000
@@ -35,6 +35,9 @@
       <annotation name="com.netsplit.Nih.Method.Async" value="true" />
       <arg name="wait" type="b" direction="in" />
     </method>
+    <method name="Reload">
+      <annotation name="com.netsplit.Nih.Method.Async" value="true" />
+    </method>
 
     <signal name="GoalChanged">
       <arg name="goal" type="s" />

=== modified file 'init/job.c'
--- init/job.c	2013-05-29 10:36:36 +0000
+++ init/job.c	2013-08-21 11:08:31 +0000
@@ -1397,6 +1397,54 @@
 
 
 /**
+ * job_reload:
+ * @job: job to reload,
+ * @message: D-Bus connection and message received,
+ *
+ * Implements the Reload method of the com.ubuntu.Upstart.Instance
+ * interface.
+ *
+ * Called on a running instance @job to reload.
+ *
+ * Returns: zero on success, negative value on raised error.
+ **/
+int
+job_reload (Job            *job,
+	    NihDBusMessage *message)
+{
+	Session *session;
+
+	nih_assert (job != NULL);
+	nih_assert (message != NULL);
+
+	/* Don't permit out-of-session modification */
+	session = session_from_dbus (NULL, message);
+	if (session != job->class->session) {
+		nih_dbus_error_raise_printf (
+			DBUS_INTERFACE_UPSTART ".Error.PermissionDenied",
+			_("You do not have permission to modify job: %s"),
+			job_name (job));
+		return -1;
+	}
+
+	if (job->pid[PROCESS_MAIN] <= 0) {
+		nih_dbus_error_raise_printf (
+			DBUS_INTERFACE_UPSTART ".Error.NotRunning",
+			_("Job is not running: %s"),
+			job_name (job));
+
+		return -1;
+	}
+
+	if (kill (job->pid[PROCESS_MAIN], job->class->reload_signal) < 0)
+		nih_return_system_error (-1);
+
+	NIH_ZERO (job_reload_reply (message));
+	return 0;
+}
+
+
+/**
  * job_get_name:
  * @job: job to obtain name from,
  * @message: D-Bus connection and message received,

=== modified file 'init/job.h'
--- init/job.h	2013-05-29 10:36:36 +0000
+++ init/job.h	2013-08-21 11:08:31 +0000
@@ -196,6 +196,8 @@
 	__attribute__ ((warn_unused_result));
 int         job_restart         (Job *job, NihDBusMessage *message, int wait)
 	__attribute__ ((warn_unused_result));
+int         job_reload          (Job *job, NihDBusMessage *message)
+	__attribute__ ((warn_unused_result));
 
 int         job_get_name        (Job *job, NihDBusMessage *message,
 				 char **name)

=== modified file 'init/job_class.c'
--- init/job_class.c	2013-07-16 15:47:12 +0000
+++ init/job_class.c	2013-08-21 11:08:31 +0000
@@ -342,6 +342,8 @@
 	class->kill_timeout = JOB_DEFAULT_KILL_TIMEOUT;
 	class->kill_signal = SIGTERM;
 
+	class->reload_signal = SIGHUP;
+
 	class->respawn = FALSE;
 	class->respawn_limit = JOB_DEFAULT_RESPAWN_LIMIT;
 	class->respawn_interval = JOB_DEFAULT_RESPAWN_INTERVAL;
@@ -1918,6 +1920,9 @@
 	if (! state_set_json_int_var_from_obj (json, class, kill_signal))
 		goto error;
 
+	if (! state_set_json_int_var_from_obj (json, class, reload_signal))
+		goto error;
+
 	if (! state_set_json_int_var_from_obj (json, class, respawn))
 		goto error;
 
@@ -2218,6 +2223,12 @@
 	if (! state_get_json_int_var_to_obj (json, class, kill_signal))
 		goto error;
 
+	/* reload_signal is new in upstart 1.10+ */
+	if (json_object_object_get (json, "reload_signal")) {
+		if (! state_get_json_int_var_to_obj (json, class, reload_signal))
+			goto error;
+	}
+
 	if (! state_get_json_int_var_to_obj (json, class, respawn))
 		goto error;
 

=== modified file 'init/job_class.h'
--- init/job_class.h	2013-05-29 10:36:36 +0000
+++ init/job_class.h	2013-08-21 11:08:31 +0000
@@ -148,6 +148,7 @@
  * @task: start requests are not unblocked until instances have finished,
  * @kill_timeout: time to wait between sending TERM and KILL signals,
  * @kill_signal: first signal to send (usually SIGTERM),
+ * @reload_signal: reload signal to send (usually SIGHUP),
  * @respawn: instances should be restarted if main process fails,
  * @respawn_limit: number of respawns in @respawn_interval that we permit,
  * @respawn_interval: barrier for @respawn_limit,
@@ -199,6 +200,8 @@
 	time_t          kill_timeout;
 	int             kill_signal;
 
+	int             reload_signal;
+
 	int             respawn;
 	int             respawn_limit;
 	time_t          respawn_interval;

=== modified file 'init/parse_job.c'
--- init/parse_job.c	2013-05-15 13:21:54 +0000
+++ init/parse_job.c	2013-08-21 11:08:31 +0000
@@ -171,6 +171,11 @@
 			       size_t *pos, size_t *lineno)
 	__attribute__ ((warn_unused_result));
 
+static int stanza_reload      (JobClass *class, NihConfigStanza *stanza,
+			       const char *file, size_t len,
+			       size_t *pos, size_t *lineno)
+	__attribute__ ((warn_unused_result));
+
 static int stanza_apparmor    (JobClass *class, NihConfigStanza *stanza,
 			       const char *file, size_t len,
 			       size_t *pos, size_t *lineno)
@@ -262,6 +267,7 @@
 	{ "expect",      (NihConfigHandler)stanza_expect      },
 	{ "task",        (NihConfigHandler)stanza_task        },
 	{ "kill",        (NihConfigHandler)stanza_kill        },
+	{ "reload",      (NihConfigHandler)stanza_reload      },
 	{ "respawn",     (NihConfigHandler)stanza_respawn     },
 	{ "normal",      (NihConfigHandler)stanza_normal      },
 	{ "console",     (NihConfigHandler)stanza_console     },
@@ -1938,6 +1944,92 @@
 	return ret;
 }
 
+
+/**
+ * stanza_reload:
+ * @class: job class being parsed,
+ * @stanza: stanza found,
+ * @file: file or string to parse,
+ * @len: length of @file,
+ * @pos: offset within @file,
+ * @lineno: line number.
+ *
+ * Parse a reload stanza from @file, extracting a second-level stanza that
+ * states which value to set from its argument.
+ *
+ * Returns: zero on success, negative value on error.
+ **/
+static int
+stanza_reload (JobClass        *class,
+	       NihConfigStanza *stanza,
+	       const char      *file,
+	       size_t           len,
+	       size_t          *pos,
+	       size_t          *lineno)
+{
+	size_t          a_pos, a_lineno;
+	int             ret = -1;
+	char           *endptr;
+	nih_local char *arg = NULL;
+
+	nih_assert (class != NULL);
+	nih_assert (stanza != NULL);
+	nih_assert (file != NULL);
+	nih_assert (pos != NULL);
+
+	a_pos = *pos;
+	a_lineno = (lineno ? *lineno : 1);
+
+	arg = nih_config_next_token (NULL, file, len, &a_pos, &a_lineno,
+				     NIH_CONFIG_CNLWS, FALSE);
+	if (! arg)
+		goto finish;
+
+	if (! strcmp (arg, "signal")) {
+		unsigned long   status;
+		nih_local char *sigarg = NULL;
+		int		signal;
+
+		/* Update error position to the exit status */
+		*pos = a_pos;
+		if (lineno)
+			*lineno = a_lineno;
+
+		sigarg = nih_config_next_arg (NULL, file, len, &a_pos,
+					      &a_lineno);
+
+		if (! sigarg)
+			goto finish;
+
+		signal = nih_signal_from_name (sigarg);
+		if (signal < 0) {
+			errno = 0;
+			status = strtoul (sigarg, &endptr, 10);
+			if (errno || *endptr || (status > INT_MAX))
+				nih_return_error (-1, PARSE_ILLEGAL_SIGNAL,
+						  _(PARSE_ILLEGAL_SIGNAL_STR));
+
+			signal = status;
+		}
+
+		/* Set the signal */
+		class->reload_signal = signal;
+	} else {
+		nih_return_error (-1, NIH_CONFIG_UNKNOWN_STANZA,
+				  _(NIH_CONFIG_UNKNOWN_STANZA_STR));
+	}
+
+	ret = nih_config_skip_comment (file, len, &a_pos, &a_lineno);
+
+finish:
+	*pos = a_pos;
+	if (lineno)
+		*lineno = a_lineno;
+
+	return ret;
+}
+
+
 /**
  * stanza_apparmor:
  * @class: job class being parsed,

=== modified file 'init/tests/test_job.c'
--- init/tests/test_job.c	2013-05-29 10:36:36 +0000
+++ init/tests/test_job.c	2013-08-21 11:08:31 +0000
@@ -6351,6 +6351,147 @@
 }
 
 void
+test_reload (void)
+{
+	DBusConnection  *conn, *client_conn;
+	pid_t            dbus_pid;
+	DBusMessage     *method, *reply;
+	NihDBusMessage  *message;
+	dbus_uint32_t    serial;
+	JobClass        *class;
+	Job             *job;
+	int              ret, status;
+
+	nih_error_init ();
+	nih_main_loop_init ();
+	event_init ();
+
+	TEST_DBUS (dbus_pid);
+	TEST_DBUS_OPEN (conn);
+	TEST_DBUS_OPEN (client_conn);
+
+	TEST_FUNCTION ("job_reload");
+	TEST_FEATURE ("with default reload signal");
+
+	class = job_class_new (NULL, "test", NULL);
+	class->console = CONSOLE_NONE;
+	class->process[PROCESS_MAIN] = process_new (class);
+	class->process[PROCESS_MAIN]->command = nih_sprintf (
+		class->process[PROCESS_MAIN], "sleep 10");
+
+	job = job_new (class, "");
+	job->goal = JOB_START;
+	job->state = JOB_RUNNING;
+	TEST_CHILD (job->pid[PROCESS_MAIN]) {
+		pause ();
+	}
+
+	method = dbus_message_new_method_call (
+		dbus_bus_get_unique_name (conn),
+		job->path,
+		DBUS_INTERFACE_UPSTART_INSTANCE,
+		"Reload");
+
+	dbus_connection_send (client_conn, method, &serial);
+	dbus_connection_flush (client_conn);
+	dbus_message_unref (method);
+
+	TEST_DBUS_MESSAGE (conn, method);
+	assert (dbus_message_get_serial (method) == serial);
+
+	message = nih_new (NULL, NihDBusMessage);
+	message->connection = conn;
+	message->message = method;
+
+	TEST_FREE_TAG (message);
+
+	ret = job_reload (job, message);
+
+	waitpid (job->pid[PROCESS_MAIN], &status, 0);
+	TEST_TRUE (WIFSIGNALED (status));
+	TEST_EQ (WTERMSIG (status), SIGHUP);
+
+	TEST_EQ (ret, 0);
+
+	nih_discard (message);
+	TEST_FREE (message);
+
+	dbus_message_unref (method);
+
+	dbus_connection_flush (conn);
+
+	TEST_DBUS_MESSAGE (client_conn, reply);
+
+	TEST_EQ (dbus_message_get_type (reply),
+		 DBUS_MESSAGE_TYPE_METHOD_RETURN);
+	TEST_EQ (dbus_message_get_reply_serial (reply), serial);
+
+	dbus_message_unref (reply);
+
+	nih_free (class);
+
+	TEST_FEATURE ("with SIGUSR1 reload signal");
+
+	class = job_class_new (NULL, "test", NULL);
+	class->console = CONSOLE_NONE;
+	class->process[PROCESS_MAIN] = process_new (class);
+	class->process[PROCESS_MAIN]->command = nih_sprintf (
+		class->process[PROCESS_MAIN], "sleep 10");
+	class->reload_signal = SIGUSR1;
+
+	job = job_new (class, "");
+	job->goal = JOB_START;
+	job->state = JOB_RUNNING;
+	TEST_CHILD (job->pid[PROCESS_MAIN]) {
+		pause ();
+	}
+
+	method = dbus_message_new_method_call (
+		dbus_bus_get_unique_name (conn),
+		job->path,
+		DBUS_INTERFACE_UPSTART_INSTANCE,
+		"Reload");
+
+	dbus_connection_send (client_conn, method, &serial);
+	dbus_connection_flush (client_conn);
+	dbus_message_unref (method);
+
+	TEST_DBUS_MESSAGE (conn, method);
+	assert (dbus_message_get_serial (method) == serial);
+
+	message = nih_new (NULL, NihDBusMessage);
+	message->connection = conn;
+	message->message = method;
+
+	TEST_FREE_TAG (message);
+
+	ret = job_reload (job, message);
+
+	waitpid (job->pid[PROCESS_MAIN], &status, 0);
+	TEST_TRUE (WIFSIGNALED (status));
+	TEST_EQ (WTERMSIG (status), SIGUSR1);
+
+	TEST_EQ (ret, 0);
+
+	nih_discard (message);
+	TEST_FREE (message);
+
+	dbus_message_unref (method);
+
+	dbus_connection_flush (conn);
+
+	TEST_DBUS_MESSAGE (client_conn, reply);
+
+	TEST_EQ (dbus_message_get_type (reply),
+		 DBUS_MESSAGE_TYPE_METHOD_RETURN);
+	TEST_EQ (dbus_message_get_reply_serial (reply), serial);
+
+	dbus_message_unref (reply);
+
+	nih_free (class);
+}
+
+void
 test_restart (void)
 {
 	DBusConnection  *conn, *client_conn;
@@ -7451,6 +7592,7 @@
 	test_start ();
 	test_stop ();
 	test_restart ();
+	test_reload ();
 
 	test_get_name ();
 	test_get_goal ();

=== modified file 'init/tests/test_job_class.c'
--- init/tests/test_job_class.c	2013-05-15 13:21:54 +0000
+++ init/tests/test_job_class.c	2013-08-21 11:08:31 +0000
@@ -123,6 +123,8 @@
 		TEST_EQ (class->kill_timeout, 5);
 		TEST_EQ (class->kill_signal, SIGTERM);
 
+		TEST_EQ (class->reload_signal, SIGHUP);
+
 		TEST_EQ (class->respawn, FALSE);
 		TEST_EQ (class->respawn_limit, 10);
 		TEST_EQ (class->respawn_interval, 5);

=== modified file 'init/tests/test_parse_job.c'
--- init/tests/test_parse_job.c	2013-05-15 13:21:54 +0000
+++ init/tests/test_parse_job.c	2013-08-21 11:08:31 +0000
@@ -5442,6 +5442,215 @@
 	nih_free (err);
 }
 
+
+void
+test_stanza_reload (void)
+{
+	JobClass*job;
+	NihError *err;
+	size_t    pos, lineno;
+	char      buf[1024];
+
+	TEST_FUNCTION ("stanza_reload");
+
+
+	/* Check that a reload stanza with the signal argument and signal,
+	 * sets the right signal on the jobs class.
+	 */
+	TEST_FEATURE ("with signal and single argument");
+	strcpy (buf, "reload signal USR2\n");
+
+	TEST_ALLOC_FAIL {
+		pos = 0;
+		lineno = 1;
+		job = parse_job (NULL, NULL, NULL, "test", buf, strlen (buf),
+				 &pos, &lineno);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (job, NULL);
+
+			err = nih_error_get ();
+			TEST_EQ (err->number, ENOMEM);
+			nih_free (err);
+
+			continue;
+		}
+
+		TEST_EQ (pos, strlen (buf));
+		TEST_EQ (lineno, 2);
+
+		TEST_ALLOC_SIZE (job, sizeof (JobClass));
+
+		TEST_EQ (job->reload_signal, SIGUSR2);
+
+		nih_free (job);
+	}
+
+	/* Check that a reload stanza with the signal argument and numeric signal,
+	 * sets the right signal on the jobs class.
+	 */
+	TEST_FEATURE ("with signal and single numeric argument");
+	strcpy (buf, "reload signal 31\n");
+
+	TEST_ALLOC_FAIL {
+		pos = 0;
+		lineno = 1;
+		job = parse_job (NULL, NULL, NULL, "test", buf, strlen (buf),
+				 &pos, &lineno);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (job, NULL);
+
+			err = nih_error_get ();
+			TEST_EQ (err->number, ENOMEM);
+			nih_free (err);
+
+			continue;
+		}
+
+		TEST_EQ (pos, strlen (buf));
+		TEST_EQ (lineno, 2);
+
+		TEST_ALLOC_SIZE (job, sizeof (JobClass));
+
+		/* Don't check symbolic here since different
+		 * architectures have different mappings.
+		 */
+		TEST_EQ (job->reload_signal, 31);
+
+		nih_free (job);
+	}
+
+	/* Check that the last of multiple reload stanzas is used.
+	 */
+	TEST_FEATURE ("with multiple signal and single argument stanzas");
+	strcpy (buf, "reload signal USR2\n");
+	strcat (buf, "reload signal HUP\n");
+
+	TEST_ALLOC_FAIL {
+		pos = 0;
+		lineno = 1;
+		job = parse_job (NULL, NULL, NULL, "test", buf, strlen (buf),
+				 &pos, &lineno);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (job, NULL);
+
+			err = nih_error_get ();
+			TEST_EQ (err->number, ENOMEM);
+			nih_free (err);
+
+			continue;
+		}
+
+		TEST_EQ (pos, strlen (buf));
+		TEST_EQ (lineno, 3);
+
+		TEST_ALLOC_SIZE (job, sizeof (JobClass));
+
+		TEST_EQ (job->reload_signal, SIGHUP);
+
+		nih_free (job);
+	}
+
+
+	/* Check that a reload stanza without an argument results in a syntax
+	 * error.
+	 */
+	TEST_FEATURE ("with missing argument");
+	strcpy (buf, "reload\n");
+
+	pos = 0;
+	lineno = 1;
+	job = parse_job (NULL, NULL, NULL, "test", buf, strlen (buf), &pos, &lineno);
+
+	TEST_EQ_P (job, NULL);
+
+	err = nih_error_get ();
+	TEST_EQ (err->number, NIH_CONFIG_EXPECTED_TOKEN);
+	TEST_EQ (pos, 6);
+	TEST_EQ (lineno, 1);
+	nih_free (err);
+
+
+	/* Check that a reload stanza with an invalid second-level stanza
+	 * results in a syntax error.
+	 */
+	TEST_FEATURE ("with unknown second argument");
+	strcpy (buf, "reload foo\n");
+
+	pos = 0;
+	lineno = 1;
+	job = parse_job (NULL, NULL, NULL, "test", buf, strlen (buf), &pos, &lineno);
+
+	TEST_EQ_P (job, NULL);
+
+	err = nih_error_get ();
+	TEST_EQ (err->number, NIH_CONFIG_UNKNOWN_STANZA);
+	TEST_EQ (pos, 7);
+	TEST_EQ (lineno, 1);
+	nih_free (err);
+
+
+	/* Check that a reload stanza with the timeout argument but no timeout
+	 * results in a syntax error.
+	 */
+	TEST_FEATURE ("with signal and missing argument");
+	strcpy (buf, "reload signal\n");
+
+	pos = 0;
+	lineno = 1;
+	job = parse_job (NULL, NULL, NULL, "test", buf, strlen (buf), &pos, &lineno);
+
+	TEST_EQ_P (job, NULL);
+
+	err = nih_error_get ();
+	TEST_EQ (err->number, NIH_CONFIG_EXPECTED_TOKEN);
+	TEST_EQ (pos, 13);
+	TEST_EQ (lineno, 1);
+	nih_free (err);
+
+
+	/* Check that a reload signal stanza with an unknown signal argument
+	 * results in a syntax error.
+	 */
+	TEST_FEATURE ("with signal and unknown signal argument");
+	strcpy (buf, "reload signal foo\n");
+
+	pos = 0;
+	lineno = 1;
+	job = parse_job (NULL, NULL, NULL, "test", buf, strlen (buf), &pos, &lineno);
+
+	TEST_EQ_P (job, NULL);
+
+	err = nih_error_get ();
+	TEST_EQ (err->number, PARSE_ILLEGAL_SIGNAL);
+	TEST_EQ (pos, 14);
+	TEST_EQ (lineno, 1);
+	nih_free (err);
+
+
+	/* Check that a reload stanza with the signal argument and signal,
+	 * but with an extra argument afterwards results in a syntax
+	 * error.
+	 */
+	TEST_FEATURE ("with signal and extra argument");
+	strcpy (buf, "reload signal INT foo\n");
+
+	pos = 0;
+	lineno = 1;
+	job = parse_job (NULL, NULL, NULL, "test", buf, strlen (buf), &pos, &lineno);
+
+	TEST_EQ_P (job, NULL);
+
+	err = nih_error_get ();
+	TEST_EQ (err->number, NIH_CONFIG_UNEXPECTED_TOKEN);
+	TEST_EQ (pos, 18);
+	TEST_EQ (lineno, 1);
+	nih_free (err);
+}
+
+
 void
 test_stanza_normal (void)
 {
@@ -8645,6 +8854,8 @@
 
 	test_stanza_kill ();
 
+	test_stanza_reload ();
+
 	test_stanza_respawn ();
 	test_stanza_normal ();
 

=== modified file 'init/tests/test_state.c'
--- init/tests/test_state.c	2013-07-19 22:54:24 +0000
+++ init/tests/test_state.c	2013-08-21 11:08:31 +0000
@@ -584,6 +584,9 @@
 	if (obj_num_check (a, b, kill_signal))
 		goto fail;
 
+	if (obj_num_check (a, b, reload_signal))
+		goto fail;
+
 	if (obj_num_check (a, b, respawn))
 		goto fail;
 
@@ -2281,6 +2284,7 @@
 
 	class = file->job = job_class_new (NULL, "bar", NULL);
 	TEST_NE_P (class, NULL);
+	class->reload_signal = SIGUSR1;
 	TEST_HASH_EMPTY (job_classes);
 	TEST_TRUE (job_class_consider (class));
 	TEST_HASH_NOT_EMPTY (job_classes);

=== modified file 'util/initctl.c'
--- util/initctl.c	2013-02-27 11:46:04 +0000
+++ util/initctl.c	2013-08-21 11:08:31 +0000
@@ -1034,19 +1034,8 @@
 
 	job->auto_start = FALSE;
 
-	/* Get the process list */
-	if (job_get_processes_sync (NULL, job, &processes) < 0)
-		goto error;
-
-	if ((! processes[0]) || strcmp (processes[0]->item0, "main")) {
-		nih_error (_("Not running"));
-		return 1;
-	}
-
-	if (kill (processes[0]->item1, SIGHUP) < 0) {
-		nih_error_raise_system ();
-		goto error;
-	}
+	if (job_reload_sync (NULL, job) < 0)
+	        goto error;
 
 	return 0;
 

=== modified file 'util/tests/test_initctl.c'
--- util/tests/test_initctl.c	2013-06-27 10:16:35 +0000
+++ util/tests/test_initctl.c	2013-08-21 11:08:31 +0000
@@ -8585,63 +8585,24 @@
 			dbus_message_unref (method_call);
 			dbus_message_unref (reply);
 
-			/* Expect the Get call for the processes, reply with
-			 * a main process pid.
+			/* Expect the Reload call against job instance
+			 * and reply with an instance path to
+			 * acknowledge.
 			 */
 			TEST_DBUS_MESSAGE (server_conn, method_call);
 
 			TEST_TRUE (dbus_message_is_method_call (method_call,
-								DBUS_INTERFACE_PROPERTIES,
-								"Get"));
+								DBUS_INTERFACE_UPSTART_INSTANCE,
+								"Reload"));
 
 			TEST_EQ_STR (dbus_message_get_path (method_call),
 							    DBUS_PATH_UPSTART "/jobs/test/_");
 
 			TEST_TRUE (dbus_message_get_args (method_call, NULL,
-							  DBUS_TYPE_STRING, &interface,
-							  DBUS_TYPE_STRING, &property,
 							  DBUS_TYPE_INVALID));
 
-			TEST_EQ_STR (interface, DBUS_INTERFACE_UPSTART_INSTANCE);
-			TEST_EQ_STR (property, "processes");
-
 			TEST_ALLOC_SAFE {
 				reply = dbus_message_new_method_return (method_call);
-
-				dbus_message_iter_init_append (reply, &iter);
-
-				dbus_message_iter_open_container (&iter, DBUS_TYPE_VARIANT,
-								  (DBUS_TYPE_ARRAY_AS_STRING
-								   DBUS_STRUCT_BEGIN_CHAR_AS_STRING
-								   DBUS_TYPE_STRING_AS_STRING
-								   DBUS_TYPE_INT32_AS_STRING
-								   DBUS_STRUCT_END_CHAR_AS_STRING),
-								  &subiter);
-
-				dbus_message_iter_open_container (&subiter, DBUS_TYPE_ARRAY,
-								  (DBUS_STRUCT_BEGIN_CHAR_AS_STRING
-								   DBUS_TYPE_STRING_AS_STRING
-								   DBUS_TYPE_INT32_AS_STRING
-								   DBUS_STRUCT_END_CHAR_AS_STRING),
-								  &arrayiter);
-
-				dbus_message_iter_open_container (&arrayiter, DBUS_TYPE_STRUCT,
-								  NULL,
-								  &structiter);
-
-				str_value = "main";
-				dbus_message_iter_append_basic (&structiter, DBUS_TYPE_STRING,
-								&str_value);
-
-				int32_value = proc_pid;
-				dbus_message_iter_append_basic (&structiter, DBUS_TYPE_INT32,
-								&int32_value);
-
-				dbus_message_iter_close_container (&arrayiter, &structiter);
-
-				dbus_message_iter_close_container (&subiter, &arrayiter);
-
-				dbus_message_iter_close_container (&iter, &subiter);
 			}
 
 			dbus_connection_send (server_conn, reply, NULL);
@@ -8698,10 +8659,6 @@
 		waitpid (server_pid, &status, 0);
 		TEST_TRUE (WIFEXITED (status));
 		TEST_EQ (WEXITSTATUS (status), 0);
-
-		waitpid (proc_pid, &status, 0);
-		TEST_TRUE (WIFSIGNALED (status));
-		TEST_EQ (WTERMSIG (status), SIGHUP);
 	}
 
 
@@ -8788,63 +8745,24 @@
 			dbus_message_unref (method_call);
 			dbus_message_unref (reply);
 
-			/* Expect the Get call for the processes, reply with
-			 * a main process pid.
+			/* Expect the Reload call against job instance
+			 * and reply with an instance path to
+			 * acknowledge
 			 */
 			TEST_DBUS_MESSAGE (server_conn, method_call);
 
 			TEST_TRUE (dbus_message_is_method_call (method_call,
-								DBUS_INTERFACE_PROPERTIES,
-								"Get"));
+								DBUS_INTERFACE_UPSTART_INSTANCE,
+								"Reload"));
 
 			TEST_EQ_STR (dbus_message_get_path (method_call),
 							    DBUS_PATH_UPSTART "/jobs/test/_");
 
 			TEST_TRUE (dbus_message_get_args (method_call, NULL,
-							  DBUS_TYPE_STRING, &interface,
-							  DBUS_TYPE_STRING, &property,
 							  DBUS_TYPE_INVALID));
 
-			TEST_EQ_STR (interface, DBUS_INTERFACE_UPSTART_INSTANCE);
-			TEST_EQ_STR (property, "processes");
-
 			TEST_ALLOC_SAFE {
 				reply = dbus_message_new_method_return (method_call);
-
-				dbus_message_iter_init_append (reply, &iter);
-
-				dbus_message_iter_open_container (&iter, DBUS_TYPE_VARIANT,
-								  (DBUS_TYPE_ARRAY_AS_STRING
-								   DBUS_STRUCT_BEGIN_CHAR_AS_STRING
-								   DBUS_TYPE_STRING_AS_STRING
-								   DBUS_TYPE_INT32_AS_STRING
-								   DBUS_STRUCT_END_CHAR_AS_STRING),
-								  &subiter);
-
-				dbus_message_iter_open_container (&subiter, DBUS_TYPE_ARRAY,
-								  (DBUS_STRUCT_BEGIN_CHAR_AS_STRING
-								   DBUS_TYPE_STRING_AS_STRING
-								   DBUS_TYPE_INT32_AS_STRING
-								   DBUS_STRUCT_END_CHAR_AS_STRING),
-								  &arrayiter);
-
-				dbus_message_iter_open_container (&arrayiter, DBUS_TYPE_STRUCT,
-								  NULL,
-								  &structiter);
-
-				str_value = "main";
-				dbus_message_iter_append_basic (&structiter, DBUS_TYPE_STRING,
-								&str_value);
-
-				int32_value = proc_pid;
-				dbus_message_iter_append_basic (&structiter, DBUS_TYPE_INT32,
-								&int32_value);
-
-				dbus_message_iter_close_container (&arrayiter, &structiter);
-
-				dbus_message_iter_close_container (&subiter, &arrayiter);
-
-				dbus_message_iter_close_container (&iter, &subiter);
 			}
 
 			dbus_connection_send (server_conn, reply, NULL);
@@ -8903,10 +8821,6 @@
 		waitpid (server_pid, &status, 0);
 		TEST_TRUE (WIFEXITED (status));
 		TEST_EQ (WEXITSTATUS (status), 0);
-
-		waitpid (proc_pid, &status, 0);
-		TEST_TRUE (WIFSIGNALED (status));
-		TEST_EQ (WTERMSIG (status), SIGHUP);
 	}
 
 
@@ -8995,63 +8909,24 @@
 			dbus_message_unref (method_call);
 			dbus_message_unref (reply);
 
-			/* Expect the Get call for the processes, reply with
-			 * a main process pid.
+			/* Expect the Reload call against job instance
+			 * and reply with an instance path to
+			 * acknowledge.
 			 */
 			TEST_DBUS_MESSAGE (server_conn, method_call);
 
 			TEST_TRUE (dbus_message_is_method_call (method_call,
-								DBUS_INTERFACE_PROPERTIES,
-								"Get"));
+								DBUS_INTERFACE_UPSTART_INSTANCE,
+								"Reload"));
 
 			TEST_EQ_STR (dbus_message_get_path (method_call),
 							    DBUS_PATH_UPSTART "/jobs/test/foo");
 
 			TEST_TRUE (dbus_message_get_args (method_call, NULL,
-							  DBUS_TYPE_STRING, &interface,
-							  DBUS_TYPE_STRING, &property,
 							  DBUS_TYPE_INVALID));
 
-			TEST_EQ_STR (interface, DBUS_INTERFACE_UPSTART_INSTANCE);
-			TEST_EQ_STR (property, "processes");
-
 			TEST_ALLOC_SAFE {
 				reply = dbus_message_new_method_return (method_call);
-
-				dbus_message_iter_init_append (reply, &iter);
-
-				dbus_message_iter_open_container (&iter, DBUS_TYPE_VARIANT,
-								  (DBUS_TYPE_ARRAY_AS_STRING
-								   DBUS_STRUCT_BEGIN_CHAR_AS_STRING
-								   DBUS_TYPE_STRING_AS_STRING
-								   DBUS_TYPE_INT32_AS_STRING
-								   DBUS_STRUCT_END_CHAR_AS_STRING),
-								  &subiter);
-
-				dbus_message_iter_open_container (&subiter, DBUS_TYPE_ARRAY,
-								  (DBUS_STRUCT_BEGIN_CHAR_AS_STRING
-								   DBUS_TYPE_STRING_AS_STRING
-								   DBUS_TYPE_INT32_AS_STRING
-								   DBUS_STRUCT_END_CHAR_AS_STRING),
-								  &arrayiter);
-
-				dbus_message_iter_open_container (&arrayiter, DBUS_TYPE_STRUCT,
-								  NULL,
-								  &structiter);
-
-				str_value = "main";
-				dbus_message_iter_append_basic (&structiter, DBUS_TYPE_STRING,
-								&str_value);
-
-				int32_value = proc_pid;
-				dbus_message_iter_append_basic (&structiter, DBUS_TYPE_INT32,
-								&int32_value);
-
-				dbus_message_iter_close_container (&arrayiter, &structiter);
-
-				dbus_message_iter_close_container (&subiter, &arrayiter);
-
-				dbus_message_iter_close_container (&iter, &subiter);
 			}
 
 			dbus_connection_send (server_conn, reply, NULL);
@@ -9107,10 +8982,6 @@
 		waitpid (server_pid, &status, 0);
 		TEST_TRUE (WIFEXITED (status));
 		TEST_EQ (WEXITSTATUS (status), 0);
-
-		waitpid (proc_pid, &status, 0);
-		TEST_TRUE (WIFSIGNALED (status));
-		TEST_EQ (WTERMSIG (status), SIGHUP);
 	}
 
 	unsetenv ("UPSTART_JOB");

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

Reply via email to