diff --git a/test/zdtm.sh b/test/zdtm.sh index e8ec73717..9a57ed0b2 100755 --- a/test/zdtm.sh +++ b/test/zdtm.sh @@ -200,6 +200,7 @@ generate_test_list() ns/static/sem transition/ipc ns/static/netns-dev + static/bridge static/cgroup00 static/cgroup01 static/cgroup02 @@ -361,6 +362,7 @@ different_creds inotify01 ipc_namespace utsname +bridge " TEST_EXPECTED_FAILURE=" diff --git a/test/zdtm/.gitignore b/test/zdtm/.gitignore index 77c2d1513..0160c50b2 100644 --- a/test/zdtm/.gitignore +++ b/test/zdtm/.gitignore @@ -2,6 +2,7 @@ /live/static/apparmor /live/static/arm-neon00 /live/static/bind-mount +/live/static/bridge /live/static/busyloop00 /live/static/caps00 /live/static/cgroup00 diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile index b54b300fe..90cd6f5d6 100644 --- a/test/zdtm/live/static/Makefile +++ b/test/zdtm/live/static/Makefile @@ -130,6 +130,7 @@ TST_NOFILE = \ seccomp_strict \ different_creds \ vsx \ + bridge \ # jobctl00 \ TST_FILE = \ diff --git a/test/zdtm/live/static/bridge.c b/test/zdtm/live/static/bridge.c new file mode 100644 index 000000000..273559545 --- /dev/null +++ b/test/zdtm/live/static/bridge.c @@ -0,0 +1,84 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "zdtmtst.h" + +const char *test_doc = "check that empty bridges are c/r'd correctly"; +const char *test_author = "Tycho Andersen "; + +#define BRIDGE_NAME "zdtmbr0" + +int add_bridge(void) +{ + if (system("brctl addbr " BRIDGE_NAME)) + return -1; + + if (system("ifconfig " BRIDGE_NAME " 10.0.55.55")) + return -1; + + if (system("ifconfig " BRIDGE_NAME " up")) + return -1; + + return 0; +} + +int del_bridge(void) +{ + /* don't check for errors, let's try to make sure it's deleted */ + system("ifconfig " BRIDGE_NAME " down"); + + if (system("brctl delbr " BRIDGE_NAME)) + return -1; + + return 0; +} + +int main(int argc, char **argv) +{ + int ret = 1; + test_init(argc, argv); + + if (add_bridge() < 0) + return 1; + + /* Here, we grep for inet because some of the IPV6 DAD stuff can be + * racy, and all we really care about is that the bridge got restored + * with the right MAC, since we know DAD will succeed eventually. + * + * (I got this race with zdtm.py, but not with zdtm.sh; not quite sure + * what the environment difference is/was.) + */ + if (system("ip addr list dev " BRIDGE_NAME " | grep inet > bridge.dump.test")) { + pr_perror("can't save net config"); + fail("Can't save net config"); + goto out; + } + + test_daemon(); + test_waitsig(); + + if (system("ip addr list dev " BRIDGE_NAME " | grep inet > bridge.rst.test")) { + fail("Can't get net config"); + goto out; + } + + if (system("diff bridge.rst.test bridge.dump.test")) { + fail("Net config differs after restore"); + goto out; + } + + pass(); + + ret = 0; + +out: + del_bridge(); + return ret; +} diff --git a/test/zdtm/live/static/bridge.desc b/test/zdtm/live/static/bridge.desc new file mode 100644 index 000000000..59f7d3947 --- /dev/null +++ b/test/zdtm/live/static/bridge.desc @@ -0,0 +1 @@ +{'flavor': 'ns uns', 'deps': [ '/bin/sh', '/bin/grep', '/sbin/ip', '/sbin/brctl', '/sbin/ifconfig', '/usr/bin/diff'], 'flags': 'suid'}