Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/wasix/tests/wasm_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
//! The harness also sets `WASMER_BACKEND` to the engine name (`cranelift`, `v8`,
//! etc.) before every build so shell scripts can tune compile-time parameters per backend.
//!
//! It also sets `WASMER_HOST_OS` to the host operating system (`macOS`, `Linux`,
//! or `Windows`) before every build, so `build.sh` scripts can tune compile-time
//! parameters (e.g. via `-D` defines) per host OS.
//!
//! `Env:{key}={value}` sets an environment variable before running.
//!
//! `ExpectedStdout:{line}` appends one expected stdout line.
Expand Down Expand Up @@ -655,6 +659,16 @@ fn rustc_command(toolchain: Option<&str>) -> Command {
}
}

fn host_os_name() -> &'static str {
if cfg!(target_os = "macos") {
"macOS"
} else if cfg!(target_os = "windows") {
"Windows"
} else {
"Linux"
}
}

fn run_build_script(config: &Config) -> anyhow::Result<PathBuf> {
// First, copy the test source directory to the 'build' subfolder that will
// be unique for each configuration of a test.
Expand Down Expand Up @@ -720,6 +734,7 @@ fn run_build_script(config: &Config) -> anyhow::Result<PathBuf> {
cmd.env(k, v);
}
cmd.env("WASMER_BACKEND", config.engine.name());
cmd.env("WASMER_HOST_OS", host_os_name());
let output = cmd.output()?;

if !output.status.success() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//#ExpectedStdout: stream TCP writev returns partial success after peer close
//#Ignored: flaky test (#6785)

/*
* Regression test for stream-socket fd_write partial success.
*
Expand Down
12 changes: 12 additions & 0 deletions lib/wasix/tests/wasm_tests/socket/udp-large-recv/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
##ExpectedStdout: large UDP datagram receive works
set -euo pipefail

# macOS's loopback interface has a 16KiB MTU and does not fragment oversized
# UDP datagrams (unlike Linux's 64KiB loopback MTU), so shrink the payload.
PAYLOAD_SIZE=20480
if [ "${WASMER_HOST_OS:-}" = "macOS" ]; then
PAYLOAD_SIZE=8192
fi

$CC main.c -o main -DPAYLOAD_SIZE="$PAYLOAD_SIZE"
5 changes: 1 addition & 4 deletions lib/wasix/tests/wasm_tests/socket/udp-large-recv/main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//#ExpectedStdout: large UDP datagram receive works

#include <arpa/inet.h>
#include <errno.h>
#include <stdint.h>
Expand All @@ -8,8 +6,7 @@
#include <sys/socket.h>
#include <unistd.h>

#define PAYLOAD_SIZE 20480

// build.sh passes -DPAYLOAD_SIZE based on $WASMER_HOST_OS.
static uint8_t sendbuf[PAYLOAD_SIZE];
static uint8_t recvbuf[PAYLOAD_SIZE];

Expand Down
Loading