Skip to content

Commit 74b2b06

Browse files
authored
[NFC] Move code from fuzz_opt.py to a shared place (WebAssembly#7165)
The list of tests, and which tests cannot be fuzzed, will be useful in a future PR that uses it for ClusterFuzz as well. This just moves things out so they are reusable.
1 parent 4e1ae4a commit 74b2b06

File tree

3 files changed

+97
-73
lines changed

3 files changed

+97
-73
lines changed

scripts/fuzz_opt.py

Lines changed: 5 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import traceback
4242
from os.path import abspath
4343

44+
from test import fuzzing
4445
from test import shared
4546
from test import support
4647

@@ -242,7 +243,7 @@ def randomize_fuzz_settings():
242243
def init_important_initial_contents():
243244
# Fuzz dir contents are always important to us.
244245
fuzz_dir = os.path.join(shared.options.binaryen_root, 'fuzz')
245-
fuzz_cases = shared.get_tests(fuzz_dir, test_suffixes, recursive=True)
246+
fuzz_cases = shared.get_tests(fuzz_dir, shared.test_suffixes, recursive=True)
246247
FIXED_IMPORTANT_INITIAL_CONTENTS = fuzz_cases
247248

248249
# If auto_initial_contents is set we'll also grab all test files that are
@@ -306,66 +307,9 @@ def is_git_repo():
306307
IMPORTANT_INITIAL_CONTENTS = [os.path.join(shared.get_test_dir('.'), t) for t in initial_contents]
307308

308309

309-
INITIAL_CONTENTS_IGNORE = [
310-
# Float16 is still experimental.
311-
'f16.wast',
312-
# not all relaxed SIMD instructions are implemented in the interpreter
313-
'relaxed-simd.wast',
314-
# TODO: fuzzer and interpreter support for strings
315-
'strings.wast',
316-
'simplify-locals-strings.wast',
317-
'string-lowering-instructions.wast',
318-
# TODO: fuzzer and interpreter support for extern conversions
319-
'extern-conversions.wast',
320-
# ignore DWARF because it is incompatible with multivalue atm
321-
'zlib.wasm',
322-
'cubescript.wasm',
323-
'class_with_dwarf_noprint.wasm',
324-
'fib2_dwarf.wasm',
325-
'fib_nonzero-low-pc_dwarf.wasm',
326-
'inlined_to_start_dwarf.wasm',
327-
'fannkuch3_manyopts_dwarf.wasm',
328-
'fib2_emptylocspan_dwarf.wasm',
329-
'fannkuch3_dwarf.wasm',
330-
'dwarf-local-order.wasm',
331-
'strip-producers.wasm',
332-
'multi_unit_abbrev_noprint.wasm',
333-
'reverse_dwarf_abbrevs.wasm',
334-
'print_g.wasm',
335-
'print_g_strip-dwarf.wasm',
336-
'fannkuch0_dwarf.wasm',
337-
'dwarfdump_roundtrip_dwarfdump.wasm',
338-
'dwarfdump.wasm',
339-
'fannkuch3_dwarf.wasm',
340-
'dwarf-local-order.wasm',
341-
'dwarf_unit_with_no_abbrevs_noprint.wasm',
342-
'strip-debug.wasm',
343-
'multi_line_table_dwarf.wasm',
344-
'dwarf_with_exceptions.wasm',
345-
'strip-dwarf.wasm',
346-
'ignore_missing_func_dwarf.wasm',
347-
'print.wasm',
348-
# TODO fuzzer support for multimemory
349-
'multi-memories-atomics64.wast',
350-
'multi-memories-basics.wast',
351-
'multi-memories-simd.wast',
352-
'multi-memories-atomics64.wasm',
353-
'multi-memories-basics.wasm',
354-
'multi-memories-simd.wasm',
355-
'multi-memories_size.wast',
356-
# TODO: fuzzer support for internalize/externalize
357-
'optimize-instructions-gc-extern.wast',
358-
'gufa-extern.wast',
359-
# the fuzzer does not support imported memories
360-
'multi-memory-lowering-import.wast',
361-
'multi-memory-lowering-import-error.wast',
362-
# the fuzzer does not support typed continuations
363-
'typed_continuations.wast',
364-
'typed_continuations_resume.wast',
365-
'typed_continuations_contnew.wast',
366-
'typed_continuations_contbind.wast',
367-
'typed_continuations_suspend.wast',
368-
]
310+
all_tests = shared.get_all_tests()
311+
312+
INITIAL_CONTENTS_IGNORE = fuzzing.unfuzzable_tests
369313

370314

371315
def pick_initial_contents():
@@ -1802,18 +1746,6 @@ def can_run_on_wasm(self, wasm):
18021746
]
18031747

18041748

