Commit 9da5531c authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

test: Add console trivial test

We simply check that major/minor didn't changed after restore.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ec50bd8c
...@@ -105,6 +105,7 @@ static/pty01 ...@@ -105,6 +105,7 @@ static/pty01
static/pty04 static/pty04
static/tty02 static/tty02
static/tty03 static/tty03
static/console
static/child_opened_proc static/child_opened_proc
static/cow01 static/cow01
static/fpu00 static/fpu00
...@@ -217,6 +218,7 @@ sk-netlink ...@@ -217,6 +218,7 @@ sk-netlink
tun tun
chroot chroot
chroot-file chroot-file
console
rtc rtc
tempfs tempfs
maps007 maps007
......
...@@ -138,6 +138,7 @@ TST_FILE = \ ...@@ -138,6 +138,7 @@ TST_FILE = \
fifo-ghost \ fifo-ghost \
fifo_ro \ fifo_ro \
fifo_wronly \ fifo_wronly \
console \
unlink_fifo \ unlink_fifo \
unlink_fifo_wronly \ unlink_fifo_wronly \
unlink_mmap00 \ unlink_mmap00 \
......
#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@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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment