summaryrefslogtreecommitdiff
path: root/src/test/test-util.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-01-08 20:47:25 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-01-11 18:17:33 -0500
commite801700e9acdde60078eb1d41b41b06369b83541 (patch)
tree356c3165b7ad9b5203584ff3e802f539b9873fa0 /src/test/test-util.c
parent4968105790c65af58d4ab42bffa2a4bedc0be8ee (diff)
Implement masking and overriding of generators
Sometimes it is necessary to stop a generator from running. Either because of a bug, or for testing, or some other reason. The only way to do that would be to rename or chmod the generator binary, which is inconvenient and does not survive upgrades. Allow masking and overriding generators similarly to units and other configuration files. For the systemd instance, masking would be more common, rather than overriding generators. For the user instances, it may also be useful for users to have generators in $XDG_CONFIG_HOME to augment or override system-wide generators. Directories are searched according to the usual scheme (/usr/lib, /usr/local/lib, /run, /etc), and files with the same name in higher priority directories override files with the same name in lower priority directories. Empty files and links to /dev/null mask a given name. https://bugs.freedesktop.org/show_bug.cgi?id=87230
Diffstat (limited to 'src/test/test-util.c')
-rw-r--r--src/test/test-util.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c
index d862149fa8..1a5997873c 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -1207,23 +1207,28 @@ static void test_glob_exists(void) {
}
static void test_execute_directory(void) {
- char name[] = "/tmp/test-execute_directory/script1";
- char name2[] = "/tmp/test-execute_directory/script2";
- char name3[] = "/tmp/test-execute_directory/useless";
- char tempdir[] = "/tmp/test-execute_directory/";
+ char template[] = "/tmp/test-readlink_and_make_absolute.XXXXXXX";
+ const char const* dirs[] = {template, NULL};
+ const char *name, *name2, *name3;
- assert_se(mkdir_safe(tempdir, 0755, getuid(), getgid()) >= 0);
- assert_se(write_string_file(name, "#!/bin/sh\necho 'Executing '$0\ntouch /tmp/test-execute_directory/it_works") == 0);
- assert_se(write_string_file(name2, "#!/bin/sh\necho 'Executing '$0\ntouch /tmp/test-execute_directory/it_works2") == 0);
+ assert_se(mkdtemp(template));
+
+ name = strappenda(template, "/script");
+ name2 = strappenda(template, "/script2");
+ name3 = strappenda(template, "/useless");
+
+ assert_se(write_string_file(name, "#!/bin/sh\necho 'Executing '$0\ntouch $(dirname $0)/it_works") == 0);
+ assert_se(write_string_file(name2, "#!/bin/sh\necho 'Executing '$0\ntouch $(dirname $0)/it_works2") == 0);
assert_se(chmod(name, 0755) == 0);
assert_se(chmod(name2, 0755) == 0);
assert_se(touch(name3) >= 0);
- execute_directory(tempdir, DEFAULT_TIMEOUT_USEC, NULL);
- assert_se(access("/tmp/test-execute_directory/it_works", F_OK) >= 0);
- assert_se(access("/tmp/test-execute_directory/it_works2", F_OK) >= 0);
+ assert(chdir(template) == 0);
+ execute_directories(dirs, DEFAULT_TIMEOUT_USEC, NULL);
+ assert_se(access("it_works", F_OK) >= 0);
+ assert_se(access("it_works2", F_OK) >= 0);
- rm_rf_dangerous(tempdir, false, true, false);
+ rm_rf_dangerous(template, false, true, false);
}
static void test_unquote_first_word(void) {