Line data Source code
1 : /*
2 : Authors:
3 : Jakub Hrozek <jhrozek@redhat.com>
4 :
5 : Copyright (C) 2013 Red Hat
6 :
7 : SSSD tests: Fully Qualified Names Tests
8 :
9 : This program is free software; you can redistribute it and/or modify
10 : it under the terms of the GNU General Public License as published by
11 : the Free Software Foundation; either version 3 of the License, or
12 : (at your option) any later version.
13 :
14 : This program is distributed in the hope that it will be useful,
15 : but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : GNU General Public License for more details.
18 :
19 : You should have received a copy of the GNU General Public License
20 : along with this program. If not, see <http://www.gnu.org/licenses/>.
21 : */
22 :
23 : #include <popt.h>
24 :
25 : #include "db/sysdb_private.h"
26 : #include "tests/cmocka/common_mock.h"
27 :
28 : #define NAME "name"
29 : #define DOMNAME "domname"
30 : #define FLATNAME "flatname"
31 : #define SPECIALNAME "[]{}();:'|\",<.>/?!#$%^&*_+~`"
32 : #define PROVIDER "local"
33 : #define CONNNAME "conn"
34 :
35 : #define DOMNAME2 "domname2"
36 : #define FLATNAME2 "flatname2"
37 :
38 : #define SUBDOMNAME "subdomname"
39 : #define SUBFLATNAME "subflatname"
40 :
41 19 : static struct sss_domain_info *create_test_domain(TALLOC_CTX *mem_ctx,
42 : const char *name,
43 : const char *flatname,
44 : struct sss_domain_info *parent,
45 : struct sss_names_ctx *nctx)
46 : {
47 : struct sss_domain_info *dom;
48 :
49 19 : dom = talloc_zero(mem_ctx, struct sss_domain_info);
50 19 : assert_non_null(dom);
51 :
52 : /* just to make new_subdomain happy */
53 19 : dom->sysdb = talloc_zero(dom, struct sysdb_ctx);
54 19 : assert_non_null(dom->sysdb);
55 :
56 19 : dom->name = discard_const(name);
57 19 : dom->flat_name = discard_const(flatname);
58 19 : dom->parent = parent;
59 19 : dom->names = nctx;
60 19 : dom->provider = discard_const(PROVIDER);
61 19 : dom->conn_name = discard_const(CONNNAME);
62 :
63 19 : return dom;
64 : }
65 :
66 : struct fqdn_test_ctx {
67 : struct sss_domain_info *dom;
68 :
69 : struct sss_names_ctx *nctx;
70 : };
71 :
72 5 : static int fqdn_test_setup(void **state)
73 : {
74 : struct fqdn_test_ctx *test_ctx;
75 :
76 5 : assert_true(leak_check_setup());
77 :
78 5 : test_ctx = talloc_zero(global_talloc_context, struct fqdn_test_ctx);
79 5 : assert_non_null(test_ctx);
80 :
81 5 : test_ctx->dom = create_test_domain(test_ctx, DOMNAME, FLATNAME,
82 : NULL, NULL);
83 :
84 5 : check_leaks_push(test_ctx);
85 5 : *state = test_ctx;
86 5 : return 0;
87 : }
88 :
89 5 : static int fqdn_test_teardown(void **state)
90 : {
91 5 : struct fqdn_test_ctx *test_ctx = talloc_get_type(*state,
92 : struct fqdn_test_ctx);
93 :
94 5 : if (test_ctx == NULL) {
95 0 : DEBUG(SSSDBG_CRIT_FAILURE, "Type mismatch\n");
96 0 : return 1;
97 : }
98 :
99 5 : assert_true(check_leaks_pop(test_ctx) == true);
100 5 : talloc_free(test_ctx);
101 5 : assert_true(leak_check_teardown());
102 5 : return 0;
103 : }
104 :
105 1 : void test_default(void **state)
106 1 : {
107 1 : struct fqdn_test_ctx *test_ctx = talloc_get_type(*state,
108 : struct fqdn_test_ctx);
109 : errno_t ret;
110 :
111 : char *fqdn;
112 1 : const int fqdn_size = 255;
113 1 : char fqdn_s[fqdn_size];
114 :
115 1 : if (test_ctx == NULL) {
116 0 : DEBUG(SSSDBG_CRIT_FAILURE, "Type mismatch\n");
117 0 : return;
118 : }
119 :
120 1 : ret = sss_names_init_from_args(test_ctx,
121 : "(?P<name>[^@]+)@?(?P<domain>[^@]*$)",
122 : "%1$s@%2$s", &test_ctx->nctx);
123 1 : assert_int_equal(ret, EOK);
124 :
125 1 : fqdn = sss_tc_fqname(test_ctx, test_ctx->nctx, test_ctx->dom, NAME);
126 1 : assert_non_null(fqdn);
127 1 : assert_string_equal(fqdn, NAME"@"DOMNAME);
128 1 : talloc_free(fqdn);
129 :
130 1 : ret = sss_fqname(fqdn_s, fqdn_size, test_ctx->nctx, test_ctx->dom, NAME);
131 1 : assert_int_equal(ret + 1, sizeof(NAME"@"DOMNAME));
132 1 : assert_string_equal(fqdn_s, NAME"@"DOMNAME);
133 :
134 1 : talloc_free(test_ctx->nctx);
135 : }
136 :
137 1 : void test_all(void **state)
138 1 : {
139 1 : struct fqdn_test_ctx *test_ctx = talloc_get_type(*state,
140 : struct fqdn_test_ctx);
141 : errno_t ret;
142 :
143 : char *fqdn;
144 1 : const int fqdn_size = 255;
145 1 : char fqdn_s[fqdn_size];
146 :
147 1 : if (test_ctx == NULL) {
148 0 : DEBUG(SSSDBG_CRIT_FAILURE, "Type mismatch\n");
149 0 : return;
150 : }
151 :
152 1 : ret = sss_names_init_from_args(test_ctx,
153 : "(?P<name>[^@]+)@?(?P<domain>[^@]*$)",
154 : "%1$s@%2$s@%3$s", &test_ctx->nctx);
155 1 : assert_int_equal(ret, EOK);
156 :
157 1 : fqdn = sss_tc_fqname(test_ctx, test_ctx->nctx, test_ctx->dom, NAME);
158 1 : assert_non_null(fqdn);
159 1 : assert_string_equal(fqdn, NAME"@"DOMNAME"@"FLATNAME);
160 1 : talloc_free(fqdn);
161 :
162 1 : ret = sss_fqname(fqdn_s, fqdn_size, test_ctx->nctx, test_ctx->dom, NAME);
163 1 : assert_int_equal(ret + 1, sizeof(NAME"@"DOMNAME"@"FLATNAME));
164 1 : assert_string_equal(fqdn_s, NAME"@"DOMNAME"@"FLATNAME);
165 :
166 1 : talloc_free(test_ctx->nctx);
167 : }
168 :
169 1 : void test_flat(void **state)
170 1 : {
171 1 : struct fqdn_test_ctx *test_ctx = talloc_get_type(*state,
172 : struct fqdn_test_ctx);
173 : errno_t ret;
174 :
175 : char *fqdn;
176 1 : const int fqdn_size = 255;
177 1 : char fqdn_s[fqdn_size];
178 :
179 1 : if (test_ctx == NULL) {
180 0 : DEBUG(SSSDBG_CRIT_FAILURE, "Type mismatch\n");
181 0 : return;
182 : }
183 :
184 1 : ret = sss_names_init_from_args(test_ctx,
185 : "(?P<name>[^@]+)@?(?P<domain>[^@]*$)",
186 : "%1$s@%3$s", &test_ctx->nctx);
187 1 : assert_int_equal(ret, EOK);
188 :
189 1 : fqdn = sss_tc_fqname(test_ctx, test_ctx->nctx, test_ctx->dom, NAME);
190 1 : assert_non_null(fqdn);
191 1 : assert_string_equal(fqdn, NAME"@"FLATNAME);
192 1 : talloc_free(fqdn);
193 :
194 1 : ret = sss_fqname(fqdn_s, fqdn_size, test_ctx->nctx, test_ctx->dom, NAME);
195 1 : assert_int_equal(ret + 1, sizeof(NAME"@"FLATNAME));
196 1 : assert_string_equal(fqdn_s, NAME"@"FLATNAME);
197 :
198 1 : talloc_free(test_ctx->nctx);
199 : }
200 :
201 1 : void test_flat_fallback(void **state)
202 1 : {
203 1 : struct fqdn_test_ctx *test_ctx = talloc_get_type(*state,
204 : struct fqdn_test_ctx);
205 : errno_t ret;
206 :
207 : char *fqdn;
208 1 : const int fqdn_size = 255;
209 1 : char fqdn_s[fqdn_size];
210 :
211 1 : if (test_ctx == NULL) {
212 0 : DEBUG(SSSDBG_CRIT_FAILURE, "Type mismatch\n");
213 0 : return;
214 : }
215 :
216 1 : ret = sss_names_init_from_args(test_ctx,
217 : "(?P<name>[^@]+)@?(?P<domain>[^@]*$)",
218 : "%1$s@%3$s", &test_ctx->nctx);
219 1 : assert_int_equal(ret, EOK);
220 :
221 1 : test_ctx->dom->flat_name = NULL;
222 :
223 : /* If flat name is requested but does not exist, the code falls back to domain
224 : * name
225 : */
226 1 : fqdn = sss_tc_fqname(test_ctx, test_ctx->nctx, test_ctx->dom, NAME);
227 1 : assert_non_null(fqdn);
228 1 : assert_string_equal(fqdn, NAME"@"DOMNAME);
229 1 : talloc_free(fqdn);
230 :
231 1 : ret = sss_fqname(fqdn_s, fqdn_size, test_ctx->nctx, test_ctx->dom, NAME);
232 1 : assert_int_equal(ret + 1, sizeof(NAME"@"DOMNAME));
233 1 : assert_string_equal(fqdn_s, NAME"@"DOMNAME);
234 :
235 1 : talloc_free(test_ctx->nctx);
236 : }
237 :
238 : struct parse_name_test_ctx {
239 : struct sss_domain_info *dom;
240 : struct sss_domain_info *subdom;
241 : struct sss_names_ctx *nctx;
242 : };
243 :
244 11 : void parse_name_check(struct parse_name_test_ctx *test_ctx,
245 : const char *full_name,
246 : const char *default_domain,
247 : const char exp_ret,
248 : const char *exp_name,
249 : const char *exp_domain)
250 : {
251 : errno_t ret;
252 11 : char *domain = NULL;
253 11 : char *name = NULL;
254 :
255 11 : check_leaks_push(test_ctx);
256 11 : ret = sss_parse_name_for_domains(test_ctx, test_ctx->dom, default_domain,
257 : full_name, &domain, &name);
258 11 : assert_int_equal(ret, exp_ret);
259 :
260 11 : if (exp_name) {
261 8 : assert_non_null(name);
262 8 : assert_string_equal(name, exp_name);
263 : }
264 :
265 11 : if (exp_domain) {
266 7 : assert_non_null(domain);
267 7 : assert_string_equal(domain, exp_domain);
268 : }
269 :
270 11 : talloc_free(name);
271 11 : talloc_free(domain);
272 11 : assert_true(check_leaks_pop(test_ctx) == true);
273 11 : }
274 :
275 7 : static int parse_name_test_setup(void **state)
276 : {
277 : struct parse_name_test_ctx *test_ctx;
278 : struct sss_domain_info *dom;
279 : errno_t ret;
280 :
281 7 : assert_true(leak_check_setup());
282 :
283 7 : test_ctx = talloc_zero(global_talloc_context, struct parse_name_test_ctx);
284 7 : assert_non_null(test_ctx);
285 :
286 : /* Init with an AD-style regex to be able to test flat name */
287 7 : ret = sss_names_init_from_args(test_ctx,
288 : "(((?P<domain>[^\\\\]+)\\\\(?P<name>.+$))|" \
289 : "((?P<name>[^@]+)@(?P<domain>.+$))|" \
290 : "(^(?P<name>[^@\\\\]+)$))",
291 : "%1$s@%2$s", &test_ctx->nctx);
292 7 : assert_int_equal(ret, EOK);
293 :
294 : /* The setup is two domains, first one with no subdomains,
295 : * second one with a single subdomain
296 : */
297 7 : dom = create_test_domain(test_ctx, DOMNAME, FLATNAME,
298 : NULL, test_ctx->nctx);
299 7 : assert_non_null(dom);
300 7 : DLIST_ADD_END(test_ctx->dom, dom, struct sss_domain_info *);
301 :
302 7 : dom = create_test_domain(test_ctx, DOMNAME2,
303 : FLATNAME2, NULL, test_ctx->nctx);
304 7 : assert_non_null(dom);
305 7 : DLIST_ADD_END(test_ctx->dom, dom, struct sss_domain_info *);
306 :
307 : /* Create the subdomain, but don't add it yet, we want to be able to
308 : * test sss_parse_name_for_domains() signaling that domains must be
309 : * discovered
310 : */
311 7 : test_ctx->subdom = new_subdomain(dom, dom, SUBDOMNAME, NULL, SUBFLATNAME,
312 : NULL, false, false, NULL, 0);
313 7 : assert_non_null(test_ctx->subdom);
314 :
315 7 : check_leaks_push(test_ctx);
316 7 : *state = test_ctx;
317 7 : return 0;
318 : }
319 :
320 7 : static int parse_name_test_teardown(void **state)
321 : {
322 7 : struct parse_name_test_ctx *test_ctx = talloc_get_type(*state,
323 : struct parse_name_test_ctx);
324 :
325 7 : assert_true(check_leaks_pop(test_ctx) == true);
326 7 : talloc_free(test_ctx);
327 7 : assert_true(leak_check_teardown());
328 7 : return 0;
329 : }
330 :
331 13 : void sss_parse_name_check(struct parse_name_test_ctx *test_ctx,
332 : const char *input_name,
333 : const int exp_ret,
334 : const char *exp_name,
335 : const char *exp_domain)
336 : {
337 : errno_t ret;
338 13 : char *domain = NULL;
339 13 : char *name = NULL;
340 13 : const char *domain_const = NULL;
341 13 : const char *name_const = NULL;
342 :
343 :
344 13 : check_leaks_push(test_ctx);
345 13 : ret = sss_parse_name(test_ctx, test_ctx->nctx, input_name,
346 : &domain, &name);
347 13 : assert_int_equal(ret, exp_ret);
348 :
349 13 : if (exp_name) {
350 6 : assert_non_null(name);
351 6 : assert_string_equal(name, exp_name);
352 : }
353 :
354 13 : if (exp_domain) {
355 4 : assert_non_null(domain);
356 4 : assert_string_equal(domain, exp_domain);
357 : }
358 :
359 13 : talloc_zfree(name);
360 13 : talloc_zfree(domain);
361 :
362 13 : ret = sss_parse_name_const(test_ctx, test_ctx->nctx, input_name,
363 : &domain_const, &name_const);
364 13 : assert_int_equal(ret, exp_ret);
365 :
366 13 : if (exp_name) {
367 6 : assert_non_null(name_const);
368 6 : assert_string_equal(name_const, exp_name);
369 : }
370 :
371 13 : if (exp_domain) {
372 4 : assert_non_null(domain_const);
373 4 : assert_string_equal(domain_const, exp_domain);
374 : }
375 :
376 13 : talloc_free(discard_const(name_const));
377 13 : talloc_free(discard_const(domain_const));
378 :
379 13 : assert_true(check_leaks_pop(test_ctx) == true);
380 13 : }
381 :
382 1 : void parse_name_plain(void **state)
383 : {
384 1 : struct parse_name_test_ctx *test_ctx = talloc_get_type(*state,
385 : struct parse_name_test_ctx);
386 : int ret;
387 :
388 1 : parse_name_check(test_ctx, NAME, NULL, EOK, NAME, NULL);
389 :
390 1 : ret = sss_parse_name(test_ctx, test_ctx->nctx, NAME,
391 : NULL, NULL);
392 1 : assert_int_equal(ret, EOK);
393 1 : ret = sss_parse_name_const(test_ctx, test_ctx->nctx, NAME,
394 : NULL, NULL);
395 1 : assert_int_equal(ret, EOK);
396 :
397 1 : sss_parse_name_check(test_ctx, NAME, EOK, NAME, NULL);
398 1 : sss_parse_name_check(test_ctx, SPECIALNAME, EOK, SPECIALNAME, NULL);
399 1 : }
400 :
401 1 : void parse_name_fqdn(void **state)
402 : {
403 1 : struct parse_name_test_ctx *test_ctx = talloc_get_type(*state,
404 : struct parse_name_test_ctx);
405 1 : parse_name_check(test_ctx, NAME"@"DOMNAME, NULL, EOK, NAME, DOMNAME);
406 1 : parse_name_check(test_ctx, NAME"@"DOMNAME2, NULL, EOK, NAME, DOMNAME2);
407 :
408 1 : sss_parse_name_check(test_ctx, NAME"@"DOMNAME, EOK, NAME, DOMNAME);
409 1 : sss_parse_name_check(test_ctx, NAME"@"DOMNAME2, EOK, NAME, DOMNAME2);
410 1 : sss_parse_name_check(test_ctx, DOMNAME"\\"NAME, EOK, NAME, DOMNAME);
411 1 : sss_parse_name_check(test_ctx, DOMNAME2"\\"NAME, EOK, NAME, DOMNAME2);
412 1 : }
413 :
414 1 : void parse_name_sub(void **state)
415 : {
416 1 : struct parse_name_test_ctx *test_ctx = talloc_get_type(*state,
417 : struct parse_name_test_ctx);
418 : /* The subdomain name is valid, but not known */
419 1 : parse_name_check(test_ctx, NAME"@"SUBDOMNAME, NULL, EAGAIN, NULL, NULL);
420 :
421 : /* Link the subdomain (simulating subdom handler) and retry */
422 1 : test_ctx->dom->subdomains = test_ctx->subdom;
423 1 : parse_name_check(test_ctx, NAME"@"SUBDOMNAME, NULL, EOK, NAME, SUBDOMNAME);
424 1 : }
425 :
426 1 : void parse_name_flat(void **state)
427 : {
428 1 : struct parse_name_test_ctx *test_ctx = talloc_get_type(*state,
429 : struct parse_name_test_ctx);
430 :
431 : /* Link the subdomain (simulating subdom handler) */
432 1 : parse_name_check(test_ctx, FLATNAME"\\"NAME, NULL, EOK, NAME, DOMNAME);
433 1 : parse_name_check(test_ctx, FLATNAME2"\\"NAME, NULL, EOK, NAME, DOMNAME2);
434 :
435 : /* The subdomain name is valid, but not known */
436 1 : parse_name_check(test_ctx, SUBFLATNAME"\\"NAME, NULL, EAGAIN, NULL, NULL);
437 1 : test_ctx->dom->subdomains = test_ctx->subdom;
438 1 : parse_name_check(test_ctx, SUBFLATNAME"\\"NAME, NULL, EOK, NAME, SUBDOMNAME);
439 1 : }
440 :
441 1 : void parse_name_default(void **state)
442 : {
443 1 : struct parse_name_test_ctx *test_ctx = talloc_get_type(*state,
444 : struct parse_name_test_ctx);
445 : struct sss_domain_info *dom2;
446 :
447 1 : parse_name_check(test_ctx, NAME, DOMNAME2, EOK, NAME, DOMNAME2);
448 1 : dom2 = test_ctx->dom->next;
449 :
450 : /* Simulate uknown default domain */
451 1 : DLIST_REMOVE(test_ctx->dom, dom2);
452 1 : parse_name_check(test_ctx, NAME, DOMNAME2, EAGAIN, NULL, NULL);
453 1 : }
454 :
455 1 : void test_init_nouser(void **state)
456 : {
457 1 : struct fqdn_test_ctx *test_ctx = talloc_get_type(*state,
458 : struct fqdn_test_ctx);
459 : errno_t ret;
460 :
461 1 : if (test_ctx == NULL) {
462 0 : DEBUG(SSSDBG_CRIT_FAILURE, "Type mismatch\n");
463 0 : return;
464 : }
465 :
466 1 : ret = sss_names_init_from_args(test_ctx,
467 : "(?P<name>[^@]+)@?(?P<domain>[^@]*$)",
468 : "%2$s@%3$s", &test_ctx->nctx);
469 : /* Initialization with no user name must fail */
470 1 : assert_int_not_equal(ret, EOK);
471 : }
472 :
473 1 : void sss_parse_name_fail(void **state)
474 : {
475 1 : struct parse_name_test_ctx *test_ctx = talloc_get_type(*state,
476 : struct parse_name_test_ctx);
477 :
478 1 : sss_parse_name_check(test_ctx, "", ERR_REGEX_NOMATCH, NULL, NULL);
479 1 : sss_parse_name_check(test_ctx, "@", ERR_REGEX_NOMATCH, NULL, NULL);
480 1 : sss_parse_name_check(test_ctx, "\\", ERR_REGEX_NOMATCH, NULL, NULL);
481 1 : sss_parse_name_check(test_ctx, "\\"NAME, ERR_REGEX_NOMATCH, NULL, NULL);
482 1 : sss_parse_name_check(test_ctx, "@"NAME, ERR_REGEX_NOMATCH, NULL, NULL);
483 1 : sss_parse_name_check(test_ctx, NAME"@", ERR_REGEX_NOMATCH, NULL, NULL);
484 1 : sss_parse_name_check(test_ctx, NAME"\\", ERR_REGEX_NOMATCH, NULL, NULL);
485 1 : }
486 :
487 1 : void test_sss_get_domain_name(void **state)
488 : {
489 1 : struct parse_name_test_ctx *test_ctx = talloc_get_type(*state,
490 : struct parse_name_test_ctx);
491 : struct {
492 : const char *input;
493 : struct sss_domain_info *domain;
494 : const char *expected;
495 3 : } data[] = {{"user", test_ctx->dom, "user"},
496 1 : {"user", test_ctx->subdom, "user@" SUBDOMNAME},
497 1 : {"user@" SUBDOMNAME, test_ctx->subdom, "user@" SUBDOMNAME},
498 : {NULL, NULL, NULL}};
499 : char *name;
500 : int i;
501 :
502 4 : for (i = 0; data[i].input != NULL; i++) {
503 3 : name = sss_get_domain_name(test_ctx, data[i].input, data[i].domain);
504 3 : assert_non_null(name);
505 3 : assert_string_equal(name, data[i].expected);
506 3 : talloc_free(name);
507 : }
508 1 : }
509 :
510 1 : int main(int argc, const char *argv[])
511 : {
512 : poptContext pc;
513 : int opt;
514 6 : struct poptOption long_options[] = {
515 : POPT_AUTOHELP
516 5 : SSSD_DEBUG_OPTS
517 : POPT_TABLEEND
518 : };
519 :
520 1 : const struct CMUnitTest tests[] = {
521 : cmocka_unit_test_setup_teardown(test_default,
522 : fqdn_test_setup, fqdn_test_teardown),
523 : cmocka_unit_test_setup_teardown(test_all,
524 : fqdn_test_setup, fqdn_test_teardown),
525 : cmocka_unit_test_setup_teardown(test_flat,
526 : fqdn_test_setup, fqdn_test_teardown),
527 : cmocka_unit_test_setup_teardown(test_flat_fallback,
528 : fqdn_test_setup, fqdn_test_teardown),
529 : cmocka_unit_test_setup_teardown(test_init_nouser,
530 : fqdn_test_setup, fqdn_test_teardown),
531 :
532 : cmocka_unit_test_setup_teardown(parse_name_plain,
533 : parse_name_test_setup,
534 : parse_name_test_teardown),
535 : cmocka_unit_test_setup_teardown(parse_name_fqdn,
536 : parse_name_test_setup,
537 : parse_name_test_teardown),
538 : cmocka_unit_test_setup_teardown(parse_name_sub,
539 : parse_name_test_setup,
540 : parse_name_test_teardown),
541 : cmocka_unit_test_setup_teardown(parse_name_flat,
542 : parse_name_test_setup,
543 : parse_name_test_teardown),
544 : cmocka_unit_test_setup_teardown(parse_name_default,
545 : parse_name_test_setup,
546 : parse_name_test_teardown),
547 : cmocka_unit_test_setup_teardown(sss_parse_name_fail,
548 : parse_name_test_setup,
549 : parse_name_test_teardown),
550 :
551 : cmocka_unit_test_setup_teardown(test_sss_get_domain_name,
552 : parse_name_test_setup,
553 : parse_name_test_teardown),
554 : };
555 :
556 : /* Set debug level to invalid value so we can deside if -d 0 was used. */
557 1 : debug_level = SSSDBG_INVALID;
558 :
559 1 : pc = poptGetContext(argv[0], argc, argv, long_options, 0);
560 1 : while((opt = poptGetNextOpt(pc)) != -1) {
561 : switch(opt) {
562 : default:
563 0 : fprintf(stderr, "\nInvalid option %s: %s\n\n",
564 : poptBadOption(pc, 0), poptStrerror(opt));
565 0 : poptPrintUsage(pc, stderr, 0);
566 0 : return 1;
567 : }
568 : }
569 1 : poptFreeContext(pc);
570 :
571 1 : DEBUG_CLI_INIT(debug_level);
572 :
573 : /* Even though normally the tests should clean up after themselves
574 : * they might not after a failed run. Remove the old db to be sure */
575 1 : tests_set_cwd();
576 :
577 1 : return cmocka_run_group_tests(tests, NULL, NULL);
578 : }
|