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

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

DEFINITIONS

This source file includes following definitions.
  1. rscs_equal
  2. rsc1_first
  3. rsc2_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 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 #include "pe_status_private.h"
  16 
  17 pcmk_resource_t rsc1;
  18 pcmk_resource_t rsc2;
  19 
  20 static void
  21 rscs_equal(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  22 {
  23     rsc1.priority = 0;
  24     rsc2.priority = 0;
  25     assert_int_equal(pe__cmp_rsc_priority(NULL, NULL), 0);
  26     assert_int_equal(pe__cmp_rsc_priority(&rsc1, &rsc2), 0);
  27 }
  28 
  29 static void
  30 rsc1_first(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  31 {
  32     rsc1.priority = 1;
  33     rsc2.priority = 0;
  34     assert_int_equal(pe__cmp_rsc_priority(&rsc1, NULL), -1);
  35     assert_int_equal(pe__cmp_rsc_priority(&rsc1, &rsc2), -1);
  36 }
  37 
  38 static void
  39 rsc2_first(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  40 {
  41     rsc1.priority = 0;
  42     rsc2.priority = 1;
  43     assert_int_equal(pe__cmp_rsc_priority(NULL, &rsc2), 1);
  44     assert_int_equal(pe__cmp_rsc_priority(&rsc1, &rsc2), 1);
  45 }
  46 
  47 PCMK__UNIT_TEST(NULL, NULL,
  48                 cmocka_unit_test(rscs_equal),
  49                 cmocka_unit_test(rsc1_first),
  50                 cmocka_unit_test(rsc2_first))

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