]> git.proxmox.com Git - mirror_lxc.git/commitdiff
tests: cleanup list.c
author2xsec <dh48.jeong@samsung.com>
Tue, 3 Jul 2018 09:19:50 +0000 (18:19 +0900)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 3 Jul 2018 10:44:41 +0000 (12:44 +0200)
Signed-off-by: 2xsec <dh48.jeong@samsung.com>
src/tests/list.c

index 9641dccbb1350e54483c36e22d97caedc7438277..37f910e61f3ef5c4862f32b31edfc267947dd370 100644 (file)
@@ -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);