summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-05-01 03:48:21 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-05-05 04:07:37 +0200
commit86c2a9f1c2ea3873e555f0d035bd1fe72a24658a (patch)
tree4997a9adf8d4acc7689b0a397ad7329666c0e879 /src/test
parentnsflags: drop namespace_flag_to_string_many_with_check() (diff)
downloadsystemd-86c2a9f1c2ea3873e555f0d035bd1fe72a24658a.tar.xz
systemd-86c2a9f1c2ea3873e555f0d035bd1fe72a24658a.zip
nsflsgs: drop namespace_flag_{from,to}_string()
This also drops namespace_flag_to_string_many_with_check(), and renames namespace_flag_{from,to}_string_many() to namespace_flags_{from,to}_string().
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-seccomp.c45
1 files changed, 26 insertions, 19 deletions
diff --git a/src/test/test-seccomp.c b/src/test/test-seccomp.c
index 155ce5cfbf..6062ca1baf 100644
--- a/src/test/test-seccomp.c
+++ b/src/test/test-seccomp.c
@@ -133,29 +133,36 @@ static void test_filter_sets(void) {
}
static void test_restrict_namespace(void) {
- _cleanup_free_ char *s = NULL;
+ char *s = NULL;
unsigned long ul;
pid_t pid;
- assert_se(namespace_flag_to_string(0) == NULL);
- assert_se(streq(namespace_flag_to_string(CLONE_NEWNS), "mnt"));
- assert_se(namespace_flag_to_string(CLONE_NEWNS|CLONE_NEWIPC) == NULL);
- assert_se(streq(namespace_flag_to_string(CLONE_NEWCGROUP), "cgroup"));
-
- assert_se(namespace_flag_from_string("mnt") == CLONE_NEWNS);
- assert_se(namespace_flag_from_string(NULL) == 0);
- assert_se(namespace_flag_from_string("") == 0);
- assert_se(namespace_flag_from_string("uts") == CLONE_NEWUTS);
- assert_se(namespace_flag_from_string(namespace_flag_to_string(CLONE_NEWUTS)) == CLONE_NEWUTS);
- assert_se(streq(namespace_flag_to_string(namespace_flag_from_string("ipc")), "ipc"));
-
- assert_se(namespace_flag_from_string_many(NULL, &ul) == 0 && ul == 0);
- assert_se(namespace_flag_from_string_many("", &ul) == 0 && ul == 0);
- assert_se(namespace_flag_from_string_many("mnt uts ipc", &ul) == 0 && ul == (CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC));
-
- assert_se(namespace_flag_to_string_many(NAMESPACE_FLAGS_ALL, &s) == 0);
+ assert_se(namespace_flags_to_string(0, &s) == 0 && streq(s, ""));
+ s = mfree(s);
+ assert_se(namespace_flags_to_string(CLONE_NEWNS, &s) == 0 && streq(s, "mnt"));
+ s = mfree(s);
+ assert_se(namespace_flags_to_string(CLONE_NEWNS|CLONE_NEWIPC, &s) == 0 && streq(s, "ipc mnt"));
+ s = mfree(s);
+ assert_se(namespace_flags_to_string(CLONE_NEWCGROUP, &s) == 0 && streq(s, "cgroup"));
+ s = mfree(s);
+
+ assert_se(namespace_flags_from_string("mnt", &ul) == 0 && ul == CLONE_NEWNS);
+ assert_se(namespace_flags_from_string(NULL, &ul) == 0 && ul == 0);
+ assert_se(namespace_flags_from_string("", &ul) == 0 && ul == 0);
+ assert_se(namespace_flags_from_string("uts", &ul) == 0 && ul == CLONE_NEWUTS);
+ assert_se(namespace_flags_from_string("mnt uts ipc", &ul) == 0 && ul == (CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC));
+
+ assert_se(namespace_flags_to_string(CLONE_NEWUTS, &s) == 0 && streq(s, "uts"));
+ assert_se(namespace_flags_from_string(s, &ul) == 0 && ul == CLONE_NEWUTS);
+ s = mfree(s);
+ assert_se(namespace_flags_from_string("ipc", &ul) == 0 && ul == CLONE_NEWIPC);
+ assert_se(namespace_flags_to_string(ul, &s) == 0 && streq(s, "ipc"));
+ s = mfree(s);
+
+ assert_se(namespace_flags_to_string(NAMESPACE_FLAGS_ALL, &s) == 0);
assert_se(streq(s, "cgroup ipc net mnt pid user uts"));
- assert_se(namespace_flag_from_string_many(s, &ul) == 0 && ul == NAMESPACE_FLAGS_ALL);
+ assert_se(namespace_flags_from_string(s, &ul) == 0 && ul == NAMESPACE_FLAGS_ALL);
+ s = mfree(s);
if (!is_seccomp_available())
return;