From 2767027bb7c6c8c71cf8061fb6beabb4c91cf32f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 20 Dec 2017 18:13:23 +0100 Subject: [PATCH] test: fix condition test if there are no controllers As an optimization cg_mask_to_string() returns NULL if there are no controllers available. We need to handle that. --- src/test/test-condition.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/test-condition.c b/src/test/test-condition.c index 8323a66ad39..ad64a2bb36e 100644 --- a/src/test/test-condition.c +++ b/src/test/test-condition.c @@ -29,8 +29,8 @@ #include "apparmor-util.h" #include "architecture.h" #include "audit-util.h" -#include "condition.h" #include "cgroup-util.h" +#include "condition.h" #include "hostname-util.h" #include "id128-util.h" #include "ima-util.h" @@ -187,12 +187,12 @@ static int test_condition_test_control_group_controller(void) { /* Multiple valid controllers at the same time */ assert_se(cg_mask_to_string(system_mask, &controller_name) >= 0); - condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, controller_name, false, false); + condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, strempty(controller_name), false, false); assert_se(condition); assert_se(condition_test(condition)); condition_free(condition); - condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, controller_name, false, true); + condition = condition_new(CONDITION_CONTROL_GROUP_CONTROLLER, strempty(controller_name), false, true); assert_se(condition); assert_se(!condition_test(condition)); condition_free(condition); -- 2.47.3