]>
git.proxmox.com Git - mirror_lxc.git/blob - src/tests/getkeys.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.
26 #include <sys/types.h>
28 #include <lxc/lxccontainer.h>
30 #include "lxc/state.h"
32 #define MYNAME "lxctest1"
34 int main(int argc
, char *argv
[])
36 struct lxc_container
*c
;
40 if ((c
= lxc_container_new(MYNAME
, NULL
)) == NULL
) {
41 fprintf(stderr
, "%d: error opening lxc_container %s\n", __LINE__
, MYNAME
);
46 c
->set_config_item(c
, "lxc.net.0.type", "veth");
48 len
= c
->get_keys(c
, NULL
, NULL
, 0);
50 fprintf(stderr
, "%d: failed to get length of all keys (%d)\n", __LINE__
, len
);
54 ret
= c
->get_keys(c
, NULL
, v3
, len
+1);
56 fprintf(stderr
, "%d: failed to get keys (%d)\n", __LINE__
, ret
);
60 printf("get_keys returned %d\n%s", ret
, v3
);
62 ret
= c
->get_keys(c
, "lxc.net.0", v3
, 2000);
64 fprintf(stderr
, "%d: failed to get nic 0 keys(%d)\n", __LINE__
, ret
);
68 printf("get_keys for nic 1 returned %d\n%s", ret
, v3
);
70 ret
= c
->get_keys(c
, "lxc.apparmor", v3
, 2000);
72 fprintf(stderr
, "%d: failed to get keys(%d)\n", __LINE__
, ret
);
76 printf("get_keys returned %d\n%s", ret
, v3
);
78 ret
= c
->get_keys(c
, "lxc.selinux", v3
, 2000);
80 fprintf(stderr
, "%d: failed to get keys(%d)\n", __LINE__
, ret
);
84 printf("get_keys returned %d\n%s", ret
, v3
);
86 ret
= c
->get_keys(c
, "lxc.mount", v3
, 2000);
88 fprintf(stderr
, "%d: failed to get keys(%d)\n", __LINE__
, ret
);
92 printf("get_keys returned %d\n%s", ret
, v3
);
94 ret
= c
->get_keys(c
, "lxc.rootfs", v3
, 2000);
96 fprintf(stderr
, "%d: failed to get keys(%d)\n", __LINE__
, ret
);
100 printf("get_keys returned %d\n%s", ret
, v3
);
102 ret
= c
->get_keys(c
, "lxc.uts", v3
, 2000);
104 fprintf(stderr
, "%d: failed to get keys(%d)\n", __LINE__
, ret
);
108 printf("get_keys returned %d\n%s", ret
, v3
);
110 ret
= c
->get_keys(c
, "lxc.hook", v3
, 2000);
112 fprintf(stderr
, "%d: failed to get keys(%d)\n", __LINE__
, ret
);
116 printf("get_keys returned %d\n%s", ret
, v3
);
118 ret
= c
->get_keys(c
, "lxc.cap", v3
, 2000);
120 fprintf(stderr
, "%d: failed to get keys(%d)\n", __LINE__
, ret
);
124 printf("get_keys returned %d\n%s", ret
, v3
);
126 ret
= c
->get_keys(c
, "lxc.console", v3
, 2000);
128 fprintf(stderr
, "%d: failed to get keys(%d)\n", __LINE__
, ret
);
132 printf("get_keys returned %d\n%s", ret
, v3
);
134 ret
= c
->get_keys(c
, "lxc.seccomp", v3
, 2000);
136 fprintf(stderr
, "%d: failed to get keys(%d)\n", __LINE__
, ret
);
140 printf("get_keys returned %d\n%s", ret
, v3
);
142 ret
= c
->get_keys(c
, "lxc.signal", v3
, 2000);
144 fprintf(stderr
, "%d: failed to get keys(%d)\n", __LINE__
, ret
);
148 printf("get_keys returned %d\n%s", ret
, v3
);
150 ret
= c
->get_keys(c
, "lxc.start", v3
, 2000);
152 fprintf(stderr
, "%d: failed to get keys(%d)\n", __LINE__
, ret
);
156 printf("get_keys returned %d\n%s", ret
, v3
);
158 ret
= c
->get_keys(c
, "lxc.monitor", v3
, 2000);
160 fprintf(stderr
, "%d: failed to get keys(%d)\n", __LINE__
, ret
);
164 printf("get_keys returned %d\n%s", ret
, v3
);
166 ret
= c
->get_keys(c
, "lxc.cgroup", v3
, 2000);
168 fprintf(stderr
, "%d: failed to get keys(%d)\n", __LINE__
, ret
);
172 printf("get_keys returned %d\n%s", ret
, v3
);
177 lxc_container_put(c
);