From 96fba5f37f7c8f8b2a2d35bfe54607ca7cddffc0 Mon Sep 17 00:00:00 2001 From: Sergiy Byelozyorov Date: Tue, 9 Oct 2018 17:45:35 +0200 Subject: [PATCH] Reland "[tools] Report infra failure on incorrect usage or uncaptured exceptions" This is a reland of 2bac24fe2cc7a26d0e754f24001ca2542c9a3b9e Original change's description: > [tools] Report infra failure on incorrect usage or uncaptured exceptions > > TBR=machenbach@chromium.org > > No-Try: true > Bug: chromium:893464 > Change-Id: If7d9f839a715468ded293a488e7fa12fc4ef3347 > Reviewed-on: https://chromium-review.googlesource.com/c/1270995 > Commit-Queue: Sergiy Byelozyorov > Reviewed-by: Sergiy Byelozyorov > Cr-Commit-Position: refs/heads/master@{#56485} TBR=machenbach@google.com Test: ran run_perf_test.py locally (it reports same errors as before this CL) No-Try: true Bug: chromium:893464 Change-Id: I1bb2fae6fe2e2b7350695e491d7c3d52ff06db14 Reviewed-on: https://chromium-review.googlesource.com/c/1270965 Commit-Queue: Sergiy Byelozyorov Reviewed-by: Sergiy Byelozyorov Cr-Commit-Position: refs/heads/master@{#56495} --- tools/run_perf.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/tools/run_perf.py b/tools/run_perf.py index 67861db3ea..2e1aaf0d59 100755 --- a/tools/run_perf.py +++ b/tools/run_perf.py @@ -108,6 +108,7 @@ import os import re import subprocess import sys +import traceback from testrunner.local import android from testrunner.local import command @@ -125,6 +126,7 @@ GENERIC_RESULTS_RE = re.compile(r"^RESULT ([^:]+): ([^=]+)= ([^ ]+) ([^ ]*)$") RESULT_STDDEV_RE = re.compile(r"^\{([^\}]+)\}$") RESULT_LIST_RE = re.compile(r"^\[([^\]]+)\]$") TOOLS_BASE = os.path.abspath(os.path.dirname(__file__)) +INFRA_FAILURE_RETCODE = 87 def GeometricMean(values): @@ -970,20 +972,20 @@ def Main(args): if len(args) == 0: # pragma: no cover parser.print_help() - return 1 + return INFRA_FAILURE_RETCODE if options.arch in ["auto", "native"]: # pragma: no cover options.arch = ARCH_GUESS if not options.arch in SUPPORTED_ARCHS: # pragma: no cover logging.error("Unknown architecture %s", options.arch) - return 1 + return INFRA_FAILURE_RETCODE if (options.json_test_results_secondary and not options.outdir_secondary): # pragma: no cover logging.error("For writing secondary json test results, a secondary outdir " "patch must be specified.") - return 1 + return INFRA_FAILURE_RETCODE workspace = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) @@ -998,10 +1000,10 @@ def Main(args): else: if not os.path.isfile(options.binary_override_path): logging.error("binary-override-path must be a file name") - return 1 + return INFRA_FAILURE_RETCODE if options.outdir_secondary: logging.error("specify either binary-override-path or outdir-secondary") - return 1 + return INFRA_FAILURE_RETCODE options.shell_dir = os.path.abspath( os.path.dirname(options.binary_override_path)) default_binary_name = os.path.basename(options.binary_override_path) @@ -1086,7 +1088,20 @@ def Main(args): else: # pragma: no cover print results_secondary - return min(1, len(results.errors)) + if results.errors: + return 1 + + return 0 + + +def MainWrapper(): + try: + return Main(sys.argv[1:]) + except: + # Log uncaptured exceptions and report infra failure to the caller. + traceback.print_exc() + return INFRA_FAILURE_RETCODE + if __name__ == "__main__": # pragma: no cover - sys.exit(Main(sys.argv[1:])) + sys.exit(MainWrapper())