X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Ftest-ptsname.c;h=8c95100a298292aad316ad98753c90d48da90e6a;hb=f7fecbfc47c114a633f1fa754a0d9e1ad6cfc868;hp=ce392833cc30354709e94bb92d5aff4da3609714;hpb=1a56c64d39a790bc69b58166f7b963334951e1a9;p=pspp diff --git a/tests/test-ptsname.c b/tests/test-ptsname.c index ce392833cc..8c95100a29 100644 --- a/tests/test-ptsname.c +++ b/tests/test-ptsname.c @@ -25,9 +25,32 @@ SIGNATURE_CHECK (ptsname, char *, (int)); #include #include #include +#include + +#include "same-inode.h" #include "macros.h" +/* Compare two slave names. + On some systems, there are hard links in the /dev/ directory. + For example, on OSF/1 5.1, + /dev/ttyp0 == /dev/pts/0 + /dev/ttyp9 == /dev/pts/9 + /dev/ttypa == /dev/pts/10 + /dev/ttype == /dev/pts/14 + */ +static int +same_slave (const char *slave_name1, const char *slave_name2) +{ + struct stat statbuf1; + struct stat statbuf2; + + return (strcmp (slave_name1, slave_name2) == 0 + || (stat (slave_name1, &statbuf1) >= 0 + && stat (slave_name2, &statbuf2) >= 0 + && SAME_INODE (statbuf1, statbuf2))); +} + int main (void) { @@ -75,7 +98,7 @@ main (void) result = ptsname (fd); ASSERT (result != NULL); sprintf (slave_name, "/dev/tty%c%c", char1, char2); - ASSERT (strcmp (result, slave_name) == 0); + ASSERT (same_slave (result, slave_name)); close (fd); } @@ -105,7 +128,7 @@ main (void) result = ptsname (fd); ASSERT (result != NULL); sprintf (slave_name, "/dev/tty%c%c", char1, char2); - ASSERT (strcmp (result, slave_name) == 0); + ASSERT (same_slave (result, slave_name)); close (fd); }