[CRIU] [PATCH 9/9] tty: Add support of /dev/console
Cyrill Gorcunov
gorcunov at gmail.com
Fri Oct 24 02:42:30 PDT 2014
On Fri, Oct 24, 2014 at 01:05:01AM +0400, Pavel Emelyanov wrote:
> On 10/24/2014 12:52 AM, Cyrill Gorcunov wrote:
> > On Thu, Oct 23, 2014 at 06:16:47PM +0400, Pavel Emelyanov wrote:
> >>
> >> No, please. Don't make the dump_one_pty() be 3-screen long.
> >
> > Pavel, please take a look on the attached one, hopefully it address
> > the concern. Still at moment I can't figure out a way to make a
> > separate test for this (I use this series with openvz kernel where
> > devtmpfs is virtualized and container is using own /dev/console).
> >
> > The main problem -- we can't simly create new console if system
> > one is present, iow console should be created on devtmpfs which
> > is in one instance for vanilla kernel.
>
> What do you mean by "can't create"?
> On my laptop 'sudo mknod /root/my_cons c 5 1' "just works".
The test is attached. Pavel, what you prefer -- pick up patches
from here or I to send them anew?
-------------- next part --------------
>From 7414ec530185dc99ed718ce8e3e57f20a2f7ec9e Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Fri, 24 Oct 2014 00:22:05 +0400
Subject: [PATCH 2/2] test: Add console trivial test
We simply check that major/minor didn't changed after restore.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
test/zdtm.sh | 2 ++
test/zdtm/live/static/Makefile | 1 +
test/zdtm/live/static/console.c | 60 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+)
create mode 100644 test/zdtm/live/static/console.c
diff --git a/test/zdtm.sh b/test/zdtm.sh
index b8a1cca980d9..066e2e3b708f 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -105,6 +105,7 @@ static/pty01
static/pty04
static/tty02
static/tty03
+static/console
static/child_opened_proc
static/cow01
static/fpu00
@@ -217,6 +218,7 @@ sk-netlink
tun
chroot
chroot-file
+console
rtc
tempfs
maps007
diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index 986a9182b176..e418ad4a798d 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -137,6 +137,7 @@ TST_FILE = \
fifo-ghost \
fifo_ro \
fifo_wronly \
+ console \
unlink_fifo \
unlink_fifo_wronly \
unlink_mmap00 \
diff --git a/test/zdtm/live/static/console.c b/test/zdtm/live/static/console.c
new file mode 100644
index 000000000000..0a275217c437
--- /dev/null
+++ b/test/zdtm/live/static/console.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 for console device";
+const char *test_author = "Cyrill Gorcunov <gorcunov at openvz.org>";
+
+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(5,1))) {
+ err("Can't create console %s", filename);
+ return 1;
+ }
+
+ fd = open(filename, O_RDONLY);
+ if (fd < 0) {
+ err("Open console %s failed", filename);
+ return 1;
+ }
+
+ if (fstat(fd, &st1)) {
+ err("Can't stat %s console", filename);
+ return 1;
+ }
+
+ test_daemon();
+ test_waitsig();
+
+ if (fstat(fd, &st2)) {
+ err("Can't stat %s console", filename);
+ return 1;
+ }
+
+ if (st1.st_rdev != st2.st_rdev) {
+ fail("Console rdev mismatch %x != %x on %s",
+ (int)st1.st_rdev, (int)st2.st_rdev,
+ filename);
+ return 1;
+ }
+
+ pass();
+ return 0;
+}
--
1.9.3
More information about the CRIU
mailing list