2014-10-24 00:22:05 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
2016-12-07 18:40:00 +03:00
|
|
|
#include <sys/sysmacros.h>
|
2014-10-24 00:22:05 +04:00
|
|
|
|
|
|
|
#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))) {
|
2015-10-20 18:10:00 +03:00
|
|
|
pr_perror("Can't create console %s", filename);
|
2014-10-24 00:22:05 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
fd = open(filename, O_RDONLY);
|
|
|
|
if (fd < 0) {
|
2015-10-20 18:10:00 +03:00
|
|
|
pr_perror("Open console %s failed", filename);
|
2014-10-24 00:22:05 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fstat(fd, &st1)) {
|
2015-10-20 18:10:00 +03:00
|
|
|
pr_perror("Can't stat %s console", filename);
|
2014-10-24 00:22:05 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
test_daemon();
|
|
|
|
test_waitsig();
|
|
|
|
|
|
|
|
if (fstat(fd, &st2)) {
|
2015-10-20 18:10:00 +03:00
|
|
|
pr_perror("Can't stat %s console", filename);
|
2014-10-24 00:22:05 +04:00
|
|
|
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;
|
|
|
|
}
|