pacemaker
2.1.4-dc6eb4362
Scalable High-Availability cluster resource manager
lib
common
tests
health
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),
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
}
pcmk__parse_health_strategy
enum pcmk__health_strategy pcmk__parse_health_strategy(const char *value)
Definition:
health.c:41
pcmk__health_strategy_no_red
Definition:
health_internal.h:26
crm_internal.h
main
int main(int argc, char **argv)
Definition:
pcmk__parse_health_strategy_test.c:59
pcmk__health_strategy_progressive
Definition:
health_internal.h:28
pcmk__health_strategy_none
Definition:
health_internal.h:25
pcmk__health_strategy_only_green
Definition:
health_internal.h:27
pcmk__health_strategy_custom
Definition:
health_internal.h:29
Generated on Wed Jun 15 2022 10:47:45 for pacemaker by
1.8.14