shutdowntest.c revision afeecbba0359d2b4404cdf896e6b6d0b5a8443b0
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes * Copyright © 2012 Serge Hallyn <serge.hallyn@ubuntu.com>.
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes * Copyright © 2012 Canonical Ltd.
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes * This program is free software; you can redistribute it and/or modify
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes * it under the terms of the GNU General Public License version 2, as
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes * published by the Free Software Foundation.
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes * This program is distributed in the hope that it will be useful,
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes * but WITHOUT ANY WARRANTY; without even the implied warranty of
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes * GNU General Public License for more details.
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes * You should have received a copy of the GNU General Public License along
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes * with this program; if not, write to the Free Software Foundation, Inc.,
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes if ((c = lxc_container_new(MYNAME, NULL)) == NULL) {
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes fprintf(stderr, "%d: error opening lxc_container %s\n", __LINE__, MYNAME);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes fprintf(stderr, "%d: %s thought it was defined\n", __LINE__, MYNAME);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes if (!c->set_config_item(c, "lxc.network.type", "veth")) {
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes fprintf(stderr, "%d: failed to set network type\n", __LINE__);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes c->set_config_item(c, "lxc.network.link", "lxcbr0");
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes if (!c->createl(c, "ubuntu", "-r", "lucid", NULL)) {
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes fprintf(stderr, "%d: failed to create a lucid container\n", __LINE__);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes if (!c->is_defined(c)) {
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg fprintf(stderr, "%d: %s thought it was not defined\n", __LINE__, MYNAME);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes fprintf(stderr, "%d: failed to start %s\n", __LINE__, MYNAME);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes fprintf(stderr, "%d: %s started, you have 60 seconds to test a console\n", __LINE__, MYNAME);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes sleep(60); // wait a minute to let user connect to console
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg fprintf(stderr, "%d: failed to shut down %s\n", __LINE__, MYNAME);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes if (!c->destroy(c)) {
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes fprintf(stderr, "%d: error deleting %s\n", __LINE__, MYNAME);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes fprintf(stderr, "%d: %s thought it was defined\n", __LINE__, MYNAME);
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes fprintf(stderr, "all lxc_container tests passed for %s\n", c->name);