destroytest.c revision afeecbba0359d2b4404cdf896e6b6d0b5a8443b0
6bdda696b3ea703c47e87fea61017ec655f91d92nd/* liblxcapi
6bdda696b3ea703c47e87fea61017ec655f91d92nd * Copyright © 2012 Serge Hallyn <serge.hallyn@ubuntu.com>.
6bdda696b3ea703c47e87fea61017ec655f91d92nd * Copyright © 2012 Canonical Ltd.
6bdda696b3ea703c47e87fea61017ec655f91d92nd * This program is free software; you can redistribute it and/or modify
6bdda696b3ea703c47e87fea61017ec655f91d92nd * it under the terms of the GNU General Public License version 2, as
6bdda696b3ea703c47e87fea61017ec655f91d92nd * published by the Free Software Foundation.
6bdda696b3ea703c47e87fea61017ec655f91d92nd * This program is distributed in the hope that it will be useful,
0662ed52e814f8f08ef0e09956413a792584eddffuankg * but WITHOUT ANY WARRANTY; without even the implied warranty of
6bdda696b3ea703c47e87fea61017ec655f91d92nd * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6bdda696b3ea703c47e87fea61017ec655f91d92nd * GNU General Public License for more details.
6bdda696b3ea703c47e87fea61017ec655f91d92nd * You should have received a copy of the GNU General Public License along
6bdda696b3ea703c47e87fea61017ec655f91d92nd * with this program; if not, write to the Free Software Foundation, Inc.,
6bdda696b3ea703c47e87fea61017ec655f91d92nd * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
6bdda696b3ea703c47e87fea61017ec655f91d92nd#include "../lxc/lxccontainer.h"
6bdda696b3ea703c47e87fea61017ec655f91d92ndstatic int create_ubuntu(void)
6bdda696b3ea703c47e87fea61017ec655f91d92nd if (pid < 0) {
6bdda696b3ea703c47e87fea61017ec655f91d92nd return -1;
6bdda696b3ea703c47e87fea61017ec655f91d92nd if (pid == 0) {
6bdda696b3ea703c47e87fea61017ec655f91d92nd ret = execlp("lxc-create", "lxc-create", "-t", "ubuntu", "-f", "/etc/lxc/default.conf", "-n", MYNAME, NULL);
6bdda696b3ea703c47e87fea61017ec655f91d92nd // Should not return
6bdda696b3ea703c47e87fea61017ec655f91d92nd return -1;
6bdda696b3ea703c47e87fea61017ec655f91d92nd fprintf(stderr, "%d: lxc-create exited abnormally\n", __LINE__);
6bdda696b3ea703c47e87fea61017ec655f91d92nd return -1;
6bdda696b3ea703c47e87fea61017ec655f91d92nd fprintf(stderr, "%d: error opening lxc_container %s\n", __LINE__, MYNAME);
6bdda696b3ea703c47e87fea61017ec655f91d92nd if (c->is_defined(c)) {
6bdda696b3ea703c47e87fea61017ec655f91d92nd fprintf(stderr, "%d: %s thought it was defined\n", __LINE__, MYNAME);
6bdda696b3ea703c47e87fea61017ec655f91d92nd fprintf(stderr, "%d: failed to create a ubuntu container\n", __LINE__);
6bdda696b3ea703c47e87fea61017ec655f91d92nd if (!c->is_defined(c)) {
6bdda696b3ea703c47e87fea61017ec655f91d92nd fprintf(stderr, "%d: %s thought it was not defined\n", __LINE__, MYNAME);
6bdda696b3ea703c47e87fea61017ec655f91d92nd if (!c->destroy(c)) {
6bdda696b3ea703c47e87fea61017ec655f91d92nd fprintf(stderr, "%d: error deleting %s\n", __LINE__, MYNAME);
6bdda696b3ea703c47e87fea61017ec655f91d92nd if (c->is_defined(c)) {
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg fprintf(stderr, "%d: %s thought it was defined\n", __LINE__, MYNAME);
6bdda696b3ea703c47e87fea61017ec655f91d92nd fprintf(stderr, "all lxc_container tests passed for %s\n", c->name);