X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-ptsname_r.c;h=b194303815bef311ac561601bfdbb5fa688a828e;hb=4e1dc0e3d73be7c53e10b8541a0313df3d1ae35b;hp=edb5e3d9d08e5466c4703eb20567c5dfd99de0b7;hpb=06b335ade65c8fe60fee8b9e18b670bb54ed924a;p=gnulib.git diff --git a/tests/test-ptsname_r.c b/tests/test-ptsname_r.c index edb5e3d9d..b19430381 100644 --- a/tests/test-ptsname_r.c +++ b/tests/test-ptsname_r.c @@ -1,5 +1,5 @@ /* Test of ptsname_r(3). - Copyright (C) 2010-2012 Free Software Foundation, Inc. + Copyright (C) 2010-2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -104,8 +104,9 @@ main (void) #if HAVE_DECL_ALARM /* Declare failure if test takes too long, by using default abort caused by SIGALRM. */ + int alarm_value = 5; signal (SIGALRM, SIG_DFL); - alarm (5); + alarm (alarm_value); #endif { @@ -151,7 +152,7 @@ main (void) char buffer[256]; int result; - /* Open the controlling tty of the current process. */ + /* Open a pty master. */ fd = open ("/dev/ptmx", O_RDWR | O_NOCTTY); if (fd < 0) { @@ -168,6 +169,32 @@ main (void) close (fd); } +#elif defined _AIX + /* AIX has BSD-style /dev/ptyp[0-9a-f] files, but the modern way to open + a pty is to go through /dev/ptc. */ + { + int fd; + char buffer[256]; + int result; + + /* Open a pty master. */ + fd = open ("/dev/ptc", O_RDWR | O_NOCTTY); + if (fd < 0) + { + fprintf (stderr, "Skipping test: cannot open pseudo-terminal\n"); + return 77; + } + + result = ptsname_r (fd, buffer, sizeof buffer); + ASSERT (result == 0); + ASSERT (memcmp (buffer, "/dev/pts/", 9) == 0); + + test_errors (fd, buffer); + + /* This call hangs on AIX. */ + close (fd); + } + #else /* Try various master names of Mac OS X: /dev/pty[p-w][0-9a-f] */ @@ -196,6 +223,7 @@ main (void) test_errors (fd, buffer); + /* This call hangs on AIX. */ close (fd); } }