[CRIU] [PATCH 2/2] zdtm:tty:vt: add simple test
Ruslan Kuprieiev
kupruser at gmail.com
Tue Dec 16 15:21:40 PST 2014
Inspired by static/console test.
Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
test/zdtm.sh | 3 +++
test/zdtm/.gitignore | 1 +
test/zdtm/live/static/Makefile | 1 +
test/zdtm/live/static/vt.c | 60 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 65 insertions(+)
create mode 100644 test/zdtm/live/static/vt.c
diff --git a/test/zdtm.sh b/test/zdtm.sh
index aacdc71..92d2cf2 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -107,6 +107,7 @@ static/pty04
static/tty02
static/tty03
static/console
+static/vt
static/child_opened_proc
static/cow01
static/fpu00
@@ -244,6 +245,7 @@ ns/static/clean_mntns
ns/static/mntns_link_remap
ns/static/mntns_link_ghost
ns/static/console
+ns/static/vt
ns/static/rtc
ns/static/mntns_shared_bind
ns/static/mntns_shared_bind02
@@ -289,6 +291,7 @@ tun
chroot
chroot-file
console
+vt
rtc
tempfs
maps007
diff --git a/test/zdtm/.gitignore b/test/zdtm/.gitignore
index e244cca..31850df 100644
--- a/test/zdtm/.gitignore
+++ b/test/zdtm/.gitignore
@@ -168,6 +168,7 @@
/live/static/zombie00
/live/static/ip.dump
/live/static/ip.rst
+/live/static/vt
/live/streaming/fifo_dyn
/live/streaming/fifo_loop
/live/streaming/file_aio
diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index e2431f5..226cb6c 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -139,6 +139,7 @@ TST_FILE = \
fifo_ro \
fifo_wronly \
console \
+ vt \
unlink_fifo \
unlink_fifo_wronly \
unlink_mmap00 \
diff --git a/test/zdtm/live/static/vt.c b/test/zdtm/live/static/vt.c
new file mode 100644
index 0000000..631a765
--- /dev/null
+++ b/test/zdtm/live/static/vt.c
@@ -0,0 +1,60 @@
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc = "Check c/r of a virtual terminal";
+const char *test_author = "Ruslan Kuprieiev <kupruser at gmail.com>";
+
+char *filename;
+TEST_OPTION(filename, string, "file name", 1);
+
+int main(int argc, char **argv)
+{
+ struct stat st1, st2;
+ int fd;
+
+ test_init(argc, argv);
+
+ if (mknod(filename, S_IFCHR | S_IRUSR | S_IWUSR, makedev(4, 5))) {
+ err("Can't create virtual terminal %s", filename);
+ return 1;
+ }
+
+ fd = open(filename, O_RDONLY);
+ if (fd < 0) {
+ err("Open virtual terminal %s failed", filename);
+ return 1;
+ }
+
+ if (fstat(fd, &st1)) {
+ err("Can't stat %s virtual terminal", filename);
+ return 1;
+ }
+
+ test_daemon();
+ test_waitsig();
+
+ if (fstat(fd, &st2)) {
+ err("Can't stat %s virtual terminal", filename);
+ return 1;
+ }
+
+ if (st1.st_rdev != st2.st_rdev) {
+ fail("Virtual terminal rdev mismatch %x != %x on %s",
+ (int)st1.st_rdev, (int)st2.st_rdev,
+ filename);
+ return 1;
+ }
+
+ pass();
+ return 0;
+}
--
2.1.0
More information about the CRIU
mailing list