Merge branch 'test/fix_unit_test_job_pass_even_no_test_executed_v3.2' into 'release/v3.2'

test: fix CI UT job pass even ut app bootup fail (backport v3.2)

See merge request idf/esp-idf!4388
This commit is contained in:
Jiang Jiang Jian 2019-04-28 10:25:53 +08:00
commit 0beb60e8fc

View file

@ -276,9 +276,10 @@ def run_unit_test_cases(env, extra_data):
junit_test_case = TinyFW.JunitReport.create_test_case("[{}] {}".format(ut_config, one_case["name"]))
try:
run_one_normal_case(dut, one_case, junit_test_case, failed_cases)
TinyFW.JunitReport.test_case_finish(junit_test_case)
except Exception as e:
junit_test_case.add_error_info("Unexpected exception: " + str(e))
junit_test_case.add_failure_info("Unexpected exception: " + str(e))
failed_cases.append(one_case["name"])
finally:
TinyFW.JunitReport.test_case_finish(junit_test_case)
# raise exception if any case fails
@ -397,7 +398,7 @@ def get_dut(duts, env, name, ut_config, app_bin=None):
return dut
def run_one_multiple_devices_case(duts, ut_config, env, one_case, failed_cases, app_bin, junit_test_case):
def run_one_multiple_devices_case(duts, ut_config, env, one_case, app_bin, junit_test_case):
lock = threading.RLock()
threads = []
send_signal_list = []
@ -419,12 +420,9 @@ def run_one_multiple_devices_case(duts, ut_config, env, one_case, failed_cases,
if not thread.result:
[thd.stop() for thd in threads]
if result:
Utility.console_log("Success: " + one_case["name"], color="green")
else:
failed_cases.append(one_case["name"])
if not result:
junit_test_case.add_failure_info(output)
Utility.console_log("Failed: " + one_case["name"], color="red")
return result
@IDF.idf_unit_test(env_tag="UT_T2_1", junit_report_by_case=True)
@ -455,13 +453,19 @@ def run_multiple_devices_cases(env, extra_data):
for ut_config in case_config:
Utility.console_log("Running unit test for config: " + ut_config, "O")
for one_case in case_config[ut_config]:
result = False
junit_test_case = TinyFW.JunitReport.create_test_case("[{}] {}".format(ut_config, one_case["name"]))
try:
run_one_multiple_devices_case(duts, ut_config, env, one_case, failed_cases,
one_case.get('app_bin'), junit_test_case)
TinyFW.JunitReport.test_case_finish(junit_test_case)
result = run_one_multiple_devices_case(duts, ut_config, env, one_case,
one_case.get('app_bin'), junit_test_case)
except Exception as e:
junit_test_case.add_error_info("Unexpected exception: " + str(e))
junit_test_case.add_failure_info("Unexpected exception: " + str(e))
finally:
if result:
Utility.console_log("Success: " + one_case["name"], color="green")
else:
failed_cases.append(one_case["name"])
Utility.console_log("Failed: " + one_case["name"], color="red")
TinyFW.JunitReport.test_case_finish(junit_test_case)
if failed_cases:
@ -604,9 +608,10 @@ def run_multiple_stage_cases(env, extra_data):
junit_test_case = TinyFW.JunitReport.create_test_case("[{}] {}".format(ut_config, one_case["name"]))
try:
run_one_multiple_stage_case(dut, one_case, failed_cases, junit_test_case)
TinyFW.JunitReport.test_case_finish(junit_test_case)
except Exception as e:
junit_test_case.add_error_info("Unexpected exception: " + str(e))
junit_test_case.add_failure_info("Unexpected exception: " + str(e))
failed_cases.append(one_case["name"])
finally:
TinyFW.JunitReport.test_case_finish(junit_test_case)
# raise exception if any case fails