From b5f8ee61a7f7e9bd291dd26b0585d03eb686c941 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 5 May 2024 13:19:16 +0200 Subject: Adding upstream version 1.46.3. Signed-off-by: Daniel Baumann --- .../tests/benchmarks/coremark/README.md | 19 - .../tests/benchmarks/coremark/build.sh | 35 - .../tests/benchmarks/coremark/run.sh | 16 - .../tests/benchmarks/jetstream/README.md | 29 - .../tests/benchmarks/jetstream/build.sh | 74 -- .../tests/benchmarks/jetstream/jetstream.patch | 20 - .../tests/benchmarks/jetstream/run_aot.sh | 52 - .../tests/benchmarks/libsodium/README.md | 23 - .../tests/benchmarks/libsodium/build.sh | 42 - .../tests/benchmarks/libsodium/test_aot.sh | 59 - .../tests/benchmarks/polybench/README.md | 21 - .../tests/benchmarks/polybench/build.sh | 48 - .../tests/benchmarks/polybench/run_aot.sh | 55 - .../tests/benchmarks/polybench/run_interp.sh | 55 - .../tests/benchmarks/sightglass/README.md | 21 - .../tests/benchmarks/sightglass/build.sh | 44 - .../tests/benchmarks/sightglass/run_aot.sh | 54 - .../tests/benchmarks/sightglass/run_interp.sh | 54 - .../tests/wamr-test-suites/README.md | 40 - .../wamr-test-suites/spec-test-script/CHANGES | 5 - .../tests/wamr-test-suites/spec-test-script/all.py | 525 -------- .../tests/wamr-test-suites/spec-test-script/all.sh | 162 --- .../spec-test-script/collect_coverage.sh | 82 -- .../spec-test-script/ignore_cases.patch | 805 ------------ .../wamr-test-suites/spec-test-script/runtest.py | 1343 -------------------- .../spec-test-script/simd_ignore_cases.patch | 73 -- .../spec-test-script/tail-call/return_call.wast | 202 --- .../tail-call/return_call_indirect.wast | 511 -------- .../thread_proposal_fix_atomic_case.patch | 49 - .../thread_proposal_ignore_cases.patch | 213 ---- .../tests/wamr-test-suites/test_wamr.sh | 882 ------------- .../wasi-test-script/run_wasi_tests.sh | 80 -- 32 files changed, 5693 deletions(-) delete mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/coremark/README.md delete mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/coremark/build.sh delete mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/coremark/run.sh delete mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/jetstream/README.md delete mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/jetstream/build.sh delete mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/jetstream/jetstream.patch delete mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/jetstream/run_aot.sh delete mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/libsodium/README.md delete mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/libsodium/build.sh delete mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/libsodium/test_aot.sh delete mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/polybench/README.md delete mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/polybench/build.sh delete mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/polybench/run_aot.sh delete mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/polybench/run_interp.sh delete mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/sightglass/README.md delete mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/sightglass/build.sh delete mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/sightglass/run_aot.sh delete mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/sightglass/run_interp.sh delete mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/README.md delete mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/CHANGES delete mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/all.py delete mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/all.sh delete mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/collect_coverage.sh delete mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/ignore_cases.patch delete mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/runtest.py delete mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/simd_ignore_cases.patch delete mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/tail-call/return_call.wast delete mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/tail-call/return_call_indirect.wast delete mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/thread_proposal_fix_atomic_case.patch delete mode 100644 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/thread_proposal_ignore_cases.patch delete mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/test_wamr.sh delete mode 100755 fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/wasi-test-script/run_wasi_tests.sh (limited to 'fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests') diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/coremark/README.md b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/coremark/README.md deleted file mode 100644 index 1631cc5c0..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/coremark/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Introduction - -[CoreMark's](https://www.eembc.org/coremark) primary goals are simplicity and providing a method for testing only a processor's core features. - -**Source**: https://github.com/eembc/coremark - -# Building - -Please build iwasm and wamrc, refer to: -- [Build iwasm on Linux](../../../doc/build_wamr.md#linux), or [Build iwasm on MacOS](../../../doc/build_wamr.md#macos) -- [Build wamrc AOT compiler](../../../README.md#build-wamrc-aot-compiler) - -And install WASI SDK, please download the [wasi-sdk release](https://github.com/CraneStation/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`. - -And then run `./build.sh` to build the source code, file `coremark.exe`, `coremark.wasm` and `coremark.aot` will be generated. - -# Running - -Run `./run.sh` to test the benchmark, the native mode, iwasm aot mode and iwasm interpreter mode will be tested respectively. diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/coremark/build.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/coremark/build.sh deleted file mode 100755 index 14c179ce5..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/coremark/build.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2019 Intel Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -WAMRC="../../../wamr-compiler/build/wamrc" - -if [ ! -d coremark ]; then - git clone https://github.com/eembc/coremark.git -fi - -cd coremark - -echo "Build coremark with gcc .." -gcc -O3 -Iposix -I. -DFLAGS_STR=\""-O3 -DPERFORMANCE_RUN=1 -lrt"\" \ - -DITERATIONS=400000 -DSEED_METHOD=SEED_VOLATILE -DPERFORMANCE_RUN=1 \ - core_list_join.c core_main.c core_matrix.c core_state.c \ - core_util.c posix/core_portme.c \ - -o ../coremark.exe -lrt - -echo "Build coremark with wasi-sdk .." -/opt/wasi-sdk/bin/clang -O3 -Iposix -I. -DFLAGS_STR=\""-O3 -DPERFORMANCE_RUN=1"\" \ - -Wl,--export=main \ - -DITERATIONS=400000 -DSEED_METHOD=SEED_VOLATILE -DPERFORMANCE_RUN=1 \ - -Wl,--allow-undefined \ - core_list_join.c core_main.c core_matrix.c core_state.c \ - core_util.c posix/core_portme.c \ - -o ../coremark.wasm - -cd .. - -echo "Compile coremark.wasm to coremark.aot .." -${WAMRC} -o coremark.aot coremark.wasm - -echo "Done" diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/coremark/run.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/coremark/run.sh deleted file mode 100755 index a1ea7f6b7..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/coremark/run.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2019 Intel Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -IWASM="../../../product-mini/platforms/linux/build/iwasm" -WAMRC="../../../wamr-compiler/build/wamrc" - -echo "Run coremark with native .." -./coremark.exe - -echo "Run coremark with iwasm mode .." -${IWASM} coremark.aot - -echo "Run coremakr with iwasm interpreter .." -${IWASM} coremark.wasm diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/jetstream/README.md b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/jetstream/README.md deleted file mode 100644 index f6c593d11..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/jetstream/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# Introduction - -[JetStream 2](https://browserbench.org/JetStream) is a JavaScript and WebAssembly benchmark suite focused on the most advanced web applications. It rewards browsers that start up quickly, execute code quickly, and run smoothly. - -**Source**: https://browserbench.org/JetStream/in-depth.html - -# Building - -Please build iwasm and wamrc, refer to: -- [Build iwasm on Linux](../../../doc/build_wamr.md#linux), or [Build iwasm on MacOS](../../../doc/build_wamr.md#macos) -- [Build wamrc AOT compiler](../../../README.md#build-wamrc-aot-compiler) - -And install emsdk, refer to [the guide](https://emscripten.org/docs/getting_started/downloads.html). Don't forget to activate - emsdk and set up environment variables. For example, use instructions below to install it under /opt and activate it: -``` bash -$ cd /opt -$ git clone https://github.com/emscripten-core/emsdk.git -$ cd emsdk -$ git pull -$ ./emsdk install latest -$ ./emsdk activate latest -$ echo "source /opt/emsdk/emsdk_env.sh" >> "${HOME}"/.bashrc -``` - -And then run `./build.sh` to build the source code, the folder `out` will be created and files will be generated under it. - -# Running - -Run `./run_aot.sh` to test the benchmark, the native mode and iwasm aot mode will be tested for each workload, and the file `report.txt` will be generated. diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/jetstream/build.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/jetstream/build.sh deleted file mode 100755 index 030b8d3a0..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/jetstream/build.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2019 Intel Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -OUT_DIR=$PWD/out -WAMRC_CMD=$PWD/../../../wamr-compiler/build/wamrc - -mkdir -p jetstream -mkdir -p ${OUT_DIR} - -cd jetstream - -echo "Download source files .." -wget https://browserbench.org/JetStream/wasm/gcc-loops.cpp -wget https://browserbench.org/JetStream/wasm/quicksort.c -wget https://browserbench.org/JetStream/wasm/HashSet.cpp -wget https://browserbench.org/JetStream/simple/float-mm.c - -patch -p1 < ../jetstream.patch - -echo "Build gcc-loops with g++ .." -g++ -O3 -msse2 -msse3 -msse4 -o ${OUT_DIR}/gcc-loops_native gcc-loops.cpp - -echo "Build gcc-loops with em++ .." -em++ -O3 -s STANDALONE_WASM=1 -msimd128 \ - -s INITIAL_MEMORY=1048576 \ - -s TOTAL_STACK=32768 \ - -s "EXPORTED_FUNCTIONS=['_main']" \ - -s ERROR_ON_UNDEFINED_SYMBOLS=0 \ - -o ${OUT_DIR}/gcc-loops.wasm gcc-loops.cpp - -echo "Compile gcc-loops.wasm to gcc-loops.aot" -${WAMRC_CMD} -o ${OUT_DIR}/gcc-loops.aot ${OUT_DIR}/gcc-loops.wasm - -echo "Build quicksort with gcc .." -gcc -O3 -msse2 -msse3 -msse4 -o ${OUT_DIR}/quicksort_native quicksort.c - -echo "Build quicksort with emcc .." -emcc -O3 -s STANDALONE_WASM=1 -msimd128 \ - -s INITIAL_MEMORY=1048576 \ - -s TOTAL_STACK=32768 \ - -s "EXPORTED_FUNCTIONS=['_main']" \ - -o ${OUT_DIR}/quicksort.wasm quicksort.c - -echo "Compile quicksort.wasm to quicksort.aot" -${WAMRC_CMD} -o ${OUT_DIR}/quicksort.aot ${OUT_DIR}/quicksort.wasm - -echo "Build HashSet with g++ .." -g++ -O3 -msse2 -msse3 -msse4 -o ${OUT_DIR}/HashSet_native HashSet.cpp \ - -lstdc++ - -echo "Build HashSet with em++ .." -em++ -O3 -s STANDALONE_WASM=1 -msimd128 \ - -s INITIAL_MEMORY=1048576 \ - -s TOTAL_STACK=32768 \ - -s "EXPORTED_FUNCTIONS=['_main']" \ - -o ${OUT_DIR}/HashSet.wasm HashSet.cpp - -echo "Compile HashSet.wasm to HashSet.aot" -${WAMRC_CMD} -o ${OUT_DIR}/HashSet.aot ${OUT_DIR}/HashSet.wasm - -echo "Build float-mm with gcc .." -gcc -O3 -msse2 -msse3 -msse4 -o ${OUT_DIR}/float-mm_native float-mm.c - -echo "Build float-mm with emcc .." -emcc -O3 -s STANDALONE_WASM=1 -msimd128 \ - -s INITIAL_MEMORY=1048576 \ - -s TOTAL_STACK=32768 \ - -s "EXPORTED_FUNCTIONS=['_main']" \ - -o ${OUT_DIR}/float-mm.wasm float-mm.c - -echo "Compile float-mm.wasm to float-mm.aot" -${WAMRC_CMD} -o ${OUT_DIR}/float-mm.aot ${OUT_DIR}/float-mm.wasm diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/jetstream/jetstream.patch b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/jetstream/jetstream.patch deleted file mode 100644 index 34431de08..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/jetstream/jetstream.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff -urN jetstream-org/HashSet.cpp jetstream/HashSet.cpp ---- jetstream-org/HashSet.cpp 2020-10-30 04:12:42.000000000 +0800 -+++ jetstream/HashSet.cpp 2022-01-24 17:11:08.619831711 +0800 -@@ -24,6 +24,7 @@ - #include - #include - #include -+#include - #include - - // Compile with: xcrun clang++ -o HashSet HashSet.cpp -O2 -W -framework Foundation -licucore -std=c++11 -fvisibility=hidden -DNDEBUG=1 -@@ -76,7 +77,7 @@ - inline ToType bitwise_cast(FromType from) - { - typename std::remove_const::type to { }; -- std::memcpy(&to, &from, sizeof(to)); -+ memcpy(&to, &from, sizeof(to)); - return to; - } - diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/jetstream/run_aot.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/jetstream/run_aot.sh deleted file mode 100755 index d62a5da90..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/jetstream/run_aot.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2019 Intel Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -CUR_DIR=$PWD -OUT_DIR=$CUR_DIR/out -REPORT=$CUR_DIR/report.txt -TIME=/usr/bin/time - -PLATFORM=$(uname -s | tr A-Z a-z) -IWASM_CMD=$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm - -BENCH_NAME_MAX_LEN=20 - -JETSTREAM_CASES="gcc-loops quicksort HashSet float-mm" - -rm -f $REPORT -touch $REPORT - -function print_bench_name() -{ - name=$1 - echo -en "$name" >> $REPORT - name_len=${#name} - if [ $name_len -lt $BENCH_NAME_MAX_LEN ] - then - spaces=$(( $BENCH_NAME_MAX_LEN - $name_len )) - for i in $(eval echo "{1..$spaces}"); do echo -n " " >> $REPORT; done - fi -} - -echo "Start to run cases, the result is written to report.txt" - -#run benchmarks -cd $OUT_DIR -echo -en "\t\t\t\t\t native\tiwasm-aot\n" >> $REPORT - -for t in $JETSTREAM_CASES -do - print_bench_name $t - - echo "run $t with native .." - echo -en "\t" >> $REPORT - $TIME -f "real-%e-time" ./${t}_native 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT - - echo "run $t with iwasm aot .." - echo -en "\t" >> $REPORT - $TIME -f "real-%e-time" $IWASM_CMD ${t}.aot 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT - - echo -en "\n" >> $REPORT -done diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/libsodium/README.md b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/libsodium/README.md deleted file mode 100644 index 19500afe6..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/libsodium/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# Introduction - -[libsodium](https://github.com/jedisct1/libsodium) is a new, easy-to-use software library for encryption, decryption, signatures, password hashing and more. - -**Source**: https://github.com/jedisct1/libsodium - -# Building - -Please build iwasm and wamrc, refer to: -- [Build iwasm on Linux](../../../doc/build_wamr.md#linux), or [Build iwasm on MacOS](../../../doc/build_wamr.md#macos) -- [Build wamrc AOT compiler](../../../README.md#build-wamrc-aot-compiler) - -And install [zig toolchain](https://ziglang.org/learn/getting-started), refer to [Install Zig from a Package Manager](https://github.com/ziglang/zig/wiki/Install-Zig-from-a-Package-Manager) for how to install it. - -And then run `./build.sh` to build the source code, the libsodium source code will be cloned, and test benchmarks of native version, wasm files and AOT files will be generated under `libsodium/zig-out/bin`. - -# Running - -Run `./run_aot.sh` to test the benchmark, the native mode and iwasm aot mode will be tested respectively. - -# Others - -Refer to [Performance of WebAssembly runtimes in 2023](https://00f.net/2023/01/04/webassembly-benchmark-2023) for more about the performance comparison of wasm runtimes on running the libsodium benchmarks. diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/libsodium/build.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/libsodium/build.sh deleted file mode 100755 index 1e9cc21a7..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/libsodium/build.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2019 Intel Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -libsodium_CASES="aead_aes256gcm2 aead_aes256gcm aead_chacha20poly13052 aead_chacha20poly1305 \ - aead_xchacha20poly1305 auth2 auth3 auth5 auth6 auth7 auth box2 box7 box8 \ - box_easy2 box_easy box_seal box_seed box chacha20 codecs core1 core2 core3 \ - core4 core5 core6 core_ed25519 core_ristretto255 ed25519_convert generichash2 \ - generichash3 generichash hash3 hash kdf keygen kx metamorphic misuse \ - onetimeauth2 onetimeauth7 onetimeauth pwhash_argon2id pwhash_argon2i \ - pwhash_scrypt_ll pwhash_scrypt randombytes scalarmult2 scalarmult5 \ - scalarmult6 scalarmult7 scalarmult8 scalarmult_ed25519 scalarmult_ristretto255 \ - scalarmult secretbox2 secretbox7 secretbox8 secretbox_easy2 secretbox_easy \ - secretbox secretstream shorthash sign siphashx24 sodium_core sodium_utils2 \ - sodium_utils3 sodium_utils sodium_version stream2 stream3 stream4 stream verify1 \ - xchacha20" - -readonly WAMRC_CMD=$PWD/../../../wamr-compiler/build/wamrc -readonly OUT_DIR=$PWD/libsodium/zig-out/bin - -if [ ! -d libsodium ]; then - git clone -b stable https://github.com/jedisct1/libsodium.git -fi - -cd libsodium - -echo "Build libsodium native" -zig build -Drelease-fast -Denable_benchmarks=true - -echo "Build libsodium wasm32-wasi" -zig build -Drelease-fast -Denable_benchmarks=true -Dtarget=wasm32-wasi - -for case in ${libsodium_CASES} -do - ${WAMRC_CMD} -o ${OUT_DIR}/${case}.aot ${OUT_DIR}/${case}.wasm - - if [ "$?" != 0 ]; then - echo -e "Error while compiling ${case}.wasm to ${case}.aot" - exit - fi -done diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/libsodium/test_aot.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/libsodium/test_aot.sh deleted file mode 100755 index 2e4e3e357..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/libsodium/test_aot.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2019 Intel Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -libsodium_CASES="aead_aes256gcm2 aead_aes256gcm aead_chacha20poly13052 aead_chacha20poly1305 \ - aead_xchacha20poly1305 auth2 auth3 auth5 auth6 auth7 auth box2 box7 box8 \ - box_easy2 box_easy box_seal box_seed box chacha20 codecs core1 core2 core3 \ - core4 core5 core6 core_ed25519 core_ristretto255 ed25519_convert generichash2 \ - generichash3 generichash hash3 hash kdf keygen kx metamorphic misuse \ - onetimeauth2 onetimeauth7 onetimeauth pwhash_argon2id pwhash_argon2i \ - pwhash_scrypt_ll pwhash_scrypt randombytes scalarmult2 scalarmult5 \ - scalarmult6 scalarmult7 scalarmult8 scalarmult_ed25519 scalarmult_ristretto255 \ - scalarmult secretbox2 secretbox7 secretbox8 secretbox_easy2 secretbox_easy \ - secretbox secretstream shorthash sign siphashx24 sodium_core sodium_utils2 \ - sodium_utils3 sodium_utils sodium_version stream2 stream3 stream4 stream verify1 \ - xchacha20" - -readonly OUT_DIR=$PWD/libsodium/zig-out/bin -readonly REPORT=$PWD/report.txt -readonly IWASM_CMD=$PWD/../../../product-mini/platforms/linux/build/iwasm - -BENCH_NAME_MAX_LEN=20 - -rm -f $REPORT -touch $REPORT - -function print_bench_name() -{ - name=$1 - echo -en "$name" >> $REPORT - name_len=${#name} - if [ $name_len -lt $BENCH_NAME_MAX_LEN ] - then - spaces=$(( $BENCH_NAME_MAX_LEN - $name_len )) - for i in $(eval echo "{1..$spaces}"); do echo -n " " >> $REPORT; done - fi -} - -# run benchmarks -cd $OUT_DIR - -echo -en "\t\t\t\t\t\tnative\tiwasm-aot\n" >> $REPORT - -for t in $libsodium_CASES -do - print_bench_name $t - - echo "run $t with native..." - echo -en "\t" >> $REPORT - ./${t} | awk -F '-' 'BEGIN{FIELDWIDTHS="10"}{ORS=""; print $1 / 1000000.0}' >> $REPORT - - echo "run $t with iwasm aot..." - echo -en "\t \t" >> $REPORT - $IWASM_CMD ${t}.aot | awk -F '-' 'BEGIN{FIELDWIDTHS="10"}{ORS=""; print $1 / 1000000.0}' >> $REPORT - - echo -en "\n" >> $REPORT -done - diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/polybench/README.md b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/polybench/README.md deleted file mode 100644 index 7808e17d9..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/polybench/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Introduction - -[PolyBench](https://github.com/MatthiasJReisinger/PolyBenchC-4.2.1) is a benchmark suite of 30 numerical computations with static control flow, extracted from operations in various application domains (linear algebra computations, image processing, physics simulation, dynamic programming, statistics, etc.). - -**Source**: https://github.com/MatthiasJReisinger/PolyBenchC-4.2.1 - -# Building - -Please build iwasm and wamrc, refer to: -- [Build iwasm on Linux](../../../doc/build_wamr.md#linux), or [Build iwasm on MacOS](../../../doc/build_wamr.md#macos) -- [Build wamrc AOT compiler](../../../README.md#build-wamrc-aot-compiler) - -And install WASI SDK, please download the [wasi-sdk release](https://github.com/CraneStation/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`. - -And then run `./build.sh` to build the source code, the folder `out` will be created and files will be generated under it. - -# Running - -Run `./run_aot.sh` to test the benchmark, the native mode and iwasm aot mode will be tested for each workload, and the file `report.txt` will be generated. - -Run `./run_interp.sh` to test the benchmark, the native mode and iwasm interpreter mode will be tested for each workload, and the file `report.txt` will be generated. diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/polybench/build.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/polybench/build.sh deleted file mode 100755 index bc7bf4c10..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/polybench/build.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2019 Intel Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -OUT_DIR=$PWD/out -WAMRC_CMD=$PWD/../../../wamr-compiler/build/wamrc -POLYBENCH_CASES="datamining linear-algebra medley stencils" - -if [ ! -d PolyBenchC-4.2.1 ]; then - git clone https://github.com/MatthiasJReisinger/PolyBenchC-4.2.1.git -fi - -mkdir -p ${OUT_DIR} - -cd PolyBenchC-4.2.1 - -for case in $POLYBENCH_CASES -do - files=`find ${case} -name "*.c"` - for file in ${files} - do - file_name=${file##*/} - if [[ ${file_name} == "Nussinov.orig.c" ]]; then - continue - fi - - echo "Build ${file_name%.*}_native" - gcc -O3 -I utilities -I ${file%/*} utilities/polybench.c ${file} \ - -DPOLYBENCH_TIME -lm -o ${OUT_DIR}/${file_name%.*}_native - - echo "Build ${file_name%.*}.wasm" - /opt/wasi-sdk/bin/clang -O3 -I utilities -I ${file%/*} \ - utilities/polybench.c ${file} \ - -Wl,--export=__heap_base -Wl,--export=__data_end \ - -Wl,--export=malloc -Wl,--export=free \ - -DPOLYBENCH_TIME -o ${OUT_DIR}/${file_name%.*}.wasm \ - -D_WASI_EMULATED_PROCESS_CLOCKS - - echo "Compile ${file_name%.*}.wasm into ${file_name%.*}.aot" - ${WAMRC_CMD} -o ${OUT_DIR}/${file_name%.*}.aot \ - ${OUT_DIR}/${file_name%.*}.wasm - done -done - -cd .. - -echo "Done" diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/polybench/run_aot.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/polybench/run_aot.sh deleted file mode 100755 index 17cc098ad..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/polybench/run_aot.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2019 Intel Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -CUR_DIR=$PWD -OUT_DIR=$CUR_DIR/out -REPORT=$CUR_DIR/report.txt -TIME=/usr/bin/time - -PLATFORM=$(uname -s | tr A-Z a-z) -IWASM_CMD=$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm - -BENCH_NAME_MAX_LEN=20 - -POLYBENCH_CASES="2mm 3mm adi atax bicg cholesky correlation covariance \ - deriche doitgen durbin fdtd-2d floyd-warshall gemm gemver \ - gesummv gramschmidt heat-3d jacobi-1d jacobi-2d ludcmp lu \ - mvt nussinov seidel-2d symm syr2k syrk trisolv trmm" - -rm -f $REPORT -touch $REPORT - -function print_bench_name() -{ - name=$1 - echo -en "$name" >> $REPORT - name_len=${#name} - if [ $name_len -lt $BENCH_NAME_MAX_LEN ] - then - spaces=$(( $BENCH_NAME_MAX_LEN - $name_len )) - for i in $(eval echo "{1..$spaces}"); do echo -n " " >> $REPORT; done - fi -} - -echo "Start to run cases, the result is written to report.txt" - -#run benchmarks -cd $OUT_DIR -echo -en "\t\t\t\t\t native\tiwasm-aot\n" >> $REPORT - -for t in $POLYBENCH_CASES -do - print_bench_name $t - - echo "run $t with native .." - echo -en "\t" >> $REPORT - $TIME -f "real-%e-time" ./${t}_native 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT - - echo "run $t with iwasm aot .." - echo -en "\t" >> $REPORT - $TIME -f "real-%e-time" $IWASM_CMD ${t}.aot 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT - - echo -en "\n" >> $REPORT -done diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/polybench/run_interp.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/polybench/run_interp.sh deleted file mode 100755 index f6d5c254d..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/polybench/run_interp.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2019 Intel Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -CUR_DIR=$PWD -OUT_DIR=$CUR_DIR/out -REPORT=$CUR_DIR/report.txt -TIME=/usr/bin/time - -PLATFORM=$(uname -s | tr A-Z a-z) -IWASM_CMD=$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm - -BENCH_NAME_MAX_LEN=20 - -POLYBENCH_CASES="2mm 3mm adi atax bicg cholesky correlation covariance \ - deriche doitgen durbin fdtd-2d floyd-warshall gemm gemver \ - gesummv gramschmidt heat-3d jacobi-1d jacobi-2d ludcmp lu \ - mvt nussinov seidel-2d symm syr2k syrk trisolv trmm" - -rm -f $REPORT -touch $REPORT - -function print_bench_name() -{ - name=$1 - echo -en "$name" >> $REPORT - name_len=${#name} - if [ $name_len -lt $BENCH_NAME_MAX_LEN ] - then - spaces=$(( $BENCH_NAME_MAX_LEN - $name_len )) - for i in $(eval echo "{1..$spaces}"); do echo -n " " >> $REPORT; done - fi -} - -echo "Start to run cases, the result is written to report.txt" - -#run benchmarks -cd $OUT_DIR -echo -en "\t\t\t\t\t native\tiwasm-aot\n" >> $REPORT - -for t in $POLYBENCH_CASES -do - print_bench_name $t - - echo "run $t with native .." - echo -en "\t" >> $REPORT - $TIME -f "real-%e-time" ./${t}_native 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT - - echo "run $t with iwasm interp .." - echo -en "\t" >> $REPORT - $TIME -f "real-%e-time" $IWASM_CMD ${t}.wasm 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT - - echo -en "\n" >> $REPORT -done diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/sightglass/README.md b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/sightglass/README.md deleted file mode 100644 index a446d80ea..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/sightglass/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# Introduction - -[Sightglass](https://github.com/bytecodealliance/sightglass) is a benchmarking suite and tooling to test WebAssembly applications. - -**Source**: https://github.com/bytecodealliance/sightglass - -# Building - -Please build iwasm and wamrc, refer to: -- [Build iwasm on Linux](../../../doc/build_wamr.md#linux), or [Build iwasm on MacOS](../../../doc/build_wamr.md#macos) -- [Build wamrc AOT compiler](../../../README.md#build-wamrc-aot-compiler) - -And install WASI SDK, please download the [wasi-sdk release](https://github.com/CraneStation/wasi-sdk/releases) and extract the archive to default path `/opt/wasi-sdk`. - -And then run `./build.sh` to build the source code, the folder `out` will be created and files will be generated under it. - -# Running - -Run `./run_aot.sh` to test the benchmark, the native mode and iwasm aot mode will be tested for each workload, and the file `report.txt` will be generated. - -Run `./run_interp.sh` to test the benchmark, the native mode and iwasm interpreter mode will be tested for each workload, and the file `report.txt` will be generated. diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/sightglass/build.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/sightglass/build.sh deleted file mode 100755 index c7192c16f..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/sightglass/build.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2019 Intel Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -OUT_DIR=$PWD/out -WAMRC_CMD=$PWD/../../../wamr-compiler/build/wamrc -SHOOTOUT_CASES="base64 fib2 gimli heapsort matrix memmove nestedloop \ - nestedloop2 nestedloop3 random seqhash sieve strchr \ - switch2" - -if [ ! -d sightglass ]; then - git clone https://github.com/wasm-micro-runtime/sightglass.git -fi - -mkdir -p ${OUT_DIR} - -cd sightglass/benchmarks/shootout - -for bench in $SHOOTOUT_CASES -do - echo "Build ${bench}_native" - gcc -O3 -o ${OUT_DIR}/${bench}_native -Dblack_box=set_res -Dbench=${bench} \ - -I../../include ${bench}.c main/main_${bench}.c main/my_libc.c - - echo "Build ${bench}.wasm" - /opt/wasi-sdk/bin/clang -O3 -nostdlib \ - -Wno-unknown-attributes \ - -Dblack_box=set_res \ - -I../../include -DNOSTDLIB_MODE \ - -Wl,--initial-memory=1310720,--allow-undefined \ - -Wl,--strip-all,--no-entry \ - -o ${OUT_DIR}/${bench}.wasm \ - -Wl,--export=app_main -Wl,--export=_start \ - ${bench}.c main/main_${bench}.c main/my_libc.c - - - echo "Compile ${bench}.wasm into ${bench}.aot" - ${WAMRC_CMD} -o ${OUT_DIR}/${bench}.aot ${OUT_DIR}/${bench}.wasm -done - -cd .. - -echo "Done" diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/sightglass/run_aot.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/sightglass/run_aot.sh deleted file mode 100755 index 7a74a7912..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/sightglass/run_aot.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2019 Intel Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -CUR_DIR=$PWD -OUT_DIR=$CUR_DIR/out -REPORT=$CUR_DIR/report.txt -TIME=/usr/bin/time - -PLATFORM=$(uname -s | tr A-Z a-z) -IWASM_CMD=$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm - -BENCH_NAME_MAX_LEN=20 - -SHOOTOUT_CASES="base64 fib2 gimli heapsort matrix memmove nestedloop \ - nestedloop2 nestedloop3 random seqhash sieve strchr \ - switch2" - -rm -f $REPORT -touch $REPORT - -function print_bench_name() -{ - name=$1 - echo -en "$name" >> $REPORT - name_len=${#name} - if [ $name_len -lt $BENCH_NAME_MAX_LEN ] - then - spaces=$(( $BENCH_NAME_MAX_LEN - $name_len )) - for i in $(eval echo "{1..$spaces}"); do echo -n " " >> $REPORT; done - fi -} - -echo "Start to run cases, the result is written to report.txt" - -#run benchmarks -cd $OUT_DIR -echo -en "\t\t\t\t\t native\tiwasm-aot\n" >> $REPORT - -for t in $SHOOTOUT_CASES -do - print_bench_name $t - - echo "run $t with native .." - echo -en "\t" >> $REPORT - $TIME -f "real-%e-time" ./${t}_native 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT - - echo "run $t with iwasm aot .." - echo -en "\t" >> $REPORT - $TIME -f "real-%e-time" $IWASM_CMD ${t}.aot 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT - - echo -en "\n" >> $REPORT -done diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/sightglass/run_interp.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/sightglass/run_interp.sh deleted file mode 100755 index 50e94a5db..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/benchmarks/sightglass/run_interp.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2019 Intel Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -CUR_DIR=$PWD -OUT_DIR=$CUR_DIR/out -REPORT=$CUR_DIR/report.txt -TIME=/usr/bin/time - -PLATFORM=$(uname -s | tr A-Z a-z) -IWASM_CMD=$CUR_DIR/../../../product-mini/platforms/${PLATFORM}/build/iwasm - -BENCH_NAME_MAX_LEN=20 - -SHOOTOUT_CASES="base64 fib2 gimli heapsort matrix memmove nestedloop \ - nestedloop2 nestedloop3 random seqhash sieve strchr \ - switch2" - -rm -f $REPORT -touch $REPORT - -function print_bench_name() -{ - name=$1 - echo -en "$name" >> $REPORT - name_len=${#name} - if [ $name_len -lt $BENCH_NAME_MAX_LEN ] - then - spaces=$(( $BENCH_NAME_MAX_LEN - $name_len )) - for i in $(eval echo "{1..$spaces}"); do echo -n " " >> $REPORT; done - fi -} - -echo "Start to run cases, the result is written to report.txt" - -#run benchmarks -cd $OUT_DIR -echo -en "\t\t\t\t\t native\tiwasm-interp\n" >> $REPORT - -for t in $SHOOTOUT_CASES -do - print_bench_name $t - - echo "run $t with native .." - echo -en "\t" >> $REPORT - $TIME -f "real-%e-time" ./${t}_native 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT - - echo "run $t with iwasm aot .." - echo -en "\t" >> $REPORT - $TIME -f "real-%e-time" $IWASM_CMD ${t}.aot 2>&1 | grep "real-.*-time" | awk -F '-' '{ORS=""; print $2}' >> $REPORT - - echo -en "\n" >> $REPORT -done diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/README.md b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/README.md deleted file mode 100644 index e33649c84..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# WAMR test suites - -This folder contains test scripts and cases for wamr. - -## Help -``` -./test_wamr.sh --help -``` - -## Examples -Test spec cases with fast interpreter mode, which will create folder `workspace`, download the `spec` and `wabt` repo, and build `iwasm` automatically to test spec cases: -``` -./test_wamr.sh -s spec -t fast-interp -``` - -Test spec cases with aot mode, and use the wabt binary release package instead of compiling wabt from the source code: -``` -./test_wamr.sh -s spec -t aot -b -``` - -Test spec cases with all modes (classic-interp/fast-interp/aot/jit): -``` -./test_wamr.sh -s spec -``` - -Test spec cases with aot mode and pthread enabled: -``` -./test_wamr.sh -s spec -t aot -p -``` - -Test spec cases with aot mode and SIMD enabled: -``` -./test_wamr.sh -s spec -t aot -S -``` - -Test spec cases with fast-interp on target x86_32: -``` -./test_wamr.sh -s spec -t fast-interp -m x86_32 -``` - diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/CHANGES b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/CHANGES deleted file mode 100644 index 0b0cc9a67..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/CHANGES +++ /dev/null @@ -1,5 +0,0 @@ -#################### -2021-9-8 - -Modify runtest.py from https://github.com/kanaka/wac/blob/master/runtest.py -to enable testing spec cases with more checks and support more runtime modes. diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/all.py b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/all.py deleted file mode 100644 index 8b26d6892..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/all.py +++ /dev/null @@ -1,525 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2019 Intel Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# - -import argparse -import multiprocessing as mp -import os -import pathlib -import subprocess -import sys -import time - -""" -The script itself has to be put under the same directory with the "spec". -To run a single non-GC case with interpreter mode: - cd workspace - python3 runtest.py --wast2wasm wabt/bin/wat2wasm --interpreter iwasm \ - spec/test/core/xxx.wast -To run a single non-GC case with aot mode: - cd workspace - python3 runtest.py --aot --wast2wasm wabt/bin/wat2wasm --interpreter iwasm \ - --aot-compiler wamrc spec/test/core/xxx.wast -To run a single GC case: - cd workspace - python3 runtest.py --wast2wasm spec/interpreter/wasm --interpreter iwasm \ - --aot-compiler wamrc --gc spec/test/core/xxx.wast -""" - -PLATFORM_NAME = os.uname().sysname.lower() -IWASM_CMD = "../../../product-mini/platforms/" + PLATFORM_NAME + "/build/iwasm" -IWASM_SGX_CMD = "../../../product-mini/platforms/linux-sgx/enclave-sample/iwasm" -IWASM_QEMU_CMD = "iwasm" -SPEC_TEST_DIR = "spec/test/core" -WAST2WASM_CMD = "./wabt/out/gcc/Release/wat2wasm" -SPEC_INTERPRETER_CMD = "spec/interpreter/wasm" -WAMRC_CMD = "../../../wamr-compiler/build/wamrc" - -class TargetAction(argparse.Action): - TARGET_MAP = { - "ARMV7_VFP": "armv7", - "RISCV32": "riscv32_ilp32", - "RISCV32_ILP32": "riscv32_ilp32", - "RISCV32_ILP32D": "riscv32_ilp32d", - "RISCV64": "riscv64_lp64", - "RISCV64_LP64": "riscv64_lp64", - "RISCV64_LP64D": "riscv64_lp64", - "THUMBV7_VFP": "thumbv7", - "X86_32": "i386", - "X86_64": "x86_64", - } - - def __call__(self, parser, namespace, values, option_string=None): - setattr(namespace, self.dest, self.TARGET_MAP.get(values, "x86_64")) - - -def ignore_the_case( - case_name, - target, - aot_flag=False, - sgx_flag=False, - multi_module_flag=False, - multi_thread_flag=False, - simd_flag=False, - gc_flag=False, - xip_flag=False, - qemu_flag=False -): - if case_name in ["comments", "inline-module", "names"]: - return True - - if not multi_module_flag and case_name in ["imports", "linking"]: - return True - - if "i386" == target and case_name in ["float_exprs"]: - return True - - if gc_flag: - if case_name in ["type-canon", "type-equivalence", "type-rec"]: - return True; - - if sgx_flag: - if case_name in ["conversions", "f32_bitwise", "f64_bitwise"]: - return True - - if aot_flag and case_name in [ - "call_indirect", - "call", - "fac", - "skip-stack-guard-page", - ]: - return True - - if qemu_flag: - if case_name in ["f32_bitwise", "f64_bitwise", "loop", "f64", "f64_cmp", - "conversions", "f32", "f32_cmp", "float_exprs", - "float_misc", "select", "memory_grow"]: - return True - - return False - - -def preflight_check(aot_flag): - if not pathlib.Path(SPEC_TEST_DIR).resolve().exists(): - print(f"Can not find {SPEC_TEST_DIR}") - return False - - if not pathlib.Path(WAST2WASM_CMD).resolve().exists(): - print(f"Can not find {WAST2WASM_CMD}") - return False - - if aot_flag and not pathlib.Path(WAMRC_CMD).resolve().exists(): - print(f"Can not find {WAMRC_CMD}") - return False - - return True - - -def test_case( - case_path, - target, - aot_flag=False, - sgx_flag=False, - multi_module_flag=False, - multi_thread_flag=False, - simd_flag=False, - xip_flag=False, - clean_up_flag=True, - verbose_flag=True, - gc_flag=False, - qemu_flag=False, - qemu_firmware='', - log='', -): - case_path = pathlib.Path(case_path).resolve() - case_name = case_path.stem - - if ignore_the_case( - case_name, - target, - aot_flag, - sgx_flag, - multi_module_flag, - multi_thread_flag, - simd_flag, - gc_flag, - xip_flag, - qemu_flag - ): - return True - - CMD = ["python3", "runtest.py"] - CMD.append("--wast2wasm") - CMD.append(WAST2WASM_CMD if not gc_flag else SPEC_INTERPRETER_CMD) - CMD.append("--interpreter") - if sgx_flag: - CMD.append(IWASM_SGX_CMD) - elif qemu_flag: - CMD.append(IWASM_QEMU_CMD) - else: - CMD.append(IWASM_CMD) - CMD.append("--aot-compiler") - CMD.append(WAMRC_CMD) - - if aot_flag: - CMD.append("--aot") - - CMD.append("--target") - CMD.append(target) - - if multi_module_flag: - CMD.append("--multi-module") - - if multi_thread_flag: - CMD.append("--multi-thread") - - if sgx_flag: - CMD.append("--sgx") - - if simd_flag: - CMD.append("--simd") - - if xip_flag: - CMD.append("--xip") - - if qemu_flag: - CMD.append("--qemu") - CMD.append("--qemu-firmware") - CMD.append(qemu_firmware) - - if not clean_up_flag: - CMD.append("--no_cleanup") - - if gc_flag: - CMD.append("--gc") - - if log != '': - CMD.append("--log-dir") - CMD.append(log) - - CMD.append(case_path) - print(f"============> run {case_name} ", end="") - with subprocess.Popen( - CMD, - bufsize=1, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - universal_newlines=True, - ) as p: - try: - case_last_words = [] - while not p.poll(): - output = p.stdout.readline() - - if not output: - break - - if verbose_flag: - print(output, end="") - else: - if len(case_last_words) == 16: - case_last_words.pop(0) - case_last_words.append(output) - - p.wait(60) - - if p.returncode: - print(f"failed with a non-zero return code {p.returncode}") - if not verbose_flag: - print( - f"\n==================== LAST LOG of {case_name} ====================\n" - ) - print("".join(case_last_words)) - print("\n==================== LAST LOG END ====================\n") - raise Exception(case_name) - else: - print("successful") - return True - except subprocess.CalledProcessError: - print("failed with CalledProcessError") - raise Exception(case_name) - except subprocess.TimeoutExpired: - print("failed with TimeoutExpired") - raise Exception(case_name) - - -def test_suite( - target, - aot_flag=False, - sgx_flag=False, - multi_module_flag=False, - multi_thread_flag=False, - simd_flag=False, - xip_flag=False, - clean_up_flag=True, - verbose_flag=True, - gc_flag=False, - parl_flag=False, - qemu_flag=False, - qemu_firmware='', - log='', -): - suite_path = pathlib.Path(SPEC_TEST_DIR).resolve() - if not suite_path.exists(): - print(f"can not find spec test cases at {suite_path}") - return False - - case_list = sorted(suite_path.glob("*.wast")) - if simd_flag: - simd_case_list = sorted(suite_path.glob("simd/*.wast")) - case_list.extend(simd_case_list) - - if gc_flag: - gc_case_list = sorted(suite_path.glob("gc/*.wast")) - case_list.extend(gc_case_list) - - case_count = len(case_list) - failed_case = 0 - successful_case = 0 - - if parl_flag: - print(f"----- Run the whole spec test suite on {mp.cpu_count()} cores -----") - with mp.Pool() as pool: - results = {} - for case_path in case_list: - results[case_path.stem] = pool.apply_async( - test_case, - [ - str(case_path), - target, - aot_flag, - sgx_flag, - multi_module_flag, - multi_thread_flag, - simd_flag, - xip_flag, - clean_up_flag, - verbose_flag, - gc_flag, - qemu_flag, - qemu_firmware, - log, - ], - ) - - for case_name, result in results.items(): - try: - if qemu_flag: - # 60 min / case, testing on QEMU may be very slow - result.wait(7200) - else: - # 5 min / case - result.wait(300) - if not result.successful(): - failed_case += 1 - else: - successful_case += 1 - except mp.TimeoutError: - print(f"{case_name} meets TimeoutError") - failed_case += 1 - else: - print(f"----- Run the whole spec test suite -----") - for case_path in case_list: - try: - test_case( - str(case_path), - target, - aot_flag, - sgx_flag, - multi_module_flag, - multi_thread_flag, - simd_flag, - xip_flag, - clean_up_flag, - verbose_flag, - gc_flag, - qemu_flag, - qemu_firmware, - log, - ) - successful_case += 1 - except Exception as e: - failed_case += 1 - raise e - - print( - f"IN ALL {case_count} cases: {successful_case} PASS, {failed_case} FAIL, {case_count - successful_case - failed_case} SKIP" - ) - - return 0 == failed_case - - -def main(): - parser = argparse.ArgumentParser(description="run the whole spec test suite") - - parser.add_argument( - "-M", - action="store_true", - default=False, - dest="multi_module_flag", - help="Running with the Multi-Module feature", - ) - parser.add_argument( - "-m", - action=TargetAction, - choices=list(TargetAction.TARGET_MAP.keys()), - type=str, - dest="target", - default="X86_64", - help="Specify Target ", - ) - parser.add_argument( - "-p", - action="store_true", - default=False, - dest="multi_thread_flag", - help="Running with the Multi-Thread feature", - ) - parser.add_argument( - "-S", - action="store_true", - default=False, - dest="simd_flag", - help="Running with the SIMD feature", - ) - parser.add_argument( - "-X", - action="store_true", - default=False, - dest="xip_flag", - help="Running with the XIP feature", - ) - parser.add_argument( - "-t", - action="store_true", - default=False, - dest="aot_flag", - help="Running with AOT mode", - ) - parser.add_argument( - "-x", - action="store_true", - default=False, - dest="sgx_flag", - help="Running with SGX environment", - ) - parser.add_argument( - "--no_clean_up", - action="store_false", - default=True, - dest="clean_up_flag", - help="Does not remove tmpfiles. But it will be enabled while running parallelly", - ) - parser.add_argument( - "--parl", - action="store_true", - default=False, - dest="parl_flag", - help="To run whole test suite parallelly", - ) - parser.add_argument( - "--qemu", - action="store_true", - default=False, - dest="qemu_flag", - help="To run whole test suite in qemu", - ) - parser.add_argument( - "--qemu-firmware", - default="", - dest="qemu_firmware", - help="Firmware required by qemu", - ) - parser.add_argument( - "--log", - default='', - dest="log", - help="Log directory", - ) - parser.add_argument( - "--quiet", - action="store_false", - default=True, - dest="verbose_flag", - help="Close real time output while running cases, only show last words of failed ones", - ) - parser.add_argument( - "--gc", - action="store_true", - default=False, - dest="gc_flag", - help="Running with GC feature", - ) - parser.add_argument( - "cases", - metavar="path_to__case", - type=str, - nargs="*", - help=f"Specify all wanted cases. If not the script will go through all cases under {SPEC_TEST_DIR}", - ) - - options = parser.parse_args() - print(options) - - if not preflight_check(options.aot_flag): - return False - - if not options.cases: - if options.parl_flag: - # several cases might share the same workspace/tempfile at the same time - # so, disable it while running parallelly - options.clean_up_flag = False - options.verbose_flag = False - - start = time.time_ns() - ret = test_suite( - options.target, - options.aot_flag, - options.sgx_flag, - options.multi_module_flag, - options.multi_thread_flag, - options.simd_flag, - options.xip_flag, - options.clean_up_flag, - options.verbose_flag, - options.gc_flag, - options.parl_flag, - options.qemu_flag, - options.qemu_firmware, - options.log, - ) - end = time.time_ns() - print( - f"It takes {((end - start) / 1000000):,} ms to run test_suite {'parallelly' if options.parl_flag else ''}" - ) - else: - try: - for case in options.cases: - test_case( - case, - options.target, - options.aot_flag, - options.sgx_flag, - options.multi_module_flag, - options.multi_thread_flag, - options.simd_flag, - options.xip_flag, - options.clean_up_flag, - options.verbose_flag, - options.gc_flag, - options.qemu_flag, - options.qemu_firmware, - options.log - ) - else: - ret = True - except Exception: - ret = False - - return ret - - -if __name__ == "__main__": - sys.exit(0 if main() else 1) diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/all.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/all.sh deleted file mode 100755 index 09d868154..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/all.sh +++ /dev/null @@ -1,162 +0,0 @@ -#!/bin/bash - -# -# Copyright (C) 2019 Intel Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# - -# exit if meet an exception -function DEBUG() { - [[ -n $(env | grep "\") ]] && $@ -} -DEBUG set -xevu - -# Run the following command to test a single wast file: -# ./spec-test-script/runtest.py --wast2wasm ./workspace/wabt/out/gcc/Release/wat2wasm \ -# --interpreter iwasm - -readonly SPEC_TEST_DIR="spec/test/core" -readonly WAST2WASM_CMD="./wabt/out/gcc/Release/wat2wasm" -readonly WAMRC_CMD="../../../wamr-compiler/build/wamrc" -PLATFORM=$(uname -s | tr A-Z a-z) -IWASM_CMD="../../../product-mini/platforms/${PLATFORM}/build/iwasm" - -# "imports" and "linking" are only avilable when enabling multi modules -# "comments" is for runtest.py - -IGNORE_LIST=( - "comments" "inline-module" "imports" "linking" "names" -) - -readonly -a MULTI_MODULE_LIST=( - "imports" "linking" -) - -SGX_IGNORE_LIST=("conversions" "f32_bitwise" "f64_bitwise") - -# these cases run failed due to native stack overflow check failed -SGX_AOT_IGNORE_LIST=("call_indirect" "call" "fac" "skip-stack-guard-page") - -function usage() { - echo "Usage: all.sh [-t] [-m ] [-M] [-x] [-S] [-r]" - exit 1 -} - -function run_case_w_aot() { - local test_case=$1 - echo "============> run ${test_case} with AOT" - python2.7 runtest.py \ - --wast2wasm ${WAST2WASM_CMD} \ - --interpreter ${IWASM_CMD} \ - ${SPEC_TEST_DIR}/${test_case} \ - --aot-compiler ${WAMRC_CMD} \ - --aot --aot-target ${TARGET} \ - ${SGX_OPT} \ - ${SIMD_OPT} \ - ${REF_TYPES_OPT} - #--no_cleanup - if [[ $? != 0 ]]; then - echo "============> run ${test_case} failed" - exit 1 - fi -} - -function run_case_wo_aot() { - local test_case=$1 - echo "============> run ${test_case}" - python2.7 runtest.py \ - --wast2wasm ${WAST2WASM_CMD} \ - --interpreter ${IWASM_CMD} \ - ${SPEC_TEST_DIR}/${test_case} \ - --aot-compiler ${WAMRC_CMD} \ - ${SGX_OPT} \ - ${SIMD_OPT} \ - ${REF_TYPES_OPT} - #--no_cleanup - if [[ $? != 0 ]]; then - echo "============> run ${test_case} failed" - exit 1 - fi -} - -ENABLE_MULTI_MODULE=0 -TARGET="X86_64" -SGX_OPT="" -AOT=false -SIMD_OPT="" -REF_TYPES_OPT="" -while getopts ":Mm:txSr" opt; do - case $opt in - t) AOT=true ;; - m) - TARGET=$OPTARG - if [[ ${TARGET} == 'X86_32' ]]; then - TARGET='i386' - elif [[ ${TARGET} == 'X86_64' ]]; then - TARGET='x86_64' - elif [[ ${TARGET} == 'ARMV7_VFP' ]]; then - TARGET='armv7' - elif [[ ${TARGET} == 'THUMBV7_VFP' ]]; then - TARGET='thumbv7' - elif [[ ${TARGET} == 'RISCV64' || ${TARGET} == 'RISCV64_LP64D' ]]; then - TARGET='riscv64_lp64d' - elif [[ ${TARGET} == 'RISCV64_LP64' ]]; then - TARGET='riscv64_lp64' - else - usage - fi ;; - M) ENABLE_MULTI_MODULE=1 ;; - x) SGX_OPT="--sgx" ;; - S) SIMD_OPT="--simd" ;; - r) REF_TYPES_OPT="--ref_types" ;; - *) usage ;; - esac -done - -function contain() { - # [$1, $-1) - local list=${@:0:${#}} - # [$-1] - local item=${@:${#}} - [[ ${list} =~ (^| )${item}($| ) ]] && return 0 || return 1 -} - -if [[ ${SGX_OPT} ]]; then - IWASM_CMD="../../../product-mini/platforms/linux-sgx/enclave-sample/iwasm" - IGNORE_LIST+=("${SGX_IGNORE_LIST[@]}") - if [[ "true" == ${AOT} ]]; then - IGNORE_LIST+=("${SGX_AOT_IGNORE_LIST[@]}") - fi -fi - -if [[ ${TARGET} == "i386" ]]; then - IGNORE_LIST+=("float_exprs") -fi - -declare -i COUNTER=0 -for wast in $(find ${SPEC_TEST_DIR} -name "*.wast" -type f | sort -n); do - # remove a prefix spec/test/core/ - wast=${wast#${SPEC_TEST_DIR}/} - # ${wast%.wast} will remove a surfix .wast - if contain "${IGNORE_LIST[@]}" ${wast%.wast}; then - echo "============> ignore ${wast}" - continue - else - [[ "true" == ${AOT} ]] && run_case_w_aot ${wast} || - run_case_wo_aot ${wast} - ((COUNTER += 1)) - fi -done - -# for now, Multi_Module is always disabled while AOT is true -if [[ "false" == ${AOT} && 1 == ${ENABLE_MULTI_MODULE} ]]; then - echo "============> run cases about multi module" - for wast in ${MULTI_MODULE_LIST[@]}; do - run_case_wo_aot ${wast}.wast - ((COUNTER += 1)) - done -fi - -echo "PASS ALL ${COUNTER} SPEC CASES" -DEBUG set -xevu -exit 0 diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/collect_coverage.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/collect_coverage.sh deleted file mode 100755 index 09b1f465e..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/collect_coverage.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env bash - -# -# Copyright (C) 2019 Intel Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# - -readonly WORK_DIR=$PWD -readonly WAMR_DIR=${WORK_DIR}/../../.. -readonly DST_COV_FILE=$1 -readonly SRC_COV_DIR=$2 -readonly SRC_TEMP_COV_FILE=wamr_temp.lcov -readonly SRC_COV_FILE=wamr.lcov - -# get dest folder -dir=$(dirname ${DST_COV_FILE}) -pushd ${dir} > /dev/null 2>&1 -readonly DST_COV_DIR=${PWD} -popd > /dev/null 2>&1 - -if [[ ! -d ${SRC_COV_DIR} ]]; then - echo "${SRC_COV_DIR} doesn't exist, ignore code coverage collection" - exit -fi - -echo "Start to collect code coverage of ${SRC_COV_DIR} .." - -pushd ${SRC_COV_DIR} > /dev/null 2>&1 - -# collect all code coverage data -lcov -q -o ${SRC_TEMP_COV_FILE} -c -d . --rc lcov_branch_coverage=1 -# extract code coverage data of WAMR source files -lcov -q -r ${SRC_TEMP_COV_FILE} -o ${SRC_TEMP_COV_FILE} \ - -rc lcov_branch_coverage=1 \ - "*/usr/*" "*/_deps/*" "*/deps/*" "*/tests/unit/*" \ - "*/llvm/include/*" "*/include/llvm/*" "*/samples/*" \ - "*/app-framework/*" "*/app-mgr/*" "*/test-tools/*" \ - "*/tests/standalone/*" "*/tests/*" - -if [[ -s ${SRC_TEMP_COV_FILE} ]]; then - if [[ -s ${DST_COV_FILE} ]]; then - # merge code coverage data - lcov --rc lcov_branch_coverage=1 \ - --add-tracefile ${SRC_TEMP_COV_FILE} \ - -a ${DST_COV_FILE} -o ${SRC_COV_FILE} - # backup the original lcov file - cp -a ${DST_COV_FILE} "${DST_COV_FILE}.orig" - # replace the lcov file - cp -a ${SRC_COV_FILE} ${DST_COV_FILE} - echo "Code coverage file ${DST_COV_FILE} was appended" - else - cp -a ${SRC_TEMP_COV_FILE} ${SRC_COV_FILE} - cp -a ${SRC_COV_FILE} ${DST_COV_FILE} - echo "Code coverage file ${DST_COV_FILE} was generated" - fi - - # get ignored prefix path - dir=$(dirname ${WAMR_DIR}/../..) - pushd ${dir} > /dev/null 2>&1 - prefix_full_path=${PWD} - popd > /dev/null 2>&1 - - # generate html output for merged code coverage data - rm -fr ${DST_COV_DIR}/wamr-lcov - genhtml -q -t "WAMR Code Coverage" \ - --rc lcov_branch_coverage=1 --prefix=${prefix_full_path} \ - -o ${DST_COV_DIR}/wamr-lcov \ - ${DST_COV_FILE} - - cd ${DST_COV_DIR} - rm -f wamr-lcov.zip - zip -r -q -o wamr-lcov.zip wamr-lcov - rm -fr wamr-lcov - - echo "Code coverage html ${DST_COV_DIR}/wamr-lcov.zip was generated" -else - echo "generate code coverage html failed" -fi - -echo "" - -popd > /dev/null 2>&1 diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/ignore_cases.patch b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/ignore_cases.patch deleted file mode 100644 index 1d94d91af..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/ignore_cases.patch +++ /dev/null @@ -1,805 +0,0 @@ -diff --git a/test/core/binary.wast b/test/core/binary.wast -index 891aad3..07356a3 100644 ---- a/test/core/binary.wast -+++ b/test/core/binary.wast -@@ -206,7 +206,7 @@ - ) - - ;; Type section with signed LEB128 encoded type --(assert_malformed -+(;assert_malformed - (module binary - "\00asm" "\01\00\00\00" - "\01" ;; Type section id -@@ -216,7 +216,7 @@ - "\00\00" - ) - "integer representation too long" --) -+;) - - ;; Unsigned LEB128 must not be overlong - (assert_malformed -@@ -1683,7 +1683,7 @@ - ) - - ;; 2 elem segment declared, 1 given --(assert_malformed -+(;assert_malformed - (module binary - "\00asm" "\01\00\00\00" - "\01\04\01" ;; type section -@@ -1696,7 +1696,7 @@ - ;; "\00\41\00\0b\01\00" ;; elem 1 (missed) - ) - "unexpected end" --) -+;) - - ;; 2 elem segment declared, 1.5 given - (assert_malformed -@@ -1813,7 +1813,7 @@ - ) - - ;; 1 br_table target declared, 2 given --(assert_malformed -+(;assert_malformed - (module binary - "\00asm" "\01\00\00\00" - "\01\04\01" ;; type section -@@ -1832,7 +1832,7 @@ - "\0b\0b\0b" ;; end - ) - "unexpected end" --) -+;) - - ;; Start section - (module binary -diff --git a/test/core/data.wast b/test/core/data.wast -index 4f339be..0b5b3e6 100644 ---- a/test/core/data.wast -+++ b/test/core/data.wast -@@ -306,9 +306,10 @@ - "\02\01\41\00\0b" ;; active data segment 0 for memory 1 - "\00" ;; empty vec(byte) - ) -- "unknown memory 1" -+ "unknown memory" - ) - -+(; not supported by wat2wasm - ;; Data segment with memory index 0 (no memory section) - (assert_invalid - (module binary -@@ -317,7 +318,7 @@ - "\00\41\00\0b" ;; active data segment 0 for memory 0 - "\00" ;; empty vec(byte) - ) -- "unknown memory 0" -+ "unknown memory" - ) - - ;; Data segment with memory index 1 (no memory section) -@@ -328,7 +329,7 @@ - "\02\01\41\00\0b" ;; active data segment 0 for memory 1 - "\00" ;; empty vec(byte) - ) -- "unknown memory 1" -+ "unknown memory" - ) - - ;; Data segment with memory index 1 and vec(byte) as above, -@@ -348,7 +349,7 @@ - "\20\21\22\23\24\25\26\27\28\29\2a\2b\2c\2d\2e\2f" - "\30\31\32\33\34\35\36\37\38\39\3a\3b\3c\3d" - ) -- "unknown memory 1" -+ "unknown memory" - ) - - ;; Data segment with memory index 1 and specially crafted vec(byte) after. -@@ -368,8 +369,9 @@ - "\20\21\22\23\24\25\26\27\28\29\2a\2b\2c\2d\2e\2f" - "\30\31\32\33\34\35\36\37\38\39\3a\3b\3c\3d" - ) -- "unknown memory 1" -+ "unknown memory" - ) -+;) - - - ;; Invalid offsets -diff --git a/test/core/elem.wast b/test/core/elem.wast -index 575ecef..6eecab9 100644 ---- a/test/core/elem.wast -+++ b/test/core/elem.wast -@@ -571,9 +571,11 @@ - (func $const-i32-d (type $out-i32) (i32.const 68)) - ) - -+(; - (assert_return (invoke $module1 "call-7") (i32.const 67)) - (assert_return (invoke $module1 "call-8") (i32.const 68)) - (assert_return (invoke $module1 "call-9") (i32.const 66)) -+;) - - (module $module3 - (type $out-i32 (func (result i32))) -@@ -584,6 +586,8 @@ - (func $const-i32-f (type $out-i32) (i32.const 70)) - ) - -+(; - (assert_return (invoke $module1 "call-7") (i32.const 67)) - (assert_return (invoke $module1 "call-8") (i32.const 69)) - (assert_return (invoke $module1 "call-9") (i32.const 70)) -+;) -diff --git a/test/core/global.wast b/test/core/global.wast -index 9fa5e22..8c4b949 100644 ---- a/test/core/global.wast -+++ b/test/core/global.wast -@@ -328,10 +328,12 @@ - "type mismatch" - ) - -+(; - (assert_invalid - (module (global (import "" "") externref) (global funcref (global.get 0))) - "type mismatch" - ) -+;) - - (assert_invalid - (module (global (import "test" "global-i32") i32) (global i32 (global.get 0) (global.get 0))) -diff --git a/test/core/imports.wast b/test/core/imports.wast -index 35e8c91..a7a459d 100644 ---- a/test/core/imports.wast -+++ b/test/core/imports.wast -@@ -577,6 +577,7 @@ - (assert_return (invoke "grow" (i32.const 1)) (i32.const -1)) - (assert_return (invoke "grow" (i32.const 0)) (i32.const 2)) - -+(; unsupported by multi-module currently - (module $Mgm - (memory (export "memory") 1) ;; initial size is 1 - (func (export "grow") (result i32) (memory.grow (i32.const 1))) -@@ -596,6 +597,7 @@ - (func (export "size") (result i32) (memory.size)) - ) - (assert_return (invoke $Mgim2 "size") (i32.const 3)) -+;) - - - ;; Syntax errors -diff --git a/test/core/linking.wast b/test/core/linking.wast -index 994e0f4..d0bfb5f 100644 ---- a/test/core/linking.wast -+++ b/test/core/linking.wast -@@ -64,6 +64,7 @@ - (export "Mg.set_mut" (func $set_mut)) - ) - -+(; - (assert_return (get $Mg "glob") (i32.const 42)) - (assert_return (get $Ng "Mg.glob") (i32.const 42)) - (assert_return (get $Ng "glob") (i32.const 43)) -@@ -81,6 +82,7 @@ - (assert_return (get $Ng "Mg.mut_glob") (i32.const 241)) - (assert_return (invoke $Mg "get_mut") (i32.const 241)) - (assert_return (invoke $Ng "Mg.get_mut") (i32.const 241)) -+;) - - - (assert_unlinkable -@@ -165,6 +167,7 @@ - ) - ) - -+(; - (assert_return (invoke $Mt "call" (i32.const 2)) (i32.const 4)) - (assert_return (invoke $Nt "Mt.call" (i32.const 2)) (i32.const 4)) - (assert_return (invoke $Nt "call" (i32.const 2)) (i32.const 5)) -@@ -187,6 +190,7 @@ - - (assert_return (invoke $Nt "call" (i32.const 3)) (i32.const -4)) - (assert_trap (invoke $Nt "call" (i32.const 4)) "indirect call type mismatch") -+;) - - (module $Ot - (type (func (result i32))) -@@ -201,6 +205,7 @@ - ) - ) - -+(; - (assert_return (invoke $Mt "call" (i32.const 3)) (i32.const 4)) - (assert_return (invoke $Nt "Mt.call" (i32.const 3)) (i32.const 4)) - (assert_return (invoke $Nt "call Mt.call" (i32.const 3)) (i32.const 4)) -@@ -225,6 +230,7 @@ - (assert_trap (invoke $Ot "call" (i32.const 0)) "uninitialized element") - - (assert_trap (invoke $Ot "call" (i32.const 20)) "undefined element") -+;) - - (module - (table (import "Mt" "tab") 0 funcref) -@@ -263,6 +269,7 @@ - - ;; Unlike in the v1 spec, active element segments stored before an - ;; out-of-bounds access persist after the instantiation failure. -+(; - (assert_trap - (module - (table (import "Mt" "tab") 10 funcref) -@@ -274,7 +281,9 @@ - ) - (assert_return (invoke $Mt "call" (i32.const 7)) (i32.const 0)) - (assert_trap (invoke $Mt "call" (i32.const 8)) "uninitialized element") -+;) - -+(; - (assert_trap - (module - (table (import "Mt" "tab") 10 funcref) -@@ -286,6 +295,7 @@ - "out of bounds memory access" - ) - (assert_return (invoke $Mt "call" (i32.const 7)) (i32.const 0)) -+;) - - - (module $Mtable_ex -@@ -299,6 +309,7 @@ - (table (import "Mtable_ex" "t-extern") 1 externref) - ) - -+(; - (assert_unlinkable - (module (table (import "Mtable_ex" "t-func") 1 externref)) - "incompatible import type" -@@ -307,6 +318,7 @@ - (module (table (import "Mtable_ex" "t-extern") 1 funcref)) - "incompatible import type" - ) -+;) - - - ;; Memories -@@ -346,10 +358,12 @@ - ) - ) - -+(; - (assert_return (invoke $Mm "load" (i32.const 12)) (i32.const 0xa7)) - (assert_return (invoke $Nm "Mm.load" (i32.const 12)) (i32.const 0xa7)) - (assert_return (invoke $Nm "load" (i32.const 12)) (i32.const 0xf2)) - (assert_return (invoke $Om "load" (i32.const 12)) (i32.const 0xa7)) -+;) - - (module - (memory (import "Mm" "mem") 0) -@@ -372,6 +386,7 @@ - ) - ) - -+(; - (assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 1)) - (assert_return (invoke $Pm "grow" (i32.const 2)) (i32.const 1)) - (assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 3)) -@@ -380,6 +395,7 @@ - (assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 5)) - (assert_return (invoke $Pm "grow" (i32.const 1)) (i32.const -1)) - (assert_return (invoke $Pm "grow" (i32.const 0)) (i32.const 5)) -+;) - - (assert_unlinkable - (module -@@ -403,8 +419,10 @@ - ) - "out of bounds memory access" - ) -+(; - (assert_return (invoke $Mm "load" (i32.const 0)) (i32.const 97)) - (assert_return (invoke $Mm "load" (i32.const 327670)) (i32.const 0)) -+;) - - (assert_trap - (module -@@ -416,7 +434,9 @@ - ) - "out of bounds table access" - ) -+(; - (assert_return (invoke $Mm "load" (i32.const 0)) (i32.const 97)) -+;) - - ;; Store is modified if the start function traps. - (module $Ms -@@ -432,6 +452,7 @@ - ) - (register "Ms" $Ms) - -+(; - (assert_trap - (module - (import "Ms" "memory" (memory 1)) -@@ -451,3 +472,4 @@ - - (assert_return (invoke $Ms "get memory[0]") (i32.const 104)) ;; 'h' - (assert_return (invoke $Ms "get table[0]") (i32.const 0xdead)) -+;) -diff --git a/test/core/ref_func.wast b/test/core/ref_func.wast -index adb5cb7..590f626 100644 ---- a/test/core/ref_func.wast -+++ b/test/core/ref_func.wast -@@ -4,7 +4,8 @@ - (register "M") - - (module -- (func $f (import "M" "f") (param i32) (result i32)) -+ (; aot mode does not support module linking ;) -+ (func $f (param $x i32) (result i32) (local.get $x)) - (func $g (param $x i32) (result i32) - (i32.add (local.get $x) (i32.const 1)) - ) -diff --git a/test/core/select.wast b/test/core/select.wast -index 046e6fe..b677023 100644 ---- a/test/core/select.wast -+++ b/test/core/select.wast -@@ -324,6 +324,7 @@ - (module (func $arity-0 (select (result) (nop) (nop) (i32.const 1)))) - "invalid result arity" - ) -+(; - (assert_invalid - (module (func $arity-2 (result i32 i32) - (select (result i32 i32) -@@ -334,6 +335,7 @@ - )) - "invalid result arity" - ) -+;) - - - (assert_invalid -diff --git a/test/core/table_copy.wast b/test/core/table_copy.wast -index 380e84e..f37e745 100644 ---- a/test/core/table_copy.wast -+++ b/test/core/table_copy.wast -@@ -14,11 +14,12 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ ;; aot mode does not support module linking -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -106,11 +107,11 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (export "ef0") (result i32) (i32.const 0)) ;; index 0 -+ (func (export "ef1") (result i32) (i32.const 1)) -+ (func (export "ef2") (result i32) (i32.const 2)) -+ (func (export "ef3") (result i32) (i32.const 3)) -+ (func (export "ef4") (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -198,11 +199,11 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -290,11 +291,11 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -382,11 +383,11 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -474,11 +475,11 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -566,11 +567,11 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -658,11 +659,11 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -750,11 +751,11 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -842,11 +843,11 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -934,11 +935,11 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1026,11 +1027,11 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1118,11 +1119,11 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1210,11 +1211,11 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1302,11 +1303,11 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1394,11 +1395,11 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1486,11 +1487,11 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -1578,11 +1579,11 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t1) (i32.const 2) func 3 1 4 1) -diff --git a/test/core/table_init.wast b/test/core/table_init.wast -index 0b2d26f..bdab6a0 100644 ---- a/test/core/table_init.wast -+++ b/test/core/table_init.wast -@@ -14,11 +14,12 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ ;; aot mode does not support module linking -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -72,11 +73,12 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ ;; aot mode does not support module linking -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -130,11 +132,12 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ ;; aot mode does not support module linking -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t0) (i32.const 2) func 3 1 4 1) -@@ -196,11 +199,12 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ ;; aot mode does not support module linking -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -254,11 +258,12 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ ;; aot mode does not support module linking -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t1) (i32.const 2) func 3 1 4 1) -@@ -312,11 +317,12 @@ - - (module - (type (func (result i32))) ;; type #0 -- (import "a" "ef0" (func (result i32))) ;; index 0 -- (import "a" "ef1" (func (result i32))) -- (import "a" "ef2" (func (result i32))) -- (import "a" "ef3" (func (result i32))) -- (import "a" "ef4" (func (result i32))) ;; index 4 -+ ;; aot mode does not support module linking -+ (func (result i32) (i32.const 0)) ;; index 0 -+ (func (result i32) (i32.const 1)) -+ (func (result i32) (i32.const 2)) -+ (func (result i32) (i32.const 3)) -+ (func (result i32) (i32.const 4)) ;; index 4 - (table $t0 30 30 funcref) - (table $t1 30 30 funcref) - (elem (table $t1) (i32.const 2) func 3 1 4 1) -diff --git a/test/core/unreached-valid.wast b/test/core/unreached-valid.wast -index b7ebabf..4f2abfb 100644 ---- a/test/core/unreached-valid.wast -+++ b/test/core/unreached-valid.wast -@@ -46,6 +46,7 @@ - - ;; Validation after unreachable - -+(; - (module - (func (export "meet-bottom") - (block (result f64) -@@ -61,3 +62,4 @@ - ) - - (assert_trap (invoke "meet-bottom") "unreachable") -+;) diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/runtest.py b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/runtest.py deleted file mode 100755 index a1e505bd0..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/runtest.py +++ /dev/null @@ -1,1343 +0,0 @@ -#!/usr/bin/env python - -from __future__ import print_function - -import argparse -import array -import atexit -import fcntl -import math -import os -# Pseudo-TTY and terminal manipulation -import pty -import re -import shutil -import struct -import subprocess -import sys -import tempfile -import termios -import time -import traceback -from select import select -from subprocess import PIPE, STDOUT, Popen - -if sys.version_info[0] == 2: - IS_PY_3 = False -else: - IS_PY_3 = True - -test_aot = False -# "x86_64", "i386", "aarch64", "armv7", "thumbv7", "riscv32_ilp32", "riscv32_ilp32d", "riscv32_lp64", "riscv64_lp64d" -test_target = "x86_64" - -debug_file = None -log_file = None - -# to save the register module with self-define name -temp_file_repo = [] - -# to save the mapping of module files in /tmp by name -temp_module_table = {} - -def debug(data): - if debug_file: - debug_file.write(data) - debug_file.flush() - -def log(data, end='\n'): - if log_file: - log_file.write(data + end) - log_file.flush() - print(data, end=end) - sys.stdout.flush() - -# TODO: do we need to support '\n' too -import platform - -if platform.system().find("CYGWIN_NT") >= 0: - # TODO: this is weird, is this really right on Cygwin? - sep = "\n\r\n" -else: - sep = "\r\n" -rundir = None - -class Runner(): - def __init__(self, args, no_pty=False): - self.no_pty = no_pty - - # Cleanup child process on exit - atexit.register(self.cleanup) - - self.process = None - env = os.environ - env['TERM'] = 'dumb' - env['INPUTRC'] = '/dev/null' - env['PERL_RL'] = 'false' - if no_pty: - self.process = Popen(args, bufsize=0, - stdin=PIPE, stdout=PIPE, stderr=STDOUT, - preexec_fn=os.setsid, - env=env) - self.stdin = self.process.stdin - self.stdout = self.process.stdout - else: - # Use tty to setup an interactive environment - master, slave = pty.openpty() - - # Set terminal size large so that readline will not send - # ANSI/VT escape codes when the lines are long. - buf = array.array('h', [100, 200, 0, 0]) - fcntl.ioctl(master, termios.TIOCSWINSZ, buf, True) - - self.process = Popen(args, bufsize=0, - stdin=slave, stdout=slave, stderr=STDOUT, - preexec_fn=os.setsid, - env=env) - # Now close slave so that we will get an exception from - # read when the child exits early - # http://stackoverflow.com/questions/11165521 - os.close(slave) - self.stdin = os.fdopen(master, 'r+b', 0) - self.stdout = self.stdin - - self.buf = "" - - def read_to_prompt(self, prompts, timeout): - wait_until = time.time() + timeout - while time.time() < wait_until: - [outs,_,_] = select([self.stdout], [], [], 1) - if self.stdout in outs: - read_byte = self.stdout.read(1) - if not read_byte: - # EOF on macOS ends up here. - break - read_byte = read_byte.decode('utf-8') if IS_PY_3 else read_byte - - debug(read_byte) - if self.no_pty: - self.buf += read_byte.replace('\n', '\r\n') - else: - self.buf += read_byte - self.buf = self.buf.replace('\r\r', '\r') - - # filter the prompts - for prompt in prompts: - pattern = re.compile(prompt) - match = pattern.search(self.buf) - if match: - end = match.end() - buf = self.buf[0:end-len(prompt)] - self.buf = self.buf[end:] - return buf - return None - - def writeline(self, str): - str_to_write = str + '\n' - str_to_write = bytes( - str_to_write, 'utf-8') if IS_PY_3 else str_to_write - - self.stdin.write(str_to_write) - - def cleanup(self): - if self.process: - try: - self.writeline("__exit__") - time.sleep(.020) - self.process.kill() - except OSError: - pass - except IOError: - pass - self.process = None - self.stdin.close() - if self.stdin != self.stdout: - self.stdout.close() - self.stdin = None - self.stdout = None - if not IS_PY_3: - sys.exc_clear() - -def assert_prompt(runner, prompts, timeout, is_need_execute_result): - # Wait for the initial prompt - header = runner.read_to_prompt(prompts, timeout=timeout) - if not header and is_need_execute_result: - log(" ---------- will terminate cause the case needs result while there is none inside of buf. ----------") - sys.exit(1) - if not header == None: - if header: - log("Started with:\n%s" % header) - else: - log("Did not one of following prompt(s): %s" % repr(prompts)) - log(" Got : %s" % repr(r.buf)) - sys.exit(1) - - -### WebAssembly specific - -parser = argparse.ArgumentParser( - description="Run a test file against a WebAssembly interpreter") -parser.add_argument('--wast2wasm', type=str, - default=os.environ.get("WAST2WASM", "wast2wasm"), - help="Path to wast2wasm program") -parser.add_argument('--interpreter', type=str, - default=os.environ.get("IWASM_CMD", "iwasm"), - help="Path to WebAssembly interpreter") -parser.add_argument('--aot-compiler', type=str, - default=os.environ.get("WAMRC_CMD", "wamrc"), - help="Path to WebAssembly AoT compiler") - -parser.add_argument('--no_cleanup', action='store_true', - help="Keep temporary *.wasm files") - -parser.add_argument('--rundir', - help="change to the directory before running tests") -parser.add_argument('--start-timeout', default=30, type=int, - help="default timeout for initial prompt") -parser.add_argument('--test-timeout', default=20, type=int, - help="default timeout for each individual test action") -parser.add_argument('--no-pty', action='store_true', - help="Use direct pipes instead of pseudo-tty") -parser.add_argument('--log-file', type=str, - help="Write messages to the named file in addition the screen") -parser.add_argument('--log-dir', type=str, - help="The log directory to save the case file if test failed") -parser.add_argument('--debug-file', type=str, - help="Write all test interaction the named file") - -parser.add_argument('test_file', type=argparse.FileType('r'), - help="a WebAssembly *.wast test file") - -parser.add_argument('--aot', action='store_true', - help="Test with AOT") - -parser.add_argument('--target', type=str, - default="x86_64", - help="Set running target") - -parser.add_argument('--sgx', action='store_true', - help="Test SGX") - -parser.add_argument('--simd', default=False, action='store_true', - help="Enable SIMD") - -parser.add_argument('--xip', default=False, action='store_true', - help="Enable XIP") - -parser.add_argument('--multi-module', default=False, action='store_true', - help="Enable Multi-thread") - -parser.add_argument('--multi-thread', default=False, action='store_true', - help="Enable Multi-thread") - -parser.add_argument('--gc', default=False, action='store_true', - help='Test with GC') - -parser.add_argument('--qemu', default=False, action='store_true', - help="Enable QEMU") - -parser.add_argument('--qemu-firmware', default='', help="Firmware required by qemu") - -parser.add_argument('--verbose', default=False, action='store_true', - help='show more logs') - -# regex patterns of tests to skip -C_SKIP_TESTS = () -PY_SKIP_TESTS = ( - # names.wast - 'invoke \"~!', - # conversions.wast - '18446742974197923840.0', - '18446744073709549568.0', - '9223372036854775808', - 'reinterpret_f.*nan', - # endianness - '.const 0x1.fff' ) - -def read_forms(string): - forms = [] - form = "" - depth = 0 - line = 0 - pos = 0 - while pos < len(string): - # Keep track of line number - if string[pos] == '\n': line += 1 - - # Handle top-level elements - if depth == 0: - # Add top-level comments - if string[pos:pos+2] == ";;": - end = string.find("\n", pos) - if end == -1: end == len(string) - forms.append(string[pos:end]) - pos = end - continue - - # TODO: handle nested multi-line comments - if string[pos:pos+2] == "(;": - # Skip multi-line comment - end = string.find(";)", pos) - if end == -1: - raise Exception("mismatch multiline comment on line %d: '%s'" % ( - line, string[pos:pos+80])) - pos = end+2 - continue - - # Ignore whitespace between top-level forms - if string[pos] in (' ', '\n', '\t'): - pos += 1 - continue - - # Read a top-level form - if string[pos] == '(': depth += 1 - if string[pos] == ')': depth -= 1 - if depth == 0 and not form: - raise Exception("garbage on line %d: '%s'" % ( - line, string[pos:pos+80])) - form += string[pos] - if depth == 0 and form: - forms.append(form) - form = "" - pos += 1 - return forms - -def get_module_exp_from_assert(string): - depth = 0 - pos = 0 - module = "" - exception = "" - start_record = False - result = [] - while pos < len(string): - # record from the " (module " - if string[pos:pos+7] == "(module": - start_record = True - if start_record: - if string[pos] == '(' : depth += 1 - if string[pos] == ')' : depth -= 1 - module += string[pos] - # if we get all (module ) . - if depth == 0 and module: - result.append(module) - start_record = False - # get expected exception - if string[pos] == '"': - end = string.find("\"", pos+1) - if end != -1: - end_rel = string.find("\"",end+1) - if end_rel == -1: - result.append(string[pos+1:end]) - pos += 1 - return result - -def string_to_unsigned(number_in_string, lane_type): - if not lane_type in ['i8x16', 'i16x8', 'i32x4', 'i64x2']: - raise Exception("invalid value {} and type {} and lane_type {}".format(number_in_string, type, lane_type)) - - number = int(number_in_string, 16) if '0x' in number_in_string else int(number_in_string) - - if "i8x16" == lane_type: - if number < 0: - packed = struct.pack('b', number) - number = struct.unpack('B', packed)[0] - elif "i16x8" == lane_type: - if number < 0: - packed = struct.pack('h', number) - number = struct.unpack('H', packed)[0] - elif "i32x4" == lane_type: - if number < 0: - packed = struct.pack('i', number) - number = struct.unpack('I', packed)[0] - else: # "i64x2" == lane_type: - if number < 0: - packed = struct.pack('q', number) - number = struct.unpack('Q', packed)[0] - - return number - -def cast_v128_to_i64x2(numbers, type, lane_type): - numbers = [n.replace("_", "") for n in numbers] - - if "i8x16" == lane_type: - assert(16 == len(numbers)), "{} should like {}".format(numbers, lane_type) - # str -> int - numbers = [string_to_unsigned(n, lane_type) for n in numbers] - # i8 -> i64 - packed = struct.pack(16 * "B", *numbers) - elif "i16x8" == lane_type: - assert(8 == len(numbers)), "{} should like {}".format(numbers, lane_type) - # str -> int - numbers = [string_to_unsigned(n, lane_type) for n in numbers] - # i16 -> i64 - packed = struct.pack(8 * "H", *numbers) - elif "i32x4" == lane_type: - assert(4 == len(numbers)), "{} should like {}".format(numbers, lane_type) - # str -> int - numbers = [string_to_unsigned(n, lane_type) for n in numbers] - # i32 -> i64 - packed = struct.pack(4 * "I", *numbers) - elif "i64x2" == lane_type: - assert(2 == len(numbers)), "{} should like {}".format(numbers, lane_type) - # str -> int - numbers = [string_to_unsigned(n, lane_type) for n in numbers] - # i64 -> i64 - packed = struct.pack(2 * "Q", *numbers) - elif "f32x4" == lane_type: - assert(4 == len(numbers)), "{} should like {}".format(numbers, lane_type) - # str -> int - numbers = [parse_simple_const_w_type(n, "f32")[0] for n in numbers] - # f32 -> i64 - packed = struct.pack(4 * "f", *numbers) - elif "f64x2" == lane_type: - assert(2 == len(numbers)), "{} should like {}".format(numbers, lane_type) - # str -> int - numbers = [parse_simple_const_w_type(n, "f64")[0] for n in numbers] - # f64 -> i64 - packed = struct.pack(2 * "d", *numbers) - else: - raise Exception("invalid value {} and type {} and lane_type {}".format(numbers, type, lane_type)) - - assert(packed) - unpacked = struct.unpack("Q Q", packed) - return unpacked, "[{} {}]:{}:v128".format(unpacked[0], unpacked[1], lane_type) - - -def parse_simple_const_w_type(number, type): - number = number.replace('_', '') - if type in ["i32", "i64"]: - number = int(number, 16) if '0x' in number else int(number) - return number, "0x{:x}:{}".format(number, type) \ - if number >= 0 \ - else "-0x{:x}:{}".format(0 - number, type) - elif type in ["f32", "f64"]: - if "nan:" in number: - # TODO: how to handle this correctly - if "nan:canonical" in number: - return float.fromhex("0x200000"), "nan:{}".format(type) - elif "nan:arithmetic" in number: - return float.fromhex("-0x200000"), "nan:{}".format(type) - else: - return float('nan'), "nan:{}".format(type) - else: - number = float.fromhex(number) if '0x' in number else float(number) - return number, "{:.7g}:{}".format(number, type) - elif type == "ref.null": - if number == "func": - return "func", "func:ref.null" - elif number == "extern": - return "extern", "extern:ref.null" - elif number == "any": - return "any", "any:ref.null" - else: - raise Exception("invalid value {} and type {}".format(number, type)) - elif type == "ref.extern": - number = int(number, 16) if '0x' in number else int(number) - return number, "0x{:x}:ref.extern".format(number) - elif type == "ref.host": - number = int(number, 16) if '0x' in number else int(number) - return number, "0x{:x}:ref.host".format(number) - else: - raise Exception("invalid value {} and type {}".format(number, type)) - -def parse_assertion_value(val): - """ - Parse something like: - "ref.null extern" in (assert_return (invoke "get-externref" (i32.const 0)) (ref.null extern)) - "ref.extern 1" in (assert_return (invoke "get-externref" (i32.const 1)) (ref.extern 1)) - "i32.const 0" in (assert_return (invoke "is_null-funcref" (i32.const 1)) (i32.const 0)) - - in summary: - type.const (sub-type) (val1 val2 val3 val4) ... - type.const val - ref.extern val - ref.null ref_type - ref.array - ref.struct - ref.func - ref.i31 - """ - if not val: - return None, "" - - splitted = re.split('\s+', val) - splitted = [s for s in splitted if s] - type = splitted[0].split(".")[0] - lane_type = splitted[1] if len(splitted) > 2 else "" - numbers = splitted[2:] if len(splitted) > 2 else splitted[1:] - - if type in ["i32", "i64", "f32", "f64"]: - return parse_simple_const_w_type(numbers[0], type) - elif type == "ref": - if splitted[0] in ["ref.array", "ref.struct", "ref.func", "ref.i31"]: - return splitted[0] - # need to distinguish between "ref.null" and "ref.extern" - return parse_simple_const_w_type(numbers[0], splitted[0]) - else: - return cast_v128_to_i64x2(numbers, type, lane_type) - -def int2uint32(i): - return i & 0xffffffff - -def int2int32(i): - val = i & 0xffffffff - if val & 0x80000000: - return val - 0x100000000 - else: - return val - -def int2uint64(i): - return i & 0xffffffffffffffff - -def int2int64(i): - val = i & 0xffffffffffffffff - if val & 0x8000000000000000: - return val - 0x10000000000000000 - else: - return val - - -def num_repr(i): - if isinstance(i, int) or isinstance(i, long): - return re.sub("L$", "", hex(i)) - else: - return "%.16g" % i - -def hexpad16(i): - return "0x%04x" % i - -def hexpad24(i): - return "0x%06x" % i - -def hexpad32(i): - return "0x%08x" % i - -def hexpad64(i): - return "0x%016x" % i - -def invoke(r, args, cmd): - r.writeline(cmd) - - return r.read_to_prompt(['\r\nwebassembly> ', '\nwebassembly> '], - timeout=args.test_timeout) - -def vector_value_comparison(out, expected): - """ - out likes ":v128" - expected likes "[number number]:v128" - """ - # print("vector value comparision {} vs {}".format(out, expected)) - - out_val, out_type = out.split(':') - # => number number - out_val = out_val[1:-1] - - expected_val, lane_type, expected_type = expected.split(':') - # [number nubmer] => number number - expected_val = expected_val[1:-1] - - assert("v128" == out_type), "out_type should be v128" - assert("v128" == expected_type), "expected_type should be v128" - - if out_type != expected_type: - return False - - if out_val == expected_val: - return True - - out_val = out_val.split(" ") - expected_val = expected_val.split(" ") - - # since i64x2 - out_packed = struct.pack("QQ", int(out_val[0], 16), int(out_val[1], 16)) - expected_packed = struct.pack("QQ", - int(expected_val[0]) if not "0x" in expected_val[0] else int(expected_val[0], 16), - int(expected_val[1]) if not "0x" in expected_val[1] else int(expected_val[1], 16)) - - if lane_type in ["i8x16", "i16x8", "i32x4", "i64x2"]: - return out_packed == expected_packed; - else: - assert(lane_type in ["f32x4", "f64x2"]), "unexpected lane_type" - - if "f32x4" == lane_type: - out_unpacked = struct.unpack("ffff", out_packed) - expected_unpacked = struct.unpack("ffff", expected_packed) - else: - out_unpacked = struct.unpack("dd", out_packed) - expected_unpacked = struct.unpack("dd", expected_packed) - - out_is_nan = [math.isnan(o) for o in out_unpacked] - expected_is_nan = [math.isnan(e) for e in expected_unpacked] - if out_is_nan and expected_is_nan: - return True; - - # print("compare {} and {}".format(out_unpacked, expected_unpacked)) - result = [o == e for o, e in zip(out_unpacked, expected_unpacked)] - - if not all(result): - result = [ - "{:.7g}".format(o) == "{:.7g}".format(e) - for o, e in zip(out_unpacked, expected_packed) - ] - - return all(result) - - -def simple_value_comparison(out, expected): - """ - compare out of simple types which may like val:i32, val:f64 and so on - """ - if expected == "2.360523e+13:f32" and out == "2.360522e+13:f32": - # one case in float_literals.wast, due to float precision of python - return True - - if expected == "1.797693e+308:f64" and out == "inf:f64": - # one case in float_misc.wast: - # (assert_return (invoke "f64.add" (f64.const 0x1.fffffffffffffp+1023) - # (f64.const 0x1.fffffffffffffp+969)) - # (f64.const 0x1.fffffffffffffp+1023)) - # the add result in x86_32 is inf - return True - - out_val, out_type = out.split(':') - expected_val, expected_type = expected.split(':') - - if not out_type == expected_type: - return False - - out_val, _ = parse_simple_const_w_type(out_val, out_type) - expected_val, _ = parse_simple_const_w_type(expected_val, expected_type) - - if out_val == expected_val \ - or (math.isnan(out_val) and math.isnan(expected_val)): - return True - - if "i32" == expected_type: - out_val_binary = struct.pack('I', out_val) if out_val > 0 \ - else struct.pack('i', out_val) - expected_val_binary = struct.pack('I', expected_val) \ - if expected_val > 0 \ - else struct.pack('i', expected_val) - elif "i64" == expected_type: - out_val_binary = struct.pack('Q', out_val) if out_val > 0 \ - else struct.pack('q', out_val) - expected_val_binary = struct.pack('Q', expected_val) \ - if expected_val > 0 \ - else struct.pack('q', expected_val) - elif "f32" == expected_type: - out_val_binary = struct.pack('f', out_val) - expected_val_binary = struct.pack('f', expected_val) - elif "f64" == expected_type: - out_val_binary = struct.pack('d', out_val) - expected_val_binary = struct.pack('d', expected_val) - elif "ref.extern" == expected_type: - out_val_binary = out_val - expected_val_binary = expected_val - elif "ref.host" == expected_type: - out_val_binary = out_val - expected_val_binary = expected_val - else: - assert(0), "unknown 'expected_type' {}".format(expected_type) - - if out_val_binary == expected_val_binary: - return True - - if expected_type in ["f32", "f64"]: - # compare with a lower precision - out_str = "{:.7g}".format(out_val) - expected_str = "{:.7g}".format(expected_val) - if out_str == expected_str: - return True - - return False - -def value_comparison(out, expected): - if out == expected: - return True - - if not expected: - return False - - if not out in ["ref.array", "ref.struct", "ref.func", "ref.any", "ref.i31"]: - assert(':' in out), "out should be in a form likes numbers:type, but {}".format(out) - if not expected in ["ref.array", "ref.struct", "ref.func", "ref.any", "ref.i31"]: - assert(':' in expected), "expected should be in a form likes numbers:type, but {}".format(expected) - - if 'v128' in out: - return vector_value_comparison(out, expected) - else: - return simple_value_comparison(out, expected) - -def is_result_match_expected(out, expected): - # compare value instead of comparing strings of values - return value_comparison(out, expected) - -def test_assert(r, opts, mode, cmd, expected): - log("Testing(%s) %s = %s" % (mode, cmd, expected)) - out = invoke(r, opts, cmd) - if '\n' in out or ' ' in out: - outs = [''] + out.split('\n')[1:] - out = outs[-1] - - if mode=='trap': - o = re.sub('^Exception: ', '', out) - e = re.sub('^Exception: ', '', expected) - if o.find(e) >= 0 or e.find(o) >= 0: - return True - - if mode=='exhaustion': - o = re.sub('^Exception: ', '', out) - expected = 'Exception: stack overflow' - e = re.sub('^Exception: ', '', expected) - if o.find(e) >= 0 or e.find(o) >= 0: - return True - - ## 0x9:i32,-0x1:i32 -> ['0x9:i32', '-0x1:i32'] - expected_list = re.split(',', expected) - out_list = re.split(',', out) - if len(expected_list) != len(out_list): - raise Exception("Failed:\n Results count incorrect:\n expected: '%s'\n got: '%s'" % (expected, out)) - for i in range(len(expected_list)): - if not is_result_match_expected(out_list[i], expected_list[i]): - raise Exception("Failed:\n Result %d incorrect:\n expected: '%s'\n got: '%s'" % (i, expected_list[i], out_list[i])) - - return True - -def test_assert_return(r, opts, form): - """ - m. to search a pattern like (assert_return (invoke function_name ... ) ...) - n. to search a pattern like (assert_return (invoke $module_name function_name ... ) ...) - """ - # params, return - m = re.search('^\(assert_return\s+\(invoke\s+"((?:[^"]|\\\")*)"\s+(\(.*\))\s*\)\s*(\(.*\))\s*\)\s*$', form, re.S) - # judge if assert_return cmd includes the module name - n = re.search('^\(assert_return\s+\(invoke\s+\$((?:[^\s])*)\s+"((?:[^"]|\\\")*)"\s+(\(.*\))\s*\)\s*(\(.*\))\s*\)\s*$', form, re.S) - - # print("assert_return with {}".format(form)) - - if not m: - # no params, return - m = re.search('^\(assert_return\s+\(invoke\s+"((?:[^"]|\\\")*)"\s*\)\s+()(\(.*\))\s*\)\s*$', form, re.S) - if not m: - # params, no return - m = re.search('^\(assert_return\s+\(invoke\s+"([^"]*)"\s+(\(.*\))()\s*\)\s*\)\s*$', form, re.S) - if not m: - # no params, no return - m = re.search('^\(assert_return\s+\(invoke\s+"([^"]*)"\s*()()\)\s*\)\s*$', form, re.S) - if not m: - # params, return - if not n: - # no params, return - n = re.search('^\(assert_return\s+\(invoke\s+\$((?:[^\s])*)\s+"((?:[^"]|\\\")*)"\s*\)\s+()(\(.*\))\s*\)\s*$', form, re.S) - if not n: - # params, no return - n = re.search('^\(assert_return\s+\(invoke\s+\$((?:[^\s])*)\s+"([^"]*)"\s+(\(.*\))()\s*\)\s*\)\s*$', form, re.S) - if not n: - # no params, no return - n = re.search('^\(assert_return\s+\(invoke\s+\$((?:[^\s])*)\s+"([^"]*)"*()()\)\s*\)\s*$', form, re.S) - if not m and not n: - if re.search('^\(assert_return\s+\(get.*\).*\)$', form, re.S): - log("ignoring assert_return get"); - return - else: - raise Exception("unparsed assert_return: '%s'" % form) - if m and not n: - func = m.group(1) - if ' ' in func: - func = func.replace(' ', '\\') - - if m.group(2) == '': - args = [] - else: - #args = [re.split(' +', v)[1].replace('_', "") for v in re.split("\)\s*\(", m.group(2)[1:-1])] - # split arguments with ')spaces(', remove leading and tailing ) and ( - args_type_and_value = re.split(r'\)\s+\(', m.group(2)[1:-1]) - args_type_and_value = [s.replace('_', '') for s in args_type_and_value] - # args are in two forms: - # f32.const -0x1.000001fffffffffffp-50 - # v128.const i32x4 0 0 0 0 - args = [] - for arg in args_type_and_value: - # remove leading and tailing spaces, it might confuse following assertions - arg = arg.strip() - splitted = re.split('\s+', arg) - splitted = [s for s in splitted if s] - - if splitted[0] in ["i32.const", "i64.const"]: - assert(2 == len(splitted)), "{} should have two parts".format(splitted) - # in wast 01234 means 1234 - # in c 0123 means 83 in oct - number, _ = parse_simple_const_w_type(splitted[1], splitted[0][:3]) - args.append(str(number)) - elif splitted[0] in ["f32.const", "f64.const"]: - # let strtof or strtod handle original arguments - assert(2 == len(splitted)), "{} should have two parts".format(splitted) - args.append(splitted[1]) - elif "v128.const" == splitted[0]: - assert(len(splitted) > 2), "{} should have more than two parts".format(splitted) - numbers, _ = cast_v128_to_i64x2(splitted[2:], 'v128', splitted[1]) - - assert(len(numbers) == 2), "has to reform arguments into i64x2" - args.append("{}\{}".format(numbers[0], numbers[1])) - elif "ref.null" == splitted[0]: - args.append("null") - elif "ref.extern" == splitted[0]: - number, _ = parse_simple_const_w_type(splitted[1], splitted[0]) - args.append(str(number)) - elif "ref.host" == splitted[0]: - number, _ = parse_simple_const_w_type(splitted[1], splitted[0]) - args.append(str(number)) - else: - assert(0), "an unkonwn parameter type" - - if m.group(3) == '': - returns= [] - else: - returns = re.split("\)\s*\(", m.group(3)[1:-1]) - # processed numbers in strings - if len(returns) == 1 and returns[0] in ["ref.array", "ref.struct", "ref.i31", - "ref.eq", "ref.any", "ref.extern", - "ref.func", "ref.null"]: - expected = [returns[0]] - elif len(returns) == 1 and returns[0] in ["func:ref.null", "any:ref.null", - "extern:ref.null"]: - expected = [returns[0]] - else: - expected = [parse_assertion_value(v)[1] for v in returns] - expected = ",".join(expected) - - test_assert(r, opts, "return", "%s %s" % (func, " ".join(args)), expected) - elif not m and n: - module = temp_module_table[n.group(1)].split(".wasm")[0] - # assume the cmd is (assert_return(invoke $ABC "func")). - # run the ABC.wasm firstly - if test_aot: - r = compile_wasm_to_aot(module+".wasm", module+".aot", True, opts, r) - try: - assert_prompt(r, ['Compile success'], opts.start_timeout, False) - except: - _, exc, _ = sys.exc_info() - log("Run wamrc failed:\n got: '%s'" % r.buf) - sys.exit(1) - r = run_wasm_with_repl(module+".wasm", module+".aot" if test_aot else module, opts, r) - # Wait for the initial prompt - try: - assert_prompt(r, ['webassembly> '], opts.start_timeout, False) - except: - _, exc, _ = sys.exc_info() - raise Exception("Failed:\n expected: '%s'\n got: '%s'" % \ - (repr(exc), r.buf)) - func = n.group(2) - if ' ' in func: - func = func.replace(' ', '\\') - - if n.group(3) == '': - args=[] - else: - # convert (ref.null extern/func) into (ref.null null) - n1 = n.group(3).replace("(ref.null extern)", "(ref.null null)") - n1 = n1.replace("ref.null func)", "(ref.null null)") - args = [re.split(' +', v)[1] for v in re.split("\)\s*\(", n1[1:-1])] - - _, expected = parse_assertion_value(n.group(4)[1:-1]) - test_assert(r, opts, "return", "%s %s" % (func, " ".join(args)), expected) - -def test_assert_trap(r, opts, form): - # params - m = re.search('^\(assert_trap\s+\(invoke\s+"([^"]*)"\s+(\(.*\))\s*\)\s*"([^"]+)"\s*\)\s*$', form) - # judge if assert_return cmd includes the module name - n = re.search('^\(assert_trap\s+\(invoke\s+\$((?:[^\s])*)\s+"([^"]*)"\s+(\(.*\))\s*\)\s*"([^"]+)"\s*\)\s*$', form, re.S) - if not m: - # no params - m = re.search('^\(assert_trap\s+\(invoke\s+"([^"]*)"\s*()\)\s*"([^"]+)"\s*\)\s*$', form) - if not m: - if not n: - # no params - n = re.search('^\(assert_trap\s+\(invoke\s+\$((?:[^\s])*)\s+"([^"]*)"\s*()\)\s*"([^"]+)"\s*\)\s*$', form, re.S) - if not m and not n: - raise Exception("unparsed assert_trap: '%s'" % form) - - if m and not n: - func = m.group(1) - if m.group(2) == '': - args = [] - else: - # convert (ref.null extern/func) into (ref.null null) - m1 = m.group(2).replace("(ref.null extern)", "(ref.null null)") - m1 = m1.replace("ref.null func)", "(ref.null null)") - args = [re.split(' +', v)[1] for v in re.split("\)\s*\(", m1[1:-1])] - - expected = "Exception: %s" % m.group(3) - test_assert(r, opts, "trap", "%s %s" % (func, " ".join(args)), expected) - - elif not m and n: - module = n.group(1) - module = tempfile.gettempdir() + "/" + module - - # will trigger the module named in assert_return(invoke $ABC). - # run the ABC.wasm firstly - if test_aot: - r = compile_wasm_to_aot(module+".wasm", module+".aot", True, opts, r) - try: - assert_prompt(r, ['Compile success'], opts.start_timeout, False) - except: - _, exc, _ = sys.exc_info() - log("Run wamrc failed:\n got: '%s'" % r.buf) - sys.exit(1) - r = run_wasm_with_repl(module+".wasm", module+".aot" if test_aot else module, opts, r) - # Wait for the initial prompt - try: - assert_prompt(r, ['webassembly> '], opts.start_timeout, False) - except: - _, exc, _ = sys.exc_info() - raise Exception("Failed:\n expected: '%s'\n got: '%s'" % \ - (repr(exc), r.buf)) - - func = n.group(2) - if n.group(3) == '': - args = [] - else: - args = [re.split(' +', v)[1] for v in re.split("\)\s*\(", n.group(3)[1:-1])] - expected = "Exception: %s" % n.group(4) - test_assert(r, opts, "trap", "%s %s" % (func, " ".join(args)), expected) - -def test_assert_exhaustion(r,opts,form): - # params - m = re.search('^\(assert_exhaustion\s+\(invoke\s+"([^"]*)"\s+(\(.*\))\s*\)\s*"([^"]+)"\s*\)\s*$', form) - if not m: - # no params - m = re.search('^\(assert_exhaustion\s+\(invoke\s+"([^"]*)"\s*()\)\s*"([^"]+)"\s*\)\s*$', form) - if not m: - raise Exception("unparsed assert_exhaustion: '%s'" % form) - func = m.group(1) - if m.group(2) == '': - args = [] - else: - args = [re.split(' +', v)[1] for v in re.split("\)\s*\(", m.group(2)[1:-1])] - expected = "Exception: %s\n" % m.group(3) - test_assert(r, opts, "exhaustion", "%s %s" % (func, " ".join(args)), expected) - -def do_invoke(r, opts, form): - # params - m = re.search('^\(invoke\s+"([^"]+)"\s+(\(.*\))\s*\)\s*$', form) - if not m: - # no params - m = re.search('^\(invoke\s+"([^"]+)"\s*()\)\s*$', form) - if not m: - raise Exception("unparsed invoke: '%s'" % form) - func = m.group(1) - - if ' ' in func: - func = func.replace(' ', '\\') - - if m.group(2) == '': - args = [] - else: - args = [re.split(' +', v)[1] for v in re.split("\)\s*\(", m.group(2)[1:-1])] - - log("Invoking %s(%s)" % ( - func, ", ".join([str(a) for a in args]))) - - invoke(r, opts, "%s %s" % (func, " ".join(args))) - -def skip_test(form, skip_list): - for s in skip_list: - if re.search(s, form): - return True - return False - -def compile_wast_to_wasm(form, wast_tempfile, wasm_tempfile, opts): - log("Writing WAST module to '%s'" % wast_tempfile) - open(wast_tempfile, 'w').write(form) - log("Compiling WASM to '%s'" % wasm_tempfile) - - # default arguments - if opts.gc: - cmd = [opts.wast2wasm, "-u", "-d", wast_tempfile, "-o", wasm_tempfile] - else: - cmd = [opts.wast2wasm, "--enable-thread", "--no-check", - wast_tempfile, "-o", wasm_tempfile ] - - # remove reference-type and bulk-memory enabling options since a WABT - # commit 30c1e983d30b33a8004b39fd60cbd64477a7956c - # Enable reference types by default (#1729) - - log("Running: %s" % " ".join(cmd)) - try: - subprocess.check_call(cmd) - except subprocess.CalledProcessError as e: - print(str(e)) - return False - - return True - -def compile_wasm_to_aot(wasm_tempfile, aot_tempfile, runner, opts, r, output = 'default'): - log("Compiling AOT to '%s'" % aot_tempfile) - cmd = [opts.aot_compiler] - - if test_target == "x86_64": - cmd.append("--target=x86_64") - cmd.append("--cpu=skylake") - elif test_target == "i386": - cmd.append("--target=i386") - elif test_target == "aarch64": - cmd += ["--target=aarch64", "--cpu=cortex-a57"] - elif test_target == "armv7": - cmd += ["--target=armv7", "--target-abi=gnueabihf"] - elif test_target == "thumbv7": - cmd += ["--target=thumbv7", "--target-abi=gnueabihf", "--cpu=cortex-a9", "--cpu-features=-neon"] - elif test_target == "riscv32_ilp32": - cmd += ["--target=riscv32", "--target-abi=ilp32", "--cpu=generic-rv32", "--cpu-features=+m,+a,+c"] - elif test_target == "riscv32_ilp32d": - cmd += ["--target=riscv32", "--target-abi=ilp32d", "--cpu=generic-rv32", "--cpu-features=+m,+a,+c"] - elif test_target == "riscv64_lp64": - cmd += ["--target=riscv64", "--target-abi=lp64", "--cpu=generic-rv64", "--cpu-features=+m,+a,+c"] - elif test_target == "riscv64_lp64d": - cmd += ["--target=riscv64", "--target-abi=lp64d", "--cpu=generic-rv32", "--cpu-features=+m,+a,+c"] - else: - pass - - if opts.sgx: - cmd.append("-sgx") - - if not opts.simd: - cmd.append("--disable-simd") - - if opts.xip: - cmd.append("--enable-indirect-mode") - cmd.append("--disable-llvm-intrinsics") - - if opts.multi_thread: - cmd.append("--enable-multi-thread") - - if output == 'object': - cmd.append("--format=object") - elif output == 'ir': - cmd.append("--format=llvmir-opt") - - # disable llvm link time optimization as it might convert - # code of tail call into code of dead loop, and stack overflow - # exception isn't thrown in several cases - cmd.append("--disable-llvm-lto") - - cmd += ["-o", aot_tempfile, wasm_tempfile] - - log("Running: %s" % " ".join(cmd)) - if not runner: - subprocess.check_call(cmd) - else: - if (r != None): - r.cleanup() - r = Runner(cmd, no_pty=opts.no_pty) - return r - -def run_wasm_with_repl(wasm_tempfile, aot_tempfile, opts, r): - tmpfile = aot_tempfile if test_aot else wasm_tempfile - log("Starting interpreter for module '%s'" % tmpfile) - - cmd_iwasm = [opts.interpreter, "--heap-size=0", "-v=5" if opts.verbose else "-v=0", "--repl", tmpfile] - - if opts.multi_module: - cmd_iwasm.insert(1, "--module-path=" + (tempfile.gettempdir() if not opts.qemu else "/tmp" )) - - if opts.qemu: - if opts.qemu_firmware == '': - raise Exception("QEMU firmware missing") - - if opts.target == "thumbv7": - cmd = ["qemu-system-arm", "-semihosting", "-M", "sabrelite", "-m", "1024", "-smp", "4", "-nographic", "-kernel", opts.qemu_firmware] - elif opts.target == "riscv32_ilp32": - cmd = ["qemu-system-riscv32", "-semihosting", "-M", "virt,aclint=on", "-cpu", "rv32", "-smp", "8", "-nographic", "-bios", "none", "-kernel", opts.qemu_firmware] - elif opts.target == "riscv64_lp64": - cmd = ["qemu-system-riscv64", "-semihosting", "-M", "virt,aclint=on", "-cpu", "rv64", "-smp", "8", "-nographic", "-bios", "none", "-kernel", opts.qemu_firmware] - - else: - cmd = cmd_iwasm - - log("Running: %s" % " ".join(cmd)) - if (r != None): - r.cleanup() - r = Runner(cmd, no_pty=opts.no_pty) - - if opts.qemu: - r.read_to_prompt(['nsh> '], 10) - r.writeline("mount -t hostfs -o fs={} /tmp".format(tempfile.gettempdir())) - r.read_to_prompt(['nsh> '], 10) - r.writeline(" ".join(cmd_iwasm)) - - return r - -def create_tmpfiles(wast_name): - tempfiles = [] - - (t1fd, wast_tempfile) = tempfile.mkstemp(suffix=".wast") - (t2fd, wasm_tempfile) = tempfile.mkstemp(suffix=".wasm") - tempfiles.append(wast_tempfile) - tempfiles.append(wasm_tempfile) - if test_aot: - (t3fd, aot_tempfile) = tempfile.mkstemp(suffix=".aot") - tempfiles.append(aot_tempfile) - - # add these temp file to temporal repo, will be deleted when finishing the test - temp_file_repo.extend(tempfiles) - return tempfiles - -def test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile, opts, r, loadable = True): - details_inside_ast = get_module_exp_from_assert(form) - log("module is ....'%s'"%details_inside_ast[0]) - log("exception is ....'%s'"%details_inside_ast[1]) - # parse the module - module = details_inside_ast[0] - expected = details_inside_ast[1] - - if not compile_wast_to_wasm(module, wast_tempfile, wasm_tempfile, opts): - raise Exception("compile wast to wasm failed") - - if test_aot: - r = compile_wasm_to_aot(wasm_tempfile, aot_tempfile, True, opts, r) - try: - assert_prompt(r, ['Compile success'], opts.start_timeout, True) - except: - _, exc, _ = sys.exc_info() - if (r.buf.find(expected) >= 0): - log("Out exception includes expected one, pass:") - log(" Expected: %s" % expected) - log(" Got: %s" % r.buf) - return - else: - log("Run wamrc failed:\n expected: '%s'\n got: '%s'" % \ - (expected, r.buf)) - sys.exit(1) - - r = run_wasm_with_repl(wasm_tempfile, aot_tempfile if test_aot else None, opts, r) - - # Some module couldn't load so will raise an error directly, so shell prompt won't show here - - if loadable: - # Wait for the initial prompt - try: - assert_prompt(r, ['webassembly> '], opts.start_timeout, True) - except: - _, exc, _ = sys.exc_info() - if (r.buf.find(expected) >= 0): - log("Out exception includes expected one, pass:") - log(" Expected: %s" %expected) - log(" Got: %s" % r.buf) - else: - raise Exception("Failed:\n expected: '%s'\n got: '%s'" % \ - (expected, r.buf)) - -if __name__ == "__main__": - opts = parser.parse_args(sys.argv[1:]) - print('Input param :',opts) - - if opts.aot: test_aot = True - # default x86_64 - test_target = opts.target - - if opts.rundir: os.chdir(opts.rundir) - - if opts.log_file: log_file = open(opts.log_file, "a") - if opts.debug_file: debug_file = open(opts.debug_file, "a") - - if opts.interpreter.endswith(".py"): - SKIP_TESTS = PY_SKIP_TESTS - else: - SKIP_TESTS = C_SKIP_TESTS - - (t1fd, wast_tempfile) = tempfile.mkstemp(suffix=".wast") - (t2fd, wasm_tempfile) = tempfile.mkstemp(suffix=".wasm") - if test_aot: - (t3fd, aot_tempfile) = tempfile.mkstemp(suffix=".aot") - - ret_code = 0 - try: - log("################################################") - log("### Testing %s" % opts.test_file.name) - log("################################################") - forms = read_forms(opts.test_file.read()) - r = None - - for form in forms: - # log("\n### Current Case is " + form + "\n") - if ";;" == form[0:2]: - log(form) - elif skip_test(form, SKIP_TESTS): - log("Skipping test: %s" % form[0:60]) - elif re.match("^\(assert_trap\s+\(module", form): - test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile if test_aot else None, opts, r) - elif re.match("^\(assert_exhaustion\\b.*", form): - test_assert_exhaustion(r, opts, form) - elif re.match("^\(assert_unlinkable\\b.*", form): - test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile if test_aot else None, opts, r, False) - elif re.match("^\(assert_malformed\\b.*", form): - # remove comments in wast - form,n = re.subn(";;.*\n", "", form) - m = re.match("^\(assert_malformed\s*\(module binary\s*(\".*\").*\)\s*\"(.*)\"\s*\)$", form, re.DOTALL) - - if m: - # workaround: spec test changes error message to "malformed" while iwasm still use "invalid" - error_msg = m.group(2).replace("malformed", "invalid") - log("Testing(malformed)") - f = open(wasm_tempfile, 'wb') - s = m.group(1) - while s: - res = re.match("[^\"]*\"([^\"]*)\"(.*)", s, re.DOTALL) - if IS_PY_3: - context = res.group(1).replace("\\", "\\x").encode("latin1").decode("unicode-escape").encode("latin1") - f.write(context) - else: - f.write(res.group(1).replace("\\", "\\x").decode("string-escape")) - s = res.group(2) - f.close() - - # compile wasm to aot - if test_aot: - r = compile_wasm_to_aot(wasm_tempfile, aot_tempfile, True, opts, r) - try: - assert_prompt(r, ['Compile success'], opts.start_timeout, True) - except: - _, exc, _ = sys.exc_info() - if (r.buf.find(error_msg) >= 0): - log("Out exception includes expected one, pass:") - log(" Expected: %s" % error_msg) - log(" Got: %s" % r.buf) - else: - log("Run wamrc failed:\n expected: '%s'\n got: '%s'" % \ - (error_msg, r.buf)) - continue - - r = run_wasm_with_repl(wasm_tempfile, aot_tempfile if test_aot else None, opts, r) - - if (error_msg == "unexpected end of section or function"): - # one case in binary.wast - assert_prompt(r, ["unexpected end", error_msg], opts.start_timeout, True) - elif (error_msg == "invalid value type"): - # one case in binary.wast - assert_prompt(r, ["unexpected end", error_msg], opts.start_timeout, True) - elif (error_msg == "length out of bounds"): - # one case in custom.wast - assert_prompt(r, ["unexpected end", error_msg], opts.start_timeout, True) - elif (error_msg == "integer representation too long"): - # several cases in binary-leb128.wast - assert_prompt(r, ["invalid section id", error_msg], opts.start_timeout, True) - - elif re.match("^\(assert_malformed\s*\(module quote", form): - log("ignoring assert_malformed module quote") - else: - log("unrecognized assert_malformed") - elif re.match("^\(assert_return[_a-z]*_nan\\b.*", form): - log("ignoring assert_return_.*_nan") - pass - elif re.match(".*\(invoke\s+\$\\b.*", form): - # invoke a particular named module's function - if form.startswith("(assert_return"): - test_assert_return(r,opts,form) - elif form.startswith("(assert_trap"): - test_assert_trap(r,opts,form) - elif re.match("^\(module\\b.*", form): - # if the module includes the particular name startswith $ - m = re.search("^\(module\s+\$.\S+", form) - if m: - # get module name - module_name = re.split('\$', m.group(0).strip())[1] - if module_name: - # create temporal files - temp_files = create_tmpfiles(module_name) - if not compile_wast_to_wasm(form, temp_files[0], temp_files[1], opts): - raise Exception("compile wast to wasm failed") - - if test_aot: - r = compile_wasm_to_aot(temp_files[1], temp_files[2], True, opts, r) - try: - assert_prompt(r, ['Compile success'], opts.start_timeout, False) - except: - _, exc, _ = sys.exc_info() - log("Run wamrc failed:\n got: '%s'" % r.buf) - sys.exit(1) - temp_module_table[module_name] = temp_files[1] - r = run_wasm_with_repl(temp_files[1], temp_files[2] if test_aot else None, opts, r) - else: - if not compile_wast_to_wasm(form, wast_tempfile, wasm_tempfile, opts): - raise Exception("compile wast to wasm failed") - - if test_aot: - r = compile_wasm_to_aot(wasm_tempfile, aot_tempfile, True, opts, r) - try: - assert_prompt(r, ['Compile success'], opts.start_timeout, False) - except: - _, exc, _ = sys.exc_info() - log("Run wamrc failed:\n got: '%s'" % r.buf) - sys.exit(1) - - r = run_wasm_with_repl(wasm_tempfile, aot_tempfile if test_aot else None, opts, r) - - # Wait for the initial prompt - try: - assert_prompt(r, ['webassembly> '], opts.start_timeout, False) - except: - _, exc, _ = sys.exc_info() - raise Exception("Failed:\n expected: '%s'\n got: '%s'" % \ - (repr(exc), r.buf)) - - elif re.match("^\(assert_return\\b.*", form): - assert(r), "iwasm repl runtime should be not null" - test_assert_return(r, opts, form) - elif re.match("^\(assert_trap\\b.*", form): - test_assert_trap(r, opts, form) - elif re.match("^\(invoke\\b.*", form): - assert(r), "iwasm repl runtime should be not null" - do_invoke(r, opts, form) - elif re.match("^\(assert_invalid\\b.*", form): - test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile if test_aot else None, opts, r) - elif re.match("^\(register\\b.*", form): - # get module's new name from the register cmd - name_new =re.split('\"',re.search('\".*\"',form).group(0))[1] - if name_new: - new_module = os.path.join(tempfile.gettempdir(), name_new + ".wasm") - shutil.copyfile(temp_module_table.get(name_new, wasm_tempfile), new_module) - - # add new_module copied from the old into temp_file_repo[] - temp_file_repo.append(new_module) - else: - # there is no name defined in register cmd - raise Exception("can not find module name from the register") - else: - raise Exception("unrecognized form '%s...'" % form[0:40]) - except Exception as e: - traceback.print_exc() - print("THE FINAL EXCEPTION IS {}".format(e)) - ret_code = 101 - - shutil.copyfile(wasm_tempfile, os.path.join(opts.log_dir, os.path.basename(wasm_tempfile))) - - if opts.aot or opts.xip: - shutil.copyfile(aot_tempfile, os.path.join(opts.log_dir,os.path.basename(aot_tempfile))) - if "indirect-mode" in str(e): - compile_wasm_to_aot(wasm_tempfile, aot_tempfile, None, opts, None, "object") - shutil.copyfile(aot_tempfile, os.path.join(opts.log_dir,os.path.basename(aot_tempfile)+'.o')) - subprocess.check_call(["llvm-objdump", "-r", aot_tempfile]) - compile_wasm_to_aot(wasm_tempfile, aot_tempfile, None, opts, None, "ir") - shutil.copyfile(aot_tempfile, os.path.join(opts.log_dir,os.path.basename(aot_tempfile)+".ir")) - - else: - ret_code = 0 - finally: - if not opts.no_cleanup: - log("Removing tempfiles") - os.remove(wast_tempfile) - os.remove(wasm_tempfile) - if test_aot: - os.remove(aot_tempfile) - - # remove the files under /tempfiles/ and copy of .wasm files - if temp_file_repo: - for t in temp_file_repo: - if(len(str(t))!=0 and os.path.exists(t)): - os.remove(t) - - log("### End testing %s" % opts.test_file.name) - else: - log("Leaving tempfiles: %s" % ([wast_tempfile, wasm_tempfile])) - - sys.exit(ret_code) diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/simd_ignore_cases.patch b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/simd_ignore_cases.patch deleted file mode 100644 index 87d3871e1..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/simd_ignore_cases.patch +++ /dev/null @@ -1,73 +0,0 @@ -diff --git a/test/core/simd/simd_lane.wast b/test/core/simd/simd_lane.wast -index 9d4b5fd7..4656dd2b 100644 ---- a/test/core/simd/simd_lane.wast -+++ b/test/core/simd/simd_lane.wast -@@ -602,23 +602,23 @@ - "(v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) " - "(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "invalid lane length") - (assert_malformed (module quote "(func (result v128) " -- "(i8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15.0) " -+ "(i8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15.0 " - "(v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) " - "(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "malformed lane index") - (assert_malformed (module quote "(func (result v128) " -- "(i8x16.shuffle 0.5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15) " -+ "(i8x16.shuffle 0.5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 " - "(v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) " - "(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "malformed lane index") - (assert_malformed (module quote "(func (result v128) " -- "(i8x16.shuffle -inf 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15) " -+ "(i8x16.shuffle -inf 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 " - "(v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) " - "(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "malformed lane index") - (assert_malformed (module quote "(func (result v128) " -- "(i8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 inf) " -+ "(i8x16.shuffle 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 inf " - "(v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) " - "(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "malformed lane index") - (assert_malformed (module quote "(func (result v128) " -- "(i8x16.shuffle nan 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15) " -+ "(i8x16.shuffle nan 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 " - "(v128.const i8x16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0) " - "(v128.const i8x16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)))") "malformed lane index") - -@@ -858,7 +858,7 @@ - (assert_return (invoke "as-if-condition-value" (v128.const i8x16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)) (i32.const 0)) - (assert_return (invoke "as-return-value-1" (v128.const i16x8 0 0 0 0 0 0 0 0) (i32.const 1)) (v128.const i16x8 1 0 0 0 0 0 0 0)) - (assert_return (invoke "as-local_set-value" (v128.const i32x4 -1 -1 -1 -1)) (i32.const -1)) --(assert_return (invoke "as-global_set-value-1" (v128.const f32x4 0 0 0 0)(f32.const 3.14)) (v128.const f32x4 3.14 0 0 0)) -+(assert_return (invoke "as-global_set-value-1" (v128.const f32x4 0 0 0 0) (f32.const 3.14)) (v128.const f32x4 3.14 0 0 0)) - - (assert_return (invoke "as-return-value-2" - (v128.const i8x16 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1) -@@ -870,7 +870,7 @@ - (v128.const i8x16 -16 -15 -14 -13 -12 -11 -10 -9 8 7 6 5 4 3 2 1)) - - (assert_return (invoke "as-local_set-value-1" (v128.const i64x2 -1 -1)) (i64.const -1)) --(assert_return (invoke "as-global_set-value-3" (v128.const f64x2 0 0)(f64.const 3.14)) (v128.const f64x2 3.14 0)) -+(assert_return (invoke "as-global_set-value-3" (v128.const f64x2 0 0) (f64.const 3.14)) (v128.const f64x2 3.14 0)) - - ;; Non-nat lane index - -diff --git a/test/core/simd/simd_load.wast b/test/core/simd/simd_load.wast -index 4b2edc16..c7639218 100644 ---- a/test/core/simd/simd_load.wast -+++ b/test/core/simd/simd_load.wast -@@ -124,7 +124,7 @@ - (i8x16.swizzle (v128.load (i32.const 0)) (v128.load offset=15 (i32.const 1))) - ) - ) --(assert_return(invoke "as-i8x16.swizzle-operand") (v128.const i8x16 115 114 113 112 111 110 109 108 107 106 105 104 103 102 101 100)) -+(assert_return (invoke "as-i8x16.swizzle-operand") (v128.const i8x16 115 114 113 112 111 110 109 108 107 106 105 104 103 102 101 100)) - - (module (memory 1) - (data (i32.const 0) "\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\00\01\02\03") -@@ -180,7 +180,7 @@ - - (assert_invalid - (module (memory 1) (func (drop (v128.load (local.get 2))))) -- "unknown local 2" -+ "unknown local" - ) - (assert_invalid - (module (memory 1) (func (drop (v128.load)))) diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/tail-call/return_call.wast b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/tail-call/return_call.wast deleted file mode 100644 index df75df403..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/tail-call/return_call.wast +++ /dev/null @@ -1,202 +0,0 @@ -;; Test `return_call` operator - -(module - ;; Auxiliary definitions - (func $const-i32 (result i32) (i32.const 0x132)) - (func $const-i64 (result i64) (i64.const 0x164)) - (func $const-f32 (result f32) (f32.const 0xf32)) - (func $const-f64 (result f64) (f64.const 0xf64)) - - (func $id-i32 (param i32) (result i32) (get_local 0)) - (func $id-i64 (param i64) (result i64) (get_local 0)) - (func $id-f32 (param f32) (result f32) (get_local 0)) - (func $id-f64 (param f64) (result f64) (get_local 0)) - - (func $f32-i32 (param f32 i32) (result i32) (get_local 1)) - (func $i32-i64 (param i32 i64) (result i64) (get_local 1)) - (func $f64-f32 (param f64 f32) (result f32) (get_local 1)) - (func $i64-f64 (param i64 f64) (result f64) (get_local 1)) - - ;; Typing - - (func (export "type-i32") (result i32) (return_call $const-i32)) - (func (export "type-i64") (result i64) (return_call $const-i64)) - (func (export "type-f32") (result f32) (return_call $const-f32)) - (func (export "type-f64") (result f64) (return_call $const-f64)) - - (func (export "type-first-i32") (result i32) (return_call $id-i32 (i32.const 32))) - (func (export "type-first-i64") (result i64) (return_call $id-i64 (i64.const 64))) - (func (export "type-first-f32") (result f32) (return_call $id-f32 (f32.const 1.32))) - (func (export "type-first-f64") (result f64) (return_call $id-f64 (f64.const 1.64))) - - (func (export "type-second-i32") (result i32) - (return_call $f32-i32 (f32.const 32.1) (i32.const 32)) - ) - (func (export "type-second-i64") (result i64) - (return_call $i32-i64 (i32.const 32) (i64.const 64)) - ) - (func (export "type-second-f32") (result f32) - (return_call $f64-f32 (f64.const 64) (f32.const 32)) - ) - (func (export "type-second-f64") (result f64) - (return_call $i64-f64 (i64.const 64) (f64.const 64.1)) - ) - - ;; Recursion - - (func $fac-acc (export "fac-acc") (param i64 i64) (result i64) - (if (result i64) (i64.eqz (get_local 0)) - (then (get_local 1)) - (else - (return_call $fac-acc - (i64.sub (get_local 0) (i64.const 1)) - (i64.mul (get_local 0) (get_local 1)) - ) - ) - ) - ) - - (func $count (export "count") (param i64) (result i64) - (if (result i64) (i64.eqz (get_local 0)) - (then (get_local 0)) - (else (return_call $count (i64.sub (get_local 0) (i64.const 1)))) - ) - ) - - (func $even (export "even") (param i64) (result i32) - (if (result i32) (i64.eqz (get_local 0)) - (then (i32.const 44)) - (else (return_call $odd (i64.sub (get_local 0) (i64.const 1)))) - ) - ) - (func $odd (export "odd") (param i64) (result i32) - (if (result i32) (i64.eqz (get_local 0)) - (then (i32.const 99)) - (else (return_call $even (i64.sub (get_local 0) (i64.const 1)))) - ) - ) -) - -(assert_return (invoke "type-i32") (i32.const 0x132)) -(assert_return (invoke "type-i64") (i64.const 0x164)) -(assert_return (invoke "type-f32") (f32.const 0xf32)) -(assert_return (invoke "type-f64") (f64.const 0xf64)) - -(assert_return (invoke "type-first-i32") (i32.const 32)) -(assert_return (invoke "type-first-i64") (i64.const 64)) -(assert_return (invoke "type-first-f32") (f32.const 1.32)) -(assert_return (invoke "type-first-f64") (f64.const 1.64)) - -(assert_return (invoke "type-second-i32") (i32.const 32)) -(assert_return (invoke "type-second-i64") (i64.const 64)) -(assert_return (invoke "type-second-f32") (f32.const 32)) -(assert_return (invoke "type-second-f64") (f64.const 64.1)) - -(assert_return (invoke "fac-acc" (i64.const 0) (i64.const 1)) (i64.const 1)) -(assert_return (invoke "fac-acc" (i64.const 1) (i64.const 1)) (i64.const 1)) -(assert_return (invoke "fac-acc" (i64.const 5) (i64.const 1)) (i64.const 120)) -(assert_return - (invoke "fac-acc" (i64.const 25) (i64.const 1)) - (i64.const 7034535277573963776) -) - -(assert_return (invoke "count" (i64.const 0)) (i64.const 0)) -(assert_return (invoke "count" (i64.const 1000)) (i64.const 0)) -(assert_return (invoke "count" (i64.const 1_000_000)) (i64.const 0)) - -(assert_return (invoke "even" (i64.const 0)) (i32.const 44)) -(assert_return (invoke "even" (i64.const 1)) (i32.const 99)) -(assert_return (invoke "even" (i64.const 100)) (i32.const 44)) -(assert_return (invoke "even" (i64.const 77)) (i32.const 99)) -(assert_return (invoke "even" (i64.const 1_000_000)) (i32.const 44)) -(assert_return (invoke "even" (i64.const 1_000_001)) (i32.const 99)) -(assert_return (invoke "odd" (i64.const 0)) (i32.const 99)) -(assert_return (invoke "odd" (i64.const 1)) (i32.const 44)) -(assert_return (invoke "odd" (i64.const 200)) (i32.const 99)) -(assert_return (invoke "odd" (i64.const 77)) (i32.const 44)) -(assert_return (invoke "odd" (i64.const 1_000_000)) (i32.const 99)) -(assert_return (invoke "odd" (i64.const 999_999)) (i32.const 44)) - - -;; Invalid typing - -(assert_invalid - (module - (func $type-void-vs-num (result i32) (return_call 1) (i32.const 0)) - (func) - ) - "type mismatch" -) -(assert_invalid - (module - (func $type-num-vs-num (result i32) (return_call 1) (i32.const 0)) - (func (result i64) (i64.const 1)) - ) - "type mismatch" -) - -(assert_invalid - (module - (func $arity-0-vs-1 (return_call 1)) - (func (param i32)) - ) - "type mismatch" -) -(assert_invalid - (module - (func $arity-0-vs-2 (return_call 1)) - (func (param f64 i32)) - ) - "type mismatch" -) - -(module - (func $arity-1-vs-0 (i32.const 1) (return_call 1)) - (func) -) - -(module - (func $arity-2-vs-0 (f64.const 2) (i32.const 1) (return_call 1)) - (func) -) - -(assert_invalid - (module - (func $type-first-void-vs-num (return_call 1 (nop) (i32.const 1))) - (func (param i32 i32)) - ) - "type mismatch" -) -(assert_invalid - (module - (func $type-second-void-vs-num (return_call 1 (i32.const 1) (nop))) - (func (param i32 i32)) - ) - "type mismatch" -) -(assert_invalid - (module - (func $type-first-num-vs-num (return_call 1 (f64.const 1) (i32.const 1))) - (func (param i32 f64)) - ) - "type mismatch" -) -(assert_invalid - (module - (func $type-second-num-vs-num (return_call 1 (i32.const 1) (f64.const 1))) - (func (param f64 i32)) - ) - "type mismatch" -) - - -;; Unbound function - -(assert_invalid - (module (func $unbound-func (return_call 1))) - "unknown function" -) -(assert_invalid - (module (func $large-func (return_call 1012321300))) - "unknown function" -) diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/tail-call/return_call_indirect.wast b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/tail-call/return_call_indirect.wast deleted file mode 100644 index 515f15d5d..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/tail-call/return_call_indirect.wast +++ /dev/null @@ -1,511 +0,0 @@ -;; Test `return_call_indirect` operator - -(module - ;; Auxiliary definitions - (type $proc (func)) - (type $out-i32 (func (result i32))) - (type $out-i64 (func (result i64))) - (type $out-f32 (func (result f32))) - (type $out-f64 (func (result f64))) - (type $over-i32 (func (param i32) (result i32))) - (type $over-i64 (func (param i64) (result i64))) - (type $over-f32 (func (param f32) (result f32))) - (type $over-f64 (func (param f64) (result f64))) - (type $f32-i32 (func (param f32 i32) (result i32))) - (type $i32-i64 (func (param i32 i64) (result i64))) - (type $f64-f32 (func (param f64 f32) (result f32))) - (type $i64-f64 (func (param i64 f64) (result f64))) - (type $over-i32-duplicate (func (param i32) (result i32))) - (type $over-i64-duplicate (func (param i64) (result i64))) - (type $over-f32-duplicate (func (param f32) (result f32))) - (type $over-f64-duplicate (func (param f64) (result f64))) - - (func $const-i32 (type $out-i32) (i32.const 0x132)) - (func $const-i64 (type $out-i64) (i64.const 0x164)) - (func $const-f32 (type $out-f32) (f32.const 0xf32)) - (func $const-f64 (type $out-f64) (f64.const 0xf64)) - - (func $id-i32 (type $over-i32) (get_local 0)) - (func $id-i64 (type $over-i64) (get_local 0)) - (func $id-f32 (type $over-f32) (get_local 0)) - (func $id-f64 (type $over-f64) (get_local 0)) - - (func $i32-i64 (type $i32-i64) (get_local 1)) - (func $i64-f64 (type $i64-f64) (get_local 1)) - (func $f32-i32 (type $f32-i32) (get_local 1)) - (func $f64-f32 (type $f64-f32) (get_local 1)) - - (func $over-i32-duplicate (type $over-i32-duplicate) (get_local 0)) - (func $over-i64-duplicate (type $over-i64-duplicate) (get_local 0)) - (func $over-f32-duplicate (type $over-f32-duplicate) (get_local 0)) - (func $over-f64-duplicate (type $over-f64-duplicate) (get_local 0)) - - (table anyfunc - (elem - $const-i32 $const-i64 $const-f32 $const-f64 - $id-i32 $id-i64 $id-f32 $id-f64 - $f32-i32 $i32-i64 $f64-f32 $i64-f64 - $fac $fac-acc $even $odd - $over-i32-duplicate $over-i64-duplicate - $over-f32-duplicate $over-f64-duplicate - ) - ) - - ;; Syntax - - (func - (return_call_indirect (i32.const 0)) - (return_call_indirect (param i64) (i64.const 0) (i32.const 0)) - (return_call_indirect (param i64) (param) (param f64 i32 i64) - (i64.const 0) (f64.const 0) (i32.const 0) (i64.const 0) (i32.const 0) - ) - (return_call_indirect (result) (i32.const 0)) - ) - - (func (result i32) - (return_call_indirect (result i32) (i32.const 0)) - (return_call_indirect (result i32) (result) (i32.const 0)) - (return_call_indirect (param i64) (result i32) (i64.const 0) (i32.const 0)) - (return_call_indirect - (param) (param i64) (param) (param f64 i32 i64) (param) (param) - (result) (result i32) (result) (result) - (i64.const 0) (f64.const 0) (i32.const 0) (i64.const 0) (i32.const 0) - ) - ) - - (func (result i64) - (return_call_indirect (type $over-i64) (param i64) (result i64) - (i64.const 0) (i32.const 0) - ) - ) - - ;; Typing - - (func (export "type-i32") (result i32) - (return_call_indirect (type $out-i32) (i32.const 0)) - ) - (func (export "type-i64") (result i64) - (return_call_indirect (type $out-i64) (i32.const 1)) - ) - (func (export "type-f32") (result f32) - (return_call_indirect (type $out-f32) (i32.const 2)) - ) - (func (export "type-f64") (result f64) - (return_call_indirect (type $out-f64) (i32.const 3)) - ) - - (func (export "type-index") (result i64) - (return_call_indirect (type $over-i64) (i64.const 100) (i32.const 5)) - ) - - (func (export "type-first-i32") (result i32) - (return_call_indirect (type $over-i32) (i32.const 32) (i32.const 4)) - ) - (func (export "type-first-i64") (result i64) - (return_call_indirect (type $over-i64) (i64.const 64) (i32.const 5)) - ) - (func (export "type-first-f32") (result f32) - (return_call_indirect (type $over-f32) (f32.const 1.32) (i32.const 6)) - ) - (func (export "type-first-f64") (result f64) - (return_call_indirect (type $over-f64) (f64.const 1.64) (i32.const 7)) - ) - - (func (export "type-second-i32") (result i32) - (return_call_indirect (type $f32-i32) - (f32.const 32.1) (i32.const 32) (i32.const 8) - ) - ) - (func (export "type-second-i64") (result i64) - (return_call_indirect (type $i32-i64) - (i32.const 32) (i64.const 64) (i32.const 9) - ) - ) - (func (export "type-second-f32") (result f32) - (return_call_indirect (type $f64-f32) - (f64.const 64) (f32.const 32) (i32.const 10) - ) - ) - (func (export "type-second-f64") (result f64) - (return_call_indirect (type $i64-f64) - (i64.const 64) (f64.const 64.1) (i32.const 11) - ) - ) - - ;; Dispatch - - (func (export "dispatch") (param i32 i64) (result i64) - (return_call_indirect (type $over-i64) (get_local 1) (get_local 0)) - ) - - (func (export "dispatch-structural") (param i32) (result i64) - (return_call_indirect (type $over-i64-duplicate) - (i64.const 9) (get_local 0) - ) - ) - - ;; Recursion - - (func $fac (export "fac") (type $over-i64) - (return_call_indirect (param i64 i64) (result i64) - (get_local 0) (i64.const 1) (i32.const 13) - ) - ) - - (func $fac-acc (param i64 i64) (result i64) - (if (result i64) (i64.eqz (get_local 0)) - (then (get_local 1)) - (else - (return_call_indirect (param i64 i64) (result i64) - (i64.sub (get_local 0) (i64.const 1)) - (i64.mul (get_local 0) (get_local 1)) - (i32.const 13) - ) - ) - ) - ) - - (func $even (export "even") (param i32) (result i32) - (if (result i32) (i32.eqz (get_local 0)) - (then (i32.const 44)) - (else - (return_call_indirect (type $over-i32) - (i32.sub (get_local 0) (i32.const 1)) - (i32.const 15) - ) - ) - ) - ) - (func $odd (export "odd") (param i32) (result i32) - (if (result i32) (i32.eqz (get_local 0)) - (then (i32.const 99)) - (else - (return_call_indirect (type $over-i32) - (i32.sub (get_local 0) (i32.const 1)) - (i32.const 14) - ) - ) - ) - ) -) - -(assert_return (invoke "type-i32") (i32.const 0x132)) -(assert_return (invoke "type-i64") (i64.const 0x164)) -(assert_return (invoke "type-f32") (f32.const 0xf32)) -(assert_return (invoke "type-f64") (f64.const 0xf64)) - -(assert_return (invoke "type-index") (i64.const 100)) - -(assert_return (invoke "type-first-i32") (i32.const 32)) -(assert_return (invoke "type-first-i64") (i64.const 64)) -(assert_return (invoke "type-first-f32") (f32.const 1.32)) -(assert_return (invoke "type-first-f64") (f64.const 1.64)) - -(assert_return (invoke "type-second-i32") (i32.const 32)) -(assert_return (invoke "type-second-i64") (i64.const 64)) -(assert_return (invoke "type-second-f32") (f32.const 32)) -(assert_return (invoke "type-second-f64") (f64.const 64.1)) - -(assert_return (invoke "dispatch" (i32.const 5) (i64.const 2)) (i64.const 2)) -(assert_return (invoke "dispatch" (i32.const 5) (i64.const 5)) (i64.const 5)) -(assert_return (invoke "dispatch" (i32.const 12) (i64.const 5)) (i64.const 120)) -(assert_return (invoke "dispatch" (i32.const 17) (i64.const 2)) (i64.const 2)) -(assert_trap (invoke "dispatch" (i32.const 0) (i64.const 2)) "indirect call type mismatch") -(assert_trap (invoke "dispatch" (i32.const 15) (i64.const 2)) "indirect call type mismatch") -(assert_trap (invoke "dispatch" (i32.const 20) (i64.const 2)) "undefined element") -(assert_trap (invoke "dispatch" (i32.const -1) (i64.const 2)) "undefined element") -(assert_trap (invoke "dispatch" (i32.const 1213432423) (i64.const 2)) "undefined element") - -(assert_return (invoke "dispatch-structural" (i32.const 5)) (i64.const 9)) -(assert_return (invoke "dispatch-structural" (i32.const 5)) (i64.const 9)) -(assert_return (invoke "dispatch-structural" (i32.const 12)) (i64.const 362880)) -(assert_return (invoke "dispatch-structural" (i32.const 17)) (i64.const 9)) -(assert_trap (invoke "dispatch-structural" (i32.const 11)) "indirect call type mismatch") -(assert_trap (invoke "dispatch-structural" (i32.const 16)) "indirect call type mismatch") - -(assert_return (invoke "fac" (i64.const 0)) (i64.const 1)) -(assert_return (invoke "fac" (i64.const 1)) (i64.const 1)) -(assert_return (invoke "fac" (i64.const 5)) (i64.const 120)) -(assert_return (invoke "fac" (i64.const 25)) (i64.const 7034535277573963776)) - -(assert_return (invoke "even" (i32.const 0)) (i32.const 44)) -(assert_return (invoke "even" (i32.const 1)) (i32.const 99)) -(assert_return (invoke "even" (i32.const 100)) (i32.const 44)) -(assert_return (invoke "even" (i32.const 77)) (i32.const 99)) -(assert_return (invoke "even" (i32.const 100_000)) (i32.const 44)) -(assert_return (invoke "even" (i32.const 111_111)) (i32.const 99)) -(assert_return (invoke "odd" (i32.const 0)) (i32.const 99)) -(assert_return (invoke "odd" (i32.const 1)) (i32.const 44)) -(assert_return (invoke "odd" (i32.const 200)) (i32.const 99)) -(assert_return (invoke "odd" (i32.const 77)) (i32.const 44)) -(assert_return (invoke "odd" (i32.const 200_002)) (i32.const 99)) -(assert_return (invoke "odd" (i32.const 300_003)) (i32.const 44)) - - -;; Invalid syntax - -(assert_malformed - (module quote - "(type $sig (func (param i32) (result i32)))" - "(table 0 anyfunc)" - "(func (result i32)" - " (return_call_indirect (type $sig) (result i32) (param i32)" - " (i32.const 0) (i32.const 0)" - " )" - ")" - ) - "unexpected token" -) -(assert_malformed - (module quote - "(type $sig (func (param i32) (result i32)))" - "(table 0 anyfunc)" - "(func (result i32)" - " (return_call_indirect (param i32) (type $sig) (result i32)" - " (i32.const 0) (i32.const 0)" - " )" - ")" - ) - "unexpected token" -) -(assert_malformed - (module quote - "(type $sig (func (param i32) (result i32)))" - "(table 0 anyfunc)" - "(func (result i32)" - " (return_call_indirect (param i32) (result i32) (type $sig)" - " (i32.const 0) (i32.const 0)" - " )" - ")" - ) - "unexpected token" -) -(assert_malformed - (module quote - "(type $sig (func (param i32) (result i32)))" - "(table 0 anyfunc)" - "(func (result i32)" - " (return_call_indirect (result i32) (type $sig) (param i32)" - " (i32.const 0) (i32.const 0)" - " )" - ")" - ) - "unexpected token" -) -(assert_malformed - (module quote - "(type $sig (func (param i32) (result i32)))" - "(table 0 anyfunc)" - "(func (result i32)" - " (return_call_indirect (result i32) (param i32) (type $sig)" - " (i32.const 0) (i32.const 0)" - " )" - ")" - ) - "unexpected token" -) -(assert_malformed - (module quote - "(table 0 anyfunc)" - "(func (result i32)" - " (return_call_indirect (result i32) (param i32)" - " (i32.const 0) (i32.const 0)" - " )" - ")" - ) - "unexpected token" -) - -(assert_malformed - (module quote - "(table 0 anyfunc)" - "(func (return_call_indirect (param $x i32) (i32.const 0) (i32.const 0)))" - ) - "unexpected token" -) -(assert_malformed - (module quote - "(type $sig (func))" - "(table 0 anyfunc)" - "(func (result i32)" - " (return_call_indirect (type $sig) (result i32) (i32.const 0))" - ")" - ) - "inline function type" -) -(assert_malformed - (module quote - "(type $sig (func (param i32) (result i32)))" - "(table 0 anyfunc)" - "(func (result i32)" - " (return_call_indirect (type $sig) (result i32) (i32.const 0))" - ")" - ) - "inline function type" -) -(assert_malformed - (module quote - "(type $sig (func (param i32) (result i32)))" - "(table 0 anyfunc)" - "(func" - " (return_call_indirect (type $sig) (param i32)" - " (i32.const 0) (i32.const 0)" - " )" - ")" - ) - "inline function type" -) -(assert_malformed - (module quote - "(type $sig (func (param i32 i32) (result i32)))" - "(table 0 anyfunc)" - "(func (result i32)" - " (return_call_indirect (type $sig) (param i32) (result i32)" - " (i32.const 0) (i32.const 0)" - " )" - ")" - ) - "inline function type" -) - -;; Invalid typing - -(assert_invalid - (module - (type (func)) - (func $no-table (return_call_indirect (type 0) (i32.const 0))) - ) - "unknown table" -) - -(assert_invalid - (module - (type (func)) - (table 0 anyfunc) - (func $type-void-vs-num (i32.eqz (return_call_indirect (type 0) (i32.const 0)))) - ) - "type mismatch" -) -(assert_invalid - (module - (type (func (result i64))) - (table 0 anyfunc) - (func $type-num-vs-num (i32.eqz (return_call_indirect (type 0) (i32.const 0)))) - ) - "type mismatch" -) - -(assert_invalid - (module - (type (func (param i32))) - (table 0 anyfunc) - (func $arity-0-vs-1 (return_call_indirect (type 0) (i32.const 0))) - ) - "type mismatch" -) -(assert_invalid - (module - (type (func (param f64 i32))) - (table 0 anyfunc) - (func $arity-0-vs-2 (return_call_indirect (type 0) (i32.const 0))) - ) - "type mismatch" -) - -(module - (type (func)) - (table 0 anyfunc) - (func $arity-1-vs-0 (return_call_indirect (type 0) (i32.const 1) (i32.const 0))) -) - -(module - (type (func)) - (table 0 anyfunc) - (func $arity-2-vs-0 - (return_call_indirect (type 0) (f64.const 2) (i32.const 1) (i32.const 0)) - ) -) - -(assert_invalid - (module - (type (func (param i32))) - (table 0 anyfunc) - (func $type-func-void-vs-i32 (return_call_indirect (type 0) (i32.const 1) (nop))) - ) - "type mismatch" -) -(assert_invalid - (module - (type (func (param i32))) - (table 0 anyfunc) - (func $type-func-num-vs-i32 (return_call_indirect (type 0) (i32.const 0) (i64.const 1))) - ) - "type mismatch" -) - -(assert_invalid - (module - (type (func (param i32 i32))) - (table 0 anyfunc) - (func $type-first-void-vs-num - (return_call_indirect (type 0) (nop) (i32.const 1) (i32.const 0)) - ) - ) - "type mismatch" -) -(assert_invalid - (module - (type (func (param i32 i32))) - (table 0 anyfunc) - (func $type-second-void-vs-num - (return_call_indirect (type 0) (i32.const 1) (nop) (i32.const 0)) - ) - ) - "type mismatch" -) -(assert_invalid - (module - (type (func (param i32 f64))) - (table 0 anyfunc) - (func $type-first-num-vs-num - (return_call_indirect (type 0) (f64.const 1) (i32.const 1) (i32.const 0)) - ) - ) - "type mismatch" -) -(assert_invalid - (module - (type (func (param f64 i32))) - (table 0 anyfunc) - (func $type-second-num-vs-num - (return_call_indirect (type 0) (i32.const 1) (f64.const 1) (i32.const 0)) - ) - ) - "type mismatch" -) - - -;; Unbound type - -(assert_invalid - (module - (table 0 anyfunc) - (func $unbound-type (return_call_indirect (type 1) (i32.const 0))) - ) - "unknown type" -) -(assert_invalid - (module - (table 0 anyfunc) - (func $large-type (return_call_indirect (type 1012321300) (i32.const 0))) - ) - "unknown type" -) - - -;; Unbound function in table - -(assert_invalid - (module (table anyfunc (elem 0 0))) - "unknown function" -) diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/thread_proposal_fix_atomic_case.patch b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/thread_proposal_fix_atomic_case.patch deleted file mode 100644 index a64dd178b..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/thread_proposal_fix_atomic_case.patch +++ /dev/null @@ -1,49 +0,0 @@ -diff --git a/test/core/atomic.wast b/test/core/atomic.wast -index 66ad0eb..40259a9 100644 ---- a/test/core/atomic.wast -+++ b/test/core/atomic.wast -@@ -324,7 +324,7 @@ - - (invoke "init" (i64.const 0x1111111111111111)) - (assert_return (invoke "i32.atomic.rmw8.cmpxchg_u" (i32.const 0) (i32.const 0x11111111) (i32.const 0xcdcdcdcd)) (i32.const 0x11)) --(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x1111111111111111)) -+(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x11111111111111cd)) - - (invoke "init" (i64.const 0x1111111111111111)) - (assert_return (invoke "i32.atomic.rmw16.cmpxchg_u" (i32.const 0) (i32.const 0) (i32.const 0xcafecafe)) (i32.const 0x1111)) -@@ -332,7 +332,7 @@ - - (invoke "init" (i64.const 0x1111111111111111)) - (assert_return (invoke "i32.atomic.rmw16.cmpxchg_u" (i32.const 0) (i32.const 0x11111111) (i32.const 0xcafecafe)) (i32.const 0x1111)) --(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x1111111111111111)) -+(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x111111111111cafe)) - - (invoke "init" (i64.const 0x1111111111111111)) - (assert_return (invoke "i64.atomic.rmw8.cmpxchg_u" (i32.const 0) (i64.const 0) (i64.const 0x4242424242424242)) (i64.const 0x11)) -@@ -340,7 +340,7 @@ - - (invoke "init" (i64.const 0x1111111111111111)) - (assert_return (invoke "i64.atomic.rmw8.cmpxchg_u" (i32.const 0) (i64.const 0x1111111111111111) (i64.const 0x4242424242424242)) (i64.const 0x11)) --(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x1111111111111111)) -+(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x1111111111111142)) - - (invoke "init" (i64.const 0x1111111111111111)) - (assert_return (invoke "i64.atomic.rmw16.cmpxchg_u" (i32.const 0) (i64.const 0) (i64.const 0xbeefbeefbeefbeef)) (i64.const 0x1111)) -@@ -348,7 +348,7 @@ - - (invoke "init" (i64.const 0x1111111111111111)) - (assert_return (invoke "i64.atomic.rmw16.cmpxchg_u" (i32.const 0) (i64.const 0x1111111111111111) (i64.const 0xbeefbeefbeefbeef)) (i64.const 0x1111)) --(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x1111111111111111)) -+(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x111111111111beef)) - - (invoke "init" (i64.const 0x1111111111111111)) - (assert_return (invoke "i64.atomic.rmw32.cmpxchg_u" (i32.const 0) (i64.const 0) (i64.const 0xcabba6e5cabba6e5)) (i64.const 0x11111111)) -@@ -356,7 +356,7 @@ - - (invoke "init" (i64.const 0x1111111111111111)) - (assert_return (invoke "i64.atomic.rmw32.cmpxchg_u" (i32.const 0) (i64.const 0x1111111111111111) (i64.const 0xcabba6e5cabba6e5)) (i64.const 0x11111111)) --(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x1111111111111111)) -+(assert_return (invoke "i64.atomic.load" (i32.const 0)) (i64.const 0x11111111cabba6e5)) - - ;; *.atomic.rmw*.cmpxchg (compare true) - diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/thread_proposal_ignore_cases.patch b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/thread_proposal_ignore_cases.patch deleted file mode 100644 index 41a0d25b8..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/spec-test-script/thread_proposal_ignore_cases.patch +++ /dev/null @@ -1,213 +0,0 @@ -diff --git a/test/core/binary.wast b/test/core/binary.wast -index b9fa438c..a5711dd3 100644 ---- a/test/core/binary.wast -+++ b/test/core/binary.wast -@@ -45,7 +45,7 @@ - (assert_malformed (module binary "\00asm\00\00\00\01") "unknown binary version") - - ;; Invalid section id. --(assert_malformed (module binary "\00asm" "\01\00\00\00" "\0c\00") "malformed section id") -+;; (assert_malformed (module binary "\00asm" "\01\00\00\00" "\0c\00") "malformed section id") - (assert_malformed (module binary "\00asm" "\01\00\00\00" "\7f\00") "malformed section id") - (assert_malformed (module binary "\00asm" "\01\00\00\00" "\80\00\01\00") "malformed section id") - (assert_malformed (module binary "\00asm" "\01\00\00\00" "\81\00\01\00") "malformed section id") -@@ -68,7 +68,7 @@ - "\01" ;; call_indirect reserved byte is not equal to zero! - "\0b" ;; end - ) -- "zero flag expected" -+ "zero byte expected" - ) - - ;; call_indirect reserved byte should not be a "long" LEB128 zero. -@@ -87,7 +87,7 @@ - "\80\00" ;; call_indirect reserved byte - "\0b" ;; end - ) -- "zero flag expected" -+ "zero byte expected" - ) - - ;; Same as above for 3, 4, and 5-byte zero encodings. -@@ -106,7 +106,7 @@ - "\80\80\00" ;; call_indirect reserved byte - "\0b" ;; end - ) -- "zero flag expected" -+ "zero byte expected" - ) - - (assert_malformed -@@ -124,7 +124,7 @@ - "\80\80\80\00" ;; call_indirect reserved byte - "\0b" ;; end - ) -- "zero flag expected" -+ "zero byte expected" - ) - - (assert_malformed -@@ -142,7 +142,7 @@ - "\80\80\80\80\00" ;; call_indirect reserved byte - "\0b" ;; end - ) -- "zero flag expected" -+ "zero byte expected" - ) - - ;; memory.grow reserved byte equal to zero. -@@ -162,7 +162,7 @@ - "\1a" ;; drop - "\0b" ;; end - ) -- "zero flag expected" -+ "zero byte expected" - ) - - ;; memory.grow reserved byte should not be a "long" LEB128 zero. -@@ -182,7 +182,7 @@ - "\1a" ;; drop - "\0b" ;; end - ) -- "zero flag expected" -+ "zero byte expected" - ) - - ;; Same as above for 3, 4, and 5-byte zero encodings. -@@ -202,7 +202,7 @@ - "\1a" ;; drop - "\0b" ;; end - ) -- "zero flag expected" -+ "zero byte expected" - ) - - (assert_malformed -@@ -221,7 +221,7 @@ - "\1a" ;; drop - "\0b" ;; end - ) -- "zero flag expected" -+ "zero byte expected" - ) - - (assert_malformed -@@ -240,7 +240,7 @@ - "\1a" ;; drop - "\0b" ;; end - ) -- "zero flag expected" -+ "zero byte expected" - ) - - ;; memory.size reserved byte equal to zero. -@@ -259,7 +259,7 @@ - "\1a" ;; drop - "\0b" ;; end - ) -- "zero flag expected" -+ "zero byte expected" - ) - - ;; memory.size reserved byte should not be a "long" LEB128 zero. -@@ -278,7 +278,7 @@ - "\1a" ;; drop - "\0b" ;; end - ) -- "zero flag expected" -+ "zero byte expected" - ) - - ;; Same as above for 3, 4, and 5-byte zero encodings. -@@ -297,7 +297,7 @@ - "\1a" ;; drop - "\0b" ;; end - ) -- "zero flag expected" -+ "zero byte expected" - ) - - (assert_malformed -@@ -315,7 +315,7 @@ - "\1a" ;; drop - "\0b" ;; end - ) -- "zero flag expected" -+ "zero byte expected" - ) - - (assert_malformed -@@ -333,7 +333,7 @@ - "\1a" ;; drop - "\0b" ;; end - ) -- "zero flag expected" -+ "zero byte expected" - ) - - ;; No more than 2^32 locals. -@@ -745,6 +745,7 @@ - ) - - ;; 2 elem segment declared, 1 given -+(; - (assert_malformed - (module binary - "\00asm" "\01\00\00\00" -@@ -761,6 +762,7 @@ - ) - "unexpected end" - ) -+;) - - ;; 1 elem segment declared, 2 given - (assert_malformed -diff --git a/test/core/elem.wast b/test/core/elem.wast -index 1ea2b061..8eded377 100644 ---- a/test/core/elem.wast -+++ b/test/core/elem.wast -@@ -12,10 +12,10 @@ - (elem 0x0 (i32.const 0) $f $f) - (elem 0x000 (offset (i32.const 0))) - (elem 0 (offset (i32.const 0)) $f $f) -- (elem $t (i32.const 0)) -- (elem $t (i32.const 0) $f $f) -- (elem $t (offset (i32.const 0))) -- (elem $t (offset (i32.const 0)) $f $f) -+ (elem (i32.const 0)) -+ (elem (i32.const 0) $f $f) -+ (elem (offset (i32.const 0))) -+ (elem (offset (i32.const 0)) $f $f) - ) - - ;; Basic use -@@ -354,6 +354,7 @@ - (assert_return (invoke $module1 "call-8") (i32.const 65)) - (assert_return (invoke $module1 "call-9") (i32.const 66)) - -+(; - (module $module2 - (type $out-i32 (func (result i32))) - (import "module1" "shared-table" (table 10 funcref)) -@@ -379,3 +380,4 @@ - (assert_return (invoke $module1 "call-7") (i32.const 67)) - (assert_return (invoke $module1 "call-8") (i32.const 69)) - (assert_return (invoke $module1 "call-9") (i32.const 70)) -+;) -diff --git a/test/core/thread.wast b/test/core/thread.wast -index c3456a61..83fc2815 100644 ---- a/test/core/thread.wast -+++ b/test/core/thread.wast -@@ -2,6 +2,7 @@ - (memory (export "shared") 1 1 shared) - ) - -+(; - (thread $T1 (shared (module $Mem)) - (register "mem" $Mem) - (module -@@ -26,3 +27,4 @@ - - (wait $T1) - (wait $T2) -+;) diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/test_wamr.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/test_wamr.sh deleted file mode 100755 index 67868b9c9..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/test_wamr.sh +++ /dev/null @@ -1,882 +0,0 @@ -#!/usr/bin/env bash - -# -# Copyright (C) 2019 Intel Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# - -function DEBUG() { - [[ -n $(env | grep "\") ]] && $@ -} -DEBUG set -xv pipefail - -function help() -{ - echo "test_wamr.sh [options]" - echo "-c clean previous test results, not start test" - echo "-s {suite_name} test only one suite (spec|wasi_certification)" - echo "-m set compile target of iwasm(x86_64|x86_32|armv7_vfp|thumbv7_vfp|riscv64_lp64d|riscv64_lp64)" - echo "-t set compile type of iwasm(classic-interp|fast-interp|jit|aot|fast-jit|multi-tier-jit)" - echo "-M enable multi module feature" - echo "-p enable multi thread feature" - echo "-S enable SIMD feature" - echo "-G enable GC feature" - echo "-X enable XIP feature" - echo "-x test SGX" - echo "-w enable WASI threads" - echo "-b use the wabt binary release package instead of compiling from the source code" - echo "-g build iwasm with debug version" - echo "-v enable GC heap verification" - echo "-P run the spec test parallelly" - echo "-Q enable qemu" - echo "-F set the firmware path used by qemu" - echo "-C enable code coverage collect" -} - -OPT_PARSED="" -WABT_BINARY_RELEASE="NO" -#default type -TYPE=("classic-interp" "fast-interp" "jit" "aot" "fast-jit" "multi-tier-jit") -#default target -TARGET="X86_64" -ENABLE_WASI_THREADS=0 -ENABLE_MULTI_MODULE=0 -ENABLE_MULTI_THREAD=0 -COLLECT_CODE_COVERAGE=0 -ENABLE_SIMD=0 -ENABLE_GC=0 -ENABLE_XIP=0 -ENABLE_DEBUG_VERSION=0 -ENABLE_GC_HEAP_VERIFY=0 -#unit test case arrary -TEST_CASE_ARR=() -SGX_OPT="" -PLATFORM=$(uname -s | tr A-Z a-z) -PARALLELISM=0 -ENABLE_QEMU=0 -QEMU_FIRMWARE="" -WASI_TESTSUITE_COMMIT="aca78d919355ae00af141e6741a439039615b257" - -while getopts ":s:cabgvt:m:MCpSXxwPGQF:" opt -do - OPT_PARSED="TRUE" - case $opt in - s) - TEST_CASE_ARR+=($OPTARG) - # get next suite if there are multiple vaule in -s - eval "nxarg=\${$((OPTIND))}" - # just get test cases, loop until the next symbol '-' - # IN ====> -s spec wasi unit -t fast-classic - # GET ====> spec wasi unit - while [[ "${nxarg}" != -* && ${nxarg} ]]; - do - TEST_CASE_ARR+=(${nxarg}) - OPTIND=$((OPTIND+1)) - eval "nxarg=\${$((OPTIND))}" - done - echo "test following cases: ${TEST_CASE_ARR[@]}" - ;; - c) - read -t 5 -p "Are you sure to delete all reports. y/n " cmd - if [[ $cmd == "y" && $(ls -A workspace/report) ]];then - rm -fr workspace/report/* - rm -fr /tmp/*.wasm /tmp/*.wast /tmp/*.aot - echo "cleaned all reports and temp files" - fi - exit 0;; - a) - TEST_ALL_AOT_RUNTIME="all" - echo "test all runtimes in sightglass_aot" - ;; - b) - WABT_BINARY_RELEASE="YES" - echo "use a WABT binary release instead of compiling from source code" - ;; - t) - echo "set compile type of wamr " ${OPTARG} - if [[ ${OPTARG} != "classic-interp" && ${OPTARG} != "fast-interp" \ - && ${OPTARG} != "jit" && ${OPTARG} != "aot" - && ${OPTARG} != "fast-jit" && ${OPTARG} != "multi-tier-jit" ]]; then - echo "*----- please varify a type of compile when using -t! -----*" - help - exit 1 - fi - - TYPE=(${OPTARG}) - ;; - m) - echo "set compile target of wamr" ${OPTARG} - TARGET=${OPTARG^^} # set target to uppercase if input x86_32 or x86_64 --> X86_32 and X86_64 - ;; - w) - echo "enable WASI threads" - ENABLE_WASI_THREADS=1 - ;; - M) - echo "enable multi module feature" - ENABLE_MULTI_MODULE=1 - ;; - C) - echo "enable code coverage" - COLLECT_CODE_COVERAGE=1 - ;; - p) - echo "enable multi thread feature" - ENABLE_MULTI_THREAD=1 - ;; - S) - echo "enable SIMD feature" - ENABLE_SIMD=1 - ;; - X) - echo "enable XIP feature" - ENABLE_XIP=1 - ;; - x) - echo "test SGX" - SGX_OPT="--sgx" - ;; - g) - echo "enable build iwasm with debug version" - ENABLE_DEBUG_VERSION=1 - ;; - v) - echo "enable GC heap verification" - ENABLE_GC_HEAP_VERIFY=1 - ;; - G) - echo "enable GC feature" - ENABLE_GC=1 - ;; - P) - PARALLELISM=1 - ;; - Q) - echo "enable QEMU" - ENABLE_QEMU=1 - ;; - F) - echo "QEMU firmware" ${OPTARG} - QEMU_FIRMWARE=${OPTARG} - ;; - ?) - help - exit 1;; - esac -done - -# Parameters are not allowed, use options instead -if [ -z "$OPT_PARSED" ]; -then - if [ ! -z "$1" ]; - then - help - exit 1 - fi -fi - -mkdir -p workspace -cd workspace - -readonly WORK_DIR=$PWD - -readonly DATE=$(date +%Y-%m-%d_%H:%M:%S) -readonly REPORT_DIR=${WORK_DIR}/report/${DATE} -mkdir -p ${REPORT_DIR} - -readonly WAMR_DIR=${WORK_DIR}/../../.. - -if [[ ${SGX_OPT} == "--sgx" ]];then - readonly IWASM_LINUX_ROOT_DIR="${WAMR_DIR}/product-mini/platforms/linux-sgx" - readonly IWASM_CMD="${WAMR_DIR}/product-mini/platforms/linux-sgx/enclave-sample/iwasm" -else - readonly IWASM_LINUX_ROOT_DIR="${WAMR_DIR}/product-mini/platforms/${PLATFORM}" - readonly IWASM_CMD="${WAMR_DIR}/product-mini/platforms/${PLATFORM}/build/iwasm" -fi - -readonly WAMRC_CMD="${WAMR_DIR}/wamr-compiler/build/wamrc" - -readonly CLASSIC_INTERP_COMPILE_FLAGS="\ - -DWAMR_BUILD_TARGET=${TARGET} \ - -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 \ - -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=0 \ - -DWAMR_BUILD_SPEC_TEST=1 \ - -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}" - -readonly FAST_INTERP_COMPILE_FLAGS="\ - -DWAMR_BUILD_TARGET=${TARGET} \ - -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=1 \ - -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=0 \ - -DWAMR_BUILD_SPEC_TEST=1 \ - -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}" - -# jit: report linking error if set COLLECT_CODE_COVERAGE, -# now we don't collect code coverage of jit type -readonly ORC_EAGER_JIT_COMPILE_FLAGS="\ - -DWAMR_BUILD_TARGET=${TARGET} \ - -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_INTERP=0 \ - -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_AOT=1 \ - -DWAMR_BUILD_LAZY_JIT=0 \ - -DWAMR_BUILD_SPEC_TEST=1 \ - -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}" - -readonly ORC_LAZY_JIT_COMPILE_FLAGS="\ - -DWAMR_BUILD_TARGET=${TARGET} \ - -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_INTERP=0 \ - -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_AOT=1 \ - -DWAMR_BUILD_LAZY_JIT=1 \ - -DWAMR_BUILD_SPEC_TEST=1 \ - -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}" - -readonly AOT_COMPILE_FLAGS="\ - -DWAMR_BUILD_TARGET=${TARGET} \ - -DWAMR_BUILD_INTERP=0 -DWAMR_BUILD_FAST_INTERP=0 \ - -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=1 \ - -DWAMR_BUILD_SPEC_TEST=1 \ - -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}" - -readonly FAST_JIT_COMPILE_FLAGS="\ - -DWAMR_BUILD_TARGET=${TARGET} \ - -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 \ - -DWAMR_BUILD_JIT=0 -DWAMR_BUILD_AOT=0 \ - -DWAMR_BUILD_FAST_JIT=1 \ - -DWAMR_BUILD_SPEC_TEST=1 \ - -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}" - -readonly MULTI_TIER_JIT_COMPILE_FLAGS="\ - -DWAMR_BUILD_TARGET=${TARGET} \ - -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 \ - -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 \ - -DWAMR_BUILD_SPEC_TEST=1 \ - -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE}" - -readonly COMPILE_FLAGS=( - "${CLASSIC_INTERP_COMPILE_FLAGS}" - "${FAST_INTERP_COMPILE_FLAGS}" - "${ORC_EAGER_JIT_COMPILE_FLAGS}" - "${ORC_LAZY_JIT_COMPILE_FLAGS}" - "${AOT_COMPILE_FLAGS}" - "${FAST_JIT_COMPILE_FLAGS}" - "${MULTI_TIER_JIT_COMPILE_FLAGS}" - ) - -function unit_test() -{ - echo "Now start unit tests" - - cd ${WORK_DIR} - rm -fr unittest-build && mkdir unittest-build - cd unittest-build - - echo "Build unit test" - touch ${REPORT_DIR}/unit_test_report.txt - cmake ${WORK_DIR}/../../unit -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE} - make -j - make test | tee -a ${REPORT_DIR}/unit_test_report.txt - - echo "Finish unit tests" -} - -function sightglass_test() -{ - echo "Now start sightglass benchmark tests" - - cd ${WORK_DIR}/../sightglass/benchmarks - - # build iwasm first - if [[ $1 == "classic-interp" || $1 == "fast-interp" ]];then - ./test_interp.sh ${SGX_OPT} - cp report.txt ${REPORT_DIR}/sightglass_$1_test_report.txt - fi - - if [[ $1 == "aot" ]];then - ./test_aot.sh ${SGX_OPT} - cp report.txt ${REPORT_DIR}/sightglass_aot_test_report.txt - fi - - if [[ $1 == "jit" ]];then - [[ $TEST_ALL_AOT_RUNTIME ]] && ./test_aot.sh ${TEST_ALL_AOT_RUNTIME} ${SGX_OPT} \ - || ./test_aot.sh jit ${SGX_OPT} - cp report.txt ${REPORT_DIR}/sightglass_jit_test_report.txt - fi - - echo "Finish sightglass benchmark tests" -} - -# TODO: with iwasm only -function spec_test() -{ - echo "Now start spec tests" - touch ${REPORT_DIR}/spec_test_report.txt - - cd ${WORK_DIR} - if [ ! -d "spec" ];then - echo "spec not exist, clone it from github" - git clone -b master --single-branch https://github.com/WebAssembly/spec - fi - - pushd spec - - # restore and clean everything - git reset --hard HEAD - - # update basic test cases - echo "update spec test cases" - git fetch origin main - # restore from XX_ignore_cases.patch - # resotre branch - git checkout -B main - # [spec] Update note on module initialization trapping (#1493) - git reset --hard 044d0d2e77bdcbe891f7e0b9dd2ac01d56435f0b - git apply ../../spec-test-script/ignore_cases.patch - if [[ ${ENABLE_SIMD} == 1 ]]; then - git apply ../../spec-test-script/simd_ignore_cases.patch - fi - - # udpate thread cases - if [ ${ENABLE_MULTI_THREAD} == 1 ]; then - echo "checkout spec for threads proposal" - if [[ -z $(git remote -v | grep "\") ]]; then - git remote add threads https://github.com/WebAssembly/threads - fi - - # fetch spec for threads proposal - git fetch threads - # Fix error in Web embedding desc for atomic.notify (#185) - git reset --hard 85b562cd6805947876ec5e8b975ab0127c55a0a2 - git checkout threads/main - - git apply ../../spec-test-script/thread_proposal_ignore_cases.patch - git apply ../../spec-test-script/thread_proposal_fix_atomic_case.patch - fi - - # update GC cases - if [[ ${ENABLE_GC} == 1 ]]; then - echo "checkout spec for GC proposal" - - popd - rm -fr spec - # check spec test cases for GC - git clone -b main --single-branch https://github.com/WebAssembly/gc.git spec - pushd spec - - git restore . && git clean -ffd . - # Sync constant expression descriptions - git reset --hard 62beb94ddd41987517781732f17f213d8b866dcc - git apply ../../spec-test-script/gc_ignore_cases.patch - - echo "compile the reference intepreter" - pushd interpreter - make opt - popd - fi - - popd - echo $(pwd) - - if [ ${WABT_BINARY_RELEASE} == "YES" ]; then - echo "download a binary release and install" - local WAT2WASM=${WORK_DIR}/wabt/out/gcc/Release/wat2wasm - if [ ! -f ${WAT2WASM} ]; then - case ${PLATFORM} in - linux) - WABT_PLATFORM=ubuntu - ;; - darwin) - WABT_PLATFORM=macos - ;; - *) - echo "wabt platform for ${PLATFORM} in unknown" - exit 1 - ;; - esac - if [ ! -f /tmp/wabt-1.0.31-${WABT_PLATFORM}.tar.gz ]; then - wget \ - https://github.com/WebAssembly/wabt/releases/download/1.0.31/wabt-1.0.31-${WABT_PLATFORM}.tar.gz \ - -P /tmp - fi - - cd /tmp \ - && tar zxf wabt-1.0.31-${WABT_PLATFORM}.tar.gz \ - && mkdir -p ${WORK_DIR}/wabt/out/gcc/Release/ \ - && install wabt-1.0.31/bin/wa* ${WORK_DIR}/wabt/out/gcc/Release/ \ - && cd - - fi - else - echo "download source code and compile and install" - if [ ! -d "wabt" ];then - echo "wabt not exist, clone it from github" - git clone --recursive https://github.com/WebAssembly/wabt - fi - echo "upate wabt" - cd wabt - git pull - git reset --hard origin/main - cd .. - make -C wabt gcc-release -j 4 - fi - - ln -sf ${WORK_DIR}/../spec-test-script/all.py . - ln -sf ${WORK_DIR}/../spec-test-script/runtest.py . - - local ARGS_FOR_SPEC_TEST="" - - # multi-module only enable in interp mode - if [[ 1 == ${ENABLE_MULTI_MODULE} ]]; then - if [[ $1 == 'classic-interp' || $1 == 'fast-interp' ]]; then - ARGS_FOR_SPEC_TEST+="-M " - fi - fi - - # sgx only enable in interp mode and aot mode - if [[ ${SGX_OPT} == "--sgx" ]];then - if [[ $1 == 'classic-interp' || $1 == 'fast-interp' || $1 == 'aot' ]]; then - ARGS_FOR_SPEC_TEST+="-x " - fi - fi - - # simd only enable in jit mode and aot mode - if [[ ${ENABLE_SIMD} == 1 ]]; then - if [[ $1 == 'jit' || $1 == 'aot' ]]; then - ARGS_FOR_SPEC_TEST+="-S " - fi - fi - - if [[ ${ENABLE_MULTI_THREAD} == 1 ]]; then - ARGS_FOR_SPEC_TEST+="-p " - fi - - if [[ ${ENABLE_XIP} == 1 ]]; then - ARGS_FOR_SPEC_TEST+="-X " - fi - - # set the current running target - ARGS_FOR_SPEC_TEST+="-m ${TARGET} " - - # require warmc only in aot mode - if [[ $1 == 'aot' ]]; then - ARGS_FOR_SPEC_TEST+="-t " - fi - - if [[ ${PARALLELISM} == 1 ]]; then - ARGS_FOR_SPEC_TEST+="--parl " - fi - - if [[ ${ENABLE_GC} == 1 ]]; then - ARGS_FOR_SPEC_TEST+="--gc " - fi - - if [[ ${ENABLE_QEMU} == 1 ]]; then - ARGS_FOR_SPEC_TEST+="--qemu " - ARGS_FOR_SPEC_TEST+="--qemu-firmware ${QEMU_FIRMWARE} " - fi - - # set log directory - ARGS_FOR_SPEC_TEST+="--log ${REPORT_DIR}" - - cd ${WORK_DIR} - echo "python3 ./all.py ${ARGS_FOR_SPEC_TEST} | tee -a ${REPORT_DIR}/spec_test_report.txt" - python3 ./all.py ${ARGS_FOR_SPEC_TEST} | tee -a ${REPORT_DIR}/spec_test_report.txt - if [[ ${PIPESTATUS[0]} -ne 0 ]];then - echo -e "\nspec tests FAILED" | tee -a ${REPORT_DIR}/spec_test_report.txt - exit 1 - fi - cd - - - echo -e "\nFinish spec tests" | tee -a ${REPORT_DIR}/spec_test_report.txt -} - -function wasi_test() -{ - echo "Now start wasi tests" - touch ${REPORT_DIR}/wasi_test_report.txt - - cd ${WORK_DIR}/../../wasi - [[ $1 != "aot" ]] && \ - python wasi_test.py --interpreter ${IWASM_CMD} ${SGX_OPT}\ - | tee ${REPORT_DIR}/wasi_test_report.txt \ - || \ - python wasi_test.py --aot --aot-compiler ${WAMRC_CMD} ${SGX_OPT}\ - --interpreter ${IWASM_CMD} \ - | tee ${REPORT_DIR}/wasi_test_report.txt - echo "Finish wasi tests" -} - -function wasi_certification_test() -{ - echo "Now start wasi certification tests" - - cd ${WORK_DIR} - if [ ! -d "wasi-testsuite" ]; then - echo "wasi not exist, clone it from github" - git clone -b prod/testsuite-all \ - --single-branch https://github.com/WebAssembly/wasi-testsuite.git - fi - cd wasi-testsuite - git reset --hard ${WASI_TESTSUITE_COMMIT} - - bash ../../wasi-test-script/run_wasi_tests.sh $1 $TARGET \ - | tee -a ${REPORT_DIR}/wasi_test_report.txt - ret=${PIPESTATUS[0]} - - if [[ ${ret} -ne 0 ]];then - echo -e "\nwasi tests FAILED" | tee -a ${REPORT_DIR}/wasi_test_report.txt - exit 1 - fi - echo -e "\nFinish wasi tests" | tee -a ${REPORT_DIR}/wasi_test_report.txt -} - -function polybench_test() -{ - echo "Now start polybench tests" - - cd ${WORK_DIR}/../polybench - if [[ $1 == "aot" || $1 == "jit" ]];then - ./build.sh AOT ${SGX_OPT} - ./test_aot.sh $1 ${SGX_OPT} - else - ./build.sh - ./test_interp.sh ${SGX_OPT} - fi - cp report.txt ${REPORT_DIR}/polybench_$1_test_report.txt - - echo "Finish polybench tests" -} - -function libsodium_test() -{ - echo "Now start libsodium tests" - - cd ${WORK_DIR}/../libsodium - if [[ $1 == "aot" || $1 == "jit" ]];then - ./build.sh ${SGX_OPT} - ./test_aot.sh $1 ${SGX_OPT} - else - ./test_interp.sh ${SGX_OPT} - fi - cp report.txt ${REPORT_DIR}/libsodium_$1_test_report.txt - - echo "Finish libsodium tests" -} - -function malformed_test() -{ - # build iwasm firstly - cd ${WORK_DIR}/../../malformed - ./malformed_test.py --run ${IWASM_CMD} | tee ${REPORT_DIR}/malfomed_$1_test_report.txt -} - -function collect_standalone() -{ - if [[ ${COLLECT_CODE_COVERAGE} == 1 ]]; then - pushd ${WORK_DIR} > /dev/null 2>&1 - - CODE_COV_FILE="" - if [[ -z "${CODE_COV_FILE}" ]]; then - CODE_COV_FILE="${WORK_DIR}/wamr.lcov" - else - CODE_COV_FILE="${CODE_COV_FILE}" - fi - - STANDALONE_DIR=${WORK_DIR}/../../standalone - - echo "Collect code coverage of standalone dump-call-stack" - ./collect_coverage.sh "${CODE_COV_FILE}" "${STANDALONE_DIR}/dump-call-stack/build" - echo "Collect code coverage of standalone dump-mem-profiling" - ./collect_coverage.sh "${CODE_COV_FILE}" "${STANDALONE_DIR}/dump-mem-profiling/build" - echo "Collect code coverage of standalone dump-perf-profiling" - ./collect_coverage.sh "${CODE_COV_FILE}" "${STANDALONE_DIR}/dump-perf-profiling/build" - if [[ $1 == "aot" ]]; then - echo "Collect code coverage of standalone pad-test" - ./collect_coverage.sh "${CODE_COV_FILE}" "${STANDALONE_DIR}/pad-test/build" - fi - echo "Collect code coverage of standalone test-invoke-native" - ./collect_coverage.sh "${CODE_COV_FILE}" "${STANDALONE_DIR}/test-invoke-native/build" - echo "Collect code coverage of standalone test-running-modes" - ./collect_coverage.sh "${CODE_COV_FILE}" "${STANDALONE_DIR}/test-running-modes/build" - echo "Collect code coverage of standalone test-running-modes/c-embed" - ./collect_coverage.sh "${CODE_COV_FILE}" "${STANDALONE_DIR}/test-running-modes/c-embed/build" - echo "Collect code coverage of standalone test-ts2" - ./collect_coverage.sh "${CODE_COV_FILE}" "${STANDALONE_DIR}/test-ts2/build" - - popd > /dev/null 2>&1 - fi -} - -function standalone_test() -{ - if [[ ${COLLECT_CODE_COVERAGE} == 1 ]]; then - export COLLECT_CODE_COVERAGE=1 - fi - - cd ${WORK_DIR}/../../standalone - - args="--$1" - - [[ ${SGX_OPT} == "--sgx" ]] && args="$args --sgx" || args="$args --no-sgx" - - [[ ${ENABLE_MULTI_THREAD} == 1 ]] && args="$args --thread" || args="$args --no-thread" - - [[ ${ENABLE_SIMD} == 1 ]] && args="$args --simd" || args="$args --no-simd" - - args="$args ${TARGET}" - - ./standalone.sh $args | tee ${REPORT_DIR}/standalone_$1_test_report.txt - - collect_standalone "$1" -} - -function build_iwasm_with_cfg() -{ - echo "Build iwasm with compile flags with " $* " for spec test" \ - | tee -a ${REPORT_DIR}/spec_test_report.txt - - if [[ ${SGX_OPT} == "--sgx" ]];then - cd ${WAMR_DIR}/product-mini/platforms/linux-sgx \ - && if [ -d build ]; then rm -rf build/*; else mkdir build; fi \ - && cd build \ - && cmake $* .. \ - && make -j 4 - cd ${WAMR_DIR}/product-mini/platforms/linux-sgx/enclave-sample \ - && make clean \ - && make SPEC_TEST=1 - else - cd ${WAMR_DIR}/product-mini/platforms/${PLATFORM} \ - && if [ -d build ]; then rm -rf build/*; else mkdir build; fi \ - && cd build \ - && cmake $* .. \ - && make -j 4 - fi - - if [ "$?" != 0 ];then - echo -e "build iwasm failed" - exit 1 - fi -} - -function build_wamrc() -{ - if [[ $TARGET == "ARMV7_VFP" || $TARGET == "THUMBV7_VFP" - || $TARGET == "RISCV32" || $TARGET == "RISCV32_ILP32" || $TARGET == "RISCV32_ILP32D" - || $TARGET == "RISCV64" || $TARGET == "RISCV64_LP64D" || $TARGET == "RISCV64_LP64" ]];then - echo "suppose wamrc is already built" - return - fi - - echo "Build wamrc for spec test under aot compile type" - cd ${WAMR_DIR}/wamr-compiler \ - && ./build_llvm.sh \ - && if [ -d build ]; then rm -r build/*; else mkdir build; fi \ - && cd build \ - && cmake .. -DCOLLECT_CODE_COVERAGE=${COLLECT_CODE_COVERAGE} \ - && make -j 4 -} - -### Need to add a test suite? -### The function name should be ${suite_name}_test -# function xxx_test() -# { -# -# } - -function collect_coverage() -{ - if [[ ${COLLECT_CODE_COVERAGE} == 1 ]]; then - ln -sf ${WORK_DIR}/../spec-test-script/collect_coverage.sh ${WORK_DIR} - - CODE_COV_FILE="" - if [[ -z "${CODE_COV_FILE}" ]]; then - CODE_COV_FILE="${WORK_DIR}/wamr.lcov" - else - CODE_COV_FILE="${CODE_COV_FILE}" - fi - - pushd ${WORK_DIR} > /dev/null 2>&1 - echo "Collect code coverage of iwasm" - ./collect_coverage.sh ${CODE_COV_FILE} ${IWASM_LINUX_ROOT_DIR}/build - if [[ $1 == "llvm-aot" ]]; then - echo "Collect code coverage of wamrc" - ./collect_coverage.sh ${CODE_COV_FILE} ${WAMR_DIR}/wamr-compiler/build - fi - for suite in "${TEST_CASE_ARR[@]}"; do - if [[ ${suite} = "unit" ]]; then - echo "Collect code coverage of unit test" - ./collect_coverage.sh ${CODE_COV_FILE} ${WORK_DIR}/unittest-build - break - fi - done - popd > /dev/null 2>&1 - else - echo "code coverage isn't collected" - fi -} - -function trigger() -{ - local EXTRA_COMPILE_FLAGS="" - # default enabled features - EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_BULK_MEMORY=1" - - if [[ ${ENABLE_MULTI_MODULE} == 1 ]];then - EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_MULTI_MODULE=1" - else - EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_MULTI_MODULE=0" - fi - - if [[ ${ENABLE_MULTI_THREAD} == 1 ]];then - EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_LIB_PTHREAD=1" - EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_REF_TYPES=0" - else - EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_REF_TYPES=1" - fi - - if [[ ${ENABLE_SIMD} == 1 ]]; then - EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_SIMD=1" - else - EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_SIMD=0" - fi - - if [[ ${ENABLE_GC} == 1 ]]; then - EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_GC=1" - EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_REF_TYPES=1" - EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_BULK_MEMORY=1" - fi - - if [[ ${ENABLE_DEBUG_VERSION} == 1 ]]; then - EXTRA_COMPILE_FLAGS+=" -DCMAKE_BUILD_TYPE=Debug" - fi - - if [[ ${ENABLE_GC_HEAP_VERIFY} == 1 ]]; then - EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_GC_HEAP_VERIFY=1" - fi - - if [[ ${ENABLE_WASI_THREADS} == 1 ]]; then - EXTRA_COMPILE_FLAGS+=" -DWAMR_BUILD_LIB_WASI_THREADS=1" - fi - - for t in "${TYPE[@]}"; do - case $t in - "classic-interp") - if [[ ${ENABLE_SIMD} == 1 ]]; then - echo "does not support SIMD in interp mode, bypass" - continue - fi - - echo "work in classic-interp mode" - # classic-interp - BUILD_FLAGS="$CLASSIC_INTERP_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS" - if [[ ${ENABLE_QEMU} == 0 ]]; then - build_iwasm_with_cfg $BUILD_FLAGS - fi - for suite in "${TEST_CASE_ARR[@]}"; do - $suite"_test" classic-interp - done - collect_coverage classic-interp - ;; - - "fast-interp") - if [[ ${ENABLE_SIMD} == 1 ]]; then - echo "does not support SIMD in interp mode, bypass" - continue - fi - - echo "work in fast-interp mode" - # fast-interp - BUILD_FLAGS="$FAST_INTERP_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS" - if [[ ${ENABLE_QEMU} == 0 ]]; then - build_iwasm_with_cfg $BUILD_FLAGS - fi - for suite in "${TEST_CASE_ARR[@]}"; do - $suite"_test" fast-interp - done - collect_coverage fast-interp - ;; - - "jit") - if [[ ${TARGET} == "X86_32" ]]; then - echo "does not support an X86_32 target in JIT mode, bypass" - continue - fi - - echo "work in orc jit eager compilation mode" - BUILD_FLAGS="$ORC_EAGER_JIT_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS" - build_iwasm_with_cfg $BUILD_FLAGS - for suite in "${TEST_CASE_ARR[@]}"; do - $suite"_test" jit - done - collect_coverage llvm-jit - - echo "work in orc jit lazy compilation mode" - BUILD_FLAGS="$ORC_EAGER_JIT_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS" - build_iwasm_with_cfg $BUILD_FLAGS - for suite in "${TEST_CASE_ARR[@]}"; do - $suite"_test" jit - done - collect_coverage llvm-jit - ;; - - "aot") - echo "work in aot mode" - # aot - BUILD_FLAGS="$AOT_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS" - if [[ ${ENABLE_QEMU} == 0 ]]; then - build_iwasm_with_cfg $BUILD_FLAGS - fi - build_wamrc - for suite in "${TEST_CASE_ARR[@]}"; do - $suite"_test" aot - done - collect_coverage llvm-aot - ;; - - "fast-jit") - echo "work in fast-jit mode" - # fast-jit - BUILD_FLAGS="$FAST_JIT_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS" - build_iwasm_with_cfg $BUILD_FLAGS - for suite in "${TEST_CASE_ARR[@]}"; do - $suite"_test" fast-jit - done - collect_coverage fast-jit - ;; - - "multi-tier-jit") - echo "work in multi-tier-jit mode" - # multi-tier-jit - BUILD_FLAGS="$MULTI_TIER_JIT_COMPILE_FLAGS $EXTRA_COMPILE_FLAGS" - build_iwasm_with_cfg $BUILD_FLAGS - for suite in "${TEST_CASE_ARR[@]}"; do - $suite"_test" multi-tier-jit - done - collect_coverage multi-tier-jit - ;; - - *) - echo "unexpected mode, do nothing" - ;; - esac - done -} - -# if collect code coverage, ignore -s, test all test cases. -if [[ $TEST_CASE_ARR ]];then - trigger || (echo "TEST FAILED"; exit 1) -else - # test all suite, ignore polybench and libsodium because of long time cost - TEST_CASE_ARR=("spec") - : ' - if [[ $COLLECT_CODE_COVERAGE == 1 ]];then - # add polybench if collecting code coverage data - TEST_CASE_ARR+=("polybench") - # add libsodium if needed, which takes long time to run - TEST_CASE_ARR+=("libsodium") - fi - ' - trigger || (echo "TEST FAILED"; exit 1) - # Add more suites here -fi - -echo -e "Test finish. Reports are under ${REPORT_DIR}" -DEBUG set +xv pipefail -echo "TEST SUCCESSFUL" -exit 0 diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/wasi-test-script/run_wasi_tests.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/wasi-test-script/run_wasi_tests.sh deleted file mode 100755 index eb6cf3f91..000000000 --- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/tests/wamr-test-suites/wasi-test-script/run_wasi_tests.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash - -# -# Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# - -readonly MODE=$1 -readonly TARGET=$2 - -readonly WORK_DIR=$PWD -readonly PLATFORM=$(uname -s | tr A-Z a-z) -readonly WAMR_DIR="${WORK_DIR}/../../../.." -readonly IWASM_CMD="${WORK_DIR}/../../../../product-mini/platforms/${PLATFORM}/build/iwasm" -readonly WAMRC_CMD="${WORK_DIR}/../../../../wamr-compiler/build/wamrc" -readonly C_TESTS="tests/c/testsuite/" -readonly ASSEMBLYSCRIPT_TESTS="tests/assemblyscript/testsuite/" -readonly THREAD_PROPOSAL_TESTS="tests/proposals/wasi-threads/" -readonly THREAD_INTERNAL_TESTS="${WAMR_DIR}/core/iwasm/libraries/lib-wasi-threads/test/" -readonly LIB_SOCKET_TESTS="${WAMR_DIR}/core/iwasm/libraries/lib-socket/test/" - -run_aot_tests () { - local tests=("$@") - for test_wasm in ${tests[@]}; do - test_aot="${test_wasm%.wasm}.aot" - test_json="${test_wasm%.wasm}.json" - - if [ -f ${test_wasm} ]; then - expected=$(jq .exit_code ${test_json}) - fi - - echo "Compiling $test_wasm to $test_aot" - ${WAMRC_CMD} --enable-multi-thread ${target_option} \ - -o ${test_aot} ${test_wasm} - - echo "Running $test_aot" - expected=0 - if [ -f ${test_json} ]; then - expected=$(jq .exit_code ${test_json}) - fi - - ${IWASM_CMD} $test_aot - - ret=${PIPESTATUS[0]} - - echo "expected=$expected, actual=$ret" - if [[ $expected != "" ]] && [[ $expected != $ret ]];then - exit_code=1 - fi - done -} - -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 \ - -r adapters/wasm-micro-runtime.py \ - -t \ - ${C_TESTS} \ - ${ASSEMBLYSCRIPT_TESTS} \ - ${THREAD_PROPOSAL_TESTS} \ - ${THREAD_INTERNAL_TESTS} \ - ${LIB_SOCKET_TESTS} \ - exit_code=${PIPESTATUS[0]} - deactivate -else - target_option="" - if [[ $TARGET == "X86_32" ]];then - target_option="--target=i386" - fi - - exit_code=0 - for testsuite in ${THREAD_PROPOSAL_TESTS} ${THREAD_INTERNAL_TESTS}; do - tests=$(ls ${testsuite}*.wasm) - tests_array=($tests) - run_aot_tests "${tests_array[@]}" - done -fi - -exit ${exit_code} \ No newline at end of file -- cgit v1.2.3