pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
pe__cmp_node_name_test.c
Go to the documentation of this file.
1 /*
2  * Copyright 2022-2023 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 
13 #include <crm/pengine/internal.h>
14 
17 
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))
gint pe__cmp_node_name(gconstpointer a, gconstpointer b)
Definition: utils.c:146
pcmk_node_t node2
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))
struct pe_node_shared_s node2_details
struct pe_node_shared_s * details
Basic node information.
Definition: nodes.h:134
const char * uname
Node name in cluster.
Definition: nodes.h:68
struct pe_node_shared_s node1_details
Implementation of pcmk_node_t.
Definition: nodes.h:130
Basic node information (all node objects for the same node share this)
Definition: nodes.h:66
pcmk_node_t node1