tests: modify enter_cgroup_subroot() to return the new path
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 8 Nov 2019 15:57:25 +0000 (16:57 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 11 Nov 2019 13:55:57 +0000 (14:55 +0100)
12 files changed:
src/shared/tests.c
src/shared/tests.h
src/test/test-bpf-firewall.c
src/test/test-cgroup-mask.c
src/test/test-cgroup-unit-default.c
src/test/test-engine.c
src/test/test-execute.c
src/test/test-load-fragment.c
src/test/test-path.c
src/test/test-sched-prio.c
src/test/test-unit-name.c
src/test/test-watch-pid.c

index a4ffd3e..96b5b80 100644 (file)
@@ -172,7 +172,7 @@ bool can_memlock(void) {
         return b;
 }
 
-int enter_cgroup_subroot(void) {
+int enter_cgroup_subroot(char **ret_cgroup) {
         _cleanup_free_ char *cgroup_root = NULL, *cgroup_subroot = NULL;
         CGroupMask supported;
         int r;
@@ -192,5 +192,11 @@ int enter_cgroup_subroot(void) {
         if (r < 0)
                 return r;
 
-        return cg_attach_everywhere(supported, cgroup_subroot, 0, NULL, NULL);
+        r = cg_attach_everywhere(supported, cgroup_subroot, 0, NULL, NULL);
+        if (r < 0)
+                return r;
+
+        if (ret_cgroup)
+                *ret_cgroup = TAKE_PTR(cgroup_subroot);
+        return 0;
 }
index 3e43684..5a6fd53 100644 (file)
@@ -19,7 +19,7 @@ static inline bool manager_errno_skip_test(int r) {
 }
 
 char* setup_fake_runtime_dir(void);
-int enter_cgroup_subroot(void);
+int enter_cgroup_subroot(char **ret_cgroup);
 const char* get_testdata_dir(void);
 const char* get_catalog_dir(void);
 bool slow_tests_enabled(void);
index 13f81d4..31e0c0b 100644 (file)
@@ -44,7 +44,7 @@ int main(int argc, char *argv[]) {
         if (!can_memlock())
                 return log_tests_skipped("Can't use mlock(), skipping.");
 
-        r = enter_cgroup_subroot();
+        r = enter_cgroup_subroot(NULL);
         if (r == -ENOMEDIUM)
                 return log_tests_skipped("cgroupfs not available");
 
index 28a3721..7fad58f 100644 (file)
@@ -33,7 +33,7 @@ static int test_cgroup_mask(void) {
         int r;
         CGroupMask cpu_accounting_mask = get_cpu_accounting_mask();
 
-        r = enter_cgroup_subroot();
+        r = enter_cgroup_subroot(NULL);
         if (r == -ENOMEDIUM)
                 return log_tests_skipped("cgroupfs not available");
 
index c4af2a3..1286f11 100644 (file)
@@ -18,7 +18,7 @@ static int test_default_memory_low(void) {
         uint64_t dml_tree_default;
         int r;
 
-        r = enter_cgroup_subroot();
+        r = enter_cgroup_subroot(NULL);
         if (r == -ENOMEDIUM)
                 return log_tests_skipped("cgroupfs not available");
 
index a32e98a..b835114 100644 (file)
@@ -21,7 +21,7 @@ int main(int argc, char *argv[]) {
 
         test_setup_logging(LOG_DEBUG);
 
-        r = enter_cgroup_subroot();
+        r = enter_cgroup_subroot(NULL);
         if (r == -ENOMEDIUM)
                 return log_tests_skipped("cgroupfs not available");
 
index d846414..9d6aeed 100644 (file)
@@ -869,7 +869,7 @@ int main(int argc, char *argv[]) {
         if (getuid() != 0)
                 return log_tests_skipped("not root");
 
-        r = enter_cgroup_subroot();
+        r = enter_cgroup_subroot(NULL);
         if (r == -ENOMEDIUM)
                 return log_tests_skipped("cgroupfs not available");
 
index 8127afd..8d0a4ad 100644 (file)
@@ -779,7 +779,7 @@ int main(int argc, char *argv[]) {
 
         test_setup_logging(LOG_INFO);
 
-        r = enter_cgroup_subroot();
+        r = enter_cgroup_subroot(NULL);
         if (r == -ENOMEDIUM)
                 return log_tests_skipped("cgroupfs not available");
 
index 2537dc6..6ad222b 100644 (file)
@@ -31,7 +31,7 @@ static int setup_test(Manager **m) {
 
         assert_se(m);
 
-        r = enter_cgroup_subroot();
+        r = enter_cgroup_subroot(NULL);
         if (r == -ENOMEDIUM)
                 return log_tests_skipped("cgroupfs not available");
 
index 386cd93..cd45537 100644 (file)
@@ -20,7 +20,7 @@ int main(int argc, char *argv[]) {
 
         test_setup_logging(LOG_INFO);
 
-        r = enter_cgroup_subroot();
+        r = enter_cgroup_subroot(NULL);
         if (r == -ENOMEDIUM)
                 return log_tests_skipped("cgroupfs not available");
 
index d63647b..38e37da 100644 (file)
@@ -820,7 +820,7 @@ int main(int argc, char* argv[]) {
 
         test_setup_logging(LOG_INFO);
 
-        r = enter_cgroup_subroot();
+        r = enter_cgroup_subroot(NULL);
         if (r == -ENOMEDIUM)
                 return log_tests_skipped("cgroupfs not available");
 
index a26a0c9..bad2897 100644 (file)
@@ -16,7 +16,7 @@ int main(int argc, char *argv[]) {
 
         if (getuid() != 0)
                 return log_tests_skipped("not root");
-        r = enter_cgroup_subroot();
+        r = enter_cgroup_subroot(NULL);
         if (r == -ENOMEDIUM)
                 return log_tests_skipped("cgroupfs not available");