projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
setenv: Relax license.
[gnulib.git]
/
tests
/
test-getlogin_r.c
diff --git
a/tests/test-getlogin_r.c
b/tests/test-getlogin_r.c
index
f716ab9
..
68c6812
100644
(file)
--- a/
tests/test-getlogin_r.c
+++ b/
tests/test-getlogin_r.c
@@
-24,6
+24,7
@@
SIGNATURE_CHECK (getlogin_r, int, (char *, size_t));
#include <errno.h>
SIGNATURE_CHECK (getlogin_r, int, (char *, size_t));
#include <errno.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
@@
-35,7
+36,13
@@
main (void)
/* Test with a large enough buffer. */
char buf[1024];
/* Test with a large enough buffer. */
char buf[1024];
- ASSERT (getlogin_r (buf, sizeof (buf)) == 0);
+ if (getlogin_r (buf, sizeof (buf)) != 0)
+ {
+ /* getlogin_r() fails when stdin is not connected to a tty. */
+ ASSERT (! isatty (0));
+ fprintf (stderr, "Skipping test: stdin is not a tty.\n");
+ return 77;
+ }
/* Compare against the value from the environment. */
#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__)
/* Compare against the value from the environment. */
#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__)
@@
-69,5
+76,13
@@
main (void)
ASSERT (getlogin_r (smallbuf, i) == ERANGE);
}
ASSERT (getlogin_r (smallbuf, i) == ERANGE);
}
+ /* Test with a huge buffer. */
+ {
+ static char hugebuf[70000];
+
+ ASSERT (getlogin_r (hugebuf, sizeof (hugebuf)) == 0);
+ ASSERT (strcmp (hugebuf, buf) == 0);
+ }
+
return 0;
}
return 0;
}