root/lib/common/tests/results/pcmk__results_test.c

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

DEFINITIONS

This source file includes following definitions.
  1. test_for_pcmk_rc_name
  2. test_for_pcmk_rc_str
  3. test_for_crm_exit_name
  4. test_for_crm_exit_str
  5. test_for_pcmk_rc2exitc

   1 /*
   2  * Copyright 2020-2021 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 
  14 #include <glib.h>
  15 #include <bzlib.h>
  16 
  17 static void
  18 test_for_pcmk_rc_name(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  19     assert_string_equal(pcmk_rc_name(pcmk_rc_error-1), "pcmk_rc_unknown_format");
  20     assert_string_equal(pcmk_rc_name(pcmk_rc_ok), "pcmk_rc_ok");
  21     assert_string_equal(pcmk_rc_name(pcmk_rc_ok), "pcmk_rc_ok");
  22     assert_string_equal(pcmk_rc_name(-7777777), "Unknown");
  23 }
  24 
  25 static void
  26 test_for_pcmk_rc_str(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  27     assert_string_equal(pcmk_rc_str(pcmk_rc_error-1), "Unknown output format");
  28     assert_string_equal(pcmk_rc_str(pcmk_rc_ok), "OK");
  29     assert_string_equal(pcmk_rc_str(-1), "Error");
  30 }
  31 
  32 static void
  33 test_for_crm_exit_name(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  34     assert_string_equal(crm_exit_name(CRM_EX_OK), "CRM_EX_OK");
  35 }
  36 
  37 static void
  38 test_for_crm_exit_str(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  39     assert_string_equal(crm_exit_str(CRM_EX_OK), "OK");
  40     assert_string_equal(crm_exit_str(129), "Interrupted by signal");
  41     assert_string_equal(crm_exit_str(-7777777), "Unknown exit status");
  42 }
  43 
  44 static void
  45 test_for_pcmk_rc2exitc(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  46     assert_int_equal(pcmk_rc2exitc(pcmk_rc_ok), CRM_EX_OK);
  47     assert_int_equal(pcmk_rc2exitc(-7777777), CRM_EX_ERROR);
  48 }
  49 
  50 PCMK__UNIT_TEST(NULL, NULL,
  51                 cmocka_unit_test(test_for_pcmk_rc_name),
  52                 cmocka_unit_test(test_for_pcmk_rc_str),
  53                 cmocka_unit_test(test_for_crm_exit_name),
  54                 cmocka_unit_test(test_for_crm_exit_str),
  55                 cmocka_unit_test(test_for_pcmk_rc2exitc))

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