1805-
test_suffixes = ['*.wasm', '*.wast', '*.wat']
1806-
1807-
core_tests = shared.get_tests(shared.get_test_dir('.'), test_suffixes)
1808-
passes_tests = shared.get_tests(shared.get_test_dir('passes'), test_suffixes)
1809-
spec_tests = shared.get_tests(shared.get_test_dir('spec'), test_suffixes)
1810-
wasm2js_tests = shared.get_tests(shared.get_test_dir('wasm2js'), test_suffixes)
1811-
lld_tests = shared.get_tests(shared.get_test_dir('lld'), test_suffixes)
1812-
unit_tests = shared.get_tests(shared.get_test_dir(os.path.join('unit', 'input')), test_suffixes)
1813-
lit_tests = shared.get_tests(shared.get_test_dir('lit'), test_suffixes, recursive=True)
1814-
all_tests = core_tests + passes_tests + spec_tests + wasm2js_tests + lld_tests + unit_tests + lit_tests
1815-
1816-
18171749
# Do one test, given an input file for -ttf and some optimizations to run
18181750
def test_one(random_input, given_wasm):
18191751
randomize_pass_debug()

scripts/test/fuzzing.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Copyright 2024 WebAssembly Community Group participants
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
# Tests that the fuzzers should not operate on.
17+
unfuzzable_tests = [
18+
# Float16 is still experimental.
19+
'f16.wast',
20+
# not all relaxed SIMD instructions are implemented in the interpreter
21+
'relaxed-simd.wast',
22+
# TODO: fuzzer and interpreter support for strings
23+
'strings.wast',
24+
'simplify-locals-strings.wast',
25+
'string-lowering-instructions.wast',
26+
# TODO: fuzzer and interpreter support for extern conversions
27+
'extern-conversions.wast',
28+
# ignore DWARF because it is incompatible with multivalue atm
29+
'zlib.wasm',
30+
'cubescript.wasm',
31+
'class_with_dwarf_noprint.wasm',
32+
'fib2_dwarf.wasm',
33+
'fib_nonzero-low-pc_dwarf.wasm',
34+
'inlined_to_start_dwarf.wasm',
35+
'fannkuch3_manyopts_dwarf.wasm',
36+
'fib2_emptylocspan_dwarf.wasm',
37+
'fannkuch3_dwarf.wasm',
38+
'dwarf-local-order.wasm',
39+
'strip-producers.wasm',
40+
'multi_unit_abbrev_noprint.wasm',
41+
'reverse_dwarf_abbrevs.wasm',
42+
'print_g.wasm',
43+
'print_g_strip-dwarf.wasm',
44+
'fannkuch0_dwarf.wasm',
45+
'dwarfdump_roundtrip_dwarfdump.wasm',
46+
'dwarfdump.wasm',
47+
'fannkuch3_dwarf.wasm',
48+
'dwarf-local-order.wasm',
49+
'dwarf_unit_with_no_abbrevs_noprint.wasm',
50+
'strip-debug.wasm',
51+
'multi_line_table_dwarf.wasm',
52+
'dwarf_with_exceptions.wasm',
53+
'strip-dwarf.wasm',
54+
'ignore_missing_func_dwarf.wasm',
55+
'print.wasm',
56+
# TODO fuzzer support for multimemory
57+
'multi-memories-atomics64.wast',
58+
'multi-memories-basics.wast',
59+
'multi-memories-simd.wast',
60+
'multi-memories-atomics64.wasm',
61+
'multi-memories-basics.wasm',
62+
'multi-memories-simd.wasm',
63+
'multi-memories_size.wast',
64+
# TODO: fuzzer support for internalize/externalize
65+
'optimize-instructions-gc-extern.wast',
66+
'gufa-extern.wast',
67+
# the fuzzer does not support imported memories
68+
'multi-memory-lowering-import.wast',
69+
'multi-memory-lowering-import-error.wast',
70+
# the fuzzer does not support typed continuations
71+
'typed_continuations.wast',
72+
'typed_continuations_resume.wast',
73+
'typed_continuations_contnew.wast',
74+
'typed_continuations_contbind.wast',
75+
'typed_continuations_suspend.wast',
76+
]

scripts/test/shared.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,3 +561,19 @@ def skip_if_on_windows(name):
561561
print('skipping test "%s" on windows' % name)
562562
return True
563563
return False
564+
565+
566+
test_suffixes = ['*.wasm', '*.wast', '*.wat']
567+
568+
569+
# return a list of all the tests in the entire test suite
570+
def get_all_tests():
571+
core_tests = get_tests(get_test_dir('.'), test_suffixes)
572+
passes_tests = get_tests(get_test_dir('passes'), test_suffixes)
573+
spec_tests = get_tests(get_test_dir('spec'), test_suffixes)
574+
wasm2js_tests = get_tests(get_test_dir('wasm2js'), test_suffixes)
575+
lld_tests = get_tests(get_test_dir('lld'), test_suffixes)
576+
unit_tests = get_tests(get_test_dir(os.path.join('unit', 'input')), test_suffixes)
577+
lit_tests = get_tests(get_test_dir('lit'), test_suffixes, recursive=True)
578+
579+
return core_tests + passes_tests + spec_tests + wasm2js_tests + lld_tests + unit_tests + lit_tests

0 commit comments

Comments
 (0)