From 4dab0f7bd213644bdbfe1951da753da7759670e4 Mon Sep 17 00:00:00 2001 From: Edoardo Vacchi Date: Thu, 26 Jan 2023 14:14:03 +0100 Subject: [PATCH 01/11] Allow colorama>=0.4.3 to avoid conflicting constraints on Windows Signed-off-by: Edoardo Vacchi --- test-runner/requirements/common.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-runner/requirements/common.txt b/test-runner/requirements/common.txt index 4ae79866..42f010a6 100644 --- a/test-runner/requirements/common.txt +++ b/test-runner/requirements/common.txt @@ -1 +1 @@ -colorama==0.4.3 +colorama>=0.4.3 From d0a5099470ffeb103d39ebd9487031e244eb000a Mon Sep 17 00:00:00 2001 From: Edoardo Vacchi Date: Thu, 26 Jan 2023 14:15:22 +0100 Subject: [PATCH 02/11] Ensure scripts are runnable on Windows (use `which('bash')`) Signed-off-by: Edoardo Vacchi --- test-runner/wasi_test_runner/runtime_adapter.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test-runner/wasi_test_runner/runtime_adapter.py b/test-runner/wasi_test_runner/runtime_adapter.py index 9a12f290..c21d26f7 100644 --- a/test-runner/wasi_test_runner/runtime_adapter.py +++ b/test-runner/wasi_test_runner/runtime_adapter.py @@ -1,4 +1,5 @@ import subprocess +from shutil import which from pathlib import Path from typing import Dict, NamedTuple, List @@ -13,10 +14,14 @@ class RuntimeVersion(NamedTuple): class RuntimeAdapter: def __init__(self, adapter_path: str) -> None: self._adapter_path = self._abs(adapter_path) + # invoke the adapter with a configured shell runner. Default to bash. + # e.g. this is needed to point GHA's Windows runner to bash executable + self._shell = which('bash') def get_version(self) -> RuntimeVersion: output = ( - subprocess.check_output([self._adapter_path, "--version"], encoding="UTF-8") + # use the configured shell binary + subprocess.check_output([self._shell, self._adapter_path, "--version"], encoding="UTF-8") .strip() .split(" ") ) @@ -31,6 +36,8 @@ def run_test( ) -> Output: args = ( [ + # use the configured shell binary + self._shell, self._adapter_path, "--test-file", self._abs(test_path), From ed881d8478214e88a494cb7b681a36c0642f695c Mon Sep 17 00:00:00 2001 From: Edoardo Vacchi Date: Mon, 6 Feb 2023 16:16:07 +0100 Subject: [PATCH 03/11] Use python adapters --- adapters/runtime_adapter.py | 60 ++++++++++++++++++++++++++++++++++ adapters/wasm-micro-runtime.py | 23 +++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 adapters/runtime_adapter.py create mode 100755 adapters/wasm-micro-runtime.py diff --git a/adapters/runtime_adapter.py b/adapters/runtime_adapter.py new file mode 100644 index 00000000..940c2e2c --- /dev/null +++ b/adapters/runtime_adapter.py @@ -0,0 +1,60 @@ +import subprocess +import sys +from pathlib import Path +from typing import Dict, NamedTuple, List + +from .test_case import Output + + +class RuntimeVersion(NamedTuple): + name: str + version: str + + +class RuntimeAdapter: + def __init__(self, adapter_path: str) -> None: + self._adapter_path = self._abs(adapter_path) + + def get_version(self) -> RuntimeVersion: + output = ( + subprocess.check_output([sys.executable, self._adapter_path, "--version"], encoding="UTF-8") + .strip() + .split(" ") + ) + return RuntimeVersion(output[0], output[1]) + + def run_test( + self, + test_path: str, + args: List[str], + env_variables: Dict[str, str], + dirs: List[str], + ) -> Output: + args = ( + [ + sys.executable, + self._adapter_path, + "--test-file", + self._abs(test_path), + ] + + [a for arg in args for a in ("--arg", arg)] + + [d for dir in dirs for d in ("--dir", dir)] + + [e for env in self._env_to_list(env_variables) for e in ("--env", env)] + ) + + result = subprocess.run( + args, + capture_output=True, + text=True, + check=False, + cwd=Path(test_path).parent, + ) + return Output(result.returncode, result.stdout, result.stderr) + + @staticmethod + def _abs(path: str) -> str: + return str(Path(path).absolute()) + + @staticmethod + def _env_to_list(env: Dict[str, str]) -> List[str]: + return [f"{key}={value}" for key, value in env.items()] diff --git a/adapters/wasm-micro-runtime.py b/adapters/wasm-micro-runtime.py new file mode 100755 index 00000000..a8e73879 --- /dev/null +++ b/adapters/wasm-micro-runtime.py @@ -0,0 +1,23 @@ +import argparse +import subprocess +import sys + +parser = argparse.ArgumentParser() +parser.add_argument('--version', action='store_true') +parser.add_argument('--test-file', action='store') +parser.add_argument('--arg', action='append', default=[]) +parser.add_argument('--env', action='append', default=[]) +parser.add_argument('--dir', action='append', default=[]) + +args = parser.parse_args() + +if args.version: + subprocess.run(['iwasm', '--version']) + sys.exit(0) + +TEST_FILE=args.test_file +PROG_ARGS=args.arg +ENV_ARGS=[f'--env={i}' for i in args.env] +DIR_ARGS=[f'--dir={i}' for i in args.dir] + +sys.exit(subprocess.run(["iwasm"] + ENV_ARGS + DIR_ARGS + [TEST_FILE] + PROG_ARGS).returncode) From 4f1a3e21215b9080fc3926393d42892b08df78c2 Mon Sep 17 00:00:00 2001 From: Edoardo Vacchi Date: Wed, 8 Feb 2023 11:49:54 +0100 Subject: [PATCH 04/11] Windows runner Signed-off-by: Edoardo Vacchi --- adapters/runtime_adapter.py | 60 ------------------- .../wasi_test_runner/runtime_adapter.py | 11 +--- 2 files changed, 3 insertions(+), 68 deletions(-) delete mode 100644 adapters/runtime_adapter.py diff --git a/adapters/runtime_adapter.py b/adapters/runtime_adapter.py deleted file mode 100644 index 940c2e2c..00000000 --- a/adapters/runtime_adapter.py +++ /dev/null @@ -1,60 +0,0 @@ -import subprocess -import sys -from pathlib import Path -from typing import Dict, NamedTuple, List - -from .test_case import Output - - -class RuntimeVersion(NamedTuple): - name: str - version: str - - -class RuntimeAdapter: - def __init__(self, adapter_path: str) -> None: - self._adapter_path = self._abs(adapter_path) - - def get_version(self) -> RuntimeVersion: - output = ( - subprocess.check_output([sys.executable, self._adapter_path, "--version"], encoding="UTF-8") - .strip() - .split(" ") - ) - return RuntimeVersion(output[0], output[1]) - - def run_test( - self, - test_path: str, - args: List[str], - env_variables: Dict[str, str], - dirs: List[str], - ) -> Output: - args = ( - [ - sys.executable, - self._adapter_path, - "--test-file", - self._abs(test_path), - ] - + [a for arg in args for a in ("--arg", arg)] - + [d for dir in dirs for d in ("--dir", dir)] - + [e for env in self._env_to_list(env_variables) for e in ("--env", env)] - ) - - result = subprocess.run( - args, - capture_output=True, - text=True, - check=False, - cwd=Path(test_path).parent, - ) - return Output(result.returncode, result.stdout, result.stderr) - - @staticmethod - def _abs(path: str) -> str: - return str(Path(path).absolute()) - - @staticmethod - def _env_to_list(env: Dict[str, str]) -> List[str]: - return [f"{key}={value}" for key, value in env.items()] diff --git a/test-runner/wasi_test_runner/runtime_adapter.py b/test-runner/wasi_test_runner/runtime_adapter.py index c21d26f7..940c2e2c 100644 --- a/test-runner/wasi_test_runner/runtime_adapter.py +++ b/test-runner/wasi_test_runner/runtime_adapter.py @@ -1,5 +1,5 @@ import subprocess -from shutil import which +import sys from pathlib import Path from typing import Dict, NamedTuple, List @@ -14,14 +14,10 @@ class RuntimeVersion(NamedTuple): class RuntimeAdapter: def __init__(self, adapter_path: str) -> None: self._adapter_path = self._abs(adapter_path) - # invoke the adapter with a configured shell runner. Default to bash. - # e.g. this is needed to point GHA's Windows runner to bash executable - self._shell = which('bash') def get_version(self) -> RuntimeVersion: output = ( - # use the configured shell binary - subprocess.check_output([self._shell, self._adapter_path, "--version"], encoding="UTF-8") + subprocess.check_output([sys.executable, self._adapter_path, "--version"], encoding="UTF-8") .strip() .split(" ") ) @@ -36,8 +32,7 @@ def run_test( ) -> Output: args = ( [ - # use the configured shell binary - self._shell, + sys.executable, self._adapter_path, "--test-file", self._abs(test_path), From 6e537f4719109b20df7e2403d8ccf24eb192974d Mon Sep 17 00:00:00 2001 From: Edoardo Vacchi Date: Sun, 12 Feb 2023 16:04:29 +0100 Subject: [PATCH 05/11] support env var to override adapter executable --- adapters/wasm-micro-runtime.py | 7 +++++-- adapters/wasmtime.py | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100755 adapters/wasmtime.py diff --git a/adapters/wasm-micro-runtime.py b/adapters/wasm-micro-runtime.py index a8e73879..7efa3c58 100755 --- a/adapters/wasm-micro-runtime.py +++ b/adapters/wasm-micro-runtime.py @@ -1,6 +1,9 @@ import argparse import subprocess import sys +import os + +IWASM=os.getenv('TEST_RUNTIME_EXE', 'iwasm') parser = argparse.ArgumentParser() parser.add_argument('--version', action='store_true') @@ -12,7 +15,7 @@ args = parser.parse_args() if args.version: - subprocess.run(['iwasm', '--version']) + subprocess.run([IWASM, '--version']) sys.exit(0) TEST_FILE=args.test_file @@ -20,4 +23,4 @@ ENV_ARGS=[f'--env={i}' for i in args.env] DIR_ARGS=[f'--dir={i}' for i in args.dir] -sys.exit(subprocess.run(["iwasm"] + ENV_ARGS + DIR_ARGS + [TEST_FILE] + PROG_ARGS).returncode) +sys.exit(subprocess.run([IWASM] + ENV_ARGS + DIR_ARGS + [TEST_FILE] + PROG_ARGS).returncode) diff --git a/adapters/wasmtime.py b/adapters/wasmtime.py new file mode 100755 index 00000000..7b087557 --- /dev/null +++ b/adapters/wasmtime.py @@ -0,0 +1,26 @@ +import argparse +import subprocess +import sys +import os + +WASMTIME=os.getenv('TEST_RUNTIME_EXE', 'wasmtime') + +parser = argparse.ArgumentParser() +parser.add_argument('--version', action='store_true') +parser.add_argument('--test-file', action='store') +parser.add_argument('--arg', action='append', default=[]) +parser.add_argument('--env', action='append', default=[]) +parser.add_argument('--dir', action='append', default=[]) + +args = parser.parse_args() + +if args.version: + subprocess.run([WASMTIME, '--version']) + sys.exit(0) + +TEST_FILE=args.test_file +PROG_ARGS=args.arg +ENV_ARGS=[j for i in args.env for j in ["--env", i]] +DIR_ARGS=[j for i in args.dir for j in ["--dir", i]] + +sys.exit(subprocess.run([WASMTIME] + ENV_ARGS + DIR_ARGS + [TEST_FILE] + PROG_ARGS).returncode) From 57a051f38dd5bb313d8da21086f3d2ecb101adda Mon Sep 17 00:00:00 2001 From: Edoardo Vacchi Date: Sun, 12 Feb 2023 16:22:04 +0100 Subject: [PATCH 06/11] use shlex to split the env var --- adapters/wasm-micro-runtime.py | 8 +++++--- adapters/wasmtime.py | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/adapters/wasm-micro-runtime.py b/adapters/wasm-micro-runtime.py index 7efa3c58..b9b53585 100755 --- a/adapters/wasm-micro-runtime.py +++ b/adapters/wasm-micro-runtime.py @@ -2,8 +2,10 @@ import subprocess import sys import os +import shlex -IWASM=os.getenv('TEST_RUNTIME_EXE', 'iwasm') +# shlex.split() splits according to shell quoting rules +IWASM=shlex.split(os.getenv('TEST_RUNTIME_EXE', 'iwasm')) parser = argparse.ArgumentParser() parser.add_argument('--version', action='store_true') @@ -15,7 +17,7 @@ args = parser.parse_args() if args.version: - subprocess.run([IWASM, '--version']) + subprocess.run(IWASM + ['--version']) sys.exit(0) TEST_FILE=args.test_file @@ -23,4 +25,4 @@ ENV_ARGS=[f'--env={i}' for i in args.env] DIR_ARGS=[f'--dir={i}' for i in args.dir] -sys.exit(subprocess.run([IWASM] + ENV_ARGS + DIR_ARGS + [TEST_FILE] + PROG_ARGS).returncode) +sys.exit(subprocess.run(IWASM + ENV_ARGS + DIR_ARGS + [TEST_FILE] + PROG_ARGS).returncode) diff --git a/adapters/wasmtime.py b/adapters/wasmtime.py index 7b087557..99e93ac3 100755 --- a/adapters/wasmtime.py +++ b/adapters/wasmtime.py @@ -2,8 +2,10 @@ import subprocess import sys import os +import shlex -WASMTIME=os.getenv('TEST_RUNTIME_EXE', 'wasmtime') +# shlex.split() splits according to shell quoting rules +WASMTIME=shlex.split(os.getenv('TEST_RUNTIME_EXE', 'wasmtime')) parser = argparse.ArgumentParser() parser.add_argument('--version', action='store_true') @@ -15,7 +17,7 @@ args = parser.parse_args() if args.version: - subprocess.run([WASMTIME, '--version']) + subprocess.run(WASMTIME + ['--version']) sys.exit(0) TEST_FILE=args.test_file @@ -23,4 +25,4 @@ ENV_ARGS=[j for i in args.env for j in ["--env", i]] DIR_ARGS=[j for i in args.dir for j in ["--dir", i]] -sys.exit(subprocess.run([WASMTIME] + ENV_ARGS + DIR_ARGS + [TEST_FILE] + PROG_ARGS).returncode) +sys.exit(subprocess.run(WASMTIME + ENV_ARGS + DIR_ARGS + [TEST_FILE] + PROG_ARGS).returncode) From ed8ebcabd7d144d37bf1b16a65a50e26aedea7aa Mon Sep 17 00:00:00 2001 From: Edoardo Vacchi Date: Sun, 12 Feb 2023 16:22:26 +0100 Subject: [PATCH 07/11] remove shell scripts --- adapters/wasm-micro-runtime.sh | 47 ---------------------------------- adapters/wasmtime.sh | 42 ------------------------------ 2 files changed, 89 deletions(-) delete mode 100755 adapters/wasm-micro-runtime.sh delete mode 100755 adapters/wasmtime.sh diff --git a/adapters/wasm-micro-runtime.sh b/adapters/wasm-micro-runtime.sh deleted file mode 100755 index c500dee3..00000000 --- a/adapters/wasm-micro-runtime.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -# WARNING: this adapter assumes iwasm from the latest wasm-micro-runtime. -# Namely the change to propagate WASI exit code: -# https://github.com/bytecodealliance/wasm-micro-runtime/pull/1748 - -TEST_FILE= -ARGS=() -DIR=() -ENV=() - -IWASM="${TEST_RUNTIME_EXE:-iwasm}" - -while [[ $# -gt 0 ]]; do - case $1 in - --version) - ${IWASM} --version - exit 0 - ;; - --test-file) - TEST_FILE="$2" - shift - shift - ;; - --arg) - ARGS+=("$2") - shift - shift - ;; - --dir) - DIR+=("--dir=$2") - shift - shift - ;; - --env) - ENV+=("--env=$2") - shift - shift - ;; - *) - echo "Unknown option $1" - exit 1 - ;; - esac -done - -${IWASM} "${DIR[@]}" "${ENV[@]}" ${TEST_FILE} "${ARGS[@]}" diff --git a/adapters/wasmtime.sh b/adapters/wasmtime.sh deleted file mode 100755 index 22b2b7cf..00000000 --- a/adapters/wasmtime.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -TEST_FILE= -ARGS=() -PROG_ARGS=() - -WASMTIME="${TEST_RUNTIME_EXE:-wasmtime}" - -while [[ $# -gt 0 ]]; do - case $1 in - --version) - wasmtime -V - exit 0 - ;; - --test-file) - TEST_FILE="$2" - shift - shift - ;; - --arg) - PROG_ARGS+=("$2") - shift - shift - ;; - --env) - ARGS+=("--env" "$2") - shift - shift - ;; - --dir) - ARGS+=("--dir" "$2") - shift - shift - ;; - *) - echo "Unknown option $1" - exit 1 - ;; - esac -done - -$WASMTIME $TEST_FILE "${ARGS[@]}" "${PROG_ARGS[@]}" \ No newline at end of file From efadf112992c63a55c6474215d2a2fc6c6f0f7bb Mon Sep 17 00:00:00 2001 From: Edoardo Vacchi Date: Sun, 12 Feb 2023 16:28:15 +0100 Subject: [PATCH 08/11] formatting --- adapters/wasm-micro-runtime.py | 25 +++++++++++++------------ adapters/wasmtime.py | 25 +++++++++++++------------ 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/adapters/wasm-micro-runtime.py b/adapters/wasm-micro-runtime.py index b9b53585..ed7b49d8 100755 --- a/adapters/wasm-micro-runtime.py +++ b/adapters/wasm-micro-runtime.py @@ -5,24 +5,25 @@ import shlex # shlex.split() splits according to shell quoting rules -IWASM=shlex.split(os.getenv('TEST_RUNTIME_EXE', 'iwasm')) +IWASM = shlex.split(os.getenv("TEST_RUNTIME_EXE", "iwasm")) parser = argparse.ArgumentParser() -parser.add_argument('--version', action='store_true') -parser.add_argument('--test-file', action='store') -parser.add_argument('--arg', action='append', default=[]) -parser.add_argument('--env', action='append', default=[]) -parser.add_argument('--dir', action='append', default=[]) +parser.add_argument("--version", action="store_true") +parser.add_argument("--test-file", action="store") +parser.add_argument("--arg", action="append", default=[]) +parser.add_argument("--env", action="append", default=[]) +parser.add_argument("--dir", action="append", default=[]) args = parser.parse_args() if args.version: - subprocess.run(IWASM + ['--version']) + subprocess.run(IWASM + ["--version"]) sys.exit(0) -TEST_FILE=args.test_file -PROG_ARGS=args.arg -ENV_ARGS=[f'--env={i}' for i in args.env] -DIR_ARGS=[f'--dir={i}' for i in args.dir] +TEST_FILE = args.test_file +PROG_ARGS = args.arg +ENV_ARGS = [f"--env={i}" for i in args.env] +DIR_ARGS = [f"--dir={i}" for i in args.dir] -sys.exit(subprocess.run(IWASM + ENV_ARGS + DIR_ARGS + [TEST_FILE] + PROG_ARGS).returncode) +r = subprocess.run(IWASM + ENV_ARGS + DIR_ARGS + [TEST_FILE] + PROG_ARGS) +sys.exit(r.returncode) diff --git a/adapters/wasmtime.py b/adapters/wasmtime.py index 99e93ac3..ad102a9e 100755 --- a/adapters/wasmtime.py +++ b/adapters/wasmtime.py @@ -5,24 +5,25 @@ import shlex # shlex.split() splits according to shell quoting rules -WASMTIME=shlex.split(os.getenv('TEST_RUNTIME_EXE', 'wasmtime')) +WASMTIME = shlex.split(os.getenv("TEST_RUNTIME_EXE", "wasmtime")) parser = argparse.ArgumentParser() -parser.add_argument('--version', action='store_true') -parser.add_argument('--test-file', action='store') -parser.add_argument('--arg', action='append', default=[]) -parser.add_argument('--env', action='append', default=[]) -parser.add_argument('--dir', action='append', default=[]) +parser.add_argument("--version", action="store_true") +parser.add_argument("--test-file", action="store") +parser.add_argument("--arg", action="append", default=[]) +parser.add_argument("--env", action="append", default=[]) +parser.add_argument("--dir", action="append", default=[]) args = parser.parse_args() if args.version: - subprocess.run(WASMTIME + ['--version']) + subprocess.run(WASMTIME + ["--version"]) sys.exit(0) -TEST_FILE=args.test_file -PROG_ARGS=args.arg -ENV_ARGS=[j for i in args.env for j in ["--env", i]] -DIR_ARGS=[j for i in args.dir for j in ["--dir", i]] +TEST_FILE = args.test_file +PROG_ARGS = args.arg +ENV_ARGS = [j for i in args.env for j in ["--env", i]] +DIR_ARGS = [j for i in args.dir for j in ["--dir", i]] -sys.exit(subprocess.run(WASMTIME + ENV_ARGS + DIR_ARGS + [TEST_FILE] + PROG_ARGS).returncode) +r = subprocess.run(WASMTIME + ENV_ARGS + DIR_ARGS + [TEST_FILE] + PROG_ARGS) +sys.exit(r.returncode) From 167ae9feca50e1c0ce7f7d432b245c10050c2c30 Mon Sep 17 00:00:00 2001 From: Edoardo Vacchi Date: Sun, 12 Feb 2023 16:55:59 +0100 Subject: [PATCH 09/11] ensure wasmtime is invoked without args when version is queried --- adapters/wasmtime.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adapters/wasmtime.py b/adapters/wasmtime.py index ad102a9e..399eedaa 100755 --- a/adapters/wasmtime.py +++ b/adapters/wasmtime.py @@ -17,7 +17,8 @@ args = parser.parse_args() if args.version: - subprocess.run(WASMTIME + ["--version"]) + # ensure no args when version is queried + subprocess.run(WASMTIME[0:1] + ["--version"]) sys.exit(0) TEST_FILE = args.test_file From a97bf4688b61403358e84c37fc5aee775d85e51d Mon Sep 17 00:00:00 2001 From: Edoardo Vacchi Date: Sun, 12 Feb 2023 16:56:13 +0100 Subject: [PATCH 10/11] Update README and docs --- README.md | 6 +++--- doc/adapters.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e5739d00..29e86149 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ python3 -m pip install -r test-runner/requirements.txt python3 test-runner/wasi_test_runner.py \ -t ./tests/assemblyscript/testsuite/ `# path to folders containing .wasm test files` \ ./tests/c/testsuite/ \ - -r adapters/wasmtime.sh # path to a runtime adapter + -r adapters/wasmtime.py # path to a runtime adapter ``` Optionally you can specify test cases to skip with the `--exclude-filter` option. @@ -45,7 +45,7 @@ python3 test-runner/wasi_test_runner.py -t ./tests/assemblyscript/testsuite/ `# path to folders containing .wasm test files` \ ./tests/c/testsuite/ \ --exclude-filter examples/skip.json \ - -r adapters/wasmtime.sh # path to a runtime adapter + -r adapters/wasmtime.py # path to a runtime adapter ``` The default executable in the adapter used for test execution can be @@ -55,7 +55,7 @@ overridden using `TEST_RUNTIME_EXE` variable. This only works with adapters defi ```bash TEST_RUNTIME_EXE="wasmtime --wasm-features all" python3 test-runner/wasi_test_runner.py \ -t ./tests/assemblyscript/testsuite/ \ - -r adapters/wasmtime.sh + -r adapters/wasmtime.py ``` ## Contributing diff --git a/doc/adapters.md b/doc/adapters.md index 86c6f53a..84010f29 100644 --- a/doc/adapters.md +++ b/doc/adapters.md @@ -4,7 +4,7 @@ The test runner is designed to support different types of WebAssembly runtimes. WASI test runner is designed to support as many WASM runtimes as possible, therefore runtime peculiarities aren't hardcoded in the runner. -In order to integrate WASM runtime with a test runner, the user has to provide a `runtime adapter`. It's an executable file that takes command-line arguments and translates them to a runtime call. +In order to integrate WASM runtime with a test runner, the user has to provide a `runtime adapter`. It's a *Python script* that takes command-line arguments and translates them to a runtime call. The reason for using a Python script over a generic "she-bang" executable, is to ensure cross-platform compatibility, such an executable is expected to be a python a script. ## Interface The adapter executable must accept the following command line parameters and execute actions associated with those parameters: @@ -37,14 +37,14 @@ and check if the exit code is equal to `13`. There are also two test cases in As Print runtime version: ```bash -$ ./adapter.sh --version +$ ./adapter.py --version wasmtime-cli 1.0.1 ``` Run WASM module: ```bash -$ ./adapter.sh --arg a1 --arg a2 --env E1=env1 --env E2=env2 --test-file test.wasm +$ ./adapter.py --arg a1 --arg a2 --env E1=env1 --env E2=env2 --test-file test.wasm # Expected to start test.wasm module with E1=env1 and E2=env2 # environment variables defined and arguments a1, a2 passed to # the module. From 522d5b21166c0e633111002887c84dd506f8dfeb Mon Sep 17 00:00:00 2001 From: Edoardo Vacchi Date: Sun, 12 Feb 2023 16:57:57 +0100 Subject: [PATCH 11/11] update GHA to use .py instead .sh adapters --- .github/workflows/daily-runtime-validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/daily-runtime-validation.yml b/.github/workflows/daily-runtime-validation.yml index f21e6b70..ae5096aa 100644 --- a/.github/workflows/daily-runtime-validation.yml +++ b/.github/workflows/daily-runtime-validation.yml @@ -51,7 +51,7 @@ jobs: continue-on-error: true run: | python3 test-runner/wasi_test_runner.py \ - -r ./adapters/${{ matrix.runtime }}.sh \ + -r ./adapters/${{ matrix.runtime }}.py \ --json-output-location results.json \ -t tests/assemblyscript/testsuite \ -t tests/c/testsuite