projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
install-reloc: Support multi-binary installation.
[gnulib.git]
/
tests
/
test-getcwd-lgpl.c
diff --git
a/tests/test-getcwd-lgpl.c
b/tests/test-getcwd-lgpl.c
index
67ee66d
..
e3e7b7a
100644
(file)
--- a/
tests/test-getcwd-lgpl.c
+++ b/
tests/test-getcwd-lgpl.c
@@
-1,5
+1,5
@@
/* Test of getcwd() function.
/* Test of getcwd() function.
- Copyright (C) 2009-201
1
Free Software Foundation, Inc.
+ Copyright (C) 2009-201
3
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
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
@@
-65,12
+65,22
@@
main (int argc, char **argv)
pwd2 = malloc (len + 2);
for ( ; i <= len; i++)
{
pwd2 = malloc (len + 2);
for ( ; i <= len; i++)
{
+ char *tmp;
errno = 0;
ASSERT (getcwd (pwd2, i) == NULL);
ASSERT (errno == ERANGE);
errno = 0;
ASSERT (getcwd (pwd2, i) == NULL);
ASSERT (errno == ERANGE);
+ /* Allow either glibc or BSD behavior, since POSIX allows both. */
errno = 0;
errno = 0;
- ASSERT (getcwd (NULL, i) == NULL);
- ASSERT (errno == ERANGE);
+ tmp = getcwd (NULL, i);
+ if (tmp)
+ {
+ ASSERT (strcmp (pwd1, tmp) == 0);
+ free (tmp);
+ }
+ else
+ {
+ ASSERT (errno == ERANGE);
+ }
}
ASSERT (getcwd (pwd2, len + 1) == pwd2);
pwd2[len] = '/';
}
ASSERT (getcwd (pwd2, len + 1) == pwd2);
pwd2[len] = '/';
@@
-80,6
+90,11
@@
main (int argc, char **argv)
ASSERT (strstr (pwd2, "/../") == NULL);
ASSERT (strstr (pwd2 + 1 + (pwd2[1] == '/'), "//") == NULL);
ASSERT (strstr (pwd2, "/../") == NULL);
ASSERT (strstr (pwd2 + 1 + (pwd2[1] == '/'), "//") == NULL);
+ /* Validate a POSIX requirement on size. */
+ errno = 0;
+ ASSERT (getcwd(pwd2, 0) == NULL);
+ ASSERT (errno == EINVAL);
+
free (pwd1);
free (pwd2);
free (pwd1);
free (pwd2);