network: add test-suite for configuration items

parent 0070b1c4
...@@ -18,15 +18,14 @@ ...@@ -18,15 +18,14 @@
*/ */
#include <lxc/lxccontainer.h> #include <lxc/lxccontainer.h>
#include <unistd.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <stdlib.h> #include <unistd.h>
#include <errno.h>
#include <string.h>
#include "confile_utils.h" #include "confile_utils.h"
#include "lxc/state.h" #include "lxc/state.h"
...@@ -83,19 +82,70 @@ static int set_get_compare_clear_save_load(struct lxc_container *c, ...@@ -83,19 +82,70 @@ static int set_get_compare_clear_save_load(struct lxc_container *c,
return -1; return -1;
} }
if (config_file) { c->clear_config(c);
if (!c->save_config(c, config_file)) { c->lxc_conf = NULL;
lxc_error("%s\n", "failed to save config file");
return -1;
}
c->clear_config(c); return 0;
c->lxc_conf = NULL; }
if (!c->load_config(c, config_file)) { static int set_and_clear_complete_netdev(struct lxc_container *c)
lxc_error("%s\n", "failed to load config file"); {
return -1; if (!c->set_config_item(c, "lxc.network.1.type", "veth")) {
} lxc_error("%s\n", "lxc.network.1.type");
return -1;
}
if (!c->set_config_item(c, "lxc.network.1.ipv4", "10.0.2.3/24")) {
lxc_error("%s\n", "lxc.network.1.ipv4");
return -1;
}
if (!c->set_config_item(c, "lxc.network.1.ipv4_gateway", "10.0.2.2")) {
lxc_error("%s\n", "lxc.network.1.ipv4");
return -1;
}
if (!c->set_config_item(c, "lxc.network.1.ipv6",
"2003:db8:1:0:214:1234:fe0b:3596/64")) {
lxc_error("%s\n", "lxc.network.1.ipv6");
return -1;
}
if (!c->set_config_item(c, "lxc.network.1.ipv6_gateway",
"2003:db8:1:0::1")) {
lxc_error("%s\n", "lxc.network.1.ipv6");
return -1;
}
if (!c->set_config_item(c, "lxc.network.1.flags", "up")) {
lxc_error("%s\n", "lxc.network.1.flags");
return -1;
}
if (!c->set_config_item(c, "lxc.network.1.link", "br0")) {
lxc_error("%s\n", "lxc.network.1.link");
return -1;
}
if (!c->set_config_item(c, "lxc.network.1.veth.pair", "bla")) {
lxc_error("%s\n", "lxc.network.1.veth.pair");
return -1;
}
if (!c->set_config_item(c, "lxc.network.1.hwaddr",
"52:54:00:80:7a:5d")) {
lxc_error("%s\n", "lxc.network.1.hwaddr");
return -1;
}
if (!c->set_config_item(c, "lxc.network.1.mtu", "2000")) {
lxc_error("%s\n", "lxc.network.1.mtu");
return -1;
}
if (!c->clear_config_item(c, "lxc.network.1")) {
lxc_error("%s", "failed to clear \"lxc.network.1\"\n");
return -1;
} }
c->clear_config(c); c->clear_config(c);
...@@ -112,30 +162,30 @@ int test_idmap_parser(void) ...@@ -112,30 +162,30 @@ int test_idmap_parser(void)
const char *idmap; const char *idmap;
}; };
static struct idmap_check idmaps[] = { static struct idmap_check idmaps[] = {
/* valid idmaps */ /* valid idmaps */
{ true, "u 0 0 1" }, { true, "u 0 0 1" },
{ true, "g 0 0 1" }, { true, "g 0 0 1" },
{ true, "u 1 100001 999999999" }, { true, "u 1 100001 999999999" },
{ true, "g 1 100001 999999999" }, { true, "g 1 100001 999999999" },
{ true, "u 0 0 0" }, { true, "u 0 0 0" },
{ true, "g 0 0 0" }, { true, "g 0 0 0" },
{ true, "u 1000 165536 65536" }, { true, "u 1000 165536 65536" },
{ true, "g 999 999 1" }, { true, "g 999 999 1" },
{ true, "u 0 5000 100000" }, { true, "u 0 5000 100000" },
{ true, "g 577 789 5" }, { true, "g 577 789 5" },
{ true, "u 65536 65536 1 " }, { true, "u 65536 65536 1 " },
/* invalid idmaps */ /* invalid idmaps */
{ false, "1u 0 0 0" }, { false, "1u 0 0 0" },
{ false, "1g 0 0 0a" }, { false, "1g 0 0 0a" },
{ false, "1 u 0 0 0" }, { false, "1 u 0 0 0" },
{ false, "1g 0 0 0 1" }, { false, "1g 0 0 0 1" },
{ false, "1u a0 b0 c0 d1" }, { false, "1u a0 b0 c0 d1" },
{ false, "1g 0 b0 0 d1" }, { false, "1g 0 b0 0 d1" },
{ false, "1u a0 0 c0 1" }, { false, "1u a0 0 c0 1" },
{ false, "g -1 0 -10" }, { false, "g -1 0 -10" },
{ false, "a 1 0 10" }, { false, "a 1 0 10" },
{ false, "u 1 1 0 10" }, { false, "u 1 1 0 10" },
{ false, "g 1 0 10 z " }, { false, "g 1 0 10 z " },
}; };
for (i = 0; i < sizeof(idmaps) / sizeof(struct idmap_check); i++) { for (i = 0; i < sizeof(idmaps) / sizeof(struct idmap_check); i++) {
...@@ -155,6 +205,72 @@ int test_idmap_parser(void) ...@@ -155,6 +205,72 @@ int test_idmap_parser(void)
return 0; return 0;
} }
static int set_get_compare_clear_save_load_network(
struct lxc_container *c, const char *key, const char *value,
const char *config_file, bool compare, const char *network_type)
{
char retval[4096] = {0};
int ret;
if (!c->set_config_item(c, "lxc.network.0.type", network_type)) {
lxc_error("%s\n", "lxc.network.0.type");
return -1;
}
if (!c->set_config_item(c, key, value)) {
lxc_error("failed to set config item \"%s\" to \"%s\"\n", key,
value);
return -1;
}
ret = c->get_config_item(c, key, retval, sizeof(retval));
if (ret < 0) {
lxc_error("failed to get config item \"%s\"\n", key);
return -1;
}
if (compare) {
ret = strcmp(retval, value);
if (ret != 0) {
lxc_error(
"expected value \"%s\" and retrieved value \"%s\" "
"for config key \"%s\" do not match\n",
value, retval, key);
return -1;
}
}
if (config_file) {
if (!c->save_config(c, config_file)) {
lxc_error("%s\n", "failed to save config file");
return -1;
}
c->clear_config(c);
c->lxc_conf = NULL;
if (!c->load_config(c, config_file)) {
lxc_error("%s\n", "failed to load config file");
return -1;
}
}
if (!c->clear_config_item(c, key)) {
lxc_error("failed to clear config item \"%s\"\n", key);
return -1;
}
if (!c->clear_config_item(c, "lxc.network.0.type")) {
lxc_error("%s\n", "lxc.network.0.type");
return -1;
}
c->clear_config(c);
c->lxc_conf = NULL;
return 0;
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
struct lxc_container *c; struct lxc_container *c;
...@@ -163,7 +279,7 @@ int main(int argc, char *argv[]) ...@@ -163,7 +279,7 @@ int main(int argc, char *argv[])
char tmpf[] = "lxc-parse-config-file-XXXXXX"; char tmpf[] = "lxc-parse-config-file-XXXXXX";
char retval[4096] = {0}; char retval[4096] = {0};
c = lxc_container_new("lxc-parse-config-file-testxyz", NULL); c = lxc_container_new(tmpf, NULL);
if (!c) { if (!c) {
lxc_error("%s\n", "failed to create new container"); lxc_error("%s\n", "failed to create new container");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
...@@ -172,55 +288,63 @@ int main(int argc, char *argv[]) ...@@ -172,55 +288,63 @@ int main(int argc, char *argv[])
fd = mkstemp(tmpf); fd = mkstemp(tmpf);
if (fd < 0) { if (fd < 0) {
lxc_error("%s\n", "Could not create temporary file"); lxc_error("%s\n", "Could not create temporary file");
goto non_test_error; exit(ret);
} }
close(fd); close(fd);
/* lxc.arch */ /* lxc.arch */
if (set_get_compare_clear_save_load(c, "lxc.arch", "x86_64", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.arch", "x86_64", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.arch"); lxc_error("%s\n", "lxc.arch");
goto non_test_error; goto non_test_error;
} }
/* lxc.pts */ /* lxc.pts */
if (set_get_compare_clear_save_load(c, "lxc.pts", "1000", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.pts", "1000", tmpf, true) <
0) {
lxc_error("%s\n", "lxc.pts"); lxc_error("%s\n", "lxc.pts");
goto non_test_error; goto non_test_error;
} }
/* lxc.tty */ /* lxc.tty */
if (set_get_compare_clear_save_load(c, "lxc.tty", "4", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.tty", "4", tmpf, true) <
0) {
lxc_error("%s\n", "lxc.tty"); lxc_error("%s\n", "lxc.tty");
goto non_test_error; goto non_test_error;
} }
/* lxc.devttydir */ /* lxc.devttydir */
if (set_get_compare_clear_save_load(c, "lxc.devttydir", "not-dev", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.devttydir", "not-dev", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.devttydir"); lxc_error("%s\n", "lxc.devttydir");
goto non_test_error; goto non_test_error;
} }
/* lxc.kmsg */ /* lxc.kmsg */
if (set_get_compare_clear_save_load(c, "lxc.kmsg", "1", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.kmsg", "1", tmpf, true) <
0) {
lxc_error("%s\n", "lxc.kmsg"); lxc_error("%s\n", "lxc.kmsg");
goto non_test_error; goto non_test_error;
} }
/* lxc.aa_profile */ /* lxc.aa_profile */
if (set_get_compare_clear_save_load(c, "lxc.aa_profile", "unconfined", tmpf, true) < if (set_get_compare_clear_save_load(c, "lxc.aa_profile", "unconfined",
0) { tmpf, true) < 0) {
lxc_error("%s\n", "lxc.aa_profile"); lxc_error("%s\n", "lxc.aa_profile");
goto non_test_error; goto non_test_error;
} }
/* lxc.aa_allow_incomplete */ /* lxc.aa_allow_incomplete */
if (set_get_compare_clear_save_load(c, "lxc.aa_allow_incomplete", "1", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.aa_allow_incomplete", "1",
tmpf, true) < 0) {
lxc_error("%s\n", "lxc.aa_allow_incomplete"); lxc_error("%s\n", "lxc.aa_allow_incomplete");
goto non_test_error; goto non_test_error;
} }
/* lxc.cgroup.cpuset.cpus */ /* lxc.cgroup.cpuset.cpus */
if (set_get_compare_clear_save_load(c, "lxc.cgroup.cpuset.cpus", "1-100", tmpf, false) < 0) { if (set_get_compare_clear_save_load(c, "lxc.cgroup.cpuset.cpus",
"1-100", tmpf, false) < 0) {
lxc_error("%s\n", "lxc.cgroup.cpuset.cpus"); lxc_error("%s\n", "lxc.cgroup.cpuset.cpus");
goto non_test_error; goto non_test_error;
} }
...@@ -254,8 +378,8 @@ int main(int argc, char *argv[]) ...@@ -254,8 +378,8 @@ int main(int argc, char *argv[])
* chown the container's directory but we haven't created an on-disk * chown the container's directory but we haven't created an on-disk
* container. So let's test set-get-clear. * container. So let's test set-get-clear.
*/ */
if (set_get_compare_clear_save_load(c, "lxc.id_map", "u 0 100000 1000000000", if (set_get_compare_clear_save_load(
NULL, false) < 0) { c, "lxc.id_map", "u 0 100000 1000000000", NULL, false) < 0) {
lxc_error("%s\n", "lxc.id_map"); lxc_error("%s\n", "lxc.id_map");
goto non_test_error; goto non_test_error;
} }
...@@ -281,19 +405,22 @@ int main(int argc, char *argv[]) ...@@ -281,19 +405,22 @@ int main(int argc, char *argv[])
c->lxc_conf = NULL; c->lxc_conf = NULL;
/* lxc.loglevel */ /* lxc.loglevel */
if (set_get_compare_clear_save_load(c, "lxc.loglevel", "DEBUG", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.loglevel", "DEBUG", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.loglevel"); lxc_error("%s\n", "lxc.loglevel");
goto non_test_error; goto non_test_error;
} }
/* lxc.logfile */ /* lxc.logfile */
if (set_get_compare_clear_save_load(c, "lxc.logfile", "/some/path", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.logfile", "/some/path",
tmpf, true) < 0) {
lxc_error("%s\n", "lxc.logfile"); lxc_error("%s\n", "lxc.logfile");
goto non_test_error; goto non_test_error;
} }
/* lxc.mount */ /* lxc.mount */
if (set_get_compare_clear_save_load(c, "lxc.mount", "/some/path", NULL, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.mount", "/some/path", NULL,
true) < 0) {
lxc_error("%s\n", "lxc.mount"); lxc_error("%s\n", "lxc.mount");
goto non_test_error; goto non_test_error;
} }
...@@ -302,7 +429,9 @@ int main(int argc, char *argv[]) ...@@ -302,7 +429,9 @@ int main(int argc, char *argv[])
* Note that we cannot compare the values since the getter for * Note that we cannot compare the values since the getter for
* lxc.mount.auto does not preserve ordering. * lxc.mount.auto does not preserve ordering.
*/ */
if (set_get_compare_clear_save_load(c, "lxc.mount.auto", "proc:rw sys:rw cgroup-full:rw", tmpf, false) < 0) { if (set_get_compare_clear_save_load(c, "lxc.mount.auto",
"proc:rw sys:rw cgroup-full:rw",
tmpf, false) < 0) {
lxc_error("%s\n", "lxc.mount.auto"); lxc_error("%s\n", "lxc.mount.auto");
goto non_test_error; goto non_test_error;
} }
...@@ -313,230 +442,269 @@ int main(int argc, char *argv[]) ...@@ -313,230 +442,269 @@ int main(int argc, char *argv[])
*/ */
if (set_get_compare_clear_save_load( if (set_get_compare_clear_save_load(
c, "lxc.mount.entry", c, "lxc.mount.entry",
"/dev/dri dev/dri none bind,optional,create=dir", tmpf, false) < 0) { "/dev/dri dev/dri none bind,optional,create=dir", tmpf,
false) < 0) {
lxc_error("%s\n", "lxc.mount.entry"); lxc_error("%s\n", "lxc.mount.entry");
goto non_test_error; goto non_test_error;
} }
/* lxc.rootfs */ /* lxc.rootfs */
if (set_get_compare_clear_save_load(c, "lxc.rootfs", "/some/path", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.rootfs", "/some/path", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.rootfs"); lxc_error("%s\n", "lxc.rootfs");
goto non_test_error; goto non_test_error;
} }
/* lxc.rootfs.mount */ /* lxc.rootfs.mount */
if (set_get_compare_clear_save_load(c, "lxc.rootfs.mount", "/some/path", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.rootfs.mount", "/some/path",
tmpf, true) < 0) {
lxc_error("%s\n", "lxc.rootfs.mount"); lxc_error("%s\n", "lxc.rootfs.mount");
goto non_test_error; goto non_test_error;
} }
/* lxc.rootfs.options */ /* lxc.rootfs.options */
if (set_get_compare_clear_save_load(c, "lxc.rootfs.options", "ext4,discard", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.rootfs.options",
"ext4,discard", tmpf, true) < 0) {
lxc_error("%s\n", "lxc.rootfs.options"); lxc_error("%s\n", "lxc.rootfs.options");
goto non_test_error; goto non_test_error;
} }
/* lxc.rootfs.backend */ /* lxc.rootfs.backend */
if (set_get_compare_clear_save_load(c, "lxc.rootfs.backend", "btrfs", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.rootfs.backend", "btrfs",
tmpf, true) < 0) {
lxc_error("%s\n", "lxc.rootfs.backend"); lxc_error("%s\n", "lxc.rootfs.backend");
goto non_test_error; goto non_test_error;
} }
/* lxc.utsname */ /* lxc.utsname */
if (set_get_compare_clear_save_load(c, "lxc.utsname", "the-shire", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.utsname", "the-shire", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.utsname"); lxc_error("%s\n", "lxc.utsname");
goto non_test_error; goto non_test_error;
} }
/* lxc.hook.pre-start */ /* lxc.hook.pre-start */
if (set_get_compare_clear_save_load(c, "lxc.hook.pre-start", "/some/pre-start", tmpf, false) < 0) { if (set_get_compare_clear_save_load(
c, "lxc.hook.pre-start", "/some/pre-start", tmpf, false) < 0) {
lxc_error("%s\n", "lxc.hook.pre-start"); lxc_error("%s\n", "lxc.hook.pre-start");
goto non_test_error; goto non_test_error;
} }
/* lxc.hook.pre-mount */ /* lxc.hook.pre-mount */
if (set_get_compare_clear_save_load(c, "lxc.hook.pre-mount", "/some/pre-mount", tmpf, false) < 0) { if (set_get_compare_clear_save_load(
c, "lxc.hook.pre-mount", "/some/pre-mount", tmpf, false) < 0) {
lxc_error("%s\n", "lxc.hook.pre-mount"); lxc_error("%s\n", "lxc.hook.pre-mount");
goto non_test_error; goto non_test_error;
} }
/* lxc.hook.mount */ /* lxc.hook.mount */
if (set_get_compare_clear_save_load(c, "lxc.hook.mount", "/some/mount", tmpf, false) < 0) { if (set_get_compare_clear_save_load(c, "lxc.hook.mount", "/some/mount",
tmpf, false) < 0) {
lxc_error("%s\n", "lxc.hook.mount"); lxc_error("%s\n", "lxc.hook.mount");
goto non_test_error; goto non_test_error;
} }
/* lxc.hook.autodev */ /* lxc.hook.autodev */
if (set_get_compare_clear_save_load(c, "lxc.hook.autodev", "/some/autodev", tmpf, false) < 0) { if (set_get_compare_clear_save_load(c, "lxc.hook.autodev",
"/some/autodev", tmpf, false) < 0) {
lxc_error("%s\n", "lxc.hook.autodev"); lxc_error("%s\n", "lxc.hook.autodev");
goto non_test_error; goto non_test_error;
} }
/* lxc.hook.start */ /* lxc.hook.start */
if (set_get_compare_clear_save_load(c, "lxc.hook.start", "/some/start", tmpf, false) < 0) { if (set_get_compare_clear_save_load(c, "lxc.hook.start", "/some/start",
tmpf, false) < 0) {
lxc_error("%s\n", "lxc.hook.start"); lxc_error("%s\n", "lxc.hook.start");
goto non_test_error; goto non_test_error;
} }
/* lxc.hook.stop */ /* lxc.hook.stop */
if (set_get_compare_clear_save_load(c, "lxc.hook.stop", "/some/stop", tmpf, false) < 0) { if (set_get_compare_clear_save_load(c, "lxc.hook.stop", "/some/stop",
tmpf, false) < 0) {
lxc_error("%s\n", "lxc.hook.stop"); lxc_error("%s\n", "lxc.hook.stop");
goto non_test_error; goto non_test_error;
} }
/* lxc.hook.post-stop */ /* lxc.hook.post-stop */
if (set_get_compare_clear_save_load(c, "lxc.hook.post-stop", "/some/post-stop", tmpf, false) < 0) { if (set_get_compare_clear_save_load(
c, "lxc.hook.post-stop", "/some/post-stop", tmpf, false) < 0) {
lxc_error("%s\n", "lxc.hook.post-stop"); lxc_error("%s\n", "lxc.hook.post-stop");
goto non_test_error; goto non_test_error;
} }
/* lxc.hook.clone */ /* lxc.hook.clone */
if (set_get_compare_clear_save_load(c, "lxc.hook.clone", "/some/clone", tmpf, false) < 0) { if (set_get_compare_clear_save_load(c, "lxc.hook.clone", "/some/clone",
tmpf, false) < 0) {
lxc_error("%s\n", "lxc.hook.clone"); lxc_error("%s\n", "lxc.hook.clone");
goto non_test_error; goto non_test_error;
} }
/* lxc.hook.destroy */ /* lxc.hook.destroy */
if (set_get_compare_clear_save_load(c, "lxc.hook.destroy", "/some/destroy", tmpf, false) < 0) { if (set_get_compare_clear_save_load(c, "lxc.hook.destroy",
"/some/destroy", tmpf, false) < 0) {
lxc_error("%s\n", "lxc.hook.destroy"); lxc_error("%s\n", "lxc.hook.destroy");
goto non_test_error; goto non_test_error;
} }
/* lxc.cap.drop */ /* lxc.cap.drop */
if (set_get_compare_clear_save_load(c, "lxc.cap.drop", "sys_module mknod setuid net_raw", tmpf, false) < 0) { if (set_get_compare_clear_save_load(c, "lxc.cap.drop",
"sys_module mknod setuid net_raw",
tmpf, false) < 0) {
lxc_error("%s\n", "lxc.cap.drop"); lxc_error("%s\n", "lxc.cap.drop");
goto non_test_error; goto non_test_error;
} }
/* lxc.cap.keep */ /* lxc.cap.keep */
if (set_get_compare_clear_save_load(c, "lxc.cap.keep", "sys_module mknod setuid net_raw", tmpf, false) < 0) { if (set_get_compare_clear_save_load(c, "lxc.cap.keep",
"sys_module mknod setuid net_raw",
tmpf, false) < 0) {
lxc_error("%s\n", "lxc.cap.keep"); lxc_error("%s\n", "lxc.cap.keep");
goto non_test_error; goto non_test_error;
} }
/* lxc.console */ /* lxc.console */
if (set_get_compare_clear_save_load(c, "lxc.console", "none", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.console", "none", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.console"); lxc_error("%s\n", "lxc.console");
goto non_test_error; goto non_test_error;
} }
/* lxc.console.logfile */ /* lxc.console.logfile */
if (set_get_compare_clear_save_load(c, "lxc.console.logfile", "/some/logfile", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.console.logfile",
"/some/logfile", tmpf, true) < 0) {
lxc_error("%s\n", "lxc.console.logfile"); lxc_error("%s\n", "lxc.console.logfile");
goto non_test_error; goto non_test_error;
} }
/* lxc.seccomp */ /* lxc.seccomp */
if (set_get_compare_clear_save_load(c, "lxc.seccomp", "/some/seccomp/file", tmpf, true) < 0) { if (set_get_compare_clear_save_load(
c, "lxc.seccomp", "/some/seccomp/file", tmpf, true) < 0) {
lxc_error("%s\n", "lxc.seccomp"); lxc_error("%s\n", "lxc.seccomp");
goto non_test_error; goto non_test_error;
} }
/* lxc.autodev */ /* lxc.autodev */
if (set_get_compare_clear_save_load(c, "lxc.autodev", "1", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.autodev", "1", tmpf, true) <
0) {
lxc_error("%s\n", "lxc.autodev"); lxc_error("%s\n", "lxc.autodev");
goto non_test_error; goto non_test_error;
} }
/* lxc.haltsignal */ /* lxc.haltsignal */
if (set_get_compare_clear_save_load(c, "lxc.haltsignal", "1", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.haltsignal", "1", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.haltsignal"); lxc_error("%s\n", "lxc.haltsignal");
goto non_test_error; goto non_test_error;
} }
/* lxc.rebootsignal */ /* lxc.rebootsignal */
if (set_get_compare_clear_save_load(c, "lxc.rebootsignal", "1", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.rebootsignal", "1", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.rebootsignal"); lxc_error("%s\n", "lxc.rebootsignal");
goto non_test_error; goto non_test_error;
} }
/* lxc.stopsignal */ /* lxc.stopsignal */
if (set_get_compare_clear_save_load(c, "lxc.stopsignal", "1", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.stopsignal", "1", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.stopsignal"); lxc_error("%s\n", "lxc.stopsignal");
goto non_test_error; goto non_test_error;
} }
/* lxc.start.auto */ /* lxc.start.auto */
if (set_get_compare_clear_save_load(c, "lxc.start.auto", "1", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.start.auto", "1", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.start.auto"); lxc_error("%s\n", "lxc.start.auto");
goto non_test_error; goto non_test_error;
} }
/* lxc.start.delay */ /* lxc.start.delay */
if (set_get_compare_clear_save_load(c, "lxc.start.delay", "5", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.start.delay", "5", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.start.delay"); lxc_error("%s\n", "lxc.start.delay");
goto non_test_error; goto non_test_error;
} }
/* lxc.start.order */ /* lxc.start.order */
if (set_get_compare_clear_save_load(c, "lxc.start.order", "1", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.start.order", "1", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.start.order"); lxc_error("%s\n", "lxc.start.order");
goto non_test_error; goto non_test_error;
} }
/* lxc.syslog */ /* lxc.syslog */
if (set_get_compare_clear_save_load(c, "lxc.syslog", "local0", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.syslog", "local0", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.syslog"); lxc_error("%s\n", "lxc.syslog");
goto non_test_error; goto non_test_error;
} }
/* lxc.utsname */ /* lxc.utsname */
if (set_get_compare_clear_save_load(c, "lxc.utsname", "get-schwifty", tmpf, true) < if (set_get_compare_clear_save_load(c, "lxc.utsname", "get-schwifty",
0) { tmpf, true) < 0) {
lxc_error("%s\n", "lxc.utsname"); lxc_error("%s\n", "lxc.utsname");
goto non_test_error; goto non_test_error;
} }
/* lxc.monitor.unshare */ /* lxc.monitor.unshare */
if (set_get_compare_clear_save_load(c, "lxc.monitor.unshare", "1", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.monitor.unshare", "1", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.monitor.unshare"); lxc_error("%s\n", "lxc.monitor.unshare");
goto non_test_error; goto non_test_error;
} }
/* lxc.group */ /* lxc.group */
if (set_get_compare_clear_save_load(c, "lxc.group", "some,container,groups", tmpf, false) < 0) { if (set_get_compare_clear_save_load(
c, "lxc.group", "some,container,groups", tmpf, false) < 0) {
lxc_error("%s\n", "lxc.group"); lxc_error("%s\n", "lxc.group");
goto non_test_error; goto non_test_error;
} }
/* lxc.environment */ /* lxc.environment */
if (set_get_compare_clear_save_load(c, "lxc.environment", "FOO=BAR", tmpf, false) < 0) { if (set_get_compare_clear_save_load(c, "lxc.environment", "FOO=BAR",
tmpf, false) < 0) {
lxc_error("%s\n", "lxc.environment"); lxc_error("%s\n", "lxc.environment");
goto non_test_error; goto non_test_error;
} }
/* lxc.init_cmd */ /* lxc.init_cmd */
if (set_get_compare_clear_save_load(c, "lxc.init_cmd", "/bin/bash", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.init_cmd", "/bin/bash",
tmpf, true) < 0) {
lxc_error("%s\n", "lxc.init_cmd"); lxc_error("%s\n", "lxc.init_cmd");
goto non_test_error; goto non_test_error;
} }
/* lxc.init_uid */ /* lxc.init_uid */
if (set_get_compare_clear_save_load(c, "lxc.init_uid", "1000", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.init_uid", "1000", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.init_uid"); lxc_error("%s\n", "lxc.init_uid");
goto non_test_error; goto non_test_error;
} }
/* lxc.init_gid */ /* lxc.init_gid */
if (set_get_compare_clear_save_load(c, "lxc.init_gid", "1000", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.init_gid", "1000", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.init_gid"); lxc_error("%s\n", "lxc.init_gid");
goto non_test_error; goto non_test_error;
} }
/* lxc.ephemeral */ /* lxc.ephemeral */
if (set_get_compare_clear_save_load(c, "lxc.ephemeral", "1", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.ephemeral", "1", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.ephemeral"); lxc_error("%s\n", "lxc.ephemeral");
goto non_test_error; goto non_test_error;
} }
/* lxc.no_new_privs */ /* lxc.no_new_privs */
if (set_get_compare_clear_save_load(c, "lxc.no_new_privs", "1", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.no_new_privs", "1", tmpf,
true) < 0) {
lxc_error("%s\n", "lxc.no_new_privs"); lxc_error("%s\n", "lxc.no_new_privs");
goto non_test_error; goto non_test_error;
} }
/* lxc.limit.nofile */ /* lxc.limit.nofile */
if (set_get_compare_clear_save_load(c, "lxc.limit.nofile", "65536", tmpf, true) < 0) { if (set_get_compare_clear_save_load(c, "lxc.limit.nofile", "65536",
tmpf, true) < 0) {
lxc_error("%s\n", "lxc.limit.nofile"); lxc_error("%s\n", "lxc.limit.nofile");
goto non_test_error; goto non_test_error;
} }
...@@ -546,8 +714,151 @@ int main(int argc, char *argv[]) ...@@ -546,8 +714,151 @@ int main(int argc, char *argv[])
goto non_test_error; goto non_test_error;
} }
if (set_get_compare_clear_save_load(c, "lxc.network.0.type", "veth",
tmpf, true)) {
lxc_error("%s\n", "lxc.network.0.type");
goto non_test_error;
}
if (set_get_compare_clear_save_load(c, "lxc.network.2.type", "none",
tmpf, true)) {
lxc_error("%s\n", "lxc.network.2.type");
goto non_test_error;
}
if (set_get_compare_clear_save_load(c, "lxc.network.3.type", "empty",
tmpf, true)) {
lxc_error("%s\n", "lxc.network.3.type");
goto non_test_error;
}
if (set_get_compare_clear_save_load(c, "lxc.network.4.type", "vlan",
tmpf, true)) {
lxc_error("%s\n", "lxc.network.4.type");
goto non_test_error;
}
if (set_get_compare_clear_save_load(c, "lxc.network.0.type", "macvlan",
tmpf, true)) {
lxc_error("%s\n", "lxc.network.0.type");
goto non_test_error;
}
if (set_get_compare_clear_save_load(c, "lxc.network.1000.type", "phys",
tmpf, true)) {
lxc_error("%s\n", "lxc.network.1000.type");
goto non_test_error;
}
if (set_get_compare_clear_save_load(c, "lxc.network.0.flags", "up",
tmpf, true)) {
lxc_error("%s\n", "lxc.network.0.flags");
goto non_test_error;
}
if (set_get_compare_clear_save_load(c, "lxc.network.0.name", "eth0",
tmpf, true)) {
lxc_error("%s\n", "lxc.network.0.name");
goto non_test_error;
}
if (set_get_compare_clear_save_load(c, "lxc.network.0.link", "bla",
tmpf, true)) {
lxc_error("%s\n", "lxc.network.0.link");
goto non_test_error;
}
if (set_get_compare_clear_save_load_network(
c, "lxc.network.0.macvlan.mode", "private", tmpf, true,
"macvlan")) {
lxc_error("%s\n", "lxc.network.0.macvlan.mode");
goto non_test_error;
}
if (set_get_compare_clear_save_load_network(
c, "lxc.network.0.macvlan.mode", "vepa", tmpf, true,
"macvlan")) {
lxc_error("%s\n", "lxc.network.0.macvlan.mode");
goto non_test_error;
}
if (set_get_compare_clear_save_load_network(
c, "lxc.network.0.macvlan.mode", "bridge", tmpf, true,
"macvlan")) {
lxc_error("%s\n", "lxc.network.0.macvlan.mode");
goto non_test_error;
}
if (set_get_compare_clear_save_load_network(
c, "lxc.network.0.veth.pair", "clusterfuck", tmpf, true,
"veth")) {
lxc_error("%s\n", "lxc.network.0.veth.pair");
goto non_test_error;
}
if (set_get_compare_clear_save_load(c, "lxc.network.0.script.up",
"/some/up/path", tmpf, true)) {
lxc_error("%s\n", "lxc.network.0.script.up");
goto non_test_error;
}
if (set_get_compare_clear_save_load(c, "lxc.network.0.script.down",
"/some/down/path", tmpf, true)) {
lxc_error("%s\n", "lxc.network.0.script.down");
goto non_test_error;
}
if (set_get_compare_clear_save_load(c, "lxc.network.0.hwaddr",
"52:54:00:80:7a:5d", tmpf, true)) {
lxc_error("%s\n", "lxc.network.0.hwaddr");
goto non_test_error;
}
if (set_get_compare_clear_save_load(c, "lxc.network.0.mtu", "2000",
tmpf, true)) {
lxc_error("%s\n", "lxc.network.0.mtu");
goto non_test_error;
}
if (set_get_compare_clear_save_load_network(c, "lxc.network.0.vlan.id",
"2", tmpf, true, "vlan")) {
lxc_error("%s\n", "lxc.network.0.vlan.id");
goto non_test_error;
}
if (set_get_compare_clear_save_load(c, "lxc.network.0.ipv4.gateway",
"10.0.2.2", tmpf, true)) {
lxc_error("%s\n", "lxc.network.0.ipv4.gateway");
goto non_test_error;
}
if (set_get_compare_clear_save_load(c, "lxc.network.0.ipv6.gateway",
"2003:db8:1::1", tmpf, true)) {
lxc_error("%s\n", "lxc.network.0.ipv6.gateway");
goto non_test_error;
}
if (set_get_compare_clear_save_load(c, "lxc.network.0.ipv4",
"10.0.2.3/24", tmpf, true)) {
lxc_error("%s\n", "lxc.network.0.ipv4");
goto non_test_error;
}
if (set_get_compare_clear_save_load(
c, "lxc.network.0.ipv6", "2003:db8:1:0:214:1234:fe0b:3596/64",
tmpf, true)) {
lxc_error("%s\n", "lxc.network.0.ipv6");
goto non_test_error;
}
if (set_and_clear_complete_netdev(c) < 0) {
lxc_error("%s\n", "failed to clear whole network");
goto non_test_error;
}
ret = EXIT_SUCCESS; ret = EXIT_SUCCESS;
non_test_error: non_test_error:
(void)unlink(tmpf);
c->destroy(c); c->destroy(c);
lxc_container_put(c); lxc_container_put(c);
exit(ret); exit(ret);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment