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

Submitted by Pavel Emelianov on July 5, 2017, 2 p.m.

Details

Message ID edd0b642-d7d0-f546-5b5f-4ea9812ba180@virtuozzo.com
State Accepted
Series "SIT device support"
Headers show

Commit Message

Pavel Emelianov July 5, 2017, 2 p.m.
Signed-off-by: Pavel Emelyanov <xemul@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

Patch hide | download patch | download mbox

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@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' }