[lxc-devel] [lxc/master] tests: delete the intermediate file and directory.
0x0916 on Github
lxc-bot at linuxcontainers.org
Wed Jul 5 07:23:40 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170705/bc3e3774/attachment.bin>
-------------- next part --------------
From 6cd5db20bce261d493cdb9cdb3556fdff66ec777 Mon Sep 17 00:00:00 2001
From: Long Wang <w at laoqinren.net>
Date: Wed, 5 Jul 2017 14:51:03 +0800
Subject: [PATCH 1/2] tests: create temp file before lxc_container_new
Signed-off-by: Long Wang <w at laoqinren.net>
---
src/tests/parse_config_file.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/tests/parse_config_file.c b/src/tests/parse_config_file.c
index e20272fe7..0c9d717ec 100644
--- a/src/tests/parse_config_file.c
+++ b/src/tests/parse_config_file.c
@@ -279,12 +279,6 @@ int main(int argc, char *argv[])
char tmpf[] = "lxc-parse-config-file-XXXXXX";
char retval[4096] = {0};
- c = lxc_container_new(tmpf, NULL);
- if (!c) {
- lxc_error("%s\n", "failed to create new container");
- exit(EXIT_FAILURE);
- }
-
fd = mkstemp(tmpf);
if (fd < 0) {
lxc_error("%s\n", "Could not create temporary file");
@@ -292,6 +286,11 @@ int main(int argc, char *argv[])
}
close(fd);
+ c = lxc_container_new(tmpf, NULL);
+ if (!c) {
+ lxc_error("%s\n", "Failed to create new container");
+ exit(EXIT_FAILURE);
+ }
/* lxc.arch */
if (set_get_compare_clear_save_load(c, "lxc.arch", "x86_64", tmpf,
From df24d43699dbf1b48ed78e446be3b4c62842ac58 Mon Sep 17 00:00:00 2001
From: Long Wang <w at laoqinren.net>
Date: Wed, 5 Jul 2017 15:17:58 +0800
Subject: [PATCH 2/2] tests: remove the temp container directory
c->destory() will not remove the temp container directory.
This patch fix that.
Signed-off-by: Long Wang <w at laoqinren.net>
---
src/tests/parse_config_file.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/tests/parse_config_file.c b/src/tests/parse_config_file.c
index 0c9d717ec..dc4b586a6 100644
--- a/src/tests/parse_config_file.c
+++ b/src/tests/parse_config_file.c
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
+#include <libgen.h>
#include "confile_utils.h"
#include "lxc/state.h"
@@ -985,7 +986,7 @@ int main(int argc, char *argv[])
ret = EXIT_SUCCESS;
non_test_error:
(void)unlink(tmpf);
- c->destroy(c);
+ (void)rmdir(dirname(c->configfile));
lxc_container_put(c);
exit(ret);
}
More information about the lxc-devel
mailing list