diff options
Diffstat (limited to '3rdparty/libuv/test/test-tty.c')
-rw-r--r-- | 3rdparty/libuv/test/test-tty.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/3rdparty/libuv/test/test-tty.c b/3rdparty/libuv/test/test-tty.c index b844959d526..461d1941359 100644 --- a/3rdparty/libuv/test/test-tty.c +++ b/3rdparty/libuv/test/test-tty.c @@ -28,6 +28,13 @@ #else /* Unix */ # include <fcntl.h> # include <unistd.h> +# if defined(__linux__) +# include <pty.h> +# elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) +# include <util.h> +# elif defined(__FreeBSD__) || defined(__DragonFly__) +# include <libutil.h> +# endif #endif #include <string.h> @@ -182,3 +189,35 @@ TEST_IMPL(tty_file) { #endif return 0; } + +TEST_IMPL(tty_pty) { +# if defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__) || \ + defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) + int master_fd, slave_fd; + struct winsize w; + uv_loop_t loop; + uv_tty_t master_tty, slave_tty; + + ASSERT(0 == uv_loop_init(&loop)); + + ASSERT(0 == openpty(&master_fd, &slave_fd, NULL, NULL, &w)); + ASSERT(0 == uv_tty_init(&loop, &slave_tty, slave_fd, 0)); + ASSERT(0 == uv_tty_init(&loop, &master_tty, master_fd, 0)); + /* Check if the file descriptor was reopened. If it is, + * UV_STREAM_BLOCKING (value 0x80) isn't set on flags. + */ + ASSERT(0 == (slave_tty.flags & 0x80)); + /* The master_fd of a pty should never be reopened. + */ + ASSERT(master_tty.flags & 0x80); + ASSERT(0 == close(slave_fd)); + uv_close((uv_handle_t*) &slave_tty, NULL); + ASSERT(0 == close(master_fd)); + uv_close((uv_handle_t*) &master_tty, NULL); + + ASSERT(0 == uv_run(&loop, UV_RUN_DEFAULT)); + + MAKE_VALGRIND_HAPPY(); +#endif + return 0; +} |