diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2016-12-18 13:20:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-18 13:20:12 +0100 |
commit | 8b35656c33cca5e8d0a71d651954f2ae9f0dce24 (patch) | |
tree | b915261dea4a8e2891768a1e7a6aaf947739d1d6 /src/test | |
parent | 117d5a27a3480fd9729cfadd98d135d21732a88d (diff) | |
parent | 5b5688afbe8125af23231ca221c822be0edc3f6e (diff) |
Merge pull request #4911 from keszybz/fixlets
A few simple fixes / improvements
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-install-root.c | 3 | ||||
-rw-r--r-- | src/test/test-mount-util.c | 32 |
2 files changed, 24 insertions, 11 deletions
diff --git a/src/test/test-install-root.c b/src/test/test-install-root.c index a98de76b43..d0bc8004f3 100644 --- a/src/test/test-install-root.c +++ b/src/test/test-install-root.c @@ -22,6 +22,7 @@ #include "install.h" #include "mkdir.h" #include "rm-rf.h" +#include "special.h" #include "string-util.h" static void test_basic_mask_and_enable(const char *root) { @@ -338,7 +339,7 @@ static void test_default(const char *root) { assert_se(n_changes == 1); assert_se(changes[0].type == UNIT_FILE_SYMLINK); assert_se(streq(changes[0].source, "/usr/lib/systemd/system/test-default-real.target")); - p = strjoina(root, SYSTEM_CONFIG_UNIT_PATH"/default.target"); + p = strjoina(root, SYSTEM_CONFIG_UNIT_PATH "/" SPECIAL_DEFAULT_TARGET); assert_se(streq(changes[0].path, p)); unit_file_changes_free(changes, n_changes); changes = NULL; n_changes = 0; diff --git a/src/test/test-mount-util.c b/src/test/test-mount-util.c index da7f35623b..7c5929d009 100644 --- a/src/test/test-mount-util.c +++ b/src/test/test-mount-util.c @@ -23,23 +23,35 @@ #include "mount-util.h" #include "string-util.h" -static void test_mount_propagation_flags(const char *name, unsigned long f) { - assert(mount_propagation_flags_from_string(name) == f); +static void test_mount_propagation_flags(const char *name, int ret, unsigned long expected) { + long unsigned flags; - if (f != 0) - assert_se(streq_ptr(mount_propagation_flags_to_string(f), name)); + assert(mount_propagation_flags_from_string(name, &flags) == ret); + + if (ret >= 0) { + const char *c; + + assert_se(flags == expected); + + c = mount_propagation_flags_to_string(flags); + if (isempty(name)) + assert_se(isempty(c)); + else + assert_se(streq(c, name)); + } } int main(int argc, char *argv[]) { log_set_max_level(LOG_DEBUG); - test_mount_propagation_flags("shared", MS_SHARED); - test_mount_propagation_flags("slave", MS_SLAVE); - test_mount_propagation_flags("private", MS_PRIVATE); - test_mount_propagation_flags(NULL, 0); - test_mount_propagation_flags("", 0); - test_mount_propagation_flags("xxxx", 0); + test_mount_propagation_flags("shared", 0, MS_SHARED); + test_mount_propagation_flags("slave", 0, MS_SLAVE); + test_mount_propagation_flags("private", 0, MS_PRIVATE); + test_mount_propagation_flags(NULL, 0, 0); + test_mount_propagation_flags("", 0, 0); + test_mount_propagation_flags("xxxx", -EINVAL, 0); + test_mount_propagation_flags(" ", -EINVAL, 0); return 0; } |