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
  6. test_for_bz2_strerror
  7. main

   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 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 <stdarg.h>
  13 #include <stddef.h>
  14 #include <stdint.h>
  15 #include <setjmp.h>
  16 #include <cmocka.h>
  17 
  18 #include <glib.h>
  19 #include <bzlib.h>
  20 
  21 static void
  22 test_for_pcmk_rc_name(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  23     assert_string_equal(pcmk_rc_name(pcmk_rc_error-1), "pcmk_rc_unknown_format");
  24     assert_string_equal(pcmk_rc_name(pcmk_rc_ok), "pcmk_rc_ok");
  25     assert_string_equal(pcmk_rc_name(pcmk_rc_ok), "pcmk_rc_ok");
  26     assert_string_equal(pcmk_rc_name(-7777777), "Unknown");
  27 }
  28 
  29 static void
  30 test_for_pcmk_rc_str(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  31     assert_string_equal(pcmk_rc_str(pcmk_rc_error-1), "Unknown output format");
  32     assert_string_equal(pcmk_rc_str(pcmk_rc_ok), "OK");
  33     assert_string_equal(pcmk_rc_str(-1), "Unknown error");
  34 }
  35 
  36 static void
  37 test_for_crm_exit_name(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  38     assert_string_equal(crm_exit_name(CRM_EX_OK), "CRM_EX_OK");
  39 }
  40 
  41 static void
  42 test_for_crm_exit_str(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  43     assert_string_equal(crm_exit_str(CRM_EX_OK), "OK");
  44     assert_string_equal(crm_exit_str(129), "Interrupted by signal");
  45     assert_string_equal(crm_exit_str(-7777777), "Unknown exit status");
  46 }
  47 
  48 static void
  49 test_for_pcmk_rc2exitc(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  50     assert_int_equal(pcmk_rc2exitc(pcmk_rc_ok), CRM_EX_OK);
  51     assert_int_equal(pcmk_rc2exitc(-7777777), CRM_EX_ERROR);
  52 }
  53 
  54 static void
  55 test_for_bz2_strerror(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  56     assert_string_equal(bz2_strerror(BZ_STREAM_END), "Ok");
  57 }
  58 
  59 int main(int argc, char **argv) {
     /* [previous][next][first][last][top][bottom][index][help] */
  60     const struct CMUnitTest tests[] = {
  61         cmocka_unit_test(test_for_pcmk_rc_name),
  62         cmocka_unit_test(test_for_pcmk_rc_str),
  63         cmocka_unit_test(test_for_crm_exit_name),
  64         cmocka_unit_test(test_for_crm_exit_str),
  65         cmocka_unit_test(test_for_pcmk_rc2exitc),
  66         cmocka_unit_test(test_for_bz2_strerror),
  67     };
  68 
  69     cmocka_set_message_output(CM_OUTPUT_TAP);
  70     return cmocka_run_group_tests(tests, NULL, NULL);
  71 }

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