18 #define LISTS_EQ(a, b) { \ 19 assert_int_equal(g_strv_length((gchar **) (a)), g_strv_length((gchar **) (b))); \ 20 for (int i = 0; i < g_strv_length((a)); i++) { \ 21 assert_string_equal((a)[i], (b)[i]); \ 26 empty_input(
void **state) {
31 no_specials(
void **state) {
32 const char *argv[] = {
"crm_mon",
"-a",
"-b",
"-c",
"-d",
"-1", NULL };
33 const gchar *expected[] = {
"crm_mon",
"-a",
"-b",
"-c",
"-d",
"-1", NULL };
37 g_strfreev(processed);
41 g_strfreev(processed);
45 single_dash(
void **state) {
46 const char *argv[] = {
"crm_mon",
"-", NULL };
47 const gchar *expected[] = {
"crm_mon",
"-", NULL };
51 g_strfreev(processed);
55 double_dash(
void **state) {
56 const char *argv[] = {
"crm_mon",
"-a",
"--",
"-bc", NULL };
57 const gchar *expected[] = {
"crm_mon",
"-a",
"--",
"-bc", NULL };
61 g_strfreev(processed);
65 special_args(
void **state) {
66 const char *argv[] = {
"crm_mon",
"-aX",
"-Fval", NULL };
67 const gchar *expected[] = {
"crm_mon",
"-a",
"X",
"-F",
"val", NULL };
71 g_strfreev(processed);
75 special_arg_at_end(
void **state) {
76 const char *argv[] = {
"crm_mon",
"-a", NULL };
77 const gchar *expected[] = {
"crm_mon",
"-a", NULL };
81 g_strfreev(processed);
85 long_arg(
void **state) {
86 const char *argv[] = {
"crm_mon",
"--blah=foo", NULL };
87 const gchar *expected[] = {
"crm_mon",
"--blah=foo", NULL };
91 g_strfreev(processed);
95 negative_score(
void **state) {
96 const char *argv[] = {
"crm_mon",
"-v",
"-1000", NULL };
97 const gchar *expected[] = {
"crm_mon",
"-v",
"-1000", NULL };
101 g_strfreev(processed);
105 negative_score_2(
void **state) {
106 const char *argv[] = {
"crm_mon",
"-1i3", NULL };
107 const gchar *expected[] = {
"crm_mon",
"-1",
"-i",
"-3", NULL };
111 g_strfreev(processed);
115 negative_score_3(
void **state) {
116 const char *argv[] = {
"crm_attribute",
"-p",
"-v",
"-INFINITY", NULL };
117 const gchar *expected[] = {
"crm_attribute",
"-p",
"-v",
"-INFINITY", NULL };
121 g_strfreev(processed);
125 string_arg_with_dash(
void **state) {
126 const char *argv[] = {
"crm_mon",
"-n",
"crm_mon_options",
"-v",
"--opt1 --opt2", NULL };
127 const gchar *expected[] = {
"crm_mon",
"-n",
"crm_mon_options",
"-v",
"--opt1 --opt2", NULL };
131 g_strfreev(processed);
135 string_arg_with_dash_2(
void **state) {
136 const char *argv[] = {
"crm_mon",
"-n",
"crm_mon_options",
"-v",
"-1i3", NULL };
137 const gchar *expected[] = {
"crm_mon",
"-n",
"crm_mon_options",
"-v",
"-1i3", NULL };
141 g_strfreev(processed);
145 string_arg_with_dash_3(
void **state) {
146 const char *argv[] = {
"crm_mon",
"-abc",
"-1i3", NULL };
147 const gchar *expected[] = {
"crm_mon",
"-a",
"-b",
"-c",
"-1i3", NULL };
151 g_strfreev(processed);
155 cmocka_unit_test(empty_input),
156 cmocka_unit_test(no_specials),
157 cmocka_unit_test(single_dash),
158 cmocka_unit_test(double_dash),
159 cmocka_unit_test(special_args),
160 cmocka_unit_test(special_arg_at_end),
161 cmocka_unit_test(long_arg),
162 cmocka_unit_test(negative_score),
163 cmocka_unit_test(negative_score_2),
164 cmocka_unit_test(negative_score_3),
165 cmocka_unit_test(string_arg_with_dash),
166 cmocka_unit_test(string_arg_with_dash_2),
167 cmocka_unit_test(string_arg_with_dash_3))
#define PCMK__UNIT_TEST(group_setup, group_teardown,...)
gchar ** pcmk__cmdline_preproc(char *const *argv, const char *special)