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 <stdio.h>
  13 #include <stdbool.h>
  14 #include <glib.h>
  15 #include <bzlib.h>
  16 
  17 static void
  18 test_for_pcmk_rc_name(void) {
     /* [previous][next][first][last][top][bottom][index][help] */
  19     g_assert_cmpint(pcmk__strcmp(pcmk_rc_name(pcmk_rc_error-1), "pcmk_rc_unknown_format", pcmk__str_none), ==, 0);
  20     g_assert_cmpint(pcmk__strcmp(pcmk_rc_name(pcmk_rc_ok), "pcmk_rc_ok", pcmk__str_none), ==, 0);
  21     g_assert_cmpint(pcmk__strcmp(pcmk_rc_name(pcmk_rc_ok), "pcmk_rc_ok", pcmk__str_none), ==, 0);
  22     g_assert_cmpint(pcmk__strcmp(pcmk_rc_name(-7777777), "Unknown", pcmk__str_none), ==, 0);
  23 }
  24 
  25 static void
  26 test_for_pcmk_rc_str(void) {
     /* [previous][next][first][last][top][bottom][index][help] */
  27     g_assert_cmpint(pcmk__strcmp(pcmk_rc_str(pcmk_rc_error-1), "Unknown output format", pcmk__str_none), ==, 0);
  28     g_assert_cmpint(pcmk__strcmp(pcmk_rc_str(pcmk_rc_ok), "OK", pcmk__str_none), ==, 0);
  29     g_assert_cmpint(pcmk__strcmp(pcmk_rc_str(-1), "Unknown error", pcmk__str_none), ==, 0);
  30 }
  31 
  32 static void
  33 test_for_crm_exit_name(void) {
     /* [previous][next][first][last][top][bottom][index][help] */
  34     g_assert_cmpint(pcmk__strcmp(crm_exit_name(CRM_EX_OK), "CRM_EX_OK", pcmk__str_none), ==, 0);
  35 }
  36 
  37 static void
  38 test_for_crm_exit_str(void) {
     /* [previous][next][first][last][top][bottom][index][help] */
  39     g_assert_cmpint(pcmk__strcmp(crm_exit_str(CRM_EX_OK), "OK", pcmk__str_none), ==, 0);
  40     g_assert_cmpint(pcmk__strcmp(crm_exit_str(129), "Interrupted by signal", pcmk__str_none), ==, 0);
  41     g_assert_cmpint(pcmk__strcmp(crm_exit_str(-7777777), "Unknown exit status", pcmk__str_none), ==, 0);
  42 }
  43 
  44 static void
  45 test_for_pcmk_rc2exitc(void) {
     /* [previous][next][first][last][top][bottom][index][help] */
  46     g_assert_cmpint(pcmk_rc2exitc(pcmk_rc_ok), ==, CRM_EX_OK);
  47     g_assert_cmpint(pcmk_rc2exitc(-7777777), ==, CRM_EX_ERROR);  
  48 }
  49 
  50 static void
  51 test_for_bz2_strerror(void) {
     /* [previous][next][first][last][top][bottom][index][help] */
  52     g_assert_cmpint(pcmk__strcmp(bz2_strerror(BZ_STREAM_END), "Ok", pcmk__str_none), ==, 0);
  53 }
  54 
  55 int main(int argc, char **argv) {
     /* [previous][next][first][last][top][bottom][index][help] */
  56     g_test_init(&argc, &argv, NULL);
  57     g_test_add_func("/common/results/test_for_pcmk_rc_name", test_for_pcmk_rc_name);
  58     g_test_add_func("/common/results/test_for_pcmk_rc_str", test_for_pcmk_rc_str);
  59     g_test_add_func("/common/results/test_for_crm_exit_name", test_for_crm_exit_name);
  60     g_test_add_func("/common/results/test_for_crm_exit_str", test_for_crm_exit_str);
  61     g_test_add_func("/common/results/test_for_pcmk_rc2exitc", test_for_pcmk_rc2exitc);
  62     g_test_add_func("/common/results/test_for_bz2_strerror", test_for_bz2_strerror);
  63 
  64     return g_test_run();
  65 }

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