aboutsummaryrefslogtreecommitdiff
path: root/afdo_tools/bisection/afdo_prof_analysis_e2e_test.py
diff options
context:
space:
mode:
authorEmma Vukelj <emmavukelj@google.com>2019-07-19 13:50:41 -0700
committerEmma Vukelj <emmavukelj@google.com>2019-07-22 17:42:31 +0000
commitd8ce1d6da9f3646c0a04c7b870d31c40bfb643e5 (patch)
tree27c3080f554683929cc5cafac96f36955f433847 /afdo_tools/bisection/afdo_prof_analysis_e2e_test.py
parent0e39ab73c1b0a944f08313c2c0667419843d5b7b (diff)
downloadtoolchain-utils-d8ce1d6da9f3646c0a04c7b870d31c40bfb643e5.tar.gz
AFDO-Bisect: Exit analysis on problem_status exit code
This CL makes it such that if the user-provided external script returns PROBLEM_STATUS indicating that something went wrong (e.g. user sent SIGINT, or some part of script crashed), then the analysis raises an error stating so and terminates analysis. Receipt of the problem status code is not persisted in the state file. BUG=None TEST=Existing tests and added test confirming error raising all pass. Change-Id: Ie2ca6c608ed01b3717d5f09495660f99c3a5e05a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1710021 Reviewed-by: Caroline Tice <cmtice@chromium.org> Reviewed-by: George Burgess <gbiv@chromium.org> Tested-by: Emma Vukelj <emmavukelj@google.com>
Diffstat (limited to 'afdo_tools/bisection/afdo_prof_analysis_e2e_test.py')
-rwxr-xr-xafdo_tools/bisection/afdo_prof_analysis_e2e_test.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/afdo_tools/bisection/afdo_prof_analysis_e2e_test.py b/afdo_tools/bisection/afdo_prof_analysis_e2e_test.py
index 3f7c844a..f95d46e7 100755
--- a/afdo_tools/bisection/afdo_prof_analysis_e2e_test.py
+++ b/afdo_tools/bisection/afdo_prof_analysis_e2e_test.py
@@ -112,13 +112,28 @@ class AfdoProfAnalysisE2ETest(unittest.TestCase):
loaded_run = json.load(f)
self.assertEqual(initial_run, loaded_run)
+ def test_exit_on_problem_status(self):
+ temp_dir = tempfile.mkdtemp()
+ self.addCleanup(shutil.rmtree, temp_dir, ignore_errors=True)
+
+ fd_state, state_file = tempfile.mkstemp(dir=temp_dir)
+ os.close(fd_state)
+ with self.assertRaises(RuntimeError):
+ self.run_check(
+ self.good_prof,
+ self.bad_prof,
+ self.expected,
+ state_file=state_file,
+ extern_decider='problemstatus_external.sh')
+
def run_check(self,
good_prof,
bad_prof,
expected,
state_file=None,
no_resume=True,
- out_file=None):
+ out_file=None,
+ extern_decider=None):
temp_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, temp_dir, ignore_errors=True)
@@ -139,7 +154,7 @@ class AfdoProfAnalysisE2ETest(unittest.TestCase):
analysis.FLAGS.analysis_output_file = out_file or '/dev/null'
dir_path = os.path.dirname(os.path.realpath(__file__)) # dir of this file
- external_script = '%s/e2e_external.sh' % (dir_path)
+ external_script = '%s/%s' % (dir_path, extern_decider or 'e2e_external.sh')
analysis.FLAGS.external_decider = external_script
actual = analysis.main(None)