summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Winstein <208955+keithw@users.noreply.github.com>2024-11-11 00:58:58 -0800
committerGitHub <noreply@github.com>2024-11-11 00:58:58 -0800
commit2e23b86f2716877f6e24df0c39ac8f0f0e64c770 (patch)
tree45ece12b4c3e157ffc19de36e4b64f2a30e8ca43
parent765b47d02aac894da80b74284263d1b487415aa0 (diff)
downloadwabt-2e23b86f2716877f6e24df0c39ac8f0f0e64c770.tar.gz
wabt-2e23b86f2716877f6e24df0c39ac8f0f0e64c770.tar.bz2
wabt-2e23b86f2716877f6e24df0c39ac8f0f0e64c770.zip
test/run-roundtrip.py: test roundtrip even with --stdout (#2505)
-rw-r--r--test/regress/write-memuse.txt8
-rwxr-xr-xtest/run-roundtrip.py19
2 files changed, 19 insertions, 8 deletions
diff --git a/test/regress/write-memuse.txt b/test/regress/write-memuse.txt
index 5217cfec..20e472a2 100644
--- a/test/regress/write-memuse.txt
+++ b/test/regress/write-memuse.txt
@@ -1,4 +1,10 @@
;;; TOOL: run-roundtrip
-;;; ARGS*: --enable-multi-memory --debug-names
+;;; ARGS*: --enable-multi-memory --debug-names --stdout
(memory 0)
(memory $k (data))
+(;; STDOUT ;;;
+(module
+ (memory (;0;) 0)
+ (memory $k 0 0)
+ (data (;0;) (memory $k) (i32.const 0) ""))
+;;; STDOUT ;;)
diff --git a/test/run-roundtrip.py b/test/run-roundtrip.py
index 69c4596f..95e1e0a7 100755
--- a/test/run-roundtrip.py
+++ b/test/run-roundtrip.py
@@ -55,7 +55,7 @@ def FilesAreEqual(filename1, filename2, verbose=False):
return (OK, '')
-def DoRoundtrip(wat2wasm, wasm2wat, out_dir, filename, verbose, stdout):
+def DoRoundtrip(wat2wasm, wasm2wat, out_dir, filename, verbose, stdout, skip_roundtrip_check):
basename = os.path.basename(filename)
basename_noext = os.path.splitext(basename)[0]
wasm1_file = os.path.join(out_dir, basename_noext + '-1.wasm')
@@ -75,9 +75,9 @@ def DoRoundtrip(wat2wasm, wasm2wat, out_dir, filename, verbose, stdout):
if stdout:
with open(wat2_file) as f:
sys.stdout.write(f.read())
+ if skip_roundtrip_check:
return (OK, '')
- else:
- return FilesAreEqual(wasm1_file, wasm3_file, verbose)
+ return FilesAreEqual(wasm1_file, wasm3_file, verbose)
def main(args):
@@ -90,7 +90,7 @@ def main(args):
default=find_exe.GetDefaultPath(),
help='directory to search for all executables.')
parser.add_argument('--stdout', action='store_true',
- help='do one roundtrip and write wat output to stdout')
+ help='write wat output to stdout')
parser.add_argument('--no-error-cmdline',
help='don\'t display the subprocess\'s commandline when '
'an error occurs', dest='error_cmdline',
@@ -100,7 +100,9 @@ def main(args):
action='store_true')
parser.add_argument('--no-check', action='store_true')
parser.add_argument('--debug-names', action='store_true')
- parser.add_argument('--generate-names', action='store_true')
+ # --generate-names modifies name section, so skip roundtrip check
+ parser.add_argument('--generate-names', action='store_true',
+ help="write debug names and skip end-to-end roundtrip check")
parser.add_argument('--fold-exprs', action='store_true')
parser.add_argument('--enable-exceptions', action='store_true')
parser.add_argument('--enable-saturating-float-to-int', action='store_true')
@@ -115,7 +117,9 @@ def main(args):
parser.add_argument('--enable-annotations', action='store_true')
parser.add_argument('--enable-code-metadata', action='store_true')
parser.add_argument('--enable-custom-page-sizes', action='store_true')
- parser.add_argument('--inline-exports', action='store_true')
+ # --inline-exports can reorder exports, so skip roundtrip check
+ parser.add_argument('--inline-exports', action='store_true',
+ help="write exports inline and skip end-to-end roundtrip check")
parser.add_argument('--inline-imports', action='store_true')
parser.add_argument('--reloc', action='store_true')
parser.add_argument('file', help='test file.')
@@ -178,9 +182,10 @@ def main(args):
sys.stderr.write('File not found: %s\n' % filename)
return ERROR
+ skip_roundtrip_check = options.generate_names or options.inline_exports
with utils.TempDirectory(options.out_dir, 'roundtrip-') as out_dir:
result, msg = DoRoundtrip(wat2wasm, wasm2wat, out_dir, filename,
- options.verbose, options.stdout)
+ options.verbose, options.stdout, skip_roundtrip_check)
if result == ERROR:
sys.stderr.write(msg)
return result