From: 2xsec Date: Tue, 3 Jul 2018 09:19:50 +0000 (+0900) Subject: tests: cleanup list.c X-Git-Tag: lxc-3.1.0~221^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0353f8b0b30feb52609274865aac658f74e5f28;p=thirdparty%2Flxc.git tests: cleanup list.c Signed-off-by: 2xsec --- diff --git a/src/tests/list.c b/src/tests/list.c index 9641dccbb..37f910e61 100644 --- a/src/tests/list.c +++ b/src/tests/list.c @@ -31,17 +31,21 @@ static void test_list_func(const char *lxcpath, const char *type, char **names; printf("%-10s Counting containers\n", type); + n = func(lxcpath, NULL, NULL); printf("%-10s Counted %d containers\n", type, n); printf("%-10s Get container struct only\n", type); + n2 = func(lxcpath, NULL, &clist); if (n2 != n) printf("Warning: first call returned %d, second %d\n", n, n2); + for (i = 0; i < n2; i++) { struct lxc_container *c = clist[i]; printf("%-10s Got container struct %s\n", type, c->name); lxc_container_put(c); } + if (n2 > 0) { free(clist); clist = NULL; @@ -51,10 +55,12 @@ static void test_list_func(const char *lxcpath, const char *type, n2 = func(lxcpath, &names, NULL); if (n2 != n) printf("Warning: first call returned %d, second %d\n", n, n2); + for (i = 0; i < n2; i++) { printf("%-10s Got container name %s\n", type, names[i]); free(names[i]); } + if (n2 > 0) { free(names); names = NULL; @@ -64,14 +70,18 @@ static void test_list_func(const char *lxcpath, const char *type, n2 = func(lxcpath, &names, &clist); if (n2 != n) printf("Warning: first call returned %d, second %d\n", n, n2); + for (i = 0; i < n2; i++) { struct lxc_container *c = clist[i]; printf("%-10s Got container struct %s, name %s\n", type, c->name, names[i]); + if (strcmp(c->name, names[i])) fprintf(stderr, "ERROR: name mismatch!\n"); + free(names[i]); lxc_container_put(c); } + if (n2 > 0) { free(names); free(clist);