criu/test/zdtm/static/vt.c
Michael Holzheu c2f30337a5 s390:criu: Add support for s390 consoles
On s390 we have special console drivers with minors 64 and 65.
Add support for them in criu code and in zdtm testsuite.

Reviewed-by: Alice Frosi <alice@linux.vnet.ibm.com>
Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-08-09 18:51:41 +03:00

64 lines
1.2 KiB
C

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/sysmacros.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);
#ifdef __s390x__
#define MINOR 64 /* ttyS0 */
#else
#define MINOR 5
#endif
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, MINOR))) {
pr_perror("Can't create virtual terminal %s", filename);
return 1;
}
fd = open(filename, O_RDONLY);
if (fd < 0) {
pr_perror("Open virtual terminal %s failed", filename);
return 1;
}
if (fstat(fd, &st1)) {
pr_perror("Can't stat %s virtual terminal", filename);
return 1;
}
test_daemon();
test_waitsig();
if (fstat(fd, &st2)) {
pr_perror("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;
}