osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40039?usp=email )
Change subject: testenv: refactor run --until-nok code ......................................................................
testenv: refactor run --until-nok code
Refactor the code in preparation for using the code that checks if the testsuite was successful with a new --bisect arg in the next patch.
Change-Id: I3a8fc83c6833f0d2a8be9c0d7ddaea0546859988 --- M _testenv/testenv.py M _testenv/testenv/testsuite.py 2 files changed, 22 insertions(+), 15 deletions(-)
Approvals: laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved Jenkins Builder: Verified
diff --git a/_testenv/testenv.py b/_testenv/testenv.py index b9de4e8..f852c0c 100755 --- a/_testenv/testenv.py +++ b/_testenv/testenv.py @@ -19,17 +19,14 @@ def loop_continue_cond(loop_count): if loop_count == 0: return True - - if testenv.args.until_nok: - logging.info("Checking testsuite logs for failures and errors") - for match_str in ["failures='0'", "errors='0'"]: - if not testenv.testsuite.check_junit_logs_have(loop_count - 1, match_str): - logging.critical("Stopping the loop") - return False - return True - else: + if not testenv.args.until_nok: return False
+ if not testenv.testsuite.check_testsuite_successful(loop_count - 1): + logging.critical("Stopping the loop") + return False + return True +
def run(): testenv.testenv_cfg.init() diff --git a/_testenv/testenv/testsuite.py b/_testenv/testenv/testsuite.py index a42c4e4..1cd077b 100644 --- a/_testenv/testenv/testsuite.py +++ b/_testenv/testenv/testsuite.py @@ -104,13 +104,23 @@ testenv.cmd.run(cmd)
-def check_junit_logs_have(loop_count, match_str): - topdir = os.path.join(testenv.testdir.testdir_topdir, f"loop-{loop_count}") +def check_testsuite_successful(loop_count=None): + topdir = testenv.testdir.testdir_topdir + if loop_count is not None: + topdir = os.path.join(topdir, f"loop-{loop_count}") + + ret = True + for path in get_junit_logs(topdir): - cmd = ["grep", "-q", match_str, path] - if testenv.cmd.run(cmd, check=False).returncode: - return False - return True + for match_str in ["failures='0'", "errors='0'"]: + cmd = ["grep", "-q", match_str, path] + if testenv.cmd.run(cmd, check=False).returncode: + ret = False + break + if not ret: + break + + return ret
def run(cfg):