Skip to content

Commit

Permalink
Add spectests for Wasm threads proposal
Browse files Browse the repository at this point in the history
Signed-off-by: Anuraag Agrawal <[email protected]>
  • Loading branch information
anuraaga committed Jan 5, 2024
1 parent 312eb11 commit f644a97
Show file tree
Hide file tree
Showing 57 changed files with 986 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ spectest_v2_dir := $(spectest_base_dir)/v2
spectest_v2_testdata_dir := $(spectest_v2_dir)/testdata
# Latest draft state as of May 23, 2023.
spec_version_v2 := 2e8912e88a3118a46b90e8ccb659e24b4e8f3c23
spectest_threads_dir := $(spectest_base_dir)/threads
spectest_threads_testdata_dir := $(spectest_threads_dir)/testdata
# From https://github.com/WebAssembly/threads/tree/upstream-rebuild which has not been merged to main yet.
# It will likely be renamed to main in the future - https://github.com/WebAssembly/threads/issues/216.
spec_version_threads := 3635ca51a17e57e106988846c5b0e0cc48ac04fc

.PHONY: build.spectest
build.spectest:
Expand Down Expand Up @@ -165,6 +170,17 @@ build.spectest.v2: # Note: SIMD cases are placed in the "simd" subdirectory.
wast2json --debug-names --no-check $$f; \
done

# Note: We currently cannot build the "threads" subdirectory that spawns threads due to missing support in wast2json.
# https://github.com/WebAssembly/wabt/issues/2348#issuecomment-1878003959
.PHONY: build.spectest.threads
build.spectest.threads:
@mkdir -p $(spectest_threads_testdata_dir)
@cd $(spectest_threads_testdata_dir) \
&& curl -sSL 'https://api.github.com/repos/WebAssembly/threads/contents/test/core?ref=$(spec_version_threads)' | jq -r '.[]| .download_url' | grep -E "atomic.wast" | xargs -Iurl curl -sJL url -O
@cd $(spectest_threads_testdata_dir) && for f in `find . -name '*.wast'`; do \
wast2json --enable-threads --debug-names $$f; \
done

.PHONY: test
test:
@go test $(go_test_options) $$(go list ./... | grep -vE '$(spectest_v1_dir)|$(spectest_v2_dir)')
Expand Down
31 changes: 31 additions & 0 deletions internal/integration_test/spectest/threads/spec_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package spectest

import (
"context"
"embed"
"testing"

"github.com/tetratelabs/wazero"
"github.com/tetratelabs/wazero/api"
"github.com/tetratelabs/wazero/internal/integration_test/spectest"
"github.com/tetratelabs/wazero/internal/platform"
)

//go:embed testdata/*.wasm
//go:embed testdata/*.json
var testcases embed.FS

const enabledFeatures = api.CoreFeaturesV2 // TODO: Enable threads feature after implementing interpreter support

func TestCompiler(t *testing.T) {
t.Skip() // TODO: Delete after implementing compiler support
if !platform.CompilerSupported() {
t.Skip()
}
spectest.Run(t, testcases, context.Background(), wazero.NewRuntimeConfigCompiler().WithCoreFeatures(enabledFeatures))
}

func TestInterpreter(t *testing.T) {
t.Skip() // TODO: Delete after implementing interpreter support
spectest.Run(t, testcases, context.Background(), wazero.NewRuntimeConfigInterpreter().WithCoreFeatures(enabledFeatures))
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
329 changes: 329 additions & 0 deletions internal/integration_test/spectest/threads/testdata/atomic.json

Large diffs are not rendered by default.

610 changes: 610 additions & 0 deletions internal/integration_test/spectest/threads/testdata/atomic.wast

Large diffs are not rendered by default.

0 comments on commit f644a97

Please sign in to comment.