pacemaker  2.1.5-b7adf64e51
Scalable High-Availability cluster resource manager
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 Lesser General Public License
7  * version 2.1 or later (LGPLv2.1+) 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:180
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)
struct pe_node_shared_s node2_details
struct pe_node_shared_s * details
Definition: pe_types.h:252
const char * uname
Definition: pe_types.h:216
struct pe_node_shared_s node1_details
pe_node_t node1
pe_node_t node2