Fix perf_test_runner.py to run with python3 perf_test_runner.py doesn't run properly after recent python migration. Fix by decoding output (bytes) to string using utf-8 and then re.serach the string. Bug: None Change-Id: Id988d0f5161d0c9edc827a48a3a30f8e60f8f814 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119080 Reviewed-by: Austin Eng <enga@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Shrek Shao <shrekshao@google.com>
diff --git a/scripts/perf_test_runner.py b/scripts/perf_test_runner.py index 157d449..0bfaec0 100755 --- a/scripts/perf_test_runner.py +++ b/scripts/perf_test_runner.py
@@ -22,8 +22,12 @@ import os import re +# Assume running the dawn_perf_tests build in Chromium checkout +# Dawn locates at /path/to/Chromium/src/third_party/dawn/ +# Chromium build usually locates at /path/to/Chromium/src/out/Release/ +# You might want to change the base_path if you want to run dawn_perf_tests build from a Dawn standalone build. base_path = os.path.abspath( - os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')) + os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../')) # Look for a [Rr]elease build. perftests_paths = glob.glob('out/*elease*') @@ -112,17 +116,19 @@ stderr=subprocess.PIPE) output, err = process.communicate() - m = re.search(r'Running (\d+) tests', output) + output_string = output.decode('utf-8') + + m = re.search(r"Running (\d+) tests", output_string) if m and int(m.group(1)) > 1: print("Found more than one test result in output:") - print(output) + print(output_string) sys.exit(3) pattern = metric + r'.*= ([0-9.]+)' - m = re.findall(pattern, output) + m = re.findall(pattern, output_string) if not m: print("Did not find the metric '%s' in the test output:" % metric) - print(output) + print(output_string) sys.exit(1) return [float(value) for value in m]