From 7372d0277c003ecb7468e5dd393bdb4b5a63aa89 Mon Sep 17 00:00:00 2001 From: "Hui, Chunyang" Date: Mon, 13 Apr 2020 04:25:25 +0000 Subject: [PATCH] Fix tty ioctl test for non-tty stdout --- test/ioctl/main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/ioctl/main.c b/test/ioctl/main.c index 2d980f7a..16beb834 100644 --- a/test/ioctl/main.c +++ b/test/ioctl/main.c @@ -17,8 +17,14 @@ int test_tty_ioctl_TIOCGWINSZ(void) { struct winsize winsize; - if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize) < 0) { - THROW_ERROR("failed to ioctl TIOCGWINSZ"); + if (isatty(STDOUT_FILENO)) { + if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize) < 0) { + THROW_ERROR("failed to ioctl TIOCGWINSZ"); + } + } else { + // FIXME: /dev/tty should be opened. But it has not been implemented in Occlum yet. + // So we just skip this test if STDOUT is redirected. + printf("Warning: test_tty_ioctl_TIOCGWINSZ is skipped\n"); } return 0; }