Skip to content

Commit

Permalink
Migrate to new wasmtime CLI flags
Browse files Browse the repository at this point in the history
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
  • Loading branch information
ktock committed Jan 6, 2024
1 parent d05d697 commit 581e62b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
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.4
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") + "::/mapped/dir/test"}
},
Args: utils.StringFlags("sh"),
Want: utils.WantPrompt("/ # ",
Expand Down

0 comments on commit 581e62b

Please sign in to comment.