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

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

DEFINITIONS

This source file includes following definitions.
  1. valid_strategy
  2. invalid_strategy
  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 // Test functions
  19 
  20 static void
  21 valid_strategy(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  22     assert_true(pcmk__validate_health_strategy("none"));
  23     assert_true(pcmk__validate_health_strategy("None"));
  24     assert_true(pcmk__validate_health_strategy("NONE"));
  25     assert_true(pcmk__validate_health_strategy("NoNe"));
  26     assert_true(pcmk__validate_health_strategy("migrate-on-red"));
  27     assert_true(pcmk__validate_health_strategy("only-green"));
  28     assert_true(pcmk__validate_health_strategy("progressive"));
  29     assert_true(pcmk__validate_health_strategy("custom"));
  30 }
  31 
  32 static void
  33 invalid_strategy(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  34     assert_false(pcmk__validate_health_strategy(NULL));
  35     assert_false(pcmk__validate_health_strategy(""));
  36     assert_false(pcmk__validate_health_strategy("none to speak of"));
  37     assert_false(pcmk__validate_health_strategy("customized"));
  38 }
  39 
  40 int
  41 main(int argc, char **argv) {
     /* [previous][next][first][last][top][bottom][index][help] */
  42     const struct CMUnitTest tests[] = {
  43         cmocka_unit_test(valid_strategy),
  44         cmocka_unit_test(invalid_strategy),
  45     };
  46 
  47     cmocka_set_message_output(CM_OUTPUT_TAP);
  48     return cmocka_run_group_tests(tests, NULL, NULL);
  49 }

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