27 assert_true(
parse_op_key(
"Fencing_monitor_60000", &rsc, &ty, &ms));
28 assert_string_equal(rsc,
"Fencing");
29 assert_string_equal(ty,
"monitor");
30 assert_int_equal(ms, 60000);
36 colon_in_rsc(
void **state)
42 assert_true(
parse_op_key(
"ClusterIP:0_start_0", &rsc, &ty, &ms));
43 assert_string_equal(rsc,
"ClusterIP:0");
44 assert_string_equal(ty,
"start");
45 assert_int_equal(ms, 0);
49 assert_true(
parse_op_key(
"imagestoreclone:1_post_notify_stop_0", &rsc, &ty, &ms));
50 assert_string_equal(rsc,
"imagestoreclone:1");
51 assert_string_equal(ty,
"post_notify_stop");
52 assert_int_equal(ms, 0);
58 dashes_in_rsc(
void **state)
64 assert_true(
parse_op_key(
"httpd-bundle-0_monitor_30000", &rsc, &ty, &ms));
65 assert_string_equal(rsc,
"httpd-bundle-0");
66 assert_string_equal(ty,
"monitor");
67 assert_int_equal(ms, 30000);
71 assert_true(
parse_op_key(
"httpd-bundle-ip-192.168.122.132_start_0", &rsc, &ty, &ms));
72 assert_string_equal(rsc,
"httpd-bundle-ip-192.168.122.132");
73 assert_string_equal(ty,
"start");
74 assert_int_equal(ms, 0);
80 migrate_to_from(
void **state)
86 assert_true(
parse_op_key(
"vm_migrate_from_0", &rsc, &ty, &ms));
87 assert_string_equal(rsc,
"vm");
88 assert_string_equal(ty,
"migrate_from");
89 assert_int_equal(ms, 0);
93 assert_true(
parse_op_key(
"vm_migrate_to_0", &rsc, &ty, &ms));
94 assert_string_equal(rsc,
"vm");
95 assert_string_equal(ty,
"migrate_to");
96 assert_int_equal(ms, 0);
100 assert_true(
parse_op_key(
"vm_idcc_devel_migrate_to_0", &rsc, &ty, &ms));
101 assert_string_equal(rsc,
"vm_idcc_devel");
102 assert_string_equal(ty,
"migrate_to");
103 assert_int_equal(ms, 0);
109 pre_post(
void **state)
115 assert_true(
parse_op_key(
"rsc_drbd_7788:1_post_notify_start_0", &rsc, &ty, &ms));
116 assert_string_equal(rsc,
"rsc_drbd_7788:1");
117 assert_string_equal(ty,
"post_notify_start");
118 assert_int_equal(ms, 0);
122 assert_true(
parse_op_key(
"rabbitmq-bundle-clone_pre_notify_stop_0", &rsc, &ty, &ms));
123 assert_string_equal(rsc,
"rabbitmq-bundle-clone");
124 assert_string_equal(ty,
"pre_notify_stop");
125 assert_int_equal(ms, 0);
129 assert_true(
parse_op_key(
"post_notify_start_0", &rsc, &ty, &ms));
130 assert_string_equal(rsc,
"post_notify");
131 assert_string_equal(ty,
"start");
132 assert_int_equal(ms, 0);
138 skip_rsc(
void **state)
143 assert_true(
parse_op_key(
"Fencing_monitor_60000", NULL, &ty, &ms));
144 assert_string_equal(ty,
"monitor");
145 assert_int_equal(ms, 60000);
150 skip_ty(
void **state)
155 assert_true(
parse_op_key(
"Fencing_monitor_60000", &rsc, NULL, &ms));
156 assert_string_equal(rsc,
"Fencing");
157 assert_int_equal(ms, 60000);
162 skip_ms(
void **state)
167 assert_true(
parse_op_key(
"Fencing_monitor_60000", &rsc, &ty, NULL));
168 assert_string_equal(rsc,
"Fencing");
169 assert_string_equal(ty,
"monitor");
175 empty_input(
void **state)
184 assert_int_equal(ms, 0);
189 assert_int_equal(ms, 0);
193 malformed_input(
void **state)
199 assert_false(
parse_op_key(
"httpd-bundle-0", &rsc, &ty, &ms));
202 assert_int_equal(ms, 0);
204 assert_false(
parse_op_key(
"httpd-bundle-0_monitor", &rsc, &ty, &ms));
207 assert_int_equal(ms, 0);
209 assert_false(
parse_op_key(
"httpd-bundle-0_30000", &rsc, &ty, &ms));
212 assert_int_equal(ms, 0);
215 int main(
int argc,
char **argv)
217 const struct CMUnitTest tests[] = {
218 cmocka_unit_test(basic),
219 cmocka_unit_test(colon_in_rsc),
220 cmocka_unit_test(dashes_in_rsc),
221 cmocka_unit_test(migrate_to_from),
222 cmocka_unit_test(pre_post),
224 cmocka_unit_test(skip_rsc),
225 cmocka_unit_test(skip_ty),
226 cmocka_unit_test(skip_ms),
228 cmocka_unit_test(empty_input),
229 cmocka_unit_test(malformed_input),
232 cmocka_set_message_output(CM_OUTPUT_TAP);
233 return cmocka_run_group_tests(tests, NULL, NULL);
gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, guint *interval_ms)
int main(int argc, char **argv)