From: 2xsec Date: Tue, 3 Jul 2018 09:10:55 +0000 (+0900) Subject: tests: cleanup clonetest.c X-Git-Tag: lxc-3.1.0~221^2~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c95b732d896a40cd8c7af971085637b73bd943a;p=thirdparty%2Flxc.git tests: cleanup clonetest.c Signed-off-by: 2xsec --- diff --git a/src/tests/clonetest.c b/src/tests/clonetest.c index 814706d27..f3a8e5b0b 100644 --- a/src/tests/clonetest.c +++ b/src/tests/clonetest.c @@ -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); @@ -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)) { @@ -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)) @@ -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; @@ -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; @@ -166,13 +174,16 @@ out: 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); }