This source file includes following definitions.
- valid
- invalid
- 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 static void
19 valid(void **state) {
20 assert_int_equal(pcmk__parse_health_strategy(NULL),
21 pcmk__health_strategy_none);
22
23 assert_int_equal(pcmk__parse_health_strategy("none"),
24 pcmk__health_strategy_none);
25
26 assert_int_equal(pcmk__parse_health_strategy("NONE"),
27 pcmk__health_strategy_none);
28
29 assert_int_equal(pcmk__parse_health_strategy("None"),
30 pcmk__health_strategy_none);
31
32 assert_int_equal(pcmk__parse_health_strategy("nOnE"),
33 pcmk__health_strategy_none);
34
35 assert_int_equal(pcmk__parse_health_strategy("migrate-on-red"),
36 pcmk__health_strategy_no_red);
37
38 assert_int_equal(pcmk__parse_health_strategy("only-green"),
39 pcmk__health_strategy_only_green);
40
41 assert_int_equal(pcmk__parse_health_strategy("progressive"),
42 pcmk__health_strategy_progressive);
43
44 assert_int_equal(pcmk__parse_health_strategy("custom"),
45 pcmk__health_strategy_custom);
46 }
47
48 static void
49 invalid(void **state) {
50 assert_int_equal(pcmk__parse_health_strategy("foo"),
51 pcmk__health_strategy_none);
52 assert_int_equal(pcmk__parse_health_strategy("custom1"),
53 pcmk__health_strategy_none);
54 assert_int_equal(pcmk__parse_health_strategy("not-only-green-here"),
55 pcmk__health_strategy_none);
56 }
57
58 int
59 main(int argc, char **argv)
60 {
61 const struct CMUnitTest tests[] = {
62 cmocka_unit_test(valid),
63 cmocka_unit_test(invalid),
64 };
65
66 cmocka_set_message_output(CM_OUTPUT_TAP);
67 return cmocka_run_group_tests(tests, NULL, NULL);
68 }