pacemaker
2.1.6-802a72226b
Scalable High-Availability cluster resource manager
lib
pengine
tests
utils
pe__cmp_node_name_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 General Public License version 2
7
* or later (GPLv2+) WITHOUT ANY WARRANTY.
8
*/
9
10
#include <
crm_internal.h
>
11
12
#include <
crm/common/unittest_internal.h
>
13
#include <
crm/pengine/internal.h
>
14
15
struct
pe_node_shared_s
node1_details
;
16
struct
pe_node_shared_s
node2_details
;
17
18
pe_node_t
node1
= {.
details
= &
node1_details
};
19
pe_node_t
node2
= {.
details
= &
node2_details
};
20
21
static
void
22
nodes_equal(
void
**state)
23
{
24
assert_int_equal(
pe__cmp_node_name
(NULL, NULL), 0);
25
26
node1
.
details
->
uname
=
"node10"
;
27
node2
.
details
->
uname
=
"node10"
;
28
assert_int_equal(
pe__cmp_node_name
(&
node1
, &
node2
), 0);
29
}
30
31
static
void
32
node1_first(
void
**state)
33
{
34
assert_int_equal(
pe__cmp_node_name
(NULL, &
node2
), -1);
35
36
// The heavy testing is done in pcmk__numeric_strcasecmp()'s unit tests
37
node1
.
details
->
uname
=
"node9"
;
38
node2
.
details
->
uname
=
"node10"
;
39
assert_int_equal(
pe__cmp_node_name
(&
node1
, &
node2
), -1);
40
}
41
42
static
void
43
node2_first(
void
**state)
44
{
45
assert_int_equal(
pe__cmp_node_name
(&
node1
, NULL), 1);
46
47
node1
.
details
->
uname
=
"node10"
;
48
node2
.
details
->
uname
=
"node9"
;
49
assert_int_equal(
pe__cmp_node_name
(&
node1
, &
node2
), 1);
50
}
51
52
PCMK__UNIT_TEST
(NULL, NULL,
53
cmocka_unit_test(nodes_equal),
54
cmocka_unit_test(node1_first),
55
cmocka_unit_test(node2_first))
internal.h
pe__cmp_node_name
gint pe__cmp_node_name(gconstpointer a, gconstpointer b)
Definition:
utils.c:185
PCMK__UNIT_TEST
PCMK__UNIT_TEST(NULL, NULL, cmocka_unit_test(bad_input), cmocka_unit_test(not_found), cmocka_unit_test(find_attrB), cmocka_unit_test(find_attrA_matching))
node2_details
struct pe_node_shared_s node2_details
Definition:
pe__cmp_node_name_test.c:16
crm_internal.h
pe_node_s::details
struct pe_node_shared_s * details
Definition:
pe_types.h:268
pe_node_shared_s::uname
const char * uname
Definition:
pe_types.h:232
node1_details
struct pe_node_shared_s node1_details
Definition:
pe__cmp_node_name_test.c:15
node1
pe_node_t node1
Definition:
pe__cmp_node_name_test.c:18
pe_node_s
Definition:
pe_types.h:264
node2
pe_node_t node2
Definition:
pe__cmp_node_name_test.c:19
pe_node_shared_s
Definition:
pe_types.h:230
unittest_internal.h
Generated on Wed May 24 2023 12:29:26 for pacemaker by
1.8.14