pacemaker  2.1.4-dc6eb4362
Scalable High-Availability cluster resource manager
pcmk__parse_health_strategy_test.c
Go to the documentation of this file.
1 /*
2  * Copyright 2022 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU Lesser General Public License
7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
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),
22 
23  assert_int_equal(pcmk__parse_health_strategy("none"),
25 
26  assert_int_equal(pcmk__parse_health_strategy("NONE"),
28 
29  assert_int_equal(pcmk__parse_health_strategy("None"),
31 
32  assert_int_equal(pcmk__parse_health_strategy("nOnE"),
34 
35  assert_int_equal(pcmk__parse_health_strategy("migrate-on-red"),
37 
38  assert_int_equal(pcmk__parse_health_strategy("only-green"),
40 
41  assert_int_equal(pcmk__parse_health_strategy("progressive"),
43 
44  assert_int_equal(pcmk__parse_health_strategy("custom"),
46 }
47 
48 static void
49 invalid(void **state) {
50  assert_int_equal(pcmk__parse_health_strategy("foo"),
52  assert_int_equal(pcmk__parse_health_strategy("custom1"),
54  assert_int_equal(pcmk__parse_health_strategy("not-only-green-here"),
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 }
enum pcmk__health_strategy pcmk__parse_health_strategy(const char *value)
Definition: health.c:41
int main(int argc, char **argv)