bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ptsname tests, ptsname_r tests: Fix test failures on Hurd


From: Bruno Haible
Subject: ptsname tests, ptsname_r tests: Fix test failures on Hurd
Date: Fri, 02 Sep 2022 22:49:59 +0200

On Debian GNU/Hurd, the test-ptsname and test-ptsname_r programs no longer
terminate the current tty session. They merely fail now. And it's easy to
fix the failures.


2022-09-02  Bruno Haible  <bruno@clisp.org>

        ptsname tests, ptsname_r tests: Fix test failures on Hurd.
        * tests/test-ptsname.c (main): On Hurd, test only the BSD ptys that
        actually exist on Hurd.
        * tests/test-ptsname_r.c (main): Likewise.

diff --git a/tests/test-ptsname.c b/tests/test-ptsname.c
index 33d561b877..b300a03a26 100644
--- a/tests/test-ptsname.c
+++ b/tests/test-ptsname.c
@@ -155,6 +155,36 @@ main (void)
     close (fd);
   }
 
+#elif defined __GNU__ /* Hurd */
+
+  /* Try various master names of Hurd: /dev/pty[p-q][0-9a-v]  */
+  {
+    int char1;
+    int char2;
+
+    for (char1 = 'p'; char1 <= 'q'; char1++)
+      for (char2 = '0'; char2 <= 'v'; (char2 == '9' ? char2 = 'a' : char2++))
+        {
+          char master_name[32];
+          int fd;
+
+          sprintf (master_name, "/dev/pty%c%c", char1, char2);
+          fd = open (master_name, O_RDONLY);
+          if (fd >= 0)
+            {
+              char *result;
+              char slave_name[32];
+
+              result = ptsname (fd);
+              ASSERT (result != NULL);
+              sprintf (slave_name, "/dev/tty%c%c", char1, char2);
+              ASSERT (same_slave (result, slave_name));
+
+              close (fd);
+            }
+        }
+  }
+
 #else
 
   /* Try various master names of Mac OS X: /dev/pty[p-w][0-9a-f]  */
diff --git a/tests/test-ptsname_r.c b/tests/test-ptsname_r.c
index 4d299234f9..4987d17680 100644
--- a/tests/test-ptsname_r.c
+++ b/tests/test-ptsname_r.c
@@ -210,6 +210,39 @@ main (void)
     close (fd);
   }
 
+#elif defined __GNU__ /* Hurd */
+
+  /* Try various master names of Hurd: /dev/pty[p-q][0-9a-v]  */
+  {
+    int char1;
+    int char2;
+
+    for (char1 = 'p'; char1 <= 'q'; char1++)
+      for (char2 = '0'; char2 <= 'v'; (char2 == '9' ? char2 = 'a' : char2++))
+        {
+          char master_name[32];
+          int fd;
+
+          sprintf (master_name, "/dev/pty%c%c", char1, char2);
+          fd = open (master_name, O_RDONLY);
+          if (fd >= 0)
+            {
+              char buffer[256];
+              int result;
+              char slave_name[32];
+
+              result = ptsname_r (fd, buffer, sizeof buffer);
+              ASSERT (result == 0);
+              sprintf (slave_name, "/dev/tty%c%c", char1, char2);
+              ASSERT (same_slave (buffer, slave_name));
+
+              test_errors (fd, buffer);
+
+              close (fd);
+            }
+        }
+  }
+
 #else
 
   /* Try various master names of Mac OS X: /dev/pty[p-w][0-9a-f]  */






reply via email to

[Prev in Thread] Current Thread [Next in Thread]