Commit 79ca3eec authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

tty: test -- Add /dev/tty testing into pty00

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent f42c9b96
......@@ -21,7 +21,7 @@ static void signal_handler_sighup(int signum)
int main(int argc, char ** argv)
{
int fdm, fds, ret;
int fdm, fds, ret, tty;
char *slavename;
char buf[10];
const char teststr[] = "hello\n";
......@@ -56,6 +56,12 @@ int main(int argc, char ** argv)
return 1;
}
tty = open("/dev/tty", O_RDWR);
if (tty < 0) {
err("open(%s) failed", "/dev/tty");
return 1;
}
/* Try to reproduce a deadlock */
if (dup2(fdm, 101) != 101) {
err("dup( , 101) failed");
......@@ -93,6 +99,23 @@ int main(int argc, char ** argv)
return 1;
}
ret = write(fdm, teststr, sizeof(teststr) - 1);
if (ret != sizeof(teststr) - 1) {
err("write(fdm) failed");
return 1;
}
ret = read(tty, buf, sizeof(teststr) - 1);
if (ret != sizeof(teststr) - 1) {
err("read(tty) failed");
return 1;
}
if (strncmp(teststr, buf, sizeof(teststr) - 1)) {
fail("data mismatch");
return 1;
}
if (nr_sighups != 0) {
fail("Expected 0 SIGHUP before closing control terminal but got %d", nr_sighups);
return 1;
......@@ -100,6 +123,7 @@ int main(int argc, char ** argv)
close(fdm);
close(fds);
close(tty);
if (nr_sighups != 1) {
fail("Expected 1 SIGHUP after closing control terminal but got %d", nr_sighups);
......
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