[CRIU] [PATCH 2/3] tests: add a test for c/r of an empty bridge
Tycho Andersen
tycho.andersen at canonical.com
Wed Nov 11 11:10:02 PST 2015
v2: * add a zdtm.py .desc file
* only look to make sure inet addresses match (in particular, don't
match the state)
Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
test/zdtm.sh | 2 +
test/zdtm/.gitignore | 1 +
test/zdtm/live/static/Makefile | 1 +
test/zdtm/live/static/bridge.c | 84 +++++++++++++++++++++++++++++++++++++++
test/zdtm/live/static/bridge.desc | 1 +
5 files changed, 89 insertions(+)
create mode 100644 test/zdtm/live/static/bridge.c
create mode 100644 test/zdtm/live/static/bridge.desc
diff --git a/test/zdtm.sh b/test/zdtm.sh
index e8ec737..9a57ed0 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 77c2d15..0160c50 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 b54b300..90cd6f5 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 0000000..2735595
--- /dev/null
+++ b/test/zdtm/live/static/bridge.c
@@ -0,0 +1,84 @@
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/mount.h>
+#include <linux/limits.h>
+#include <signal.h>
+#include "zdtmtst.h"
+
+const char *test_doc = "check that empty bridges are c/r'd correctly";
+const char *test_author = "Tycho Andersen <tycho.andersen at canonical.com>";
+
+#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 0000000..59f7d39
--- /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'}
--
2.6.2
More information about the CRIU
mailing list