root/lib/common/tests/scheduler/pcmk_set_scheduler_cib_test.c

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

DEFINITIONS

This source file includes following definitions.
  1. null_scheduler
  2. null_cib
  3. previous_cib_null
  4. previous_cib_nonnull

   1 /*
   2  * Copyright 2024 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/scheduler.h>
  13 #include <crm/common/unittest_internal.h>
  14 
  15 static void
  16 null_scheduler(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  17 {
  18     xmlNode *cib = pcmk__xe_create(NULL, "test");
  19 
  20     assert_int_equal(pcmk_set_scheduler_cib(NULL, NULL), EINVAL);
  21     assert_int_equal(pcmk_set_scheduler_cib(NULL, cib), EINVAL);
  22 
  23     free_xml(cib);
  24 }
  25 
  26 static void
  27 null_cib(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  28 {
  29     pcmk_scheduler_t scheduler = {
  30         .input = NULL,
  31     };
  32 
  33     assert_int_equal(pcmk_set_scheduler_cib(&scheduler, NULL), pcmk_rc_ok);
  34     assert_null(scheduler.input);
  35 }
  36 
  37 static void
  38 previous_cib_null(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  39 {
  40     pcmk_scheduler_t scheduler = {
  41         .input = NULL,
  42     };
  43     xmlNode *cib = pcmk__xe_create(NULL, "test");
  44 
  45     assert_int_equal(pcmk_set_scheduler_cib(&scheduler, cib), pcmk_rc_ok);
  46     assert_ptr_equal(scheduler.input, cib);
  47 
  48     free_xml(cib);
  49 }
  50 
  51 static void
  52 previous_cib_nonnull(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  53 {
  54     xmlNode *old_cib = pcmk__xe_create(NULL, "old");
  55     xmlNode *new_cib = pcmk__xe_create(NULL, "new");
  56     pcmk_scheduler_t scheduler = {
  57         .input = old_cib,
  58     };
  59 
  60     assert_int_equal(pcmk_set_scheduler_cib(&scheduler, new_cib), pcmk_rc_ok);
  61     assert_ptr_equal(scheduler.input, new_cib);
  62 
  63     free_xml(old_cib);
  64     free_xml(new_cib);
  65 }
  66 
  67 PCMK__UNIT_TEST(NULL, NULL,
  68                 cmocka_unit_test(null_scheduler),
  69                 cmocka_unit_test(null_cib),
  70                 cmocka_unit_test(previous_cib_null),
  71                 cmocka_unit_test(previous_cib_nonnull))

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