This source file includes following definitions.
- all_params_null
- no_prov_or_type
- no_type
- get_std_and_ty
- get_all_values
- get_systemd_values
1
2
3
4
5
6
7
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) {
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) {
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) {
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) {
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) {
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) {
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))