diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-01-08 21:21:12 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-01-11 18:17:33 -0500 |
commit | aac7766c107273abdc5d6f52f9a9f88d18cb14b3 (patch) | |
tree | c6bd54241c4140ece0310ccbf8c373067a1a18c3 /src | |
parent | e801700e9acdde60078eb1d41b41b06369b83541 (diff) |
test-util: make sure that masking and overriding works
Diffstat (limited to 'src')
-rw-r--r-- | src/test/test-util.c | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c index 1a5997873c..1e50a29f79 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -1207,28 +1207,47 @@ static void test_glob_exists(void) { } static void test_execute_directory(void) { - char template[] = "/tmp/test-readlink_and_make_absolute.XXXXXXX"; - const char const* dirs[] = {template, NULL}; - const char *name, *name2, *name3; - - assert_se(mkdtemp(template)); - - name = strappenda(template, "/script"); - name2 = strappenda(template, "/script2"); - name3 = strappenda(template, "/useless"); + char template_lo[] = "/tmp/test-readlink_and_make_absolute-lo.XXXXXXX"; + char template_hi[] = "/tmp/test-readlink_and_make_absolute-hi.XXXXXXX"; + const char const* dirs[] = {template_hi, template_lo, NULL}; + const char *name, *name2, *name3, *overridden, *override, *masked, *mask; + + assert_se(mkdtemp(template_lo)); + assert_se(mkdtemp(template_hi)); + + name = strappenda(template_lo, "/script"); + name2 = strappenda(template_hi, "/script2"); + name3 = strappenda(template_lo, "/useless"); + overridden = strappenda(template_lo, "/overridden"); + override = strappenda(template_hi, "/overridden"); + masked = strappenda(template_lo, "/masked"); + mask = strappenda(template_hi, "/masked"); 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(write_string_file(overridden, "#!/bin/sh\necho 'Executing '$0\ntouch $(dirname $0)/failed") == 0); + assert_se(write_string_file(override, "#!/bin/sh\necho 'Executing '$0") == 0); + assert_se(write_string_file(masked, "#!/bin/sh\necho 'Executing '$0\ntouch $(dirname $0)/failed") == 0); + assert_se(symlink("/dev/null", mask) == 0); assert_se(chmod(name, 0755) == 0); assert_se(chmod(name2, 0755) == 0); + assert_se(chmod(overridden, 0755) == 0); + assert_se(chmod(override, 0755) == 0); + assert_se(chmod(masked, 0755) == 0); assert_se(touch(name3) >= 0); - assert(chdir(template) == 0); execute_directories(dirs, DEFAULT_TIMEOUT_USEC, NULL); + + assert(chdir(template_lo) == 0); assert_se(access("it_works", F_OK) >= 0); + assert_se(access("failed", F_OK) < 0); + + assert(chdir(template_hi) == 0); assert_se(access("it_works2", F_OK) >= 0); + assert_se(access("failed", F_OK) < 0); - rm_rf_dangerous(template, false, true, false); + rm_rf_dangerous(template_lo, false, true, false); + rm_rf_dangerous(template_hi, false, true, false); } static void test_unquote_first_word(void) { |