From 8e778d29c6c56639d94e9ebfdbd8d03fef5ed532 Mon Sep 17 00:00:00 2001 From: Andrew Vagin Date: Thu, 12 May 2016 21:21:46 +0300 Subject: [PATCH] zdtm: check in-flight data in ttys Signed-off-by: Andrew Vagin Signed-off-by: Cyrill Gorcunov Signed-off-by: Pavel Emelyanov --- test/zdtm/static/pty00.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/test/zdtm/static/pty00.c b/test/zdtm/static/pty00.c index 7aa9c8a07..8d4a0f997 100644 --- a/test/zdtm/static/pty00.c +++ b/test/zdtm/static/pty00.c @@ -21,9 +21,9 @@ static void signal_handler_sighup(int signum) int main(int argc, char ** argv) { - int fdm, fds, ret, tty; + int fdm, fds, ret, tty, i; char *slavename; - char buf[10]; + char buf[4096]; const char teststr[] = "hello\n"; struct sigaction sa = { @@ -77,21 +77,24 @@ int main(int argc, char ** argv) close(fds); fds = 100; - test_daemon(); - - test_waitsig(); - - /* Check connectivity */ - ret = write(fdm, teststr, sizeof(teststr) - 1); - if (ret != sizeof(teststr) - 1) { - pr_perror("write(fdm) failed"); - return 1; + for (i = 0; i < 10; i++) { + /* Check connectivity */ + ret = write(fdm, teststr, sizeof(teststr) - 1); + if (ret != sizeof(teststr) - 1) { + pr_perror("write(fdm) failed"); + return 1; + } } - ret = read(fds, buf, sizeof(teststr) - 1); - if (ret != sizeof(teststr) - 1) { - pr_perror("read(fds) failed"); - return 1; + test_daemon(); + test_waitsig(); + + for (i = 0; i < 10; i++) { + ret = read(fds, buf, sizeof(teststr) - 1); + if (ret != sizeof(teststr) - 1) { + pr_perror("read(fds) failed"); + return 1; + } } if (strncmp(teststr, buf, sizeof(teststr) - 1)) {