X-Git-Url: https://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=tests%2Ftest-login_tty.c;h=ddd5067ed638fdf3353d56345b7ef92942047ab3;hb=765ff4cb2bd24b860e29e0b712bb40b7a2ae9b5b;hp=cd08f54b42a8b3da5deaa25976dca6b923454b4a;hpb=e6b310e3cd8d3eec494f0c886bd407920faccb4a;p=gnulib.git diff --git a/tests/test-login_tty.c b/tests/test-login_tty.c index cd08f54b4..ddd5067ed 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-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 @@ -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; }