Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to new wasmtime CLI flags #194

Merged
merged 1 commit into from
Jan 8, 2024
Merged
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
2 changes: 1 addition & 1 deletion Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG WAMR_VERSION=1.3.0
ARG WASMEDGE_VERSION=0.13.5
ARG GOLANG_VERSION=1.21.5
ARG WASMER_VERSION=v4.2.5
ARG WASMTIME_VERSION=13.0.0
ARG WASMTIME_VERSION=16.0.0

FROM docker:${DOCKER_VERSION}-dind AS dind
FROM docker/buildx-bin:${BUILDX_VERSION} AS buildx
Expand Down
18 changes: 12 additions & 6 deletions cmd/c2w-net/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ func main() {
var portFlags sliceFlags
flag.Var(&portFlags, "p", "map port between host and guest (host:guest). -mac must be set correctly.")
var (
debug = flag.Bool("debug", false, "enable debug print")
listenWS = flag.Bool("listen-ws", false, "listen on a websocket port specified as argument")
invoke = flag.Bool("invoke", false, "invoke the container with NW support")
mac = flag.String("mac", vmMAC, "mac address assigned to the container")
wasiAddr = flag.String("wasi-addr", "127.0.0.1:1234", "IP address used to communicate between wasi and network stack (valid only with invoke flag)") // TODO: automatically use empty random port or unix socket
debug = flag.Bool("debug", false, "enable debug print")
listenWS = flag.Bool("listen-ws", false, "listen on a websocket port specified as argument")
invoke = flag.Bool("invoke", false, "invoke the container with NW support")
mac = flag.String("mac", vmMAC, "mac address assigned to the container")
wasiAddr = flag.String("wasi-addr", "127.0.0.1:1234", "IP address used to communicate between wasi and network stack (valid only with invoke flag)") // TODO: automatically use empty random port or unix socket
wasmtimeCli13 = flag.Bool("wasmtime-cli-13", false, "Use old wasmtime CLI (<= 13)")
)
flag.Parse()
args := flag.Args()
Expand Down Expand Up @@ -93,7 +94,12 @@ func main() {
fmt.Fprintf(os.Stderr, "failed AcceptQemu: %v\n", err)
}
}()
cmd := exec.Command("wasmtime", append([]string{"run", "--tcplisten=" + *wasiAddr, "--env='LISTEN_FDS=1'", "--"}, args...)...)
var cmd *exec.Cmd
if *wasmtimeCli13 {
cmd = exec.Command("wasmtime", append([]string{"run", "--tcplisten=" + *wasiAddr, "--env='LISTEN_FDS=1'", "--"}, args...)...)
} else {
cmd = exec.Command("wasmtime", append([]string{"run", "-S", "preview2=n", "-S", "tcplisten=" + *wasiAddr, "--env='LISTEN_FDS=1'", "--"}, args...)...)
}
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/wasmtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestWasmtime(t *testing.T) {
assert.NilError(t, os.Remove(mapdirTestDir))
},
RuntimeOpts: func(t *testing.T, workdir string) []string {
return []string{"--mapdir=/mapped/dir/test::" + filepath.Join(workdir, "wasmtime-mapdirtest")}
return []string{"--dir=" + filepath.Join(workdir, "wasmtime-mapdirtest") + "::/mapped/dir/test"}
},
Args: utils.StringFlags("cat", "/mapped/dir/test/hi"),
Want: utils.WantString("teststring"),
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestWasmtime(t *testing.T) {
},
Runtime: "wasmtime",
RuntimeOpts: func(t *testing.T, workdir string) []string {
return []string{"--mapdir=/mapped/dir/test::" + filepath.Join(workdir, "wasmtime-mapdirtest-io")}
return []string{"--dir=" + filepath.Join(workdir, "wasmtime-mapdirtest-io") + "::/mapped/dir/test"}
},
Args: utils.StringFlags("sh"),
Want: utils.WantPrompt("/ # ",
Expand Down
Loading