root/lib/common/tests/health/pcmk__parse_health_strategy_test.c

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

DEFINITIONS

This source file includes following definitions.
  1. valid
  2. invalid
  3. main

   1 /*
   2  * Copyright 2022 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 static void
  19 valid(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  20     assert_int_equal(pcmk__parse_health_strategy(NULL),
  21                      pcmk__health_strategy_none);
  22 
  23     assert_int_equal(pcmk__parse_health_strategy("none"),
  24                      pcmk__health_strategy_none);
  25 
  26     assert_int_equal(pcmk__parse_health_strategy("NONE"),
  27                      pcmk__health_strategy_none);
  28 
  29     assert_int_equal(pcmk__parse_health_strategy("None"),
  30                      pcmk__health_strategy_none);
  31 
  32     assert_int_equal(pcmk__parse_health_strategy("nOnE"),
  33                      pcmk__health_strategy_none);
  34 
  35     assert_int_equal(pcmk__parse_health_strategy("migrate-on-red"),
  36                      pcmk__health_strategy_no_red);
  37 
  38     assert_int_equal(pcmk__parse_health_strategy("only-green"),
  39                      pcmk__health_strategy_only_green);
  40 
  41     assert_int_equal(pcmk__parse_health_strategy("progressive"),
  42                      pcmk__health_strategy_progressive);
  43 
  44     assert_int_equal(pcmk__parse_health_strategy("custom"),
  45                      pcmk__health_strategy_custom);
  46 }
  47 
  48 static void
  49 invalid(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  50     assert_int_equal(pcmk__parse_health_strategy("foo"),
  51                      pcmk__health_strategy_none);
  52     assert_int_equal(pcmk__parse_health_strategy("custom1"),
  53                      pcmk__health_strategy_none);
  54     assert_int_equal(pcmk__parse_health_strategy("not-only-green-here"),
  55                      pcmk__health_strategy_none);
  56 }
  57 
  58 int
  59 main(int argc, char **argv)
     /* [previous][next][first][last][top][bottom][index][help] */
  60 {
  61     const struct CMUnitTest tests[] = {
  62         cmocka_unit_test(valid),
  63         cmocka_unit_test(invalid),
  64     };
  65 
  66     cmocka_set_message_output(CM_OUTPUT_TAP);
  67     return cmocka_run_group_tests(tests, NULL, NULL);
  68 }

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