failing tests

Marc Weber marco-oweber at gmx.de
Fri Jun 11 19:22:36 BST 2010


Boy that was hard :-)

touch, echo, and true are not found because on NixOS there is neither
/bin/true nor does execvp has the default PATH /usr/bin:/bin or such.
Its /no-such-path.

So I decided to add PATH to the env before spawning a process in order
to run the tests:


diff --git a/init/job_process.c b/init/job_process.c
index e3080d8..1feeb6f 100644
--- a/init/job_process.c
+++ b/init/job_process.c
@@ -247,6 +247,14 @@ job_process_run (Job         *job,
 	NIH_MUST (environ_set (&env, NULL, &envc, TRUE,
 			       "UPSTART_INSTANCE=%s", job->name));
 
+
+        // hack: make nixos find true, touch, echo which is found in coreutils /bin path.
+        // See man execvp. If no PATH is given usually /bin:/usr/bin is used
+        // except in NixOS :-/
+        // So add coreutils in order to run the test suite:
+	NIH_MUST (environ_set (&env, NULL, &envc, TRUE,
+			       "PATH=/nix/store/1ndvfx8sjy4jqsvzixa3w3xd4z7agygp-coreutils-8.4/bin") );
+
 	/* If we're about to spawn the main job and we expect it to become
 	 * a daemon or fork before we can move out of spawned, we need to
 	 * set a trace on it.

Of course I had to add PATH so some of the other environment tests as
well. This shows that you have good code coverage in your tests because
I couldn't fix this without tweaking them.

Still one failure is left which seems to be totally unrelated to
pre-stop scripts:

PASS: test_parse_conf
Testing conf_source_new()
Testing conf_file_new()
Testing conf_source_reload() with job directory
...with new job directory
BAD: wrong value for block file, got unexpected NULL
	at tests/test_conf.c:243 (test_source_reload_job_dir).
/bin/sh: line 5: 18628 Aborted                 ${dir}$tst
FAIL: test_conf
Testing control_server_open()


context test_conf:243:

	strcpy (filename, dirname);
	strcat (filename, "/frodo/foo.conf");
	file = (ConfFile *)nih_hash_lookup (source->files, filename);

	TEST_ALLOC_SIZE (file, sizeof (ConfFile));  /// << line 243
	TEST_ALLOC_PARENT (file, source);
	TEST_EQ (file->flag, source->flag);
	TEST_NE_P (file->job , NULL);

Anyway I found it. I took a little bit too long.
If a job has neither exec nor script then preStop is not run.

Is this a bug at all?

Marc Weber



More information about the upstart-devel mailing list