Add WSL to test fleet

All tests pass now under WSL2. They should pass under WSL1 too, but only
WSL2 is integrated into the test fleet right now. This change also fills
in some gaps in the error numbers.

Fixes #665
This commit is contained in:
Justine Tunney 2022-11-02 06:49:42 -07:00
parent fae0c0286f
commit 14d036b68d
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
43 changed files with 2867 additions and 214 deletions

View file

@ -102,6 +102,9 @@ TEST(diagnose_syscall, getpid) {
// netbsd puts parent pid in edx
// xnu seems to just clobber it!
ASSERT_STREQ("rax rdx rcx r11", _gc(DiffContexts(&x, &y)));
} else if (IsWsl1()) {
// XXX: WSL1 must be emulating SYSCALL instructions.
ASSERT_STREQ("rax rcx", _gc(DiffContexts(&x, &y)));
} else {
ASSERT_STREQ("rax rcx r11", _gc(DiffContexts(&x, &y)));
}
@ -112,6 +115,9 @@ TEST(diagnose_syscall, testWriteSuccess) {
diagnose_syscall(__NR_write, 2, Z, 0, Z, Z, Z, Z, &x, &y);
if (IsFreebsd()) {
ASSERT_STREQ("rax rcx r8 r9 r10 r11", _gc(DiffContexts(&x, &y)));
} else if (IsWsl1()) {
// XXX: WSL1 must be emulating SYSCALL instructions.
ASSERT_STREQ("rax rcx", _gc(DiffContexts(&x, &y)));
} else {
ASSERT_STREQ("rax rcx r11", _gc(DiffContexts(&x, &y)));
}
@ -124,6 +130,9 @@ TEST(diagnose_syscall, testWriteFailed) {
ASSERT_STREQ("rax rcx r8 r9 r10 r11 cf", _gc(DiffContexts(&x, &y)));
} else if (IsBsd()) {
ASSERT_STREQ("rax rcx r11 cf", _gc(DiffContexts(&x, &y)));
} else if (IsWsl1()) {
// XXX: WSL1 must be emulating SYSCALL instructions.
ASSERT_STREQ("rax rcx", _gc(DiffContexts(&x, &y)));
} else {
ASSERT_STREQ("rax rcx r11", _gc(DiffContexts(&x, &y)));
}

View file

@ -199,7 +199,7 @@ TEST(sigaction, autoZombieSlayer) {
ASSERT_NE(-1, (pid = fork()));
if (!pid) _Exit(0);
// XXX: WSL does the wrong thing here.
if (__is_wsl()) usleep(10);
if (IsWsl1()) usleep(10);
ASSERT_SYS(ECHILD, -1, wait(0));
// clean up
ASSERT_SYS(0, 0, sigaction(SIGCHLD, &sa, 0));

View file

@ -326,7 +326,7 @@ TEST(ShowCrashReports, testDivideByZero) {
__die();
}
// XXX: WSL doesn't save and restore x87 registers to ucontext_t
if (!__is_wsl()) {
if (!IsWsl1()) {
if (!strstr(output, "3.141")) {
fprintf(stderr, "ERROR: crash report didn't have fpu register\n%s\n",
_gc(IndentLines(output, -1, 0, 4)));

View file

@ -53,7 +53,8 @@ TEST(sbrk, underflowsEnd_returnsEinval) {
}
TEST(sbrk, giantDelta_returnsEnomem) {
if (IsXnu()) return; // mmap polyfills this but brk doesn't right now
if (IsXnu()) return; // mmap polyfills this but brk doesn't right now
if (IsWsl1()) return; // WSL1 setrlimit() is busted
SPAWN(fork);
struct rlimit rl = {1024 * 1024, 1024 * 1024};
ASSERT_SYS(0, 0, setrlimit(RLIMIT_AS, &rl));

View file

@ -126,8 +126,8 @@ TEST(sendfile, testPositioning) {
ASSERT_EQ(-1, sendfile(4, 5, 0, 6));
ASSERT_TRUE(errno == EINVAL || errno == EPIPE);
errno = 0;
// XXX: WSL clobbers file offset on failure!
if (!__is_wsl()) {
// XXX: WSL1 clobbers file offset on failure!
if (!IsWsl1()) {
ASSERT_EQ(12, GetFileOffset(5));
}
_Exit(0);

View file

@ -22,6 +22,7 @@
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/nt/version.h"
#include "libc/runtime/internal.h"
#include "libc/runtime/runtime.h"
#include "libc/sock/sock.h"
#include "libc/sock/struct/sockaddr.h"
@ -165,7 +166,8 @@ TEST(unix, serverGoesDown_usingSendTo_unlink) { // much easier
ASSERT_SYS(0, 5, sendto(4, "hello", 5, 0, (void *)&addr, len));
ASSERT_SYS(0, 5, read(3, buf, 8));
ASSERT_SYS(0, 0, close(3));
ASSERT_SYS(ECONNREFUSED, -1, sendto(4, "hello", 5, 0, (void *)&addr, len));
ASSERT_SYS(IsWsl1() ? ENOTCONN : ECONNREFUSED, -1,
sendto(4, "hello", 5, 0, (void *)&addr, len));
ASSERT_SYS(0, 0, unlink(addr.sun_path));
ASSERT_SYS(ENOENT, -1, sendto(4, "hello", 5, 0, (void *)&addr, len));
ASSERT_SYS(0, 3, socket(AF_UNIX, SOCK_DGRAM, 0));