From: Felix Abecassis Date: Wed, 29 Nov 2017 04:27:34 +0000 (-0800) Subject: tests: add a function for negative netdev tests X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cd70a8ed1a19a56af99c29243ba063fa9347c292;p=thirdparty%2Flxc.git tests: add a function for negative netdev tests Signed-off-by: Felix Abecassis --- diff --git a/src/tests/parse_config_file.c b/src/tests/parse_config_file.c index db61dd044..7479793ac 100644 --- a/src/tests/parse_config_file.c +++ b/src/tests/parse_config_file.c @@ -155,6 +155,23 @@ static int set_and_clear_complete_netdev(struct lxc_container *c) return 0; } +static int set_invalid_netdev(struct lxc_container *c) { + if (c->set_config_item(c, "lxc.net.0.asdf", "veth")) { + lxc_error("%s\n", "lxc.net.0.asdf should be invalid"); + return -1; + } + + if (c->set_config_item(c, "lxc.net.2147483647.type", "veth")) { + lxc_error("%s\n", "lxc.net.2147483647.type should be invalid"); + return -1; + } + + c->clear_config(c); + c->lxc_conf = NULL; + + return 0; +} + int test_idmap_parser(void) { size_t i; @@ -970,12 +987,6 @@ int main(int argc, char *argv[]) goto non_test_error; } - if (!set_get_compare_clear_save_load(c, "lxc.net.0.asdf", "veth", - tmpf, true)) { - lxc_error("%s\n", "lxc.net.0.asdf"); - goto non_test_error; - } - if (set_get_compare_clear_save_load_network( c, "lxc.net.0.macvlan.mode", "private", tmpf, true, "macvlan")) { @@ -1070,6 +1081,11 @@ int main(int argc, char *argv[]) goto non_test_error; } + if (set_invalid_netdev(c) < 0) { + lxc_error("%s\n", "failed to reject invalid configuration"); + goto non_test_error; + } + ret = EXIT_SUCCESS; non_test_error: (void)unlink(tmpf);