From 4f81aa5778dc88b99d21ad8d04a4bc9401366311 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 9 Nov 2012 01:03:33 -0800 Subject: [PATCH] getlogin-tests: allow errno == ENOENT * tests/test-getlogin.c (main): Skip tests if getlogin fails with errno == ENOENT. This happened to me on Ubuntu 12.04.1 x86, when running a test in an Emacs shell buffer. --- ChangeLog | 7 +++++++ tests/test-getlogin.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7e0129ecfa..cca6c07136 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-11-09 Paul Eggert + + getlogin-tests: allow errno == ENOENT + * tests/test-getlogin.c (main): Skip tests if getlogin fails + with errno == ENOENT. This happened to me on Ubuntu 12.04.1 x86, + when running a test in an Emacs shell buffer. + 2012-11-08 Jim Meyering tests/nap.h: avoid warning about unused variable diff --git a/tests/test-getlogin.c b/tests/test-getlogin.c index 449ceaa26c..d86fec2758 100644 --- a/tests/test-getlogin.c +++ b/tests/test-getlogin.c @@ -39,6 +39,13 @@ main (void) buf = getlogin (); if (buf == NULL) { + if (errno == ENOENT) + { + /* This can happen on GNU/Linux. */ + fprintf (stderr, "Skipping test: no entry in utmp file.\n"); + return 77; + } + /* getlogin() fails when stdin is not connected to a tty. */ ASSERT (errno == ENOTTY || errno == EINVAL /* seen on Linux/SPARC */ -- 2.39.5