X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-login_tty.c;h=001b009257e740ec467a258338ae0050cd2651d2;hb=d599e5add275f75ed08e6527b8ee4d3f4f7c3aea;hp=cd08f54b42a8b3da5deaa25976dca6b923454b4a;hpb=23737e3dd01ef6ac0ae9134300a4c66807ae00d2;p=gnulib.git diff --git a/tests/test-login_tty.c b/tests/test-login_tty.c index cd08f54b4..001b00925 100644 --- a/tests/test-login_tty.c +++ b/tests/test-login_tty.c @@ -1,5 +1,5 @@ /* Test of login_tty() function. - Copyright (C) 2010 Free Software Foundation, Inc. + Copyright (C) 2010-2011 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 @@ -19,8 +19,12 @@ /* Specification. */ extern int login_tty (int); +#include #include #include +#include +#include +#include int main () @@ -48,5 +52,23 @@ main () } } + /* From here on, we cannot use stderr for error messages any more. + If a test fails, just abort. */ + + /* Check that fd = 0, 1, 2 are now open to the controlling terminal for the + current process and that it is a session of its own. */ + { + int fd; + for (fd = 0; fd < 3; fd++) + if (!(tcgetpgrp (fd) == getpid ())) + abort (); + for (fd = 0; fd < 3; fd++) + { + int sid = tcgetsid (fd); + if (!(sid == -1 ? errno == ENOSYS : sid == getpid ())) + abort (); + } + } + return 0; }