]> git.proxmox.com Git - mirror_lxc.git/commitdiff
tests: create temp file before lxc_container_new
authorLong Wang <w@laoqinren.net>
Wed, 5 Jul 2017 06:51:03 +0000 (14:51 +0800)
committerLong Wang <w@laoqinren.net>
Wed, 5 Jul 2017 06:51:03 +0000 (14:51 +0800)
Signed-off-by: Long Wang <w@laoqinren.net>
src/tests/parse_config_file.c

index e20272fe7ac6efd8bad7b958e62fd9803f333d86..0c9d717ec3145ee0c0b43cf4327fa79b175bbaf0 100644 (file)
@@ -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,