summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/bluetooth/testing/clusterfuzz/fuzz_main_run.py
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/modules/bluetooth/testing/clusterfuzz/fuzz_main_run.py')
-rw-r--r--chromium/third_party/blink/renderer/modules/bluetooth/testing/clusterfuzz/fuzz_main_run.py73
1 files changed, 39 insertions, 34 deletions
diff --git a/chromium/third_party/blink/renderer/modules/bluetooth/testing/clusterfuzz/fuzz_main_run.py b/chromium/third_party/blink/renderer/modules/bluetooth/testing/clusterfuzz/fuzz_main_run.py
index d4f2f055f38..1703291f939 100644
--- a/chromium/third_party/blink/renderer/modules/bluetooth/testing/clusterfuzz/fuzz_main_run.py
+++ b/chromium/third_party/blink/renderer/modules/bluetooth/testing/clusterfuzz/fuzz_main_run.py
@@ -1,7 +1,6 @@
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-
"""Script to generate Web Bluetooth web tests that can be run in ClusterFuzz.
This script uses templates in the templates/ directory to generate html files
@@ -21,10 +20,10 @@ from fuzzer_helpers import FillInParameter
import parameter_fuzzer
import test_case_fuzzer
-JS_FILES_AND_PARAMETERS = (
- ('testharness.js', 'INCLUDE_TESTHARNESS'),
- ('testharnessreport.js', 'INCLUDE_REPORT'),
- ('bluetooth-helpers.js', 'INCLUDE_BLUETOOTH_HELPERS'))
+JS_FILES_AND_PARAMETERS = (('testharness.js', 'INCLUDE_TESTHARNESS'),
+ ('testharnessreport.js',
+ 'INCLUDE_REPORT'), ('bluetooth-helpers.js',
+ 'INCLUDE_BLUETOOTH_HELPERS'))
SCRIPT_PREFIX = '<script type="text/javascript">\n'
SCRIPT_SUFFIX = '\n</script>\n'
@@ -39,20 +38,30 @@ def _GetArguments():
parser = argparse.ArgumentParser()
# Arguments used by ClusterFuzz:
- parser.add_argument('-n', '--no_of_files', type=int, required=True,
- help='The number of test cases that the fuzzer is '
- 'expected to generate')
- parser.add_argument('-i', '--input_dir',
- help='The directory containing the fuzzer\'s data '
- 'bundle.')
- parser.add_argument('-o', '--output_dir', required=True,
- help='The directory where test case files should be '
- 'written to.')
-
- parser.add_argument('--content_shell_dir',
- help='The directory of content shell. If present the '
- 'program will print a command to run the '
- 'generated test file.')
+ parser.add_argument(
+ '-n',
+ '--no_of_files',
+ type=int,
+ required=True,
+ help='The number of test cases that the fuzzer is '
+ 'expected to generate')
+ parser.add_argument(
+ '-i',
+ '--input_dir',
+ help='The directory containing the fuzzer\'s data '
+ 'bundle.')
+ parser.add_argument(
+ '-o',
+ '--output_dir',
+ required=True,
+ help='The directory where test case files should be '
+ 'written to.')
+
+ parser.add_argument(
+ '--content_shell_dir',
+ help='The directory of content shell. If present the '
+ 'program will print a command to run the '
+ 'generated test file.')
return parser.parse_args()
@@ -93,9 +102,10 @@ def FuzzTemplate(template_path, resources_path):
js_file_data = (SCRIPT_PREFIX + js_file_data + SCRIPT_SUFFIX)
- fuzzed_file_data = FillInParameter(include_parameter,
- lambda data=js_file_data: data,
- fuzzed_file_data)
+ fuzzed_file_data = FillInParameter(
+ include_parameter,
+ lambda data=js_file_data: data,
+ fuzzed_file_data)
return fuzzed_file_data.encode('utf-8')
@@ -113,13 +123,11 @@ def WriteTestFile(test_file_data, test_file_prefix, output_dir):
"""
file_descriptor, file_path = tempfile.mkstemp(
- prefix=test_file_prefix,
- suffix='.html',
- dir=output_dir)
+ prefix=test_file_prefix, suffix='.html', dir=output_dir)
with os.fdopen(file_descriptor, 'wb') as output:
- print 'Writing {} bytes to \'{}\''.format(len(test_file_data),
- file_path)
+ print 'Writing {} bytes to \'{}\''.format(
+ len(test_file_data), file_path)
output.write(test_file_data)
return file_path
@@ -135,9 +143,8 @@ def main():
# Get Templates
current_path = os.path.dirname(os.path.realpath(__file__))
- available_templates = glob.glob(os.path.join(current_path,
- 'templates',
- '*.html'))
+ available_templates = glob.glob(
+ os.path.join(current_path, 'templates', '*.html'))
# Generate Test Files
resources_path = os.path.join(current_path, 'resources')
@@ -149,12 +156,10 @@ def main():
# Get Test File
template_name = os.path.splitext(os.path.basename(template_path))[0]
- test_file_name = 'fuzz-{}-{}-{}'.format(template_name,
- int(start_time),
+ test_file_name = 'fuzz-{}-{}-{}'.format(template_name, int(start_time),
int(file_no))
- test_file_path = WriteTestFile(test_file_data,
- test_file_name,
+ test_file_path = WriteTestFile(test_file_data, test_file_name,
args.output_dir)
if args.content_shell_dir: