diff options
author | Keith Winstein <keithw@cs.stanford.edu> | 2022-07-13 18:06:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-14 01:06:53 +0000 |
commit | ec53e183716f39741bee01f8d7f4d18d76ced695 (patch) | |
tree | 3424e1f658762d129a1c265f65d355bb247f89ad /test | |
parent | 54c55355c95fdbe5288c7f690fe63f626bb26b7d (diff) | |
download | wabt-ec53e183716f39741bee01f8d7f4d18d76ced695.tar.gz wabt-ec53e183716f39741bee01f8d7f4d18d76ced695.tar.bz2 wabt-ec53e183716f39741bee01f8d7f4d18d76ced695.zip |
wasm2c: implement the exception-handling proposal (#1930)
(The imports.txt and exports.txt tests require multi-table and
are disabled until reference types is supported.)
Diffstat (limited to 'test')
-rwxr-xr-x | test/run-spec-wasm2c.py | 5 | ||||
-rw-r--r-- | test/spec-wasm2c-prefix.c | 11 | ||||
-rw-r--r-- | test/wasm2c/bad-enable-feature.txt | 4 | ||||
-rw-r--r-- | test/wasm2c/spec/exception-handling/binary.txt | 6 | ||||
-rw-r--r-- | test/wasm2c/spec/exception-handling/exports.txt | 13 | ||||
-rw-r--r-- | test/wasm2c/spec/exception-handling/imports.txt | 24 | ||||
-rw-r--r-- | test/wasm2c/spec/exception-handling/rethrow.txt | 6 | ||||
-rw-r--r-- | test/wasm2c/spec/exception-handling/tag.txt | 6 | ||||
-rw-r--r-- | test/wasm2c/spec/exception-handling/throw.txt | 6 | ||||
-rw-r--r-- | test/wasm2c/spec/exception-handling/try_catch.txt | 6 | ||||
-rw-r--r-- | test/wasm2c/spec/exception-handling/try_delegate.txt | 6 |
11 files changed, 91 insertions, 2 deletions
diff --git a/test/run-spec-wasm2c.py b/test/run-spec-wasm2c.py index 5a246650..3660f804 100755 --- a/test/run-spec-wasm2c.py +++ b/test/run-spec-wasm2c.py @@ -200,6 +200,7 @@ class CWriter(object): 'action': self._WriteActionCommand, 'assert_return': self._WriteAssertReturnCommand, 'assert_trap': self._WriteAssertActionCommand, + 'assert_exception': self._WriteAssertActionCommand, 'assert_exhaustion': self._WriteAssertActionCommand, } @@ -276,6 +277,7 @@ class CWriter(object): 'assert_exhaustion': 'ASSERT_EXHAUSTION', 'assert_return': 'ASSERT_RETURN', 'assert_trap': 'ASSERT_TRAP', + 'assert_exception': 'ASSERT_EXCEPTION', } assert_macro = assert_map[command['type']] @@ -412,6 +414,7 @@ def main(args): help='print the commands that are run.', action='store_true') parser.add_argument('file', help='wast file.') + parser.add_argument('--enable-exceptions', action='store_true') parser.add_argument('--enable-multi-memory', action='store_true') parser.add_argument('--disable-bulk-memory', action='store_true') parser.add_argument('--disable-reference-types', action='store_true') @@ -425,6 +428,7 @@ def main(args): wast2json.verbose = options.print_cmd wast2json.AppendOptionalArgs({ '-v': options.verbose, + '--enable-exceptions': options.enable_exceptions, '--enable-multi-memory': options.enable_multi_memory, '--disable-bulk-memory': options.disable_bulk_memory, '--disable-reference-types': options.disable_reference_types}) @@ -438,6 +442,7 @@ def main(args): error_cmdline=options.error_cmdline) wasm2c.verbose = options.print_cmd wasm2c.AppendOptionalArgs({ + '--enable-exceptions': options.enable_exceptions, '--enable-multi-memory': options.enable_multi_memory}) options.cflags += shlex.split(os.environ.get('WASM2C_CFLAGS', '')) diff --git a/test/spec-wasm2c-prefix.c b/test/spec-wasm2c-prefix.c index 4415be6f..8e570588 100644 --- a/test/spec-wasm2c-prefix.c +++ b/test/spec-wasm2c-prefix.c @@ -25,6 +25,17 @@ static void error(const char* file, int line, const char* format, ...) { va_end(args); } +#define ASSERT_EXCEPTION(f) \ + do { \ + g_tests_run++; \ + if (wasm_rt_impl_try() == WASM_RT_TRAP_UNCAUGHT_EXCEPTION) { \ + g_tests_passed++; \ + } else { \ + (void)(f); \ + error(__FILE__, __LINE__, "expected " #f " to throw exception.\n"); \ + } \ + } while (0) + #define ASSERT_TRAP(f) \ do { \ g_tests_run++; \ diff --git a/test/wasm2c/bad-enable-feature.txt b/test/wasm2c/bad-enable-feature.txt index 609cb53b..9c748bb7 100644 --- a/test/wasm2c/bad-enable-feature.txt +++ b/test/wasm2c/bad-enable-feature.txt @@ -1,6 +1,6 @@ ;;; RUN: %(wasm2c)s -;;; ARGS: --enable-exceptions %(in_file)s +;;; ARGS: --enable-threads %(in_file)s ;;; ERROR: 1 (;; STDERR ;;; -wasm2c currently only supports a fixed set of features. +wasm2c currently only supports a limited set of features. ;;; STDERR ;;) diff --git a/test/wasm2c/spec/exception-handling/binary.txt b/test/wasm2c/spec/exception-handling/binary.txt new file mode 100644 index 00000000..59615955 --- /dev/null +++ b/test/wasm2c/spec/exception-handling/binary.txt @@ -0,0 +1,6 @@ +;;; TOOL: run-spec-wasm2c +;;; STDIN_FILE: third_party/testsuite/proposals/exception-handling/binary.wast +;;; ARGS*: --enable-exceptions +(;; STDOUT ;;; +0/0 tests passed. +;;; STDOUT ;;) diff --git a/test/wasm2c/spec/exception-handling/exports.txt b/test/wasm2c/spec/exception-handling/exports.txt new file mode 100644 index 00000000..4b1fc5a4 --- /dev/null +++ b/test/wasm2c/spec/exception-handling/exports.txt @@ -0,0 +1,13 @@ +;;; TOOL: run-spec-wasm2c +(module) +(;; STDOUT ;;; +0/0 tests passed. +;;; STDOUT ;;) + +;; To be replaced with below after reference types land +;; ;;; TOOL: run-spec-wasm2c +;; ;;; STDIN_FILE: third_party/testsuite/proposals/exception-handling/exports.wast +;; ;;; ARGS*: --enable-exceptions +;; (;; STDOUT ;;; +;; 9/9 tests passed. +;; ;;; STDOUT ;;) diff --git a/test/wasm2c/spec/exception-handling/imports.txt b/test/wasm2c/spec/exception-handling/imports.txt new file mode 100644 index 00000000..797faf50 --- /dev/null +++ b/test/wasm2c/spec/exception-handling/imports.txt @@ -0,0 +1,24 @@ +;;; TOOL: run-spec-wasm2c +(module) +(;; STDOUT ;;; +0/0 tests passed. +;;; STDOUT ;;) + +;; To be replaced with below after reference types land +;; ;;; TOOL: run-spec-wasm2c +;; ;;; STDIN_FILE: third_party/testsuite/proposals/exception-handling/imports.wast +;; ;;; ARGS*: --enable-exceptions +;; (;; STDOUT ;;; +;; spectest.print_i32(13) +;; spectest.print_i32_f32(14 42) +;; spectest.print_i32(13) +;; spectest.print_i32(13) +;; spectest.print_f32(13) +;; spectest.print_i32(13) +;; spectest.print_f64_f64(25 53) +;; spectest.print_f64(24) +;; spectest.print_f64(24) +;; spectest.print_f64(24) +;; spectest.print_i32(13) +;; 34/34 tests passed. +;; ;;; STDOUT ;;) diff --git a/test/wasm2c/spec/exception-handling/rethrow.txt b/test/wasm2c/spec/exception-handling/rethrow.txt new file mode 100644 index 00000000..7f1903cf --- /dev/null +++ b/test/wasm2c/spec/exception-handling/rethrow.txt @@ -0,0 +1,6 @@ +;;; TOOL: run-spec-wasm2c +;;; STDIN_FILE: third_party/testsuite/proposals/exception-handling/rethrow.wast +;;; ARGS*: --enable-exceptions +(;; STDOUT ;;; +12/12 tests passed. +;;; STDOUT ;;) diff --git a/test/wasm2c/spec/exception-handling/tag.txt b/test/wasm2c/spec/exception-handling/tag.txt new file mode 100644 index 00000000..8824d43c --- /dev/null +++ b/test/wasm2c/spec/exception-handling/tag.txt @@ -0,0 +1,6 @@ +;;; TOOL: run-spec-wasm2c +;;; STDIN_FILE: third_party/testsuite/proposals/exception-handling/tag.wast +;;; ARGS*: --enable-exceptions +(;; STDOUT ;;; +0/0 tests passed. +;;; STDOUT ;;) diff --git a/test/wasm2c/spec/exception-handling/throw.txt b/test/wasm2c/spec/exception-handling/throw.txt new file mode 100644 index 00000000..fd751380 --- /dev/null +++ b/test/wasm2c/spec/exception-handling/throw.txt @@ -0,0 +1,6 @@ +;;; TOOL: run-spec-wasm2c +;;; STDIN_FILE: third_party/testsuite/proposals/exception-handling/throw.wast +;;; ARGS*: --enable-exceptions +(;; STDOUT ;;; +7/7 tests passed. +;;; STDOUT ;;) diff --git a/test/wasm2c/spec/exception-handling/try_catch.txt b/test/wasm2c/spec/exception-handling/try_catch.txt new file mode 100644 index 00000000..049cf665 --- /dev/null +++ b/test/wasm2c/spec/exception-handling/try_catch.txt @@ -0,0 +1,6 @@ +;;; TOOL: run-spec-wasm2c +;;; STDIN_FILE: third_party/testsuite/proposals/exception-handling/try_catch.wast +;;; ARGS*: --enable-exceptions +(;; STDOUT ;;; +27/27 tests passed. +;;; STDOUT ;;) diff --git a/test/wasm2c/spec/exception-handling/try_delegate.txt b/test/wasm2c/spec/exception-handling/try_delegate.txt new file mode 100644 index 00000000..9b1d7999 --- /dev/null +++ b/test/wasm2c/spec/exception-handling/try_delegate.txt @@ -0,0 +1,6 @@ +;;; TOOL: run-spec-wasm2c +;;; STDIN_FILE: third_party/testsuite/proposals/exception-handling/try_delegate.wast +;;; ARGS*: --enable-exceptions +(;; STDOUT ;;; +15/15 tests passed. +;;; STDOUT ;;) |