containertests.c revision f2363e38d07db2ad4796b5580b95e3665ed34a88
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen * Copyright © 2012 Serge Hallyn <serge.hallyn@ubuntu.com>.
bdd36cfdba3ff66d25570a9ff568d69e1eb543cfTimo Sirainen * Copyright © 2012 Canonical Ltd.
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen * This program is free software; you can redistribute it and/or modify
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen * it under the terms of the GNU General Public License version 2, as
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen * published by the Free Software Foundation.
73bfdbe28c2ce6d143eadf0bab8ccfbe4cab0faeTimo Sirainen * This program is distributed in the hope that it will be useful,
73bfdbe28c2ce6d143eadf0bab8ccfbe4cab0faeTimo Sirainen * but WITHOUT ANY WARRANTY; without even the implied warranty of
d8702d15ee7721ed1fcfc8f00a589970bd6b3598Timo Sirainen * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d8702d15ee7721ed1fcfc8f00a589970bd6b3598Timo Sirainen * GNU General Public License for more details.
38505846b6d083e19f0a7d1373761bdda5d9a5a9Timo Sirainen * You should have received a copy of the GNU General Public License along
2087543679f0b35a8f70e1277b234e66ffdf96edTimo Sirainen * with this program; if not, write to the Free Software Foundation, Inc.,
2087543679f0b35a8f70e1277b234e66ffdf96edTimo Sirainen * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainenstatic int destroy_busybox(void)
939451389b8e0ad529277b84fe51dab38a8cf77cTimo Sirainen ret = execlp("lxc-destroy", "lxc-destroy", "-f", "-n", MYNAME, NULL);
73bfdbe28c2ce6d143eadf0bab8ccfbe4cab0faeTimo Sirainen // Should not return
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen if (!WIFEXITED(status)) { // did not exit normally
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen fprintf(stderr, "%d: lxc-create exited abnormally\n", __LINE__);
18ddd4fba186b1b407cae98bb388fa8add7db48dTimo Sirainenstatic int create_busybox(void)
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen ret = execlp("lxc-create", "lxc-create", "-t", "busybox", "-f", LXC_DEFAULT_CONFIG, "-n", MYNAME, NULL);
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen // Should not return
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen if (!WIFEXITED(status)) { // did not exit normally
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen fprintf(stderr, "%d: lxc-create exited abnormally\n", __LINE__);
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen const char *s;
3b8d05391336c0e4d24c8ddcc962f350409ffbd3Timo Sirainen /* test refcounting */
goto out;
if (!lxc_container_get(c)) {
goto out;
goto out;
goto out;
goto out;
if (str) {
goto out;
if (lxc_container_put(c) != 0) {
goto out;
goto out;
goto out;
goto out;
goto out;
b = c->is_defined(c);
goto out;
s = c->state(c);
goto out;
if (ret) {
goto out;
b = c->is_defined(c);
goto out;
s = c->state(c);
fprintf(stderr, "%d: %s is in state %s, not in STOPPED.\n", __LINE__, c->name, s ? s : "undefined");
goto out;
goto out;
goto out;
for (i=0; i<numstates; i++) {
char mychar;
if (ret < 0)
goto out;
c->want_daemonize(c, true);
goto out;
goto out;
s = c->state(c);
fprintf(stderr, "%d: %s is in state %s, not in RUNNING.\n", __LINE__, c->name, s ? s : "undefined");
goto out;
if (ret < 0)
goto out;
ret = 0;
out:
c->stop(c);