dicej / wasi-sockets-tests

Test harness for prototyping support for wasi-sockets in the Rust std library and wasi-libc
4 stars 2 forks source link

wasi-sockets test harness

This is a test harness for prototyping support for wasi-sockets in the Rust std library and wasi-libc.

Note that you can already use wasi-sockets by calling host functions directly from C, Rust, Python, and other languages with Component Model support. What's missing as of this writing is standard library support for those languages, which is what this repository is intended to exercise as progress is made.

Directory structure

Building and running

Prerequisites

In the commands that follow, replace aarch64-apple-darwin with your host platform's target triple, and replace macos with linux or mingw (Windows) as appropriate.

Note that cloning the llvm-project submodule of the rust repo may take a long time.

TODO: Can we speed up the Rust build by excluding tools we don't need?

curl -LO https://github.com/dicej/wasi-sdk/releases/download/wasi-sockets-alpha-5/wasi-sdk-20.46gf3a1f8991535-macos.tar.gz
tar xf wasi-sdk-20.46gf3a1f8991535-macos.tar.gz
export WASI_SDK_PATH=$(pwd)/wasi-sdk-20.46gf3a1f8991535
export WASI_SDK_SYSROOT=$WASI_SDK_PATH/share/wasi-sysroot
cd ..
git clone https://github.com/dicej/rust -b sockets
cd rust
./configure \
    --target=wasm32-wasi,wasm32-unknown-unknown,aarch64-apple-darwin \
    --set=target.wasm32-wasi.wasi-root=$WASI_SDK_SYSROOT \
    --enable-lld \
    --tools=cargo \
    --prefix=$(pwd)/build/install \
    --sysconfdir=$(pwd)/build/etc \
    --set=build.docs=false
./x.py install
rustup toolchain link wasi-sockets build/install
export WASI_SOCKETS_TESTS_TOOLCHAIN=wasi-sockets
cd ..

Once the above is complete, you can switch to the server directory in your clone of this repo and run the tests:

cd server
cargo test --release

All tests should pass. If they don't, please open an issue on this repo.