diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index c9ac559..cd2c8e1 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -22,7 +22,7 @@ jobs: go-version: '1.23.5' - uses: acifani/setup-tinygo@v2 with: - tinygo-version: '0.34.0' + tinygo-version: '0.35.0' - name: Set up Rust uses: actions-rs/toolchain@v1 diff --git a/Makefile b/Makefile index 8330747..adab7a3 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,10 @@ tests: @echo "Executing Go tests" mkdir -p .coverage - go test -v -covermode=count -coverprofile=.coverage/coverage.out ./... + go test -v -covermode=count -coverprofile=.coverage/coverage.out \ + ./engines/wasmer/... \ + ./engines/wasmtime/... \ + ./engines/wazero/... go tool cover -html=.coverage/coverage.out -o .coverage/coverage.html build-wasm: build-as build-example build-go build-rust diff --git a/engine_test.go b/engine_test.go index 70d788d..2347433 100644 --- a/engine_test.go +++ b/engine_test.go @@ -7,7 +7,6 @@ import ( "time" "github.com/wapc/wapc-go" - "github.com/wapc/wapc-go/engines/wasmtime" "github.com/wapc/wapc-go/engines/wazero" ) @@ -15,7 +14,7 @@ var ctx = context.Background() var engines = []wapc.Engine{ // wasmer.Engine(), - wasmtime.Engine(), + // wasmtime.Engine(), wazero.Engine(), } diff --git a/engines/tests/engine.go b/engines/tests/engine.go new file mode 100644 index 0000000..689b26d --- /dev/null +++ b/engines/tests/engine.go @@ -0,0 +1,172 @@ +package tests + +import ( + "context" + "os" + "path/filepath" + "testing" + "time" + + "github.com/wapc/wapc-go" +) + +var ctx = context.Background() + +const TESTDATA_DIR = "../../testdata" + +func TestGuest(t *testing.T, engine wapc.Engine) { + lang := map[string]string{ + "assemblyscript": "as/hello.wasm", + "go": "go/hello.wasm", + "rust": "rust/hello.wasm", + } + t.Run(engine.Name(), func(t *testing.T) { + for l, p := range lang { + t.Run("Module testing with "+l+" Guest", func(t *testing.T) { + // Read .wasm file + guest, err := os.ReadFile(filepath.Join(TESTDATA_DIR, p)) + if err != nil { + t.Errorf("Unable to open test file - %s", err) + } + + // Use these later + callbackCh := make(chan struct{}, 2) + host := func(context.Context, string, string, string, []byte) ([]byte, error) { + callbackCh <- struct{}{} + return []byte(""), nil + } + + payload := []byte("Testing") + + // Create new module with a callback function + m, err := engine.New(ctx, host, guest, &wapc.ModuleConfig{ + Logger: wapc.PrintlnLogger, + Stdout: os.Stdout, + Stderr: os.Stderr, + }) + if err != nil { + t.Errorf("Error creating module - %s", err) + } + defer m.Close(ctx) + + // Instantiate Module + i, err := m.Instantiate(ctx) + if err != nil { + t.Errorf("Error instantiating module - %s", err) + } + defer i.Close(ctx) + + t.Run("Call Successful Function", func(t *testing.T) { + // Call echo function + r, err := i.Invoke(ctx, "echo", payload) + if err != nil { + t.Errorf("Unexpected error when calling wasm module - %s", err) + } + + // Verify payload is returned + if len(r) != len(payload) { + t.Errorf("Unexpected response message, got %s, expected %s", r, payload) + } + + // Verify if callback is called + select { + case <-time.After(5 * time.Second): + t.Errorf("Timeout waiting for callback execution") + case <-callbackCh: + return + } + }) + + t.Run("Call Failing Function", func(t *testing.T) { + // Call nope function + _, err := i.Invoke(ctx, "nope", payload) + if err == nil { + t.Errorf("Expected error when calling failing function, got nil") + } + }) + + t.Run("Call Unregistered Function", func(t *testing.T) { + _, err := i.Invoke(ctx, "404", payload) + if err == nil { + t.Errorf("Expected error when calling unregistered function, got nil") + } + }) + + }) + } + }) +} + +func TestModuleBadBytes(t *testing.T, engine wapc.Engine) { + t.Run(engine.Name(), func(t *testing.T) { + host := wapc.NoOpHostCallHandler + guest := []byte("Do not do this at home kids") + _, err := engine.New(ctx, host, guest, &wapc.ModuleConfig{}) + if err == nil { + t.Errorf("Expected error when creating module with invalid wasm, got nil") + } + }) +} + +func TestModule(t *testing.T, engine wapc.Engine) { + t.Run(engine.Name(), func(t *testing.T) { + host := wapc.NoOpHostCallHandler + // Read .wasm file + guest, err := os.ReadFile(filepath.Join(TESTDATA_DIR, "as/hello.wasm")) + if err != nil { + t.Errorf("Unable to open test file - %s", err) + } + + // Use these later + payload := []byte("Testing") + + // Create new module with a NoOpCallback function + m, err := engine.New(ctx, host, guest, &wapc.ModuleConfig{ + Logger: wapc.PrintlnLogger, + Stdout: os.Stdout, + Stderr: os.Stderr, + }) + if err != nil { + t.Errorf("Error creating module - %s", err) + } + defer m.Close(ctx) + + // Instantiate Module + i, err := m.Instantiate(ctx) + if err != nil { + t.Errorf("Error instantiating module - %s", err) + } + defer i.Close(ctx) + + t.Run("Check MemorySize", func(t *testing.T) { + // Verify implementations didn't mistake size in bytes for page count. + expectedMemorySize := uint32(65536) // 1 page + if i.MemorySize() != expectedMemorySize { + t.Errorf("Unexpected memory size, got %d, expected %d", i.MemorySize(), expectedMemorySize) + } + }) + + t.Run("Call Function", func(t *testing.T) { + // Call echo function + r, err := i.Invoke(ctx, "echo", payload) + if err != nil { + t.Errorf("Unexpected error when calling wasm module - %s", err) + } + + // Verify payload is returned + if len(r) != len(payload) { + t.Errorf("Unexpected response message, got %s, expected %s", r, payload) + } + }) + + i.Close(ctx) + + t.Run("Call Function with Closed Instance", func(t *testing.T) { + // Call echo function + _, err := i.Invoke(ctx, "echo", payload) + if err == nil { + t.Errorf("Expected error when calling wasm module with closed instance") + } + }) + }) +} diff --git a/engines/tests/pool.go b/engines/tests/pool.go new file mode 100644 index 0000000..4fee043 --- /dev/null +++ b/engines/tests/pool.go @@ -0,0 +1,98 @@ +package tests + +import ( + "context" + "os" + "path/filepath" + "testing" + "time" + + "github.com/wapc/wapc-go" +) + +func TestGuestsWithPool(t *testing.T, engine wapc.Engine) { + lang := map[string]string{ + "assemblyscript": "as/hello.wasm", + "go": "go/hello.wasm", + "rust": "rust/hello.wasm", + } + + t.Run(engine.Name(), func(t *testing.T) { + for l, p := range lang { + t.Run("Module testing with "+l+" Guest", func(t *testing.T) { + // Read .wasm file + guest, err := os.ReadFile(filepath.Join(TESTDATA_DIR, p)) + if err != nil { + t.Errorf("Unable to open test file - %s", err) + } + + // Use these later + callbackCh := make(chan struct{}, 2) + host := func(context.Context, string, string, string, []byte) ([]byte, error) { + callbackCh <- struct{}{} + return []byte(""), nil + } + payload := []byte("Testing") + + // Create new module with a callback function + m, err := engine.New(ctx, host, guest, &wapc.ModuleConfig{}) + if err != nil { + t.Errorf("Error creating module - %s", err) + } + defer m.Close(ctx) + + p, err := wapc.NewPool(ctx, m, 10) + if err != nil { + t.Errorf("Error creating module pool - %s", err) + } + defer p.Close(ctx) + + i, err := p.Get(10 * time.Second) + if err != nil { + t.Errorf("Error unable to fetch instance from pool - %s", err) + } + + t.Run("Call Successful Function", func(t *testing.T) { + // Call echo function + r, err := i.Invoke(ctx, "echo", payload) + if err != nil { + t.Errorf("Unexpected error when calling wasm module - %s", err) + } + + // Verify payload is returned + if len(r) != len(payload) { + t.Errorf("Unexpected response message, got %s, expected %s", r, payload) + } + + // Verify if callback is called + select { + case <-time.After(5 * time.Second): + t.Errorf("Timeout waiting for callback execution") + case <-callbackCh: + return + } + }) + + t.Run("Call Failing Function", func(t *testing.T) { + // Call nope function + _, err := i.Invoke(ctx, "nope", payload) + if err == nil { + t.Errorf("Expected error when calling failing function, got nil") + } + }) + + t.Run("Call Unregistered Function", func(t *testing.T) { + _, err := i.Invoke(ctx, "404", payload) + if err == nil { + t.Errorf("Expected error when calling unregistered function, got nil") + } + }) + + err = p.Return(i) + if err != nil { + t.Errorf("Unexpected error when returning instance to pool - %s", err) + } + }) + } + }) +} diff --git a/engines/wasmer/engine_test.go b/engines/wasmer/engine_test.go new file mode 100644 index 0000000..6bc8097 --- /dev/null +++ b/engines/wasmer/engine_test.go @@ -0,0 +1,24 @@ +package wasmer_test + +// import ( +// "testing" + +// "github.com/wapc/wapc-go/engines/tests" +// "github.com/wapc/wapc-go/engines/wasmer" +// ) + +// func TestGuest(t *testing.T) { +// tests.TestGuest(t, wasmer.Engine()) +// } + +// func TestModuleBadBytes(t *testing.T) { +// tests.TestModuleBadBytes(t, wasmer.Engine()) +// } + +// func TestModule(t *testing.T) { +// tests.TestModule(t, wasmer.Engine()) +// } + +// func TestGuestsWithPool(t *testing.T) { +// tests.TestGuestsWithPool(t, wasmer.Engine()) +// } diff --git a/engines/wasmer/go.mod b/engines/wasmer/go.mod new file mode 100644 index 0000000..bdc3565 --- /dev/null +++ b/engines/wasmer/go.mod @@ -0,0 +1,14 @@ +module github.com/wapc/wapc-go/engines/wasmer + +go 1.23.0 + +toolchain go1.23.4 + +require ( + github.com/wapc/wapc-go v0.0.0 + github.com/wasmerio/wasmer-go v1.0.4 +) + +require github.com/Workiva/go-datastructures v1.0.53 // indirect + +replace github.com/wapc/wapc-go => ../.. diff --git a/engines/wasmer/go.sum b/engines/wasmer/go.sum new file mode 100644 index 0000000..21c511c --- /dev/null +++ b/engines/wasmer/go.sum @@ -0,0 +1,38 @@ +github.com/Workiva/go-datastructures v1.0.53 h1:J6Y/52yX10Xc5JjXmGtWoSSxs3mZnGSaq37xZZh7Yig= +github.com/Workiva/go-datastructures v1.0.53/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5BnDuE2Ya2MMGhzP6A= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg= +github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= +github.com/wasmerio/wasmer-go v1.0.4 h1:MnqHoOGfiQ8MMq2RF6wyCeebKOe84G88h5yv+vmxJgs= +github.com/wasmerio/wasmer-go v1.0.4/go.mod h1:0gzVdSfg6pysA6QVp6iVRPTagC6Wq9pOE8J86WKb2Fk= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/engines/wasmtime/engine_test.go b/engines/wasmtime/engine_test.go new file mode 100644 index 0000000..0b12511 --- /dev/null +++ b/engines/wasmtime/engine_test.go @@ -0,0 +1,24 @@ +package wasmtime_test + +// import ( +// "testing" + +// "github.com/wapc/wapc-go/engines/tests" +// "github.com/wapc/wapc-go/engines/wasmtime" +// ) + +// func TestGuest(t *testing.T) { +// tests.TestGuest(t, wasmtime.Engine()) +// } + +// func TestModuleBadBytes(t *testing.T) { +// tests.TestModuleBadBytes(t, wasmtime.Engine()) +// } + +// func TestModule(t *testing.T) { +// tests.TestModule(t, wasmtime.Engine()) +// } + +// func TestGuestsWithPool(t *testing.T) { +// tests.TestGuestsWithPool(t, wasmtime.Engine()) +// } diff --git a/engines/wasmtime/example_test.go b/engines/wasmtime/example_test.go index fb4d526..1d6595a 100644 --- a/engines/wasmtime/example_test.go +++ b/engines/wasmtime/example_test.go @@ -3,32 +3,32 @@ package wasmtime -import ( - "context" - "log" +// import ( +// "context" +// "log" - "github.com/bytecodealliance/wasmtime-go" +// "github.com/bytecodealliance/wasmtime-go" - "github.com/wapc/wapc-go" -) +// "github.com/wapc/wapc-go" +// ) -// This shows how to customize the underlying wasmer engine used by waPC. -func Example_custom() { - // Set up the context used to instantiate the engine. - ctx := context.Background() - cfg := wasmtime.NewConfig() - cfg.SetWasmMemory64(true) - e := EngineWithRuntime(func() (*wasmtime.Engine, error) { - return wasmtime.NewEngineWithConfig(cfg), nil - }) - // Configure waPC to use a specific wasmer feature. +// // This shows how to customize the underlying wasmer engine used by waPC. +// func Example_custom() { +// // Set up the context used to instantiate the engine. +// ctx := context.Background() +// cfg := wasmtime.NewConfig() +// cfg.SetWasmMemory64(true) +// e := EngineWithRuntime(func() (*wasmtime.Engine, error) { +// return wasmtime.NewEngineWithConfig(cfg), nil +// }) +// // Configure waPC to use a specific wasmer feature. - // Instantiate a module normally. - m, err := e.New(ctx, wapc.NoOpHostCallHandler, guest, mc) - if err != nil { - log.Panicf("Error creating module - %v\n", err) - } - defer m.Close(ctx) +// // Instantiate a module normally. +// m, err := e.New(ctx, wapc.NoOpHostCallHandler, guest, mc) +// if err != nil { +// log.Panicf("Error creating module - %v\n", err) +// } +// defer m.Close(ctx) - // Output: -} +// // Output: +// } diff --git a/engines/wasmtime/go.mod b/engines/wasmtime/go.mod new file mode 100644 index 0000000..fba5fdd --- /dev/null +++ b/engines/wasmtime/go.mod @@ -0,0 +1,14 @@ +module github.com/wapc/wapc-go/engines/wasmtime + +go 1.23.0 + +toolchain go1.23.4 + +require ( + github.com/bytecodealliance/wasmtime-go v1.0.0 + github.com/wapc/wapc-go v0.0.0 +) + +require github.com/Workiva/go-datastructures v1.0.53 // indirect + +replace github.com/wapc/wapc-go => ../.. diff --git a/engines/wasmtime/go.sum b/engines/wasmtime/go.sum new file mode 100644 index 0000000..58bcb87 --- /dev/null +++ b/engines/wasmtime/go.sum @@ -0,0 +1,41 @@ +github.com/Workiva/go-datastructures v1.0.53 h1:J6Y/52yX10Xc5JjXmGtWoSSxs3mZnGSaq37xZZh7Yig= +github.com/Workiva/go-datastructures v1.0.53/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5BnDuE2Ya2MMGhzP6A= +github.com/bytecodealliance/wasmtime-go v1.0.0 h1:9u9gqaUiaJeN5IoD1L7egD8atOnTGyJcNp8BhkL9cUU= +github.com/bytecodealliance/wasmtime-go v1.0.0/go.mod h1:jjlqQbWUfVSbehpErw3UoWFndBXRRMvfikYH6KsCwOg= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg= +github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/engines/wasmtime/wasmtime_test.go b/engines/wasmtime/wasmtime_test.go index aec2ece..11b9ee8 100644 --- a/engines/wasmtime/wasmtime_test.go +++ b/engines/wasmtime/wasmtime_test.go @@ -1,98 +1,98 @@ package wasmtime -import ( - "context" - "errors" - "log" - "os" - "testing" - - "github.com/bytecodealliance/wasmtime-go" - - "github.com/wapc/wapc-go" -) - -type testKey struct{} - -// testCtx is an arbitrary, non-default context. Non-nil also prevents linter errors. -var testCtx = context.WithValue(context.Background(), testKey{}, "arbitrary") - -var guest []byte -var mc = &wapc.ModuleConfig{ - Logger: wapc.PrintlnLogger, - Stdout: os.Stdout, - Stderr: os.Stderr, -} - -// TestMain ensures we can read the example wasm prior to running unit tests. -func TestMain(m *testing.M) { - var err error - guest, err = os.ReadFile("../../testdata/go/hello.wasm") - if err != nil { - log.Panicln(err) - } - os.Exit(m.Run()) -} - -func TestEngine_WithEngine(t *testing.T) { - t.Run("ok", func(t *testing.T) { - expected := wasmtime.NewEngine() - - e := EngineWithRuntime(func() (*wasmtime.Engine, error) { - return expected, nil - }) - m, err := e.New(testCtx, wapc.NoOpHostCallHandler, guest, mc) - if err != nil { - t.Errorf("Error creating module - %v", err) - } - defer m.Close(testCtx) - - if have := m.(*Module).engine; have != expected { - t.Errorf("Unexpected engine, have %v, expected %v", have, expected) - } - }) - t.Run("nil not ok", func(t *testing.T) { - expectedErr := "function set by WithEngine returned nil" - e := EngineWithRuntime(func() (*wasmtime.Engine, error) { - return nil, errors.New(expectedErr) - }) - - if _, err := e.New(testCtx, wapc.NoOpHostCallHandler, guest, mc); err.Error() != expectedErr { - t.Errorf("Unexpected error, have %v, expected %v", err, expectedErr) - } - }) -} - -func TestModule_Unwrap(t *testing.T) { - m, err := EngineWithRuntime(DefaultRuntime).New(testCtx, wapc.NoOpHostCallHandler, guest, mc) - if err != nil { - t.Errorf("Error creating module - %v", err) - } - defer m.Close(testCtx) - - mod := m.(*Module) - expected := mod.module - if have := mod.Unwrap(); have != expected { - t.Errorf("Unexpected module, have %v, expected %v", have, expected) - } -} - -func TestInstance_Unwrap(t *testing.T) { - m, err := EngineWithRuntime(DefaultRuntime).New(testCtx, wapc.NoOpHostCallHandler, guest, mc) - if err != nil { - t.Errorf("Error creating module - %v", err) - } - defer m.Close(testCtx) - - i, err := m.Instantiate(testCtx) - if err != nil { - t.Errorf("Error creating instance - %v", err) - } - defer m.Close(testCtx) - - inst := i.(*Instance) - expected := inst.inst - if have := inst.Unwrap(); have != expected { - t.Errorf("Unexpected instance, have %v, expected %v", have, expected) - } -} +// import ( +// "context" +// "errors" +// "log" +// "os" +// "testing" + +// "github.com/bytecodealliance/wasmtime-go" + +// "github.com/wapc/wapc-go" +// ) + +// type testKey struct{} + +// // testCtx is an arbitrary, non-default context. Non-nil also prevents linter errors. +// var testCtx = context.WithValue(context.Background(), testKey{}, "arbitrary") + +// var guest []byte +// var mc = &wapc.ModuleConfig{ +// Logger: wapc.PrintlnLogger, +// Stdout: os.Stdout, +// Stderr: os.Stderr, +// } + +// // TestMain ensures we can read the example wasm prior to running unit tests. +// func TestMain(m *testing.M) { +// var err error +// guest, err = os.ReadFile("../../testdata/go/hello.wasm") +// if err != nil { +// log.Panicln(err) +// } +// os.Exit(m.Run()) +// } + +// func TestEngine_WithEngine(t *testing.T) { +// t.Run("ok", func(t *testing.T) { +// expected := wasmtime.NewEngine() + +// e := EngineWithRuntime(func() (*wasmtime.Engine, error) { +// return expected, nil +// }) +// m, err := e.New(testCtx, wapc.NoOpHostCallHandler, guest, mc) +// if err != nil { +// t.Errorf("Error creating module - %v", err) +// } +// defer m.Close(testCtx) + +// if have := m.(*Module).engine; have != expected { +// t.Errorf("Unexpected engine, have %v, expected %v", have, expected) +// } +// }) +// t.Run("nil not ok", func(t *testing.T) { +// expectedErr := "function set by WithEngine returned nil" +// e := EngineWithRuntime(func() (*wasmtime.Engine, error) { +// return nil, errors.New(expectedErr) +// }) + +// if _, err := e.New(testCtx, wapc.NoOpHostCallHandler, guest, mc); err.Error() != expectedErr { +// t.Errorf("Unexpected error, have %v, expected %v", err, expectedErr) +// } +// }) +// } + +// func TestModule_Unwrap(t *testing.T) { +// m, err := EngineWithRuntime(DefaultRuntime).New(testCtx, wapc.NoOpHostCallHandler, guest, mc) +// if err != nil { +// t.Errorf("Error creating module - %v", err) +// } +// defer m.Close(testCtx) + +// mod := m.(*Module) +// expected := mod.module +// if have := mod.Unwrap(); have != expected { +// t.Errorf("Unexpected module, have %v, expected %v", have, expected) +// } +// } + +// func TestInstance_Unwrap(t *testing.T) { +// m, err := EngineWithRuntime(DefaultRuntime).New(testCtx, wapc.NoOpHostCallHandler, guest, mc) +// if err != nil { +// t.Errorf("Error creating module - %v", err) +// } +// defer m.Close(testCtx) + +// i, err := m.Instantiate(testCtx) +// if err != nil { +// t.Errorf("Error creating instance - %v", err) +// } +// defer m.Close(testCtx) + +// inst := i.(*Instance) +// expected := inst.inst +// if have := inst.Unwrap(); have != expected { +// t.Errorf("Unexpected instance, have %v, expected %v", have, expected) +// } +// } diff --git a/engines/wazero/engine_test.go b/engines/wazero/engine_test.go new file mode 100644 index 0000000..f80346c --- /dev/null +++ b/engines/wazero/engine_test.go @@ -0,0 +1,24 @@ +package wazero_test + +import ( + "testing" + + "github.com/wapc/wapc-go/engines/tests" + "github.com/wapc/wapc-go/engines/wazero" +) + +func TestGuest(t *testing.T) { + tests.TestGuest(t, wazero.Engine()) +} + +func TestModuleBadBytes(t *testing.T) { + tests.TestModuleBadBytes(t, wazero.Engine()) +} + +func TestModule(t *testing.T) { + tests.TestModule(t, wazero.Engine()) +} + +func TestGuestsWithPool(t *testing.T) { + tests.TestGuestsWithPool(t, wazero.Engine()) +} diff --git a/engines/wazero/go.mod b/engines/wazero/go.mod new file mode 100644 index 0000000..97c4f0a --- /dev/null +++ b/engines/wazero/go.mod @@ -0,0 +1,14 @@ +module github.com/wapc/wapc-go/engines/wazero + +go 1.23.0 + +toolchain go1.23.4 + +require ( + github.com/tetratelabs/wazero v1.8.2 + github.com/wapc/wapc-go v0.0.0 +) + +require github.com/Workiva/go-datastructures v1.1.5 // indirect + +replace github.com/wapc/wapc-go => ../.. diff --git a/engines/wazero/go.sum b/engines/wazero/go.sum new file mode 100644 index 0000000..6d48131 --- /dev/null +++ b/engines/wazero/go.sum @@ -0,0 +1,38 @@ +github.com/Workiva/go-datastructures v1.1.5 h1:5YfhQ4ry7bZc2Mc7R0YZyYwpf5c6t1cEFvdAhd6Mkf4= +github.com/Workiva/go-datastructures v1.1.5/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5BnDuE2Ya2MMGhzP6A= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tetratelabs/wazero v1.8.2 h1:yIgLR/b2bN31bjxwXHD8a3d+BogigR952csSDdLYEv4= +github.com/tetratelabs/wazero v1.8.2/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs= +github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg= +github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/engines/wazero/wazero.go b/engines/wazero/wazero.go index 9f6b46d..d7117dc 100644 --- a/engines/wazero/wazero.go +++ b/engines/wazero/wazero.go @@ -11,6 +11,7 @@ import ( "github.com/tetratelabs/wazero/api" "github.com/tetratelabs/wazero/imports/assemblyscript" "github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1" + "github.com/tetratelabs/wazero/sys" "github.com/wapc/wapc-go" ) @@ -22,8 +23,11 @@ const i32 = api.ValueTypeI32 // See https://github.com/WebAssembly/WASI/blob/snapshot-01/design/application-abi.md#current-unstable-abi const functionStart = "_start" +// functionInitialize is the name of the function to initialize the runtime. +const functionInitialize = "_initialize" + // functionInit is the name of the nullary function that initializes waPC. -const functionInit = "wapc_init" +const functionWapcInit = "wapc_init" // functionGuestCall is a callback required to be exported. Below is its signature in WebAssembly 1.0 (MVP) Text Format: // @@ -375,16 +379,24 @@ func (m *Module) Instantiate(ctx context.Context) (wapc.Instance, error) { } // Call any WASI or waPC start functions on instantiate. - funcs := []string{functionStart, functionInit} + funcs := []string{functionStart, functionInitialize, functionWapcInit} for _, f := range funcs { exportedFunc := module.ExportedFunction(f) if exportedFunc != nil { ic := invokeContext{operation: f, guestReq: nil} ictx := newInvokeContext(ctx, &ic) if _, err := exportedFunc.Call(ictx); err != nil { - module.Close(ctx) + if exitErr, ok := err.(*sys.ExitError); ok { + if exitErr.ExitCode() != 0 { + module.Close(ctx) + + return nil, fmt.Errorf("module closed with exit_code(%d)", exitErr.ExitCode()) + } + } else { + module.Close(ctx) - return nil, fmt.Errorf("error calling %s: %v", f, err) + return nil, fmt.Errorf("error calling %s: %v", f, err) + } } } } diff --git a/example/go.mod b/example/go.mod new file mode 100644 index 0000000..8068956 --- /dev/null +++ b/example/go.mod @@ -0,0 +1,20 @@ +module github.com/wapc/wapc-go/example + +go 1.23.0 + +toolchain go1.23.4 + +require ( + github.com/wapc/wapc-go v0.0.0 + github.com/wapc/wapc-go/engines/wazero v0.0.0 +) + +require ( + github.com/Workiva/go-datastructures v1.1.5 // indirect + github.com/tetratelabs/wazero v1.8.2 // indirect +) + +replace ( + github.com/wapc/wapc-go => ../ + github.com/wapc/wapc-go/engines/wazero => ../engines/wazero +) diff --git a/example/go.sum b/example/go.sum new file mode 100644 index 0000000..6d48131 --- /dev/null +++ b/example/go.sum @@ -0,0 +1,38 @@ +github.com/Workiva/go-datastructures v1.1.5 h1:5YfhQ4ry7bZc2Mc7R0YZyYwpf5c6t1cEFvdAhd6Mkf4= +github.com/Workiva/go-datastructures v1.1.5/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5BnDuE2Ya2MMGhzP6A= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tetratelabs/wazero v1.8.2 h1:yIgLR/b2bN31bjxwXHD8a3d+BogigR952csSDdLYEv4= +github.com/tetratelabs/wazero v1.8.2/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs= +github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg= +github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/go.mod b/go.mod index 3752eea..b0bc7c1 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,7 @@ module github.com/wapc/wapc-go -go 1.20 +go 1.23.0 -require ( - github.com/Workiva/go-datastructures v1.1.5 - github.com/bytecodealliance/wasmtime-go v1.0.0 - github.com/tetratelabs/wazero v1.7.3 - github.com/wasmerio/wasmer-go v1.0.4 -) +toolchain go1.23.4 + +require github.com/Workiva/go-datastructures v1.0.53 diff --git a/go.sum b/go.sum index c038411..e828ad6 100644 --- a/go.sum +++ b/go.sum @@ -1,21 +1,15 @@ -github.com/Workiva/go-datastructures v1.1.5 h1:5YfhQ4ry7bZc2Mc7R0YZyYwpf5c6t1cEFvdAhd6Mkf4= -github.com/Workiva/go-datastructures v1.1.5/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5BnDuE2Ya2MMGhzP6A= -github.com/bytecodealliance/wasmtime-go v1.0.0 h1:9u9gqaUiaJeN5IoD1L7egD8atOnTGyJcNp8BhkL9cUU= -github.com/bytecodealliance/wasmtime-go v1.0.0/go.mod h1:jjlqQbWUfVSbehpErw3UoWFndBXRRMvfikYH6KsCwOg= +github.com/Workiva/go-datastructures v1.0.53 h1:J6Y/52yX10Xc5JjXmGtWoSSxs3mZnGSaq37xZZh7Yig= +github.com/Workiva/go-datastructures v1.0.53/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5BnDuE2Ya2MMGhzP6A= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= -github.com/tetratelabs/wazero v1.7.3 h1:PBH5KVahrt3S2AHgEjKu4u+LlDbbk+nsGE3KLucy6Rw= -github.com/tetratelabs/wazero v1.7.3/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg= github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= -github.com/wasmerio/wasmer-go v1.0.4 h1:MnqHoOGfiQ8MMq2RF6wyCeebKOe84G88h5yv+vmxJgs= -github.com/wasmerio/wasmer-go v1.0.4/go.mod h1:0gzVdSfg6pysA6QVp6iVRPTagC6Wq9pOE8J86WKb2Fk= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -38,5 +32,5 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/go.work b/go.work new file mode 100644 index 0000000..eb27177 --- /dev/null +++ b/go.work @@ -0,0 +1,10 @@ +go 1.23.0 + +use ( + . + ./engines/wasmer + ./engines/wasmtime + ./engines/wazero + ./example + ./hello +) \ No newline at end of file diff --git a/go.work.sum b/go.work.sum new file mode 100644 index 0000000..a5ac37b --- /dev/null +++ b/go.work.sum @@ -0,0 +1,5 @@ +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/hello/Makefile b/hello/Makefile index f68b3b4..ec1233c 100644 --- a/hello/Makefile +++ b/hello/Makefile @@ -2,4 +2,4 @@ build: @echo "----------" @echo "Building Go wasm Guest" @echo "----------" - tinygo build -o hello.wasm -scheduler=none --no-debug -target=wasi main.go + tinygo build -o hello.wasm -scheduler=none --no-debug -target=wasip1 -buildmode=c-shared main.go diff --git a/hello/go.mod b/hello/go.mod index 47149c5..52a50d9 100644 --- a/hello/go.mod +++ b/hello/go.mod @@ -1,5 +1,7 @@ module github.com/wapc/wapc-go/hello -go 1.17 +go 1.23.0 + +toolchain go1.23.4 require github.com/wapc/wapc-guest-tinygo v0.3.3 diff --git a/hello/main.go b/hello/main.go index 3679985..bf8b7f9 100644 --- a/hello/main.go +++ b/hello/main.go @@ -6,15 +6,16 @@ import ( wapc "github.com/wapc/wapc-guest-tinygo" ) -func main() { +//go:wasmexport wapc_init +func Initialize() { // Register echo and fail functions wapc.RegisterFunctions(wapc.Functions{ - "hello": hello, + "hello": Hello, }) } -// hello will callback the host and return the payload -func hello(payload []byte) ([]byte, error) { +// Hello will callback the host and return the payload +func Hello(payload []byte) ([]byte, error) { fmt.Println("hello called") // Make a host call to capitalize the name. nameBytes, err := wapc.HostCall("", "example", "capitalize", payload) diff --git a/pool_test.go b/pool_test.go deleted file mode 100644 index 56455b8..0000000 --- a/pool_test.go +++ /dev/null @@ -1,99 +0,0 @@ -package wapc_test - -import ( - "context" - "os" - "testing" - "time" - - "github.com/wapc/wapc-go" -) - -func TestGuestsWithPool(t *testing.T) { - lang := map[string]string{ - "assemblyscript": "as/hello.wasm", - "go": "go/hello.wasm", - "rust": "rust/hello.wasm", - } - - for _, engine := range engines { - t.Run(engine.Name(), func(t *testing.T) { - for l, p := range lang { - t.Run("Module testing with "+l+" Guest", func(t *testing.T) { - // Read .wasm file - guest, err := os.ReadFile("testdata/" + p) - if err != nil { - t.Errorf("Unable to open test file - %s", err) - } - - // Use these later - callbackCh := make(chan struct{}, 2) - host := func(context.Context, string, string, string, []byte) ([]byte, error) { - callbackCh <- struct{}{} - return []byte(""), nil - } - payload := []byte("Testing") - - // Create new module with a callback function - m, err := engine.New(ctx, host, guest, &wapc.ModuleConfig{}) - if err != nil { - t.Errorf("Error creating module - %s", err) - } - defer m.Close(ctx) - - p, err := wapc.NewPool(ctx, m, 10) - if err != nil { - t.Errorf("Error creating module pool - %s", err) - } - defer p.Close(ctx) - - i, err := p.Get(10 * time.Second) - if err != nil { - t.Errorf("Error unable to fetch instance from pool - %s", err) - } - - t.Run("Call Successful Function", func(t *testing.T) { - // Call echo function - r, err := i.Invoke(ctx, "echo", payload) - if err != nil { - t.Errorf("Unexpected error when calling wasm module - %s", err) - } - - // Verify payload is returned - if len(r) != len(payload) { - t.Errorf("Unexpected response message, got %s, expected %s", r, payload) - } - - // Verify if callback is called - select { - case <-time.After(5 * time.Second): - t.Errorf("Timeout waiting for callback execution") - case <-callbackCh: - return - } - }) - - t.Run("Call Failing Function", func(t *testing.T) { - // Call nope function - _, err := i.Invoke(ctx, "nope", payload) - if err == nil { - t.Errorf("Expected error when calling failing function, got nil") - } - }) - - t.Run("Call Unregistered Function", func(t *testing.T) { - _, err := i.Invoke(ctx, "404", payload) - if err == nil { - t.Errorf("Expected error when calling unregistered function, got nil") - } - }) - - err = p.Return(i) - if err != nil { - t.Errorf("Unexpected error when returning instance to pool - %s", err) - } - }) - } - }) - } -} diff --git a/testdata/as/package-lock.json b/testdata/as/package-lock.json index d1d82b0..d94be63 100644 --- a/testdata/as/package-lock.json +++ b/testdata/as/package-lock.json @@ -12,7 +12,7 @@ "@wapc/as-guest": "^v0.3.1" }, "devDependencies": { - "assemblyscript": "^0.20.13" + "assemblyscript": "^0.27.31" } }, "node_modules/@wapc/as-guest": { @@ -21,38 +21,45 @@ "integrity": "sha512-RftwLaQTB9GPX5Nu/sKoPcTP4sxmUYYqdMLRhi9xBj14SK7rP3EP2wvIbnSga4xBBdyXvd8v5Tsq7bfAj5BhSA==" }, "node_modules/assemblyscript": { - "version": "0.20.13", - "resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.20.13.tgz", - "integrity": "sha512-F4ACXdBdXCBnPEzRCl/ovFFPGmKXQPvWW4cM6U21eRezaCoREqxA0hjSUOYTz7txY3MJclyBfjwMSEJ5e9HKsw==", + "version": "0.27.31", + "resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.27.31.tgz", + "integrity": "sha512-Ra8kiGhgJQGZcBxjtMcyVRxOEJZX64kd+XGpjWzjcjgxWJVv+CAQO0aDBk4GQVhjYbOkATarC83mHjAVGtwPBQ==", "dev": true, + "license": "Apache-2.0", "dependencies": { - "binaryen": "108.0.0-nightly.20220528", - "long": "^5.2.0" + "binaryen": "116.0.0-nightly.20240114", + "long": "^5.2.1" }, "bin": { "asc": "bin/asc.js", "asinit": "bin/asinit.js" }, + "engines": { + "node": ">=16", + "npm": ">=7" + }, "funding": { "type": "opencollective", "url": "https://opencollective.com/assemblyscript" } }, "node_modules/binaryen": { - "version": "108.0.0-nightly.20220528", - "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-108.0.0-nightly.20220528.tgz", - "integrity": "sha512-9biG357fx3NXmJNotIuY9agZBcCNHP7d1mgOGaTlPYVHZE7/61lt1IyHCXAL+W5jUOYgmFZ260PR4IbD19RKuA==", + "version": "116.0.0-nightly.20240114", + "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-116.0.0-nightly.20240114.tgz", + "integrity": "sha512-0GZrojJnuhoe+hiwji7QFaL3tBlJoA+KFUN7ouYSDGZLSo9CKM8swQX8n/UcbR0d1VuZKU+nhogNzv423JEu5A==", "dev": true, + "license": "Apache-2.0", "bin": { "wasm-opt": "bin/wasm-opt", "wasm2js": "bin/wasm2js" } }, "node_modules/long": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/long/-/long-5.2.0.tgz", - "integrity": "sha512-9RTUNjK60eJbx3uz+TEGF7fUr29ZDxR5QzXcyDpeSfeH28S9ycINflOgOlppit5U+4kNTe83KQnMEerw7GmE8w==", - "dev": true + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/long/-/long-5.2.4.tgz", + "integrity": "sha512-qtzLbJE8hq7VabR3mISmVGtoXP8KGc2Z/AT8OuqlYD7JTR3oqrgwdjnk07wpj1twXxYmgDXgoKVWUG/fReSzHg==", + "dev": true, + "license": "Apache-2.0" } }, "dependencies": { @@ -62,25 +69,25 @@ "integrity": "sha512-RftwLaQTB9GPX5Nu/sKoPcTP4sxmUYYqdMLRhi9xBj14SK7rP3EP2wvIbnSga4xBBdyXvd8v5Tsq7bfAj5BhSA==" }, "assemblyscript": { - "version": "0.20.13", - "resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.20.13.tgz", - "integrity": "sha512-F4ACXdBdXCBnPEzRCl/ovFFPGmKXQPvWW4cM6U21eRezaCoREqxA0hjSUOYTz7txY3MJclyBfjwMSEJ5e9HKsw==", + "version": "0.27.31", + "resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.27.31.tgz", + "integrity": "sha512-Ra8kiGhgJQGZcBxjtMcyVRxOEJZX64kd+XGpjWzjcjgxWJVv+CAQO0aDBk4GQVhjYbOkATarC83mHjAVGtwPBQ==", "dev": true, "requires": { - "binaryen": "108.0.0-nightly.20220528", - "long": "^5.2.0" + "binaryen": "116.0.0-nightly.20240114", + "long": "^5.2.1" } }, "binaryen": { - "version": "108.0.0-nightly.20220528", - "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-108.0.0-nightly.20220528.tgz", - "integrity": "sha512-9biG357fx3NXmJNotIuY9agZBcCNHP7d1mgOGaTlPYVHZE7/61lt1IyHCXAL+W5jUOYgmFZ260PR4IbD19RKuA==", + "version": "116.0.0-nightly.20240114", + "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-116.0.0-nightly.20240114.tgz", + "integrity": "sha512-0GZrojJnuhoe+hiwji7QFaL3tBlJoA+KFUN7ouYSDGZLSo9CKM8swQX8n/UcbR0d1VuZKU+nhogNzv423JEu5A==", "dev": true }, "long": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/long/-/long-5.2.0.tgz", - "integrity": "sha512-9RTUNjK60eJbx3uz+TEGF7fUr29ZDxR5QzXcyDpeSfeH28S9ycINflOgOlppit5U+4kNTe83KQnMEerw7GmE8w==", + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/long/-/long-5.2.4.tgz", + "integrity": "sha512-qtzLbJE8hq7VabR3mISmVGtoXP8KGc2Z/AT8OuqlYD7JTR3oqrgwdjnk07wpj1twXxYmgDXgoKVWUG/fReSzHg==", "dev": true } } diff --git a/testdata/as/package.json b/testdata/as/package.json index 251b805..c316a5c 100644 --- a/testdata/as/package.json +++ b/testdata/as/package.json @@ -11,7 +11,6 @@ "@wapc/as-guest": "^v0.3.1" }, "devDependencies": { - "assemblyscript": "Note: assemblyscript version must match @wapc/as-guest", - "assemblyscript": "^0.20.13" + "assemblyscript": "^0.27.31" } } diff --git a/testdata/go/Makefile b/testdata/go/Makefile index f68b3b4..ec1233c 100644 --- a/testdata/go/Makefile +++ b/testdata/go/Makefile @@ -2,4 +2,4 @@ build: @echo "----------" @echo "Building Go wasm Guest" @echo "----------" - tinygo build -o hello.wasm -scheduler=none --no-debug -target=wasi main.go + tinygo build -o hello.wasm -scheduler=none --no-debug -target=wasip1 -buildmode=c-shared main.go diff --git a/testdata/go/go.mod b/testdata/go/go.mod index eb8fc7f..fb11c3a 100644 --- a/testdata/go/go.mod +++ b/testdata/go/go.mod @@ -1,5 +1,7 @@ module github.com/wapc/wapc-go/testdata/go -go 1.17 +go 1.23.0 + +toolchain go1.23.4 require github.com/wapc/wapc-guest-tinygo v0.3.3 diff --git a/testdata/go/main.go b/testdata/go/main.go index 570043a..ef7e7c0 100644 --- a/testdata/go/main.go +++ b/testdata/go/main.go @@ -6,22 +6,23 @@ import ( wapc "github.com/wapc/wapc-guest-tinygo" ) -func main() { +//go:wasmexport wapc_init +func Initialize() { // Register echo and fail functions wapc.RegisterFunctions(wapc.Functions{ - "echo": echo, - "nope": fail, + "echo": Echo, + "nope": Fail, }) } -// echo will callback the host and return the payload -func echo(payload []byte) ([]byte, error) { +// Echo will callback the host and return the payload +func Echo(payload []byte) ([]byte, error) { // Callback with Payload wapc.HostCall("wapc", "testing", "echo", payload) return payload, nil } -// fail will return an error when called -func fail(payload []byte) ([]byte, error) { +// Fail will return an error when called +func Fail(payload []byte) ([]byte, error) { return []byte(""), fmt.Errorf("Planned Failure") } diff --git a/testdata/rust/Cargo.lock b/testdata/rust/Cargo.lock index e2609df..2cfa23a 100644 --- a/testdata/rust/Cargo.lock +++ b/testdata/rust/Cargo.lock @@ -10,9 +10,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" -version = "1.3.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "cfg-if" @@ -20,15 +20,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - [[package]] name = "libc" version = "0.2.126" @@ -53,34 +44,32 @@ checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" [[package]] name = "parking_lot" -version = "0.11.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ - "instant", "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.8.5" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", - "instant", "libc", "redox_syscall", "smallvec", - "winapi", + "windows-targets", ] [[package]] name = "redox_syscall" -version = "0.2.13" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ "bitflags", ] @@ -106,32 +95,74 @@ checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" [[package]] name = "wapc-guest" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d55cfd1e7647db9da8b283424bb2b24aa9c470dbe18991d0126f83aa085851" +checksum = "57b7619cdb37b84600569a46fe2e9ded4b5a68acc394efbe40092fb63ff2808c" dependencies = [ "once_cell", "parking_lot", ] [[package]] -name = "winapi" -version = "0.3.9" +name = "windows-targets" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "windows_x86_64_msvc" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/testdata/rust/Cargo.toml b/testdata/rust/Cargo.toml index 67a176b..6a56eee 100644 --- a/testdata/rust/Cargo.toml +++ b/testdata/rust/Cargo.toml @@ -7,4 +7,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -wapc-guest = "1.0.0" +wapc-guest = "1.1.0"