Skip to content

Commit

Permalink
Merge pull request #2445 from 2xsec/bugfix
Browse files Browse the repository at this point in the history
tests: cleanup source codes.
  • Loading branch information
brauner committed Jul 3, 2018
2 parents 5221c89 + 6ea8a43 commit 9b93748
Show file tree
Hide file tree
Showing 25 changed files with 453 additions and 215 deletions.
3 changes: 3 additions & 0 deletions src/tests/api_reboot.c
Expand Up @@ -59,6 +59,7 @@ int main(int argc, char *argv[])
lxc_error("%s\n", "Container \"reboot\" is not defined");
goto on_error_put;
}

c->clear_config(c);

if (!c->load_config(c, NULL)) {
Expand Down Expand Up @@ -118,7 +119,9 @@ int main(int argc, char *argv[])

on_error_put:
lxc_container_put(c);

if (ret == EXIT_SUCCESS)
lxc_debug("%s\n", "All reboot tests passed");

exit(ret);
}
11 changes: 11 additions & 0 deletions src/tests/clonetest.c
Expand Up @@ -41,6 +41,7 @@ int main(int argc, char *argv[])
lxc_container_put(c);
c = NULL;
}

if (c2) {
c2->destroy(c2);
lxc_container_put(c2);
Expand All @@ -52,11 +53,14 @@ int main(int argc, char *argv[])
ret = 1;
goto out;
}

c->save_config(c, NULL);

if (!c->createl(c, "busybox", NULL, NULL, 0, NULL)) {
fprintf(stderr, "%d: failed to create a container\n", __LINE__);
goto out;
}

c->load_config(c, NULL);

if (!c->is_defined(c)) {
Expand Down Expand Up @@ -92,12 +96,14 @@ int main(int argc, char *argv[])
c2->destroy(c2);
lxc_container_put(c2);
}

c2 = lxc_container_new("clonetest-o1", NULL);
if (c2) {
if (c2->is_defined(c2))
c2->destroy(c2);
lxc_container_put(c2);
}

c2 = lxc_container_new("clonetest-o2", NULL);
if (c2) {
if (c2->is_defined(c2))
Expand All @@ -112,6 +118,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "failed loading clonetestlvm1\n");
goto out;
}

if (!c->is_defined(c)) {
fprintf(stderr, "clonetestlvm1 does not exist, skipping lvm tests\n");
ret = 0;
Expand All @@ -138,6 +145,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "lvm clone failed\n");
goto out;
}

lxc_container_put(c2);
lxc_container_put(c);
c = c2 = NULL;
Expand Down Expand Up @@ -166,13 +174,16 @@ int main(int argc, char *argv[])
if (c3) {
lxc_container_put(c3);
}

if (c2) {
c2->destroy(c2);
lxc_container_put(c2);
}

if (c) {
c->destroy(c);
lxc_container_put(c);
}

exit(ret);
}

0 comments on commit 9b93748

Please sign in to comment.