------------------------------------------------------------
revno: 1397
committer: James Hunt <[email protected]>
branch nick: upstart
timestamp: Thu 2012-12-06 13:36:09 +0000
message:
* init/tests/test_job_process.c: Sync with lp:ubuntu/upstart branch
as unintended divergence meant lp:upstart was missing TEST_SIGNALS.
This results in two new tests:
- "ensure sane signal state with no console"
- "ensure sane signal state with log console"
modified:
init/tests/test_job_process.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 'init/tests/test_job_process.c'
--- init/tests/test_job_process.c 2012-12-05 08:56:58 +0000
+++ init/tests/test_job_process.c 2012-12-06 13:36:09 +0000
@@ -128,6 +128,7 @@
TEST_ENVIRONMENT,
TEST_OUTPUT,
TEST_OUTPUT_WITH_STOP,
+ TEST_SIGNALS,
TEST_FDS
};
@@ -174,8 +175,10 @@
const char *filename)
{
FILE *out;
+ FILE *in;
char tmpname[PATH_MAX], path[PATH_MAX];
int i;
+ char buffer[1024];
int ret = EXIT_SUCCESS;
strcpy (tmpname, filename);
@@ -240,6 +243,21 @@
fprintf(stdout, "ended\n");
fflush (NULL);
break;
+ case TEST_SIGNALS:
+ /* Write signal stats for child process to stdout */
+ in = fopen("/proc/self/status", "r");
+ if (! in) {
+ abort();
+ }
+
+ while (fgets (buffer, sizeof (buffer), in) != NULL) {
+ if (strstr (buffer, "SigBlk:") == buffer ||
+ strstr (buffer, "SigIgn:") == buffer)
+ fputs (buffer, out);
+ }
+
+ fclose(in);
+ break;
case TEST_FDS:
/* Establish list of open (valid) and closed (invalid)
* file descriptors.
@@ -4585,6 +4603,96 @@
nih_free (class);
+ /* Check that when the job process is execed that no unexpected
+ * signals are blocked or ignored.
+ */
+ TEST_FEATURE ("ensure sane signal state with no console");
+ TEST_HASH_EMPTY (job_classes);
+
+ sprintf (function, "%d", TEST_SIGNALS);
+
+ args[0] = argv0;
+ args[1] = function;
+ args[2] = filename;
+ args[3] = NULL;
+
+ class = job_class_new (NULL, "test", NULL);
+ class->console = CONSOLE_NONE;
+ job = job_new (class, "");
+
+ pid = job_process_spawn (job, args, NULL, FALSE, -1, PROCESS_MAIN);
+ TEST_GT (pid, 0);
+
+ waitpid (pid, NULL, 0);
+ output = fopen (filename, "r");
+
+ TEST_NE_P (output, NULL);
+
+ {
+ unsigned long int value;
+
+ /* No signals should be blocked */
+ TEST_TRUE (fgets (filebuf, sizeof(filebuf), output));
+ TEST_EQ (sscanf (filebuf, "SigBlk: %lx", &value), 1);
+ TEST_EQ (value, 0x0);
+
+ /* No signals should be ignored */
+ TEST_TRUE (fgets (filebuf, sizeof(filebuf), output));
+ TEST_EQ (sscanf (filebuf, "SigIgn: %lx", &value), 1);
+ TEST_EQ (value, 0x0);
+
+ TEST_FILE_END (output);
+ }
+
+ fclose (output);
+ assert0 (unlink (filename));
+
+ nih_free (class);
+
+ /********************************************************************/
+ TEST_FEATURE ("ensure sane signal state with log console");
+ TEST_HASH_EMPTY (job_classes);
+
+ sprintf (function, "%d", TEST_SIGNALS);
+
+ args[0] = argv0;
+ args[1] = function;
+ args[2] = filename;
+ args[3] = NULL;
+
+ class = job_class_new (NULL, "test", NULL);
+ class->console = CONSOLE_LOG;
+ job = job_new (class, "");
+
+ pid = job_process_spawn (job, args, NULL, FALSE, -1, PROCESS_MAIN);
+ TEST_GT (pid, 0);
+
+ waitpid (pid, NULL, 0);
+ output = fopen (filename, "r");
+
+ TEST_NE_P (output, NULL);
+
+ {
+ unsigned long int value;
+
+ /* No signals should be blocked */
+ TEST_TRUE (fgets (filebuf, sizeof(filebuf), output));
+ TEST_EQ (sscanf (filebuf, "SigBlk: %lx", &value), 1);
+ TEST_EQ (value, 0x0);
+
+ /* No signals should be ignored */
+ TEST_TRUE (fgets (filebuf, sizeof(filebuf), output));
+ TEST_EQ (sscanf (filebuf, "SigIgn: %lx", &value), 1);
+ TEST_EQ (value, 0x0);
+
+ TEST_FILE_END (output);
+ }
+
+ fclose (output);
+ assert0 (unlink (filename));
+
+ nih_free (class);
+
/********************************************************************/
TEST_FEATURE ("ensure sane fds with no console");
TEST_HASH_EMPTY (job_classes);
--
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/upstart-devel