test-cgroup-util: add basic test for cg_all_unified/cg_hybrid_unified/cg_unified_cont...
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 15 Nov 2017 09:17:10 +0000 (10:17 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 15 Nov 2017 21:58:24 +0000 (22:58 +0100)
src/test/test-cgroup-util.c

index d5bc73f..2c22057 100644 (file)
@@ -371,6 +371,32 @@ static void test_is_wanted(void) {
         test_is_wanted_print(false);
 }
 
+static void test_cg_tests(void) {
+        int all, hybrid, systemd;
+
+        assert_se(cg_unified_flush() == 0);
+
+        all = cg_all_unified();
+        assert_se(IN_SET(all, 0, 1));
+
+        hybrid = cg_hybrid_unified();
+        assert_se(IN_SET(hybrid, 0, 1));
+
+        systemd = cg_unified_controller(SYSTEMD_CGROUP_CONTROLLER);
+        assert_se(IN_SET(systemd, 0, 1));
+
+        if (all) {
+                assert_se(systemd);
+                assert_se(!hybrid);
+
+        } else if (hybrid) {
+                assert_se(systemd);
+                assert_se(!all);
+
+        } else
+                assert_se(!systemd);
+}
+
 int main(void) {
         log_set_max_level(LOG_DEBUG);
         log_parse_environment();
@@ -395,6 +421,7 @@ int main(void) {
         test_is_wanted_print(true);
         test_is_wanted_print(false); /* run twice to test caching */
         test_is_wanted();
+        test_cg_tests();
 
         return 0;
 }