Commit 12eca9fd authored by Ovidio Henriquez's avatar Ovidio Henriquez Committed by Commit Bot

bluetooth: clusterfuzz: Fix PRESUBMIT script

This change fixes an error when running the PRESUBMIT script in
//third_party/blink/renderer/modules/bluetooth/testing/clusterfuzz. This
error was caused by attempting to replace a substring in a UTF-8 encoded
string with an ASCII encoded string. The fix converts the ASCII string
to UTF-8 prior to this replacement operation.

Bug: 1064538
Change-Id: I2c69ed4dc7bb9e47a2b0ed3150c90c6357df626d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2149891Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Ovidio de Jesús Ruiz-Henríquez <odejesush@chromium.org>
Cr-Commit-Position: refs/heads/master@{#761057}
parent 4133081a
......@@ -20,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 = ((u'testharness.js', u'INCLUDE_TESTHARNESS'),
(u'testharnessreport.js',
u'INCLUDE_REPORT'), (u'bluetooth-helpers.js',
u'INCLUDE_BLUETOOTH_HELPERS'))
SCRIPT_PREFIX = '<script type="text/javascript">\n'
SCRIPT_SUFFIX = '\n</script>\n'
......@@ -97,7 +97,7 @@ def FuzzTemplate(template_path, resources_path):
for (js_file_name, include_parameter) in JS_FILES_AND_PARAMETERS:
# Read js file.
js_file_handle = open(os.path.join(resources_path, js_file_name))
js_file_data = js_file_handle.read()
js_file_data = js_file_handle.read().decode('utf-8')
js_file_handle.close()
js_file_data = (SCRIPT_PREFIX + js_file_data + SCRIPT_SUFFIX)
......
......@@ -47,17 +47,17 @@ def RetrieveResources():
current_path = _GetCurrentPath()
resources_path = os.path.join(current_path, 'resources')
if not os.path.exists(resources_path):
print '\'resources\' folder doesn\'t exist. Creating one...'
print('\'resources\' folder doesn\'t exist. Creating one...')
os.makedirs(resources_path)
else:
print '\'resources\' folder already exists. Clearing it...'
print('\'resources\' folder already exists. Clearing it...')
filelist = glob.glob(os.path.join(resources_path, '*'))
for f in filelist:
os.remove(f)
# Copy necessary files.
for r in RESOURCES:
print 'Copying: ' + os.path.abspath(os.path.join(current_path, r))
print('Copying: ' + os.path.abspath(os.path.join(current_path, r)))
shutil.copy(os.path.join(current_path, r), resources_path)
return resources_path
......@@ -85,14 +85,14 @@ def main():
args = parser.parse_args()
if not (args.cluster_fuzz or args.local):
print 'No action requested.'
print('No action requested.')
return
RetrieveResources()
# To run locally we only need to copy the files.
if args.local:
print 'Ready to run locally!'
print('Ready to run locally!')
# To run on ClusterFuzz we create a tar.bz2 file.
if args.cluster_fuzz:
......@@ -110,7 +110,7 @@ def main():
format='bztar',
root_dir=os.path.join(current_path, os.pardir),
base_dir='clusterfuzz')
print 'File wrote to: ' + compressed_file_path + '.tar.bz2'
print('File written to: ' + compressed_file_path + '.tar.bz2')
if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment