[CRIU] [PATCH 3/3] tests: add a test for c/r of an empty bridge

Tycho Andersen tycho.andersen at canonical.com
Tue Nov 10 13:05:43 PST 2015


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 | 82 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 86 insertions(+)
 create mode 100644 test/zdtm/live/static/bridge.c

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..94ade37
--- /dev/null
+++ b/test/zdtm/live/static/bridge.c
@@ -0,0 +1,82 @@
+#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)) {
+pr_err("addbr failed %s\n", strerror(errno));
+		return -1;
+	}
+
+	if (system("ifconfig " BRIDGE_NAME " 10.0.55.55")) {
+pr_err("ip addr set failed %s\n", strerror(errno));
+		return -1;
+	}
+
+	if (system("ifconfig " BRIDGE_NAME " up")) {
+pr_err("up failed %s\n", strerror(errno));
+		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;
+
+	if (system("ip addr > bridge.dump.test")) {
+		fail("Can't save net config");
+		goto out;
+	}
+
+	test_daemon();
+	test_waitsig();
+
+	if (system("ip addr > 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;
+}
-- 
2.6.2



More information about the CRIU mailing list