Discussion:
avoid test errors on WSL
(too old to reply)
Bruno Haible
2018-01-22 04:10:48 UTC
Permalink
Running the gnulib POSIX tests on Microsoft WSL (Windows Subsystem for Linux),
I see only 5 test failures:


FAIL: test-fcntl
================

../../gltests/test-fcntl.c:269: assertion 'errno == EINVAL' failed
FAIL test-fcntl (exit status: 134)

FAIL: test-poll
===============

Unconnected socket test... passed
Connected sockets test... failed (expecting POLLHUP after shutdown)
General socket test with fork... failed (expecting POLLHUP after shutdown)
Pipe test... passed
FAIL test-poll (exit status: 2)

FAIL: test-rename
=================

../../gltests/test-rename.h:342: assertion 'errno == EINVAL || errno == EBUSY || errno == EISDIR || errno == ENOTEMPTY || errno == EEXIST' failed
FAIL test-rename (exit status: 134)

FAIL: test-renameat
===================

../../gltests/test-rename.h:342: assertion 'errno == EINVAL || errno == EBUSY || errno == EISDIR || errno == ENOTEMPTY || errno == EEXIST' failed
FAIL test-renameat (exit status: 134)

FAIL: test-renameat2
====================

../../gltests/test-rename.h:342: assertion 'errno == EINVAL || errno == EBUSY || errno == EISDIR || errno == ENOTEMPTY || errno == EEXIST' failed
FAIL test-renameat2 (exit status: 134)


Which means that this implementation of the Linux kernel interface is quite
mature w.r.t. POSIX compliance.

As usual [1], let's allow the differing errno value here. It's unlikely that
an application will rely on the precise errno values here.

This reduces the number of failing tests to 1.

[1] https://lists.gnu.org/archive/html/bug-gnulib/2010-12/msg00167.html


2018-01-21 Bruno Haible <***@clisp.org>

Avoid test failures on Microsoft Windows Subsystem for Linux.
* tests/test-fcntl.c (main): Allow a different errno.
* tests/test-rename.h (test_rename): Likewise.
* tests/test-renameat.c (main): Likewise.
* tests/test-renameat2.c (main): Likewise.

diff --git a/tests/test-fcntl.c b/tests/test-fcntl.c
index 7e726b1..476231b 100644
--- a/tests/test-fcntl.c
+++ b/tests/test-fcntl.c
@@ -266,7 +266,8 @@ main (void)
ASSERT (errno == EINVAL);
errno = 0;
ASSERT (fcntl (fd, F_DUPFD_CLOEXEC, bad_fd) == -1);
- ASSERT (errno == EINVAL);
+ ASSERT (errno == EINVAL
+ || errno == EMFILE /* WSL */);

/* For F_DUPFD*, check for correct inheritance, as well as
preservation of text vs. binary. */
diff --git a/tests/test-rename.h b/tests/test-rename.h
index f959866..0548c6c 100644
--- a/tests/test-rename.h
+++ b/tests/test-rename.h
@@ -339,12 +339,14 @@ test_rename (int (*func) (char const *, char const *), bool print)
errno = 0;
ASSERT (func (BASE "dir2", BASE "dir/.") == -1);
ASSERT (errno == EINVAL || errno == EBUSY || errno == EISDIR
- || errno == ENOTEMPTY || errno == EEXIST);
+ || errno == ENOTEMPTY || errno == EEXIST
+ || errno == ENOENT /* WSL */);
}
{
errno = 0;
ASSERT (func (BASE "dir2/.", BASE "dir") == -1);
- ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST);
+ ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST
+ || errno == ENOENT /* WSL */);
}
ASSERT (rmdir (BASE "dir") == 0);
/* Files present here:
@@ -366,12 +368,14 @@ test_rename (int (*func) (char const *, char const *), bool print)
errno = 0;
ASSERT (func (BASE "dir2", BASE "dir/.//") == -1);
ASSERT (errno == EINVAL || errno == EBUSY || errno == EISDIR
- || errno == ENOTEMPTY || errno == EEXIST);
+ || errno == ENOTEMPTY || errno == EEXIST
+ || errno == ENOENT /* WSL */);
}
{
errno = 0;
ASSERT (func (BASE "dir2/.//", BASE "dir") == -1);
- ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST);
+ ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST
+ || errno == ENOENT /* WSL */);
}
ASSERT (rmdir (BASE "dir2") == 0);
/* Files present here:
diff --git a/tests/test-renameat.c b/tests/test-renameat.c
index 5496553..d72cd1f 100644
--- a/tests/test-renameat.c
+++ b/tests/test-renameat.c
@@ -155,10 +155,12 @@ main (void)
errno = 0;
ASSERT (renameat (dfd, BASE "sub2", dfd, BASE "sub1/.") == -1);
ASSERT (errno == EINVAL || errno == EISDIR || errno == EBUSY
- || errno == ENOTEMPTY || errno == EEXIST);
+ || errno == ENOTEMPTY || errno == EEXIST
+ || errno == ENOENT /* WSL */);
errno = 0;
ASSERT (renameat (dfd, BASE "sub2/.", dfd, BASE "sub1") == -1);
- ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST);
+ ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST
+ || errno == ENOENT /* WSL */);
errno = 0;
ASSERT (renameat (dfd, BASE "17", dfd, BASE "sub1") == -1);
ASSERT (errno == EISDIR);
diff --git a/tests/test-renameat2.c b/tests/test-renameat2.c
index f646cb6..0104890 100644
--- a/tests/test-renameat2.c
+++ b/tests/test-renameat2.c
@@ -158,10 +158,12 @@ main (void)
errno = 0;
ASSERT (renameat2 (dfd, BASE "sub2", dfd, BASE "sub1/.", 0) == -1);
ASSERT (errno == EINVAL || errno == EISDIR || errno == EBUSY
- || errno == ENOTEMPTY || errno == EEXIST);
+ || errno == ENOTEMPTY || errno == EEXIST
+ || errno == ENOENT /* WSL */);
errno = 0;
ASSERT (renameat2 (dfd, BASE "sub2/.", dfd, BASE "sub1", 0) == -1);
- ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST);
+ ASSERT (errno == EINVAL || errno == EBUSY || errno == EEXIST
+ || errno == ENOENT /* WSL */);
errno = 0;
ASSERT (renameat2 (dfd, BASE "17", dfd, BASE "sub1", 0) == -1);
ASSERT (errno == EISDIR);

Loading...