25 .rsc_provider =
"heartbeat",
26 .rsc_agent =
"IPaddr2",
28 .op_interval_ms = 10000,
37 "<" PCMK_XE_RULE " " PCMK_XA_ID "='r' > " \ 38 " <" PCMK_XE_OP_EXPRESSION " " PCMK_XA_ID "='e' " \ 39 PCMK_XA_NAME "='" PCMK_ACTION_MONITOR "' " \ 40 PCMK_XA_INTERVAL "='10s' />" \ 44 null_invalid(
void **state)
62 #define RULE_OP_MISSING_ID \ 63 "<" PCMK_XE_RULE "> " \ 64 " <" PCMK_XE_OP_EXPRESSION " " PCMK_XA_ID "='e' " \ 65 PCMK_XA_NAME "='" PCMK_ACTION_MONITOR "' " \ 66 PCMK_XA_INTERVAL "='10s' />" \ 70 id_missing(
void **state)
83 #define RULE_IDREF_PARENT "<" PCMK_XE_CIB ">" RULE_OP "</" PCMK_XE_CIB ">" 86 good_idref(
void **state)
101 bad_idref(
void **state)
115 #define RULE_EMPTY "<" PCMK_XE_RULE " " PCMK_XA_ID "='r' />" 118 empty_default(
void **state)
129 #define RULE_EMPTY_AND \ 130 "<" PCMK_XE_RULE " " PCMK_XA_ID "='r' " \ 131 PCMK_XA_BOOLEAN_OP "='" PCMK_VALUE_AND "' />" 134 empty_and(
void **state)
145 #define RULE_EMPTY_OR \ 146 "<" PCMK_XE_RULE " " PCMK_XA_ID "='r' " \ 147 PCMK_XA_BOOLEAN_OP "='" PCMK_VALUE_OR "' />" 150 empty_or(
void **state)
161 #define RULE_DEFAULT_BOOLEAN_OP \ 162 "<" PCMK_XE_RULE " " PCMK_XA_ID "='r' >" \ 163 " <" PCMK_XE_RSC_EXPRESSION " " PCMK_XA_ID "='e1' " \ 164 PCMK_XA_TYPE "='Dummy' />" \ 165 " <" PCMK_XE_OP_EXPRESSION " " PCMK_XA_ID "='e2' " \ 166 PCMK_XA_NAME "='" PCMK_ACTION_MONITOR "' " \ 167 PCMK_XA_INTERVAL "='10s' />" \ 168 "</" PCMK_XE_RULE ">" 171 default_boolean_op(
void **state)
182 #define RULE_INVALID_BOOLEAN_OP \ 183 "<" PCMK_XE_RULE " " PCMK_XA_ID "='r' " \ 184 PCMK_XA_BOOLEAN_OP "='not-an-op' >" \ 185 " <" PCMK_XE_RSC_EXPRESSION " " PCMK_XA_ID "='e1' " \ 186 PCMK_XA_TYPE "='Dummy' />" \ 187 " <" PCMK_XE_OP_EXPRESSION " " PCMK_XA_ID "='e2' " \ 188 PCMK_XA_NAME "='" PCMK_ACTION_MONITOR "' " \ 189 PCMK_XA_INTERVAL "='10s' />" \ 190 "</" PCMK_XE_RULE ">" 193 invalid_boolean_op(
void **state)
204 #define RULE_AND_PASSES \ 205 "<" PCMK_XE_RULE " " PCMK_XA_ID "='r' " \ 206 PCMK_XA_BOOLEAN_OP "='" PCMK_VALUE_AND "' >" \ 207 " <" PCMK_XE_RSC_EXPRESSION " " PCMK_XA_ID "='e1' " \ 208 PCMK_XA_TYPE "='IPaddr2' />" \ 209 " <" PCMK_XE_OP_EXPRESSION " " PCMK_XA_ID "='e2' " \ 210 PCMK_XA_NAME "='" PCMK_ACTION_MONITOR "' " \ 211 PCMK_XA_INTERVAL "='10s' />" \ 212 "</" PCMK_XE_RULE ">" 215 and_passes(
void **state)
224 #define RULE_LONELY_AND \ 225 "<" PCMK_XE_RULE " " PCMK_XA_ID "='r' " \ 226 PCMK_XA_BOOLEAN_OP "='" PCMK_VALUE_AND "' >" \ 227 " <" PCMK_XE_RSC_EXPRESSION " " PCMK_XA_ID "='e1' " \ 228 PCMK_XA_TYPE "='IPaddr2' />" \ 229 "</" PCMK_XE_RULE ">" 232 lonely_and_passes(
void **state)
241 #define RULE_AND_ONE_FAILS \ 242 "<" PCMK_XE_RULE " " PCMK_XA_ID "='r' " \ 243 PCMK_XA_BOOLEAN_OP "='" PCMK_VALUE_AND "' >" \ 244 " <" PCMK_XE_RSC_EXPRESSION " " PCMK_XA_ID "='e1' " \ 245 PCMK_XA_TYPE "='Dummy' />" \ 246 " <" PCMK_XE_OP_EXPRESSION " " PCMK_XA_ID "='e2' " \ 247 PCMK_XA_NAME "='" PCMK_ACTION_MONITOR "' " \ 248 PCMK_XA_INTERVAL "='10s' />" \ 249 "</" PCMK_XE_RULE ">" 252 and_one_fails(
void **state)
262 #define RULE_AND_TWO_FAIL \ 263 "<" PCMK_XE_RULE " " PCMK_XA_ID "='r' " \ 264 PCMK_XA_BOOLEAN_OP "='" PCMK_VALUE_AND "' >" \ 265 " <" PCMK_XE_RSC_EXPRESSION " " PCMK_XA_ID "='e1' " \ 266 PCMK_XA_TYPE "='Dummy' />" \ 267 " <" PCMK_XE_OP_EXPRESSION " " PCMK_XA_ID "='e2' " \ 268 PCMK_XA_NAME "='" PCMK_ACTION_MONITOR "' " \ 269 PCMK_XA_INTERVAL "='9s' />" \ 270 "</" PCMK_XE_RULE ">" 273 and_two_fail(
void **state)
283 #define RULE_OR_ONE_PASSES \ 284 "<" PCMK_XE_RULE " " PCMK_XA_ID "='r' " \ 285 PCMK_XA_BOOLEAN_OP "='" PCMK_VALUE_OR "' >" \ 286 " <" PCMK_XE_RSC_EXPRESSION " " PCMK_XA_ID "='e1' " \ 287 PCMK_XA_TYPE "='Dummy' />" \ 288 " <" PCMK_XE_OP_EXPRESSION " " PCMK_XA_ID "='e2' " \ 289 PCMK_XA_NAME "='" PCMK_ACTION_MONITOR "' " \ 290 PCMK_XA_INTERVAL "='10s' />" \ 291 "</" PCMK_XE_RULE ">" 294 or_one_passes(
void **state)
303 #define RULE_OR_TWO_PASS \ 304 "<" PCMK_XE_RULE " " PCMK_XA_ID "='r' " \ 305 PCMK_XA_BOOLEAN_OP "='" PCMK_VALUE_OR "' >" \ 306 " <" PCMK_XE_RSC_EXPRESSION " " PCMK_XA_ID "='e1' " \ 307 PCMK_XA_TYPE "='IPAddr2' />" \ 308 " <" PCMK_XE_OP_EXPRESSION " " PCMK_XA_ID "='e2' " \ 309 PCMK_XA_NAME "='" PCMK_ACTION_MONITOR "' " \ 310 PCMK_XA_INTERVAL "='10s' />" \ 311 "</" PCMK_XE_RULE ">" 314 or_two_pass(
void **state)
323 #define RULE_LONELY_OR \ 324 "<" PCMK_XE_RULE " " PCMK_XA_ID "='r' " \ 325 PCMK_XA_BOOLEAN_OP "='" PCMK_VALUE_OR "' >" \ 326 " <" PCMK_XE_OP_EXPRESSION " " PCMK_XA_ID "='e2' " \ 327 PCMK_XA_NAME "='" PCMK_ACTION_MONITOR "' " \ 328 PCMK_XA_INTERVAL "='10s' />" \ 329 "</" PCMK_XE_RULE ">" 332 lonely_or_passes(
void **state)
341 #define RULE_OR_FAILS \ 342 "<" PCMK_XE_RULE " " PCMK_XA_ID "='r' " \ 343 PCMK_XA_BOOLEAN_OP "='" PCMK_VALUE_OR "' >" \ 344 " <" PCMK_XE_RSC_EXPRESSION " " PCMK_XA_ID "='e1' " \ 345 PCMK_XA_TYPE "='Dummy' />" \ 346 " <" PCMK_XE_OP_EXPRESSION " " PCMK_XA_ID "='e2' " \ 347 PCMK_XA_NAME "='" PCMK_ACTION_MONITOR "' " \ 348 PCMK_XA_INTERVAL "='20s' />" \ 349 "</" PCMK_XE_RULE ">" 352 or_fails(
void **state)
363 cmocka_unit_test(null_invalid),
364 cmocka_unit_test(id_missing),
365 cmocka_unit_test(good_idref),
366 cmocka_unit_test(bad_idref),
367 cmocka_unit_test(empty_default),
368 cmocka_unit_test(empty_and),
369 cmocka_unit_test(empty_or),
370 cmocka_unit_test(default_boolean_op),
371 cmocka_unit_test(invalid_boolean_op),
372 cmocka_unit_test(and_passes),
373 cmocka_unit_test(lonely_and_passes),
374 cmocka_unit_test(and_one_fails),
375 cmocka_unit_test(and_two_fail),
376 cmocka_unit_test(or_one_passes),
377 cmocka_unit_test(or_two_pass),
378 cmocka_unit_test(lonely_or_passes),
379 cmocka_unit_test(or_fails))
crm_time_t * crm_time_new_undefined(void)
Allocate memory for an uninitialized time object.
#define RULE_INVALID_BOOLEAN_OP
struct crm_time_s crm_time_t
#define PCMK_ACTION_MONITOR
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)
#define PCMK_RESOURCE_CLASS_OCF
#define RULE_AND_TWO_FAIL
int pcmk_evaluate_rule(xmlNode *rule, const pcmk_rule_input_t *rule_input, crm_time_t *next_change)
Evaluate a single rule, including all its conditions.
#define RULE_OR_ONE_PASSES
int pcmk__xml_test_setup_group(void **state)
Wrappers for and extensions to libxml2.
#define RULE_AND_ONE_FAILS
#define RULE_IDREF_PARENT
void free_xml(xmlNode *child)
xmlNode * pcmk__xml_parse(const char *input)
#define RULE_OP_MISSING_ID
#define RULE_DEFAULT_BOOLEAN_OP
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)
void crm_time_free(crm_time_t *dt)