mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
zdtm: Add pty04 test
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
1603f88836
commit
8895729906
@@ -55,6 +55,7 @@ TST_NOFILE = \
|
||||
pty01 \
|
||||
pty02 \
|
||||
pty03 \
|
||||
pty04 \
|
||||
tty00 \
|
||||
mountpoints \
|
||||
netns \
|
||||
|
64
test/zdtm/live/static/pty04.c
Normal file
64
test/zdtm/live/static/pty04.c
Normal file
@@ -0,0 +1,64 @@
|
||||
#define _XOPEN_SOURCE
|
||||
#include <stdlib.h>
|
||||
#include "zdtmtst.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
#include <signal.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
const char *test_doc = "Check two pts with a fake ptmx";
|
||||
const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>";
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int master, slave1, slave2;
|
||||
char *slavename;
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
master = open("/dev/ptmx", O_RDWR);
|
||||
if (master == -1) {
|
||||
err("open(%s) failed", "/dev/ptmx");
|
||||
return 1;
|
||||
}
|
||||
|
||||
grantpt(master);
|
||||
unlockpt(master);
|
||||
|
||||
slavename = ptsname(master);
|
||||
|
||||
slave1 = open(slavename, O_RDWR);
|
||||
if (slave1 == -1) {
|
||||
err("open(%s) failed", slavename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
slave2 = open(slavename, O_RDWR);
|
||||
if (slave2 == -1) {
|
||||
err("open(%s) failed", slavename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ioctl(slave1, TIOCSCTTY, 1)) {
|
||||
err("Can't set a controll terminal");
|
||||
return 1;
|
||||
}
|
||||
|
||||
test_msg("Closing master\n");
|
||||
signal(SIGHUP, SIG_IGN);
|
||||
close(master);
|
||||
|
||||
test_daemon();
|
||||
test_waitsig();
|
||||
|
||||
close(slave1);
|
||||
close(slave2);
|
||||
|
||||
pass();
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user