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

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

DEFINITIONS

This source file includes following definitions.
  1. all_params_null
  2. no_prov_or_type
  3. no_type
  4. get_std_and_ty
  5. get_all_values
  6. get_systemd_values

   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 General Public License version 2
   7  * or later (GPLv2+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #include <crm_internal.h>
  11 
  12 #include <crm/common/unittest_internal.h>
  13 #include <crm/common/agents.h>
  14 
  15 static void
  16 all_params_null(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  17     assert_int_equal(crm_parse_agent_spec(NULL, NULL, NULL, NULL), -EINVAL);
  18     assert_int_equal(crm_parse_agent_spec("", NULL, NULL, NULL), -EINVAL);
  19     assert_int_equal(crm_parse_agent_spec(":", NULL, NULL, NULL), -EINVAL);
  20     assert_int_equal(crm_parse_agent_spec("::", NULL, NULL, NULL), -EINVAL);
  21 }
  22 
  23 static void
  24 no_prov_or_type(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  25     assert_int_equal(crm_parse_agent_spec("ocf", NULL, NULL, NULL), -EINVAL);
  26     assert_int_equal(crm_parse_agent_spec("ocf:", NULL, NULL, NULL), -EINVAL);
  27     assert_int_equal(crm_parse_agent_spec("ocf::", NULL, NULL, NULL), -EINVAL);
  28 }
  29 
  30 static void
  31 no_type(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  32     assert_int_equal(crm_parse_agent_spec("ocf:pacemaker:", NULL, NULL, NULL), -EINVAL);
  33 }
  34 
  35 static void
  36 get_std_and_ty(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  37     char *std = NULL;
  38     char *prov = NULL;
  39     char *ty = NULL;
  40 
  41     assert_int_equal(crm_parse_agent_spec("stonith:fence_xvm", &std, &prov, &ty), pcmk_ok);
  42     assert_string_equal(std, "stonith");
  43     assert_null(prov);
  44     assert_string_equal(ty, "fence_xvm");
  45 
  46     free(std);
  47     free(ty);
  48 }
  49 
  50 static void
  51 get_all_values(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  52     char *std = NULL;
  53     char *prov = NULL;
  54     char *ty = NULL;
  55 
  56     assert_int_equal(crm_parse_agent_spec("ocf:pacemaker:ping", &std, &prov, &ty), pcmk_ok);
  57     assert_string_equal(std, "ocf");
  58     assert_string_equal(prov, "pacemaker");
  59     assert_string_equal(ty, "ping");
  60 
  61     free(std);
  62     free(prov);
  63     free(ty);
  64 }
  65 
  66 static void
  67 get_systemd_values(void **state) {
     /* [previous][next][first][last][top][bottom][index][help] */
  68     char *std = NULL;
  69     char *prov = NULL;
  70     char *ty = NULL;
  71 
  72     assert_int_equal(crm_parse_agent_spec("systemd:UNIT@A:B", &std, &prov, &ty), pcmk_ok);
  73     assert_string_equal(std, "systemd");
  74     assert_null(prov);
  75     assert_string_equal(ty, "UNIT@A:B");
  76 
  77     free(std);
  78     free(ty);
  79 }
  80 
  81 PCMK__UNIT_TEST(NULL, NULL,
  82                 cmocka_unit_test(all_params_null),
  83                 cmocka_unit_test(no_prov_or_type),
  84                 cmocka_unit_test(no_type),
  85                 cmocka_unit_test(get_std_and_ty),
  86                 cmocka_unit_test(get_all_values),
  87                 cmocka_unit_test(get_systemd_values))

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