2011-08-17 Eric Blake <eblake@redhat.com>
+ getcwd: fix test failures on mingw
+ * lib/getcwd.c (__getcwd): Early exit for ERANGE.
+ * tests/test-getcwd.c (test_abort_bug, test_long_name): Don't fail
+ test if long directory cannot be created, and allow mingw errno.
+
getcwd-lgpl: fix m4 to match relaxed test for BSD
* m4/getcwd.m4 (gl_FUNC_GETCWD_NULL): Relax probe.
(gl_FUNC_GETCWD_SIGNATURE): New macro.
# undef getcwd
dir = getcwd (buf, size);
- if (dir)
+ if (dir || (size && errno == ERANGE))
return dir;
/* Solaris getcwd (NULL, 0) fails with errno == EINVAL, but it has
{
if (mkdir (dir_name, S_IRWXU) < 0 || chdir (dir_name) < 0)
{
- fail = 3; /* Unable to construct deep hierarchy. */
+ if (! (errno == ERANGE || errno == ENAMETOOLONG || errno == ENOENT))
+ fail = 3; /* Unable to construct deep hierarchy. */
break;
}
}
results in a failed assertion. */
cwd = getcwd (NULL, 0);
if (cwd == NULL)
- fail = 4; /* getcwd failed. This is ok, and expected. */
+ fail = 4; /* getcwd didn't assert, but it failed for a long name
+ where the answer could have been learned. */
free (cwd);
/* Call rmdir first, in case the above chdir failed. */
errors, be pessimistic and consider that as a failure, too. */
if (mkdir (DIR_NAME, S_IRWXU) < 0 || chdir (DIR_NAME) < 0)
{
- if (! (errno == ERANGE || errno == ENAMETOOLONG))
+ if (! (errno == ERANGE || errno == ENAMETOOLONG || errno == ENOENT))
fail = 20;
break;
}