2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 05:18:00 +00:00

zdtm:tty:vt: add simple test

Inspired by static/console test.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Ruslan Kuprieiev 2014-12-17 01:21:40 +02:00 committed by Pavel Emelyanov
parent 1ace257022
commit 16a668e5d3
4 changed files with 65 additions and 0 deletions

View File

@ -107,6 +107,7 @@ static/pty04
static/tty02
static/tty03
static/console
static/vt
static/child_opened_proc
static/cow01
static/fpu00
@ -246,6 +247,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
@ -292,6 +294,7 @@ tun
chroot
chroot-file
console
vt
rtc
tempfs
maps007

View File

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

View File

@ -139,6 +139,7 @@ TST_FILE = \
fifo_ro \
fifo_wronly \
console \
vt \
unlink_fifo \
unlink_fifo_wronly \
unlink_mmap00 \

View File

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