pacemaker
2.1.9-49aab99839
Scalable High-Availability cluster resource manager
lib
common
tests
rules
pcmk__parse_source_test.c
Go to the documentation of this file.
1
/*
2
* Copyright 2024 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 General Public License version 2
7
* or later (GPLv2+) WITHOUT ANY WARRANTY.
8
*/
9
10
#include <
crm_internal.h
>
11
12
#include <stdio.h>
13
14
#include <
crm/common/rules_internal.h
>
15
#include <
crm/common/unittest_internal.h
>
16
#include "
crmcommon_private.h
"
17
18
static
void
19
default_literal(
void
**state)
20
{
21
assert_int_equal(
pcmk__parse_source
(NULL),
pcmk__source_literal
);
22
}
23
24
static
void
25
invalid(
void
**state)
26
{
27
assert_int_equal(
pcmk__parse_source
(
""
),
pcmk__source_unknown
);
28
assert_int_equal(
pcmk__parse_source
(
" "
),
pcmk__source_unknown
);
29
assert_int_equal(
pcmk__parse_source
(
"params"
),
pcmk__source_unknown
);
30
}
31
32
static
void
33
valid(
void
**state)
34
{
35
assert_int_equal(
pcmk__parse_source
(
PCMK_VALUE_LITERAL
),
36
pcmk__source_literal
);
37
38
assert_int_equal(
pcmk__parse_source
(
PCMK_VALUE_PARAM
),
39
pcmk__source_instance_attrs
);
40
41
assert_int_equal(
pcmk__parse_source
(
PCMK_VALUE_META
),
42
pcmk__source_meta_attrs
);
43
}
44
45
static
void
46
case_insensitive(
void
**state)
47
{
48
assert_int_equal(
pcmk__parse_source
(
"LITERAL"
),
49
pcmk__source_literal
);
50
51
assert_int_equal(
pcmk__parse_source
(
"Param"
),
52
pcmk__source_instance_attrs
);
53
54
assert_int_equal(
pcmk__parse_source
(
"MeTa"
),
55
pcmk__source_meta_attrs
);
56
}
57
58
PCMK__UNIT_TEST
(NULL, NULL,
59
cmocka_unit_test(default_literal),
60
cmocka_unit_test(invalid),
61
cmocka_unit_test(valid),
62
cmocka_unit_test(case_insensitive))
rules_internal.h
PCMK__UNIT_TEST
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)
Definition:
unittest_internal.h:188
pcmk__source_unknown
Definition:
crmcommon_private.h:365
PCMK_VALUE_META
#define PCMK_VALUE_META
Definition:
options.h:170
PCMK_VALUE_PARAM
#define PCMK_VALUE_PARAM
Definition:
options.h:189
crm_internal.h
PCMK_VALUE_LITERAL
#define PCMK_VALUE_LITERAL
Definition:
options.h:165
pcmk__parse_source
G_GNUC_INTERNAL enum pcmk__reference_source pcmk__parse_source(const char *source)
Definition:
rules.c:877
pcmk__source_literal
Definition:
crmcommon_private.h:366
pcmk__source_instance_attrs
Definition:
crmcommon_private.h:367
pcmk__source_meta_attrs
Definition:
crmcommon_private.h:368
crmcommon_private.h
unittest_internal.h
Generated on Thu Oct 31 2024 15:49:03 for pacemaker by
1.8.14