From: Lennart Poettering Date: Wed, 20 Dec 2017 17:13:23 +0000 (+0100) Subject: test: fix condition test if there are no controllers X-Git-Tag: v237~139^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2767027bb7c6c8c71cf8061fb6beabb4c91cf32f;p=thirdparty%2Fsystemd.git 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. --- 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);