[CRIU] [PATCH 4/4] zdtm: Test sit device C/R

Pavel Emelyanov xemul at virtuozzo.com
Wed Jul 5 17:00:12 MSK 2017


Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 test/zdtm/static/Makefile |  1 +
 test/zdtm/static/sit.c    | 58 +++++++++++++++++++++++++++++++++++++++++++++++
 test/zdtm/static/sit.desc |  3 +++
 3 files changed, 62 insertions(+)
 create mode 100644 test/zdtm/static/sit.c
 create mode 100644 test/zdtm/static/sit.desc

diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index 2c6353e..cdff824 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -172,6 +172,7 @@ TST_NOFILE	:=				\
 		helper_zombie_child		\
 		clone_fs			\
 		macvlan			\
+		sit				\
 		cr_veth				\
 		sock_peercred			\
 		uffd-events			\
diff --git a/test/zdtm/static/sit.c b/test/zdtm/static/sit.c
new file mode 100644
index 0000000..07c36ab
--- /dev/null
+++ b/test/zdtm/static/sit.c
@@ -0,0 +1,58 @@
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/mount.h>
+#include <linux/limits.h>
+#include <signal.h>
+#include <arpa/inet.h>
+#include <net/if.h>
+#include "zdtmtst.h"
+
+const char *test_doc	= "check sit devices";
+const char *test_author	= "Pavel Emelyanov <xemul at virtuozzo.com>";
+
+#define IF_NAME "zdtmsit0"
+#define LOCAL_ADDR	"1.1.1.2"
+#define REMOT_ADDR	"2.2.2.1"
+
+int main(int argc, char **argv)
+{
+	int ret = 1;
+
+	test_init(argc, argv);
+
+	if (system("ip link add " IF_NAME " type sit ttl 13 local " LOCAL_ADDR " remote " REMOT_ADDR)) {
+		pr_perror("Can't make sit device");
+		return 1;
+	}
+
+	if (system("ip -details addr list dev " IF_NAME " > sit.dump.test")) {
+		fail("can't save net config");
+		goto out;
+	}
+
+	test_daemon();
+	test_waitsig();
+
+	if (system("ip -details addr list dev " IF_NAME " > sit.rst.test")) {
+		fail("can't get net config");
+		goto out;
+	}
+
+	if (system("diff sit.rst.test sit.dump.test")) {
+		fail("Net config differs after restore");
+		goto out;
+	}
+
+	pass();
+	ret = 0;
+
+out:
+	return ret;
+}
+
diff --git a/test/zdtm/static/sit.desc b/test/zdtm/static/sit.desc
new file mode 100644
index 0000000..01c4149
--- /dev/null
+++ b/test/zdtm/static/sit.desc
@@ -0,0 +1,3 @@
+{   'deps': [ '/bin/sh', '/sbin/ip|/bin/ip', '/usr/bin/diff' ],
+    'flags': 'suid',
+    'flavor': 'ns uns' }
-- 
2.1.4



More information about the CRIU mailing list