root/lib/common/tests/nodes/pcmk_node_is_online_test.c

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

DEFINITIONS

This source file includes following definitions.
  1. null_is_offline
  2. node_is_online
  3. node_is_offline

   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 <stdio.h>      // NULL
  13 #include <glib.h>       // TRUE, FALSE
  14 
  15 #include <crm/common/nodes.h>
  16 #include <crm/common/unittest_internal.h>
  17 
  18 static void
  19 null_is_offline(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  20 {
  21     assert_false(pcmk_node_is_online(NULL));
  22 }
  23 
  24 static void
  25 node_is_online(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  26 {
  27     struct pe_node_shared_s shared = {
  28         .online = TRUE,
  29     };
  30 
  31     pcmk_node_t node = {
  32         .details = &shared,
  33     };
  34 
  35     assert_true(pcmk_node_is_online(&node));
  36 }
  37 
  38 static void
  39 node_is_offline(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  40 {
  41     struct pe_node_shared_s shared = {
  42         .online = FALSE,
  43     };
  44     pcmk_node_t node = {
  45         .details = &shared,
  46     };
  47 
  48     assert_false(pcmk_node_is_online(&node));
  49 }
  50 
  51 PCMK__UNIT_TEST(NULL, NULL,
  52                 cmocka_unit_test(null_is_offline),
  53                 cmocka_unit_test(node_is_online),
  54                 cmocka_unit_test(node_is_offline))

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