testcase: define a network before checks

Signed-off-by: 0x0916 <w@laoqinren.net>
This commit is contained in:
0x0916 2017-06-29 07:32:54 +08:00
parent ae1dc8b42e
commit 935cfd3e36
2 changed files with 20 additions and 4 deletions

View File

@ -1,4 +1,4 @@
lxc.network.type = veth lxc.net.0.type = veth
lxc.network.link = lxcbr0 lxc.net.0.link = lxcbr0
lxc.network.flags = up lxc.net.0.flags = up
lxc.network.hwaddr = 00:16:3e:xx:xx:xx lxc.net.0.hwaddr = 00:16:3e:xx:xx:xx

View File

@ -298,6 +298,22 @@ int main(int argc, char *argv[])
} }
printf("%d: get_config_item(lxc.network) returned %d %s\n", __LINE__, ret, v2); printf("%d: get_config_item(lxc.network) returned %d %s\n", __LINE__, ret, v2);
if (!c->set_config_item(c, "lxc.network.type", "veth")) {
fprintf(stderr, "%d: failed to set network.type\n", __LINE__);
goto out;
}
if (!c->set_config_item(c, "lxc.network.link", "lxcbr0")) {
fprintf(stderr, "%d: failed to set network.link\n", __LINE__);
goto out;
}
if (!c->set_config_item(c, "lxc.network.flags", "up")) {
fprintf(stderr, "%d: failed to set network.flags\n", __LINE__);
goto out;
}
if (!c->set_config_item(c, "lxc.network.hwaddr", "00:16:3e:xx:xx:xx")) {
fprintf(stderr, "%d: failed to set network.hwaddr\n", __LINE__);
goto out;
}
if (!c->set_config_item(c, "lxc.network.ipv4", "10.2.3.4")) { if (!c->set_config_item(c, "lxc.network.ipv4", "10.2.3.4")) {
fprintf(stderr, "%d: failed to set ipv4\n", __LINE__); fprintf(stderr, "%d: failed to set ipv4\n", __LINE__);
goto out; goto out;