]> git.proxmox.com Git - mirror_lxc.git/blame - src/tests/device_add_remove.c
spelling: timeout
[mirror_lxc.git] / src / tests / device_add_remove.c
CommitLineData
710bde5e
ÇO
1/* DEVICE_add_remove.c
2 *
3 * Copyright © 2014 S.Çağlar Onur <caglar@10ur.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2, as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19#include <stdio.h>
20#include <stdlib.h>
21#include <lxc/lxccontainer.h>
22
23#define NAME "device_add_remove_test"
24#define DEVICE "/dev/network_latency"
25
26int main(int argc, char *argv[])
27{
28 int ret = 1;
29 struct lxc_container *c;
30
31 c = lxc_container_new(NAME, NULL);
32 if (!c) {
33 fprintf(stderr, "Unable to instantiate container (%s)...\n", NAME);
34 goto out;
35 }
36
37 if (!c->create(c, "busybox", NULL, NULL, 1, NULL)) {
38 fprintf(stderr, "Creating the container (%s) failed...\n", NAME);
39 goto out;
40 }
41
42 c->want_daemonize(c, true);
43
44 if (!c->start(c, false, NULL)) {
45 fprintf(stderr, "Starting the container (%s) failed...\n", NAME);
46 goto out;
47 }
48
49 if (!c->add_device_node(c, DEVICE, DEVICE)) {
50 fprintf(stderr, "Adding %s to the container (%s) failed...\n", DEVICE, NAME);
51 goto out;
52 }
e9432dfc 53
710bde5e
ÇO
54 if (!c->remove_device_node(c, DEVICE, DEVICE)) {
55 fprintf(stderr, "Removing %s from the container (%s) failed...\n", DEVICE, NAME);
56 goto out;
57 }
58
59 if (!c->stop(c)) {
60 fprintf(stderr, "Stopping the container (%s) failed...\n", NAME);
61 goto out;
62 }
63
64 if (!c->destroy(c)) {
65 fprintf(stderr, "Destroying the container (%s) failed...\n", NAME);
66 goto out;
67 }
e9432dfc 68
710bde5e
ÇO
69 ret = 0;
70
71out:
72 lxc_container_put(c);
73 return ret;
74}