This source file includes following definitions.
- op_is_not_probe_test
- op_does_not_have_right_values_test
- check_values_test
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <crm/common/unittest_internal.h>
13
14 static void
15 op_is_not_probe_test(void **state) {
16 xmlNode *node = NULL;
17
18
19
20
21
22 node = pcmk__xml_parse("<" PCMK__XE_LRM_RSC_OP " "
23 PCMK_XA_OPERATION
24 "=\"" PCMK_ACTION_START "\" "
25 PCMK_META_INTERVAL "=\"0\"/>");
26 assert_false(pcmk_xe_mask_probe_failure(node));
27 free_xml(node);
28 }
29
30 static void
31 op_does_not_have_right_values_test(void **state) {
32 xmlNode *node = NULL;
33 char *s = NULL;
34
35 node = pcmk__xml_parse("<" PCMK__XE_LRM_RSC_OP " "
36 PCMK_XA_OPERATION
37 "=\"" PCMK_ACTION_MONITOR "\" "
38 PCMK_META_INTERVAL "=\"0\"/>");
39 assert_false(pcmk_xe_mask_probe_failure(node));
40 free_xml(node);
41
42 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
43 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
44 PCMK_META_INTERVAL "=\"0\" "
45 PCMK__XA_RC_CODE "=\"%d\" "
46 PCMK__XA_OP_STATUS "=\"\"/>",
47 PCMK_OCF_OK);
48 node = pcmk__xml_parse(s);
49 assert_false(pcmk_xe_mask_probe_failure(node));
50 free(s);
51 free_xml(node);
52 }
53
54 static void
55 check_values_test(void **state) {
56 xmlNode *node = NULL;
57 char *s = NULL;
58
59
60 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
61 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
62 PCMK_META_INTERVAL "=\"0\" "
63 PCMK__XA_RC_CODE "=\"%d\" "
64 PCMK__XA_OP_STATUS "=\"%d\"/>",
65 PCMK_OCF_OK, PCMK_EXEC_NOT_SUPPORTED);
66 node = pcmk__xml_parse(s);
67 assert_false(pcmk_xe_mask_probe_failure(node));
68 free(s);
69 free_xml(node);
70
71 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
72 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
73 PCMK_META_INTERVAL "=\"0\" "
74 PCMK__XA_RC_CODE "=\"%d\" "
75 PCMK__XA_OP_STATUS "=\"%d\"/>",
76 PCMK_OCF_NOT_INSTALLED, PCMK_EXEC_NOT_SUPPORTED);
77 node = pcmk__xml_parse(s);
78 assert_true(pcmk_xe_mask_probe_failure(node));
79 free(s);
80 free_xml(node);
81
82
83 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
84 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
85 PCMK_META_INTERVAL "=\"0\" "
86 PCMK__XA_RC_CODE "=\"%d\" "
87 PCMK__XA_OP_STATUS "=\"%d\"/>",
88 PCMK_OCF_OK, PCMK_EXEC_DONE);
89 node = pcmk__xml_parse(s);
90 assert_false(pcmk_xe_mask_probe_failure(node));
91 free(s);
92 free_xml(node);
93
94 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
95 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
96 PCMK_META_INTERVAL "=\"0\" "
97 PCMK__XA_RC_CODE "=\"%d\" "
98 PCMK__XA_OP_STATUS "=\"%d\"/>",
99 PCMK_OCF_INVALID_PARAM, PCMK_EXEC_DONE);
100 node = pcmk__xml_parse(s);
101 assert_true(pcmk_xe_mask_probe_failure(node));
102 free(s);
103 free_xml(node);
104
105 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
106 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
107 PCMK_META_INTERVAL "=\"0\" "
108 PCMK__XA_RC_CODE "=\"%d\" "
109 PCMK__XA_OP_STATUS "=\"%d\"/>",
110 PCMK_OCF_NOT_INSTALLED, PCMK_EXEC_DONE);
111 node = pcmk__xml_parse(s);
112 assert_true(pcmk_xe_mask_probe_failure(node));
113 free(s);
114 free_xml(node);
115
116 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
117 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
118 PCMK_META_INTERVAL "=\"0\" "
119 PCMK__XA_RC_CODE "=\"%d\" "
120 PCMK__XA_OP_STATUS "=\"%d\"/>",
121 PCMK_OCF_NOT_CONFIGURED, PCMK_EXEC_DONE);
122 node = pcmk__xml_parse(s);
123 assert_false(pcmk_xe_mask_probe_failure(node));
124 free(s);
125 free_xml(node);
126
127 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
128 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
129 PCMK_META_INTERVAL "=\"0\" "
130 PCMK__XA_RC_CODE "=\"%d\" "
131 PCMK__XA_OP_STATUS "=\"%d\"/>",
132 PCMK_OCF_NOT_RUNNING, PCMK_EXEC_DONE);
133 node = pcmk__xml_parse(s);
134 assert_false(pcmk_xe_mask_probe_failure(node));
135 free(s);
136 free_xml(node);
137
138
139 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
140 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
141 PCMK_META_INTERVAL "=\"0\" "
142 PCMK__XA_RC_CODE "=\"%d\" "
143 PCMK__XA_OP_STATUS "=\"%d\"/>",
144 PCMK_OCF_OK, PCMK_EXEC_NOT_INSTALLED);
145 node = pcmk__xml_parse(s);
146 assert_true(pcmk_xe_mask_probe_failure(node));
147 free(s);
148 free_xml(node);
149
150 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
151 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
152 PCMK_META_INTERVAL "=\"0\" "
153 PCMK__XA_RC_CODE "=\"%d\" "
154 PCMK__XA_OP_STATUS "=\"%d\"/>",
155 PCMK_OCF_NOT_INSTALLED, PCMK_EXEC_NOT_INSTALLED);
156 node = pcmk__xml_parse(s);
157 assert_true(pcmk_xe_mask_probe_failure(node));
158 free(s);
159 free_xml(node);
160
161
162 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
163 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
164 PCMK_META_INTERVAL "=\"0\" "
165 PCMK__XA_RC_CODE "=\"%d\" "
166 PCMK__XA_OP_STATUS "=\"%d\"/>",
167 PCMK_OCF_OK, PCMK_EXEC_ERROR);
168 node = pcmk__xml_parse(s);
169 assert_false(pcmk_xe_mask_probe_failure(node));
170 free(s);
171 free_xml(node);
172
173 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
174 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
175 PCMK_META_INTERVAL "=\"0\" "
176 PCMK__XA_RC_CODE "=\"%d\" "
177 PCMK__XA_OP_STATUS "=\"%d\"/>",
178 PCMK_OCF_INVALID_PARAM, PCMK_EXEC_ERROR);
179 node = pcmk__xml_parse(s);
180 assert_true(pcmk_xe_mask_probe_failure(node));
181 free(s);
182 free_xml(node);
183
184 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
185 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
186 PCMK_META_INTERVAL "=\"0\" "
187 PCMK__XA_RC_CODE "=\"%d\" "
188 PCMK__XA_OP_STATUS "=\"%d\"/>",
189 PCMK_OCF_NOT_INSTALLED, PCMK_EXEC_ERROR);
190 node = pcmk__xml_parse(s);
191 assert_true(pcmk_xe_mask_probe_failure(node));
192 free(s);
193 free_xml(node);
194
195 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
196 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
197 PCMK_META_INTERVAL "=\"0\" "
198 PCMK__XA_RC_CODE "=\"%d\" "
199 PCMK__XA_OP_STATUS "=\"%d\"/>",
200 PCMK_OCF_NOT_CONFIGURED, PCMK_EXEC_ERROR);
201 node = pcmk__xml_parse(s);
202 assert_false(pcmk_xe_mask_probe_failure(node));
203 free(s);
204 free_xml(node);
205
206 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
207 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
208 PCMK_META_INTERVAL "=\"0\" "
209 PCMK__XA_RC_CODE "=\"%d\" "
210 PCMK__XA_OP_STATUS "=\"%d\"/>",
211 PCMK_OCF_NOT_RUNNING, PCMK_EXEC_ERROR);
212 node = pcmk__xml_parse(s);
213 assert_false(pcmk_xe_mask_probe_failure(node));
214 free(s);
215 free_xml(node);
216
217
218 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
219 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
220 PCMK_META_INTERVAL "=\"0\" "
221 PCMK__XA_RC_CODE "=\"%d\" "
222 PCMK__XA_OP_STATUS "=\"%d\"/>",
223 PCMK_OCF_OK, PCMK_EXEC_ERROR_HARD);
224 node = pcmk__xml_parse(s);
225 assert_false(pcmk_xe_mask_probe_failure(node));
226 free(s);
227 free_xml(node);
228
229 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
230 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
231 PCMK_META_INTERVAL "=\"0\" "
232 PCMK__XA_RC_CODE "=\"%d\" "
233 PCMK__XA_OP_STATUS "=\"%d\"/>",
234 PCMK_OCF_INVALID_PARAM, PCMK_EXEC_ERROR_HARD);
235 node = pcmk__xml_parse(s);
236 assert_true(pcmk_xe_mask_probe_failure(node));
237 free(s);
238 free_xml(node);
239
240 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
241 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
242 PCMK_META_INTERVAL "=\"0\" "
243 PCMK__XA_RC_CODE "=\"%d\" "
244 PCMK__XA_OP_STATUS "=\"%d\"/>",
245 PCMK_OCF_NOT_INSTALLED, PCMK_EXEC_ERROR_HARD);
246 node = pcmk__xml_parse(s);
247 assert_true(pcmk_xe_mask_probe_failure(node));
248 free(s);
249 free_xml(node);
250
251 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
252 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
253 PCMK_META_INTERVAL "=\"0\" "
254 PCMK__XA_RC_CODE "=\"%d\" "
255 PCMK__XA_OP_STATUS "=\"%d\"/>",
256 PCMK_OCF_NOT_CONFIGURED, PCMK_EXEC_ERROR_HARD);
257 node = pcmk__xml_parse(s);
258 assert_false(pcmk_xe_mask_probe_failure(node));
259 free(s);
260 free_xml(node);
261
262 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
263 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
264 PCMK_META_INTERVAL "=\"0\" "
265 PCMK__XA_RC_CODE "=\"%d\" "
266 PCMK__XA_OP_STATUS "=\"%d\"/>",
267 PCMK_OCF_NOT_RUNNING, PCMK_EXEC_ERROR_HARD);
268 node = pcmk__xml_parse(s);
269 assert_false(pcmk_xe_mask_probe_failure(node));
270 free(s);
271 free_xml(node);
272
273
274 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
275 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
276 PCMK_META_INTERVAL "=\"0\" "
277 PCMK__XA_RC_CODE "=\"%d\" "
278 PCMK__XA_OP_STATUS "=\"%d\"/>",
279 PCMK_OCF_OK, PCMK_EXEC_ERROR_FATAL);
280 node = pcmk__xml_parse(s);
281 assert_false(pcmk_xe_mask_probe_failure(node));
282 free(s);
283 free_xml(node);
284
285 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
286 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
287 PCMK_META_INTERVAL "=\"0\" "
288 PCMK__XA_RC_CODE "=\"%d\" "
289 PCMK__XA_OP_STATUS "=\"%d\"/>",
290 PCMK_OCF_INVALID_PARAM, PCMK_EXEC_ERROR_FATAL);
291 node = pcmk__xml_parse(s);
292 assert_true(pcmk_xe_mask_probe_failure(node));
293 free(s);
294 free_xml(node);
295
296 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
297 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
298 PCMK_META_INTERVAL "=\"0\" "
299 PCMK__XA_RC_CODE "=\"%d\" "
300 PCMK__XA_OP_STATUS "=\"%d\"/>",
301 PCMK_OCF_NOT_INSTALLED, PCMK_EXEC_ERROR_FATAL);
302 node = pcmk__xml_parse(s);
303 assert_true(pcmk_xe_mask_probe_failure(node));
304 free(s);
305 free_xml(node);
306
307 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
308 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
309 PCMK_META_INTERVAL "=\"0\" "
310 PCMK__XA_RC_CODE "=\"%d\" "
311 PCMK__XA_OP_STATUS "=\"%d\"/>",
312 PCMK_OCF_NOT_CONFIGURED, PCMK_EXEC_ERROR_FATAL);
313 node = pcmk__xml_parse(s);
314 assert_false(pcmk_xe_mask_probe_failure(node));
315 free(s);
316 free_xml(node);
317
318 s = crm_strdup_printf("<" PCMK__XE_LRM_RSC_OP " "
319 PCMK_XA_OPERATION "=\"" PCMK_ACTION_MONITOR "\" "
320 PCMK_META_INTERVAL "=\"0\" "
321 PCMK__XA_RC_CODE "=\"%d\" "
322 PCMK__XA_OP_STATUS "=\"%d\"/>",
323 PCMK_OCF_NOT_RUNNING, PCMK_EXEC_ERROR_FATAL);
324 node = pcmk__xml_parse(s);
325 assert_false(pcmk_xe_mask_probe_failure(node));
326 free(s);
327 free_xml(node);
328 }
329
330 PCMK__UNIT_TEST(pcmk__xml_test_setup_group, pcmk__xml_test_teardown_group,
331 cmocka_unit_test(op_is_not_probe_test),
332 cmocka_unit_test(op_does_not_have_right_values_test),
333 cmocka_unit_test(check_values_test))