/* Test of getting user name.
- 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
#include "signature.h"
SIGNATURE_CHECK (getlogin, char *, (void));
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
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 */
+ || errno == ENXIO
+ );
+#if !defined __hpux /* On HP-UX 11.11 it fails anyway. */
ASSERT (! isatty (0));
+#endif
fprintf (stderr, "Skipping test: stdin is not a tty.\n");
return 77;
}