ptsname tests: Let the test fail rather than hang (e.g. on AIX 5.1).
authorBruno Haible <bruno@clisp.org>
Sun, 18 Sep 2011 23:02:09 +0000 (01:02 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 18 Sep 2011 23:02:09 +0000 (01:02 +0200)
* tests/test-ptsname.c (main): Terminate the test if it takes longer
than 5 seconds.
* modules/ptsname-tests (configure.ac): Test for alarm.

ChangeLog
modules/ptsname-tests
tests/test-ptsname.c

index e73f7d4..f9d52f4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2011-09-18  Bruno Haible  <bruno@clisp.org>
 
+       ptsname tests: Let the test fail rather than hang (e.g. on AIX 5.1).
+       * tests/test-ptsname.c (main): Terminate the test if it takes longer
+       than 5 seconds.
+       * modules/ptsname-tests (configure.ac): Test for alarm.
+
+2011-09-18  Bruno Haible  <bruno@clisp.org>
+
        posix_spawn_file_actions_add*: Fix module dependencies.
        * modules/posix_spawn_file_actions_addclose (Dependencies): Add
        posix_spawn_file_actions_init.
index 344b8a7..e26bc9e 100644 (file)
@@ -7,6 +7,7 @@ Depends-on:
 same-inode
 
 configure.ac:
+AC_CHECK_DECLS_ONCE([alarm])
 
 Makefile.am:
 TESTS += test-ptsname
index ccf2ab1..921367c 100644 (file)
@@ -22,6 +22,7 @@
 SIGNATURE_CHECK (ptsname, char *, (int));
 
 #include <fcntl.h>
+#include <signal.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
@@ -54,6 +55,13 @@ same_slave (const char *slave_name1, const char *slave_name2)
 int
 main (void)
 {
+#if HAVE_DECL_ALARM
+  /* Declare failure if test takes too long, by using default abort
+     caused by SIGALRM.  */
+  signal (SIGALRM, SIG_DFL);
+  alarm (5);
+#endif
+
   {
     int fd;
     char *result;