This source file includes following definitions.
- valid_strategy
- invalid_strategy
- main
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <stdarg.h>
13 #include <stddef.h>
14 #include <stdint.h>
15 #include <setjmp.h>
16 #include <cmocka.h>
17
18
19
20 static void
21 valid_strategy(void **state) {
22 assert_true(pcmk__validate_health_strategy("none"));
23 assert_true(pcmk__validate_health_strategy("None"));
24 assert_true(pcmk__validate_health_strategy("NONE"));
25 assert_true(pcmk__validate_health_strategy("NoNe"));
26 assert_true(pcmk__validate_health_strategy("migrate-on-red"));
27 assert_true(pcmk__validate_health_strategy("only-green"));
28 assert_true(pcmk__validate_health_strategy("progressive"));
29 assert_true(pcmk__validate_health_strategy("custom"));
30 }
31
32 static void
33 invalid_strategy(void **state) {
34 assert_false(pcmk__validate_health_strategy(NULL));
35 assert_false(pcmk__validate_health_strategy(""));
36 assert_false(pcmk__validate_health_strategy("none to speak of"));
37 assert_false(pcmk__validate_health_strategy("customized"));
38 }
39
40 int
41 main(int argc, char **argv) {
42 const struct CMUnitTest tests[] = {
43 cmocka_unit_test(valid_strategy),
44 cmocka_unit_test(invalid_strategy),
45 };
46
47 cmocka_set_message_output(CM_OUTPUT_TAP);
48 return cmocka_run_group_tests(tests, NULL, NULL);
49 }