From 0677288f2216dfef86fed6d85bbd110ab668bd27 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 22 Sep 2023 09:57:48 +0900 Subject: [PATCH] run_wasi_tests.sh: Provide stdin by ourselves (#2576) This improves test consistency between typical local environments and github runners. This is necessary for some of latest wasi-threads tests. cf. https://github.com/yamt/toywasm/commit/570e6706312cbdccb9d5268347186b441a24444b --- .../wamr-test-suites/wasi-test-script/pipe.py | 19 +++++++++++++++++++ .../wasi-test-script/run_wasi_tests.sh | 7 +++++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 tests/wamr-test-suites/wasi-test-script/pipe.py diff --git a/tests/wamr-test-suites/wasi-test-script/pipe.py b/tests/wamr-test-suites/wasi-test-script/pipe.py new file mode 100644 index 00000000..e3740871 --- /dev/null +++ b/tests/wamr-test-suites/wasi-test-script/pipe.py @@ -0,0 +1,19 @@ +#! /usr/bin/env python3 + +# Copyright (C) 2023 YAMAMOTO Takashi +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# This is a copy of https://github.com/yamt/toywasm/blob/master/test/pipe.py + +# keep stdout open until the peer closes it + +import sys +import select + +p = select.poll() +p.register(sys.stdout, select.POLLHUP) +# http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57369 +while True: + l = p.poll(1) + if l: + break diff --git a/tests/wamr-test-suites/wasi-test-script/run_wasi_tests.sh b/tests/wamr-test-suites/wasi-test-script/run_wasi_tests.sh index 37607859..03ad9e27 100755 --- a/tests/wamr-test-suites/wasi-test-script/run_wasi_tests.sh +++ b/tests/wamr-test-suites/wasi-test-script/run_wasi_tests.sh @@ -5,6 +5,8 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # +THIS_DIR=$(cd $(dirname $0) && pwd -P) + readonly MODE=$1 readonly TARGET=$2 @@ -63,7 +65,8 @@ if [[ $MODE != "aot" ]];then python3 -m venv wasi-env && source wasi-env/bin/activate python3 -m pip install -r test-runner/requirements.txt - TEST_RUNTIME_EXE="${IWASM_CMD}" python3 test-runner/wasi_test_runner.py \ + export TEST_RUNTIME_EXE="${IWASM_CMD}" + python3 ${THIS_DIR}/pipe.py | python3 test-runner/wasi_test_runner.py \ -r adapters/wasm-micro-runtime.py \ -t \ ${C_TESTS} \ @@ -100,4 +103,4 @@ else done fi -exit ${exit_code} \ No newline at end of file +exit ${exit_code}