root/lib/common/tests/agents/pcmk_stonith_param_test.c

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

DEFINITIONS

This source file includes following definitions.
  1. is_stonith_param
  2. is_stonith_action_param
  3. 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 #include <crm/common/agents.h>
  12 
  13 #include <stdarg.h>
  14 #include <stddef.h>
  15 #include <stdint.h>
  16 #include <setjmp.h>
  17 #include <cmocka.h>
  18 
  19 static void
  20 is_stonith_param(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  21 {
  22     assert_false(pcmk_stonith_param(NULL));
  23     assert_false(pcmk_stonith_param(""));
  24     assert_false(pcmk_stonith_param("unrecognized"));
  25     assert_false(pcmk_stonith_param("pcmk_unrecognized"));
  26     assert_false(pcmk_stonith_param("x" PCMK_STONITH_ACTION_LIMIT));
  27     assert_false(pcmk_stonith_param(PCMK_STONITH_ACTION_LIMIT "x"));
  28 
  29     assert_true(pcmk_stonith_param(PCMK_STONITH_ACTION_LIMIT));
  30     assert_true(pcmk_stonith_param(PCMK_STONITH_DELAY_BASE));
  31     assert_true(pcmk_stonith_param(PCMK_STONITH_DELAY_MAX));
  32     assert_true(pcmk_stonith_param(PCMK_STONITH_HOST_ARGUMENT));
  33     assert_true(pcmk_stonith_param(PCMK_STONITH_HOST_CHECK));
  34     assert_true(pcmk_stonith_param(PCMK_STONITH_HOST_LIST));
  35     assert_true(pcmk_stonith_param(PCMK_STONITH_HOST_MAP));
  36     assert_true(pcmk_stonith_param(PCMK_STONITH_PROVIDES));
  37     assert_true(pcmk_stonith_param(PCMK_STONITH_STONITH_TIMEOUT));
  38 }
  39 
  40 static void
  41 is_stonith_action_param(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  42 {
  43     /* Currently, the function accepts any string not containing underbars as
  44      * the action name, so we do not need to verify particular action names.
  45      */
  46     assert_false(pcmk_stonith_param("pcmk_on_unrecognized"));
  47     assert_true(pcmk_stonith_param("pcmk_on_action"));
  48     assert_true(pcmk_stonith_param("pcmk_on_timeout"));
  49     assert_true(pcmk_stonith_param("pcmk_on_retries"));
  50 }
  51 
  52 int
  53 main(int argc, char **argv)
     /* [previous][next][first][last][top][bottom][index][help] */
  54 {
  55     const struct CMUnitTest tests[] = {
  56         cmocka_unit_test(is_stonith_param),
  57         cmocka_unit_test(is_stonith_action_param),
  58     };
  59 
  60     cmocka_set_message_output(CM_OUTPUT_TAP);
  61     return cmocka_run_group_tests(tests, NULL, NULL);
  62 }

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