test: skip tty_pty test if pty is not available
authorLuca Bruno <lucab@debian.org>
Sun, 23 Oct 2016 13:36:45 +0000 (14:36 +0100)
committerMattia Rizzolo <mattia@debian.org>
Sun, 23 Oct 2016 13:36:45 +0000 (14:36 +0100)
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Forwarded: yes, accepted already: https://github.com/libuv/libuv/pull/919
Last-Update: Sun, 19 Jun 2016 18:20:53 +0200

Do not let `tty_pty` test fail if no terminals are available
to `openpty()`.

Gbp-Pq: Name skip_test_if_no_pty.patch

test/test-tty.c

index 55cc016752d31b49aed88d6972b9ef97f0d717db..5787d1daeadc2dd95854e501c70b485fa770288c 100644 (file)
@@ -262,14 +262,17 @@ TEST_IMPL(tty_file) {
 TEST_IMPL(tty_pty) {
 # if defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__) || \
     defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__)
-  int master_fd, slave_fd;
+  int master_fd, slave_fd, r;
   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));
+  r = openpty(&master_fd, &slave_fd, NULL, NULL, &w);
+  if (r != 0)
+    RETURN_SKIP("No pty available, skipping.");
+
   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,