From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: login_tty tests: Be more verbose when the test fails
Date: Fri, 13 Jan 2023 15:21:24 +0100 [thread overview]
Message-ID: <3708541.zog1K27m0d@nimes> (raw)
On Android 11, when I run the unit tests of a testdir:
- './test-login_tty' yields "login_tty failed".
- 'make check TESTS=test-login_tty' yields "Aborted".
To get more information about the second case, I'm making this change.
"tcgetsid(0) = -1 and errno = 13" is more information than nothing.
2023-01-13 Bruno Haible <bruno@clisp.org>
login_tty tests: Be more verbose when the test fails.
* tests/test-login_tty.c (main): When the test fails, write a message
into a file.
diff --git a/tests/test-login_tty.c b/tests/test-login_tty.c
index 7ed09f048b..294b46d63c 100644
--- a/tests/test-login_tty.c
+++ b/tests/test-login_tty.c
@@ -53,7 +53,8 @@ main ()
}
/* From here on, we cannot use stderr for error messages any more.
- If a test fails, just abort. */
+ If a test fails, write error information into a file named 'err',
+ then 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. */
@@ -61,12 +62,38 @@ main ()
int fd;
for (fd = 0; fd < 3; fd++)
if (!(tcgetpgrp (fd) == getpid ()))
- abort ();
+ {
+ freopen ("err", "w+", stderr);
+ fprintf (stderr, "tcgetpgrp(%d) = %ld whereas getpid() = %ld\n",
+ fd, (long) tcgetpgrp (fd), (long) getpid ());
+ fflush (stderr);
+ abort ();
+ }
for (fd = 0; fd < 3; fd++)
{
pid_t sid = tcgetsid (fd);
- if (!(sid == -1 ? errno == ENOSYS : sid == getpid ()))
- abort ();
+ if (sid == -1)
+ {
+ if (!(errno == ENOSYS))
+ {
+ freopen ("err", "w+", stderr);
+ fprintf (stderr, "tcgetsid(%d) = -1 and errno = %d\n",
+ fd, errno);
+ fflush (stderr);
+ abort ();
+ }
+ }
+ else
+ {
+ if (!(sid == getpid ()))
+ {
+ freopen ("err", "w+", stderr);
+ fprintf (stderr, "tcgetsid(%d) = %ld whereas getpid() = %ld\n",
+ fd, (long) tcgetsid (fd), (long) getpid ());
+ fflush (stderr);
+ abort ();
+ }
+ }
}
}
reply other threads:[~2023-01-13 14:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3708541.zog1K27m0d@nimes \
--to=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).