root/lib/pengine/tests/utils/pe__cmp_node_name_test.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. nodes_equal
  2. node1_first
  3. node2_first

   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 <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)
     /* [previous][next][first][last][top][bottom][index][help] */
  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)
     /* [previous][next][first][last][top][bottom][index][help] */
  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)
     /* [previous][next][first][last][top][bottom][index][help] */
  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))

/* [previous][next][first][last][top][bottom][index][help] */