Sets up spectest infra for wazevo (#1647)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
This commit is contained in:
@@ -3,7 +3,6 @@ package wazevo
|
||||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"unsafe"
|
||||
|
||||
@@ -118,8 +117,6 @@ func (c *callEngine) CallWithStack(ctx context.Context, paramResultStack []uint6
|
||||
paramResultPtr = ¶mResultStack[0]
|
||||
}
|
||||
|
||||
fmt.Printf("stackGrowCallSequenceAddress ===== %#x\n", c.execCtx.stackGrowCallSequenceAddress)
|
||||
|
||||
entrypoint(c.executable, c.execCtxPtr, c.parent.opaquePtr, paramResultPtr, c.stackTop)
|
||||
for {
|
||||
switch ec := c.execCtx.exitCode; ec & wazevoapi.ExitCodeMask {
|
||||
|
||||
@@ -13,6 +13,8 @@ import (
|
||||
"github.com/tetratelabs/wazero/internal/engine/wazevo"
|
||||
"github.com/tetratelabs/wazero/internal/engine/wazevo/testcases"
|
||||
"github.com/tetratelabs/wazero/internal/filecache"
|
||||
"github.com/tetratelabs/wazero/internal/integration_test/spectest"
|
||||
v1 "github.com/tetratelabs/wazero/internal/integration_test/spectest/v1"
|
||||
"github.com/tetratelabs/wazero/internal/testing/binaryencoding"
|
||||
"github.com/tetratelabs/wazero/internal/testing/require"
|
||||
"github.com/tetratelabs/wazero/internal/wasm"
|
||||
@@ -25,6 +27,16 @@ const (
|
||||
f64 = wasm.ValueTypeF64
|
||||
)
|
||||
|
||||
func TestSpectestV1(t *testing.T) {
|
||||
config := wazero.NewRuntimeConfigCompiler().WithCoreFeatures(api.CoreFeaturesV1)
|
||||
// Configure the new optimizing backend!
|
||||
configureWazevo(config)
|
||||
|
||||
// TODO: adds incrementally one by one as we support more test cases. And eventually remove this
|
||||
// and migrate to integration_test/spectest/v1/spec_test.go by the time when closing https://github.com/tetratelabs/wazero/issues/1496
|
||||
spectest.RunJson(t, v1.Testcases, "binary.json", context.Background(), config)
|
||||
}
|
||||
|
||||
func TestE2E(t *testing.T) {
|
||||
type callCase struct {
|
||||
funcName string // defaults to testcases.ExportedFunctionName
|
||||
|
||||
@@ -909,7 +909,13 @@ func (c *Compiler) lowerOpcode(op wasm.Opcode) {
|
||||
}
|
||||
|
||||
index := state.pop()
|
||||
if labelCount == 0 { // If this br_table is empty, we can just emit the unconditional jump.
|
||||
targetBlk, argNum := state.brTargetArgNumFor(labels[0])
|
||||
args := c.loweringState.nPeekDup(argNum)
|
||||
c.insertJumpToBlock(args, targetBlk)
|
||||
} else {
|
||||
c.lowerBrTable(labels, index)
|
||||
}
|
||||
state.unreachable = true
|
||||
|
||||
case wasm.OpcodeNop:
|
||||
|
||||
@@ -330,7 +330,7 @@ func Run(t *testing.T, testDataFS embed.FS, ctx context.Context, config wazero.R
|
||||
for _, f := range files {
|
||||
filename := f.Name()
|
||||
if strings.HasSuffix(filename, ".json") {
|
||||
jsonfiles = append(jsonfiles, testdataPath(filename))
|
||||
jsonfiles = append(jsonfiles, filename)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,7 +339,13 @@ func Run(t *testing.T, testDataFS embed.FS, ctx context.Context, config wazero.R
|
||||
require.True(t, len(jsonfiles) > 1, "len(jsonfiles)=%d (not greater than one)", len(jsonfiles))
|
||||
|
||||
for _, f := range jsonfiles {
|
||||
raw, err := testDataFS.ReadFile(f)
|
||||
RunJson(t, testDataFS, f, ctx, config)
|
||||
}
|
||||
}
|
||||
|
||||
// RunJson runs the test case described by the given spectest JSON file name in the testDataFS file system.
|
||||
func RunJson(t *testing.T, testDataFS embed.FS, f string, ctx context.Context, config wazero.RuntimeConfig) {
|
||||
raw, err := testDataFS.ReadFile(testdataPath(f))
|
||||
require.NoError(t, err)
|
||||
|
||||
var base testbase
|
||||
@@ -494,7 +500,6 @@ func Run(t *testing.T, testDataFS embed.FS, ctx context.Context, config wazero.R
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// basename avoids filepath.Base to ensure a forward slash is used even in Windows.
|
||||
// See https://pkg.go.dev/embed#hdr-Directives
|
||||
|
||||
@@ -2,8 +2,6 @@ package v1
|
||||
|
||||
import (
|
||||
"embed"
|
||||
|
||||
"github.com/tetratelabs/wazero/api"
|
||||
)
|
||||
|
||||
// Testcases is exported for cross-process file cache tests.
|
||||
@@ -11,6 +9,3 @@ import (
|
||||
//go:embed testdata/*.wasm
|
||||
//go:embed testdata/*.json
|
||||
var Testcases embed.FS
|
||||
|
||||
// EnabledFeatures is exported for cross-process file cache tests.
|
||||
const EnabledFeatures = api.CoreFeaturesV1
|
||||
|
||||
Reference in New Issue
Block a user