]>
git.proxmox.com Git - mirror_lxc.git/blob - src/tests/destroytest.c
3 * Copyright © 2012 Serge Hallyn <serge.hallyn@ubuntu.com>.
4 * Copyright © 2012 Canonical Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2, as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include <lxc/lxccontainer.h>
24 #include <sys/types.h>
29 #define MYNAME "lxctest1"
31 static int create_container(void)
41 execlp("lxc-create", "lxc-create", "-t", "busybox", "-n", MYNAME
, NULL
);
45 ret
= waitpid(pid
, &status
, 0);
54 if (!WIFEXITED(status
)) { // did not exit normally
55 fprintf(stderr
, "%d: lxc-create exited abnormally\n", __LINE__
);
58 return WEXITSTATUS(status
);
61 int main(int argc
, char *argv
[])
63 struct lxc_container
*c
;
66 if ((c
= lxc_container_new(MYNAME
, NULL
)) == NULL
) {
67 fprintf(stderr
, "%d: error opening lxc_container %s\n", __LINE__
, MYNAME
);
72 if (c
->is_defined(c
)) {
73 fprintf(stderr
, "%d: %s thought it was defined\n", __LINE__
, MYNAME
);
77 if (create_container()) {
78 fprintf(stderr
, "%d: failed to create a container\n", __LINE__
);
82 if (!c
->is_defined(c
)) {
83 fprintf(stderr
, "%d: %s thought it was not defined\n", __LINE__
, MYNAME
);
88 fprintf(stderr
, "%d: error deleting %s\n", __LINE__
, MYNAME
);
92 if (c
->is_defined(c
)) {
93 fprintf(stderr
, "%d: %s thought it was defined\n", __LINE__
, MYNAME
);
97 fprintf(stderr
, "all lxc_container tests passed for %s\n", c
->name
);
100 lxc_container_put(c
);