Skip to content

Commit f497812

Browse files
bsheedy-workDawn LUCI CQ
authored andcommitted
Support tint_fuzzer_corpus_tests on Swarming
Makes the following changes: 1. Moves the Tint fuzzer test-specific code out of //tools/run.py and into a new //scripts/run_tint_fuzzer_corpus_tests.py wrapper. //tools/run.py is now solely a thin wrapper around the Go tooling without any test-specific code. 2. Adds very simple output file generation to run_tint_fuzzer_corpus_tests.py to make it compatible with ResultDB. 3. Removes the no_swarming mixin for the fuzzer tests. The end result is that the fuzzer tests now run on Swarming properly. Also drive-by adds add_help=False to //tools/run.py so that any help requests are forwarded to the underlying tool. Bug: 441327468 Change-Id: Ib13b9a6ecd597ed08bac3fe3178dc3b5a4b71df1 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/264261 Reviewed-by: Kai Ninomiya <[email protected]> Reviewed-by: Yuly Novikov <[email protected]> Commit-Queue: Brian Sheedy <[email protected]>
1 parent 95aad18 commit f497812

File tree

6 files changed

+263
-35
lines changed

6 files changed

+263
-35
lines changed

infra/specs/ci.json

Lines changed: 128 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,52 @@
1515
"isolated_scripts": [
1616
{
1717
"args": [
18-
"fuzz",
1918
"-check",
2019
"-ir",
2120
"--append-cwd-as-build"
2221
],
22+
"merge": {
23+
"script": "//testing/merge_scripts/noop_merge.py"
24+
},
2325
"name": "tint_ir_fuzzer_corpus_tests",
26+
"resultdb": {
27+
"result_format": "single"
28+
},
29+
"swarming": {
30+
"containment_type": "AUTO",
31+
"dimensions": {
32+
"cpu": "x86-64",
33+
"gpu": "none",
34+
"os": "Ubuntu-22.04",
35+
"pool": "chromium.tests.gpu"
36+
},
37+
"service_account": "[email protected]"
38+
},
2439
"test": "fuzzer_corpus_tests",
2540
"test_id_prefix": "ninja://src/tint:fuzzer_corpus_tests/"
2641
},
2742
{
2843
"args": [
29-
"fuzz",
3044
"-check",
3145
"--append-cwd-as-build"
3246
],
47+
"merge": {
48+
"script": "//testing/merge_scripts/noop_merge.py"
49+
},
3350
"name": "tint_wgsl_fuzzer_corpus_tests",
51+
"resultdb": {
52+
"result_format": "single"
53+
},
54+
"swarming": {
55+
"containment_type": "AUTO",
56+
"dimensions": {
57+
"cpu": "x86-64",
58+
"gpu": "none",
59+
"os": "Ubuntu-22.04",
60+
"pool": "chromium.tests.gpu"
61+
},
62+
"service_account": "[email protected]"
63+
},
3464
"test": "fuzzer_corpus_tests",
3565
"test_id_prefix": "ninja://src/tint:fuzzer_corpus_tests/"
3666
}
@@ -40,22 +70,52 @@
4070
"isolated_scripts": [
4171
{
4272
"args": [
43-
"fuzz",
4473
"-check",
4574
"-ir",
4675
"--append-cwd-as-build"
4776
],
77+
"merge": {
78+
"script": "//testing/merge_scripts/noop_merge.py"
79+
},
4880
"name": "tint_ir_fuzzer_corpus_tests",
81+
"resultdb": {
82+
"result_format": "single"
83+
},
84+
"swarming": {
85+
"containment_type": "AUTO",
86+
"dimensions": {
87+
"cpu": "x86-64",
88+
"gpu": "none",
89+
"os": "Ubuntu-22.04",
90+
"pool": "chromium.tests.gpu"
91+
},
92+
"service_account": "[email protected]"
93+
},
4994
"test": "fuzzer_corpus_tests",
5095
"test_id_prefix": "ninja://src/tint:fuzzer_corpus_tests/"
5196
},
5297
{
5398
"args": [
54-
"fuzz",
5599
"-check",
56100
"--append-cwd-as-build"
57101
],
102+
"merge": {
103+
"script": "//testing/merge_scripts/noop_merge.py"
104+
},
58105
"name": "tint_wgsl_fuzzer_corpus_tests",
106+
"resultdb": {
107+
"result_format": "single"
108+
},
109+
"swarming": {
110+
"containment_type": "AUTO",
111+
"dimensions": {
112+
"cpu": "x86-64",
113+
"gpu": "none",
114+
"os": "Ubuntu-22.04",
115+
"pool": "chromium.tests.gpu"
116+
},
117+
"service_account": "[email protected]"
118+
},
59119
"test": "fuzzer_corpus_tests",
60120
"test_id_prefix": "ninja://src/tint:fuzzer_corpus_tests/"
61121
}
@@ -375,22 +435,52 @@
375435
"isolated_scripts": [
376436
{
377437
"args": [
378-
"fuzz",
379438
"-check",
380439
"-ir",
381440
"--append-cwd-as-build"
382441
],
442+
"merge": {
443+
"script": "//testing/merge_scripts/noop_merge.py"
444+
},
383445
"name": "tint_ir_fuzzer_corpus_tests",
446+
"resultdb": {
447+
"result_format": "single"
448+
},
449+
"swarming": {
450+
"containment_type": "AUTO",
451+
"dimensions": {
452+
"cpu": "x86-64",
453+
"gpu": "none",
454+
"os": "Ubuntu-22.04",
455+
"pool": "chromium.tests.gpu"
456+
},
457+
"service_account": "[email protected]"
458+
},
384459
"test": "fuzzer_corpus_tests",
385460
"test_id_prefix": "ninja://src/tint:fuzzer_corpus_tests/"
386461
},
387462
{
388463
"args": [
389-
"fuzz",
390464
"-check",
391465
"--append-cwd-as-build"
392466
],
467+
"merge": {
468+
"script": "//testing/merge_scripts/noop_merge.py"
469+
},
393470
"name": "tint_wgsl_fuzzer_corpus_tests",
471+
"resultdb": {
472+
"result_format": "single"
473+
},
474+
"swarming": {
475+
"containment_type": "AUTO",
476+
"dimensions": {
477+
"cpu": "x86-64",
478+
"gpu": "none",
479+
"os": "Ubuntu-22.04",
480+
"pool": "chromium.tests.gpu"
481+
},
482+
"service_account": "[email protected]"
483+
},
394484
"test": "fuzzer_corpus_tests",
395485
"test_id_prefix": "ninja://src/tint:fuzzer_corpus_tests/"
396486
}
@@ -400,22 +490,52 @@
400490
"isolated_scripts": [
401491
{
402492
"args": [
403-
"fuzz",
404493
"-check",
405494
"-ir",
406495
"--append-cwd-as-build"
407496
],
497+
"merge": {
498+
"script": "//testing/merge_scripts/noop_merge.py"
499+
},
408500
"name": "tint_ir_fuzzer_corpus_tests",
501+
"resultdb": {
502+
"result_format": "single"
503+
},
504+
"swarming": {
505+
"containment_type": "AUTO",
506+
"dimensions": {
507+
"cpu": "x86-64",
508+
"gpu": "none",
509+
"os": "Ubuntu-22.04",
510+
"pool": "chromium.tests.gpu"
511+
},
512+
"service_account": "[email protected]"
513+
},
409514
"test": "fuzzer_corpus_tests",
410515
"test_id_prefix": "ninja://src/tint:fuzzer_corpus_tests/"
411516
},
412517
{
413518
"args": [
414-
"fuzz",
415519
"-check",
416520
"--append-cwd-as-build"
417521
],
522+
"merge": {
523+
"script": "//testing/merge_scripts/noop_merge.py"
524+
},
418525
"name": "tint_wgsl_fuzzer_corpus_tests",
526+
"resultdb": {
527+
"result_format": "single"
528+
},
529+
"swarming": {
530+
"containment_type": "AUTO",
531+
"dimensions": {
532+
"cpu": "x86-64",
533+
"gpu": "none",
534+
"os": "Ubuntu-22.04",
535+
"pool": "chromium.tests.gpu"
536+
},
537+
"service_account": "[email protected]"
538+
},
419539
"test": "fuzzer_corpus_tests",
420540
"test_id_prefix": "ninja://src/tint:fuzzer_corpus_tests/"
421541
}

infra/specs/gn_isolate_map.pyl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'fuzzer_corpus_tests': {
2020
'label': '//src/tint:fuzzer_corpus_tests',
2121
'type': 'script',
22-
'script': '//tools/run.py',
22+
'script': '//scripts/run_tint_fuzzer_corpus_tests.py',
2323
},
2424
'tint_unittests': {
2525
'label': '//src/tint/cmd/test:tint_unittests',

infra/specs/test_suites.pyl

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,27 +125,41 @@
125125
'tint_fuzzer_corpus_tests': {
126126
'tint_wgsl_fuzzer_corpus_tests': {
127127
'args': [
128-
'fuzz',
129128
'-check',
130129
'--append-cwd-as-build',
131130
],
132131
'mixins': [
133-
# TODO(crbug.com/441327468): Support running these tests on Swarming.
134-
'no_swarming',
132+
'result_adapter_single',
135133
],
134+
'merge': {
135+
# This should be removed in favor of updating the recipe code to allow
136+
# the merge script to be skipped entirely. noop is needed currently
137+
# because standard_isolated_script_merge does not work properly
138+
# without some additional Python dependencies. However, noop_merge
139+
# locks us to a single shard, and we should not have any need for the
140+
# outputs of merge scripts for Dawn.
141+
'script': '//testing/merge_scripts/noop_merge.py',
142+
},
136143
'test': 'fuzzer_corpus_tests',
137144
},
138145
'tint_ir_fuzzer_corpus_tests': {
139146
'args': [
140-
'fuzz',
141147
'-check',
142148
'-ir',
143149
'--append-cwd-as-build',
144150
],
145151
'mixins': [
146-
# TODO(crbug.com/441327468): Support running these tests on Swarming.
147-
'no_swarming',
152+
'result_adapter_single',
148153
],
154+
'merge': {
155+
# This should be removed in favor of updating the recipe code to allow
156+
# the merge script to be skipped entirely. noop is needed currently
157+
# because standard_isolated_script_merge does not work properly
158+
# without some additional Python dependencies. However, noop_merge
159+
# locks us to a single shard, and we should not have any need for the
160+
# outputs of merge scripts for Dawn.
161+
'script': '//testing/merge_scripts/noop_merge.py',
162+
},
149163
'test': 'fuzzer_corpus_tests',
150164
},
151165
},
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/usr/bin/env python3
2+
# Copyright 2025 The Dawn & Tint Authors
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions are met:
6+
#
7+
# 1. Redistributions of source code must retain the above copyright notice, this
8+
# list of conditions and the following disclaimer.
9+
#
10+
# 2. Redistributions in binary form must reproduce the above copyright notice,
11+
# this list of conditions and the following disclaimer in the documentation
12+
# and/or other materials provided with the distribution.
13+
#
14+
# 3. Neither the name of the copyright holder nor the names of its
15+
# contributors may be used to endorse or promote products derived from
16+
# this software without specific prior written permission.
17+
#
18+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
"""Runs the Tint fuzzer corpus tests.
29+
30+
This script is necessary in order to support running tests on Swarming, but it
31+
is effectively a thin wrapper around the underlying tool in //tools/.
32+
"""
33+
34+
import argparse
35+
import json
36+
import os
37+
import subprocess
38+
import sys
39+
40+
THIS_DIR = os.path.realpath(os.path.dirname(__file__))
41+
DAWN_ROOT = os.path.realpath(os.path.join(THIS_DIR, '..'))
42+
TOOLS_DIR = os.path.join(DAWN_ROOT, 'tools')
43+
44+
45+
def run_fuzzer_corpus_tests(
46+
args_to_forward: list[str],
47+
append_cwd_as_build: bool) -> subprocess.CompletedProcess:
48+
cmd = [
49+
sys.executable,
50+
os.path.join(TOOLS_DIR, 'run.py'),
51+
'fuzz',
52+
]
53+
cmd.extend(args_to_forward)
54+
if append_cwd_as_build:
55+
cmd.extend([
56+
'-build',
57+
os.getcwd(),
58+
])
59+
60+
return subprocess.run(cmd, check=False)
61+
62+
63+
def generate_results_for_resultdb_ingestion(success: bool,
64+
output_file: str) -> None:
65+
# This is a very crude pass/fail result since the fuzz command does not
66+
# have an option to output more complete information in a machine-readable
67+
# format. If the information is ever provided, this should be changed to
68+
# convert the information instead of generating it from scratch. If more
69+
# than a pass/fail for a single test is needed, this should be replaced with
70+
# native ResultDB integration instead of relying on result_adapter.
71+
generated_test_results = {
72+
'failures': [],
73+
'valid': True,
74+
}
75+
if not success:
76+
generated_test_results['failures'].append('tint_fuzzer_corpus_tests')
77+
78+
with open(output_file, 'w', encoding='utf-8') as outfile:
79+
json.dump(generated_test_results, outfile)
80+
81+
82+
def main() -> None:
83+
parser = argparse.ArgumentParser(
84+
description='Runs the Tint fuzzer corpus tests')
85+
# Doing the opposite (passing in . for build and making other paths relative
86+
# to it) doesn't work properly for the "fuzz" command. When checking IR,
87+
# the .tirb files are not correctly generated due to the -input value not
88+
# matching the default WGSL corpus directory.
89+
parser.add_argument(
90+
'--append-cwd-as-build',
91+
action='store_true',
92+
help=('Automatically appends the current directory as a -build '
93+
'argument. Meant for use on bots.'))
94+
parser.add_argument('--isolated-script-test-output',
95+
help='Path to the location to output JSON results.')
96+
parser.add_argument('--isolated-script-test-perf-output',
97+
help='Currently unused, needed for bot support.')
98+
args, unknown_args = parser.parse_known_args()
99+
100+
proc = run_fuzzer_corpus_tests(unknown_args, args.append_cwd_as_build)
101+
if args.isolated_script_test_output:
102+
generate_results_for_resultdb_ingestion(
103+
not proc.returncode, args.isolated_script_test_output)
104+
proc.check_returncode()
105+
106+
107+
if __name__ == '__main__':
108+
main()

src/tint/BUILD.gn

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,10 @@ group("fuzzer_corpus_tests") {
356356
":fuzzer_corpus_tools",
357357
"${dawn_root}/tools:go_tools",
358358
]
359-
data = [ "${dawn_root}/test/tint/" ]
359+
data = [
360+
"${dawn_root}/scripts/run_tint_fuzzer_corpus_tests.py",
361+
"${dawn_root}/test/tint/",
362+
]
360363
}
361364

362365
group("tests") {

0 commit comments

Comments
 (0)