def parse_unity_result(self, dut): """ Parses given DUTs stdout for Unity test results. :param dut: icetea DUT to inspect the results from """ re_unity_test = re.compile( r".*\<\*\*\*UnityTest\*\*\*\>TEST\((?P<suite>.*?), (?P<test>.*?)\)\<\/\*\*\*UnityTest\*\*\*\>") # noqa: E501 # pylint: disable=line-too-long re_unity_result = re.compile( r".*\<\*\*\*UnityResult\*\*\*\>(?P<result>.*?)\<\/\*\*\*UnityResult\*\*\*\>") # noqa: E501 # pylint: disable=line-too-long test_output = "" test_active = False test_results = ResultList() for line in dut.traces: line = line.strip() # Activate test output logging match = re_unity_test.match(line) if match: test_active = True test_output = "" unity_name = match.group("test") unity_suite = match.group("suite") self.logger.info("parsing %s.%s", unity_suite, unity_name) # Log test output if test_active: test_output += line + "\n" # Check if test is over match = re_unity_result.match(line) if match and test_active: unity_result = match.group("result") # Create icetea Result() test_result = Result( { "testcase": unity_suite + "." + unity_name, "stdout": test_output, "reason": line if unity_result == "FAIL" else "" }) test_result.build_result_metadata({"toolchain": unity_name}) # Would need to do runtime analysis to get duration test_result.set_verdict(unity_result, 0, 0.0) test_results.append(test_result) test_active = False self.logger.info("finished %s", unity_name) return test_results
def test_result_metainfo_generation(self): pass_result = Result() pass_result.set_verdict('pass', 0, 10) dinfo = DutInformation("Test_platform", "123456", "1") dinfo.build = Build(ref="test_file", type="file") pass_result.add_dutinformation(dinfo) self.args_tc.branch = "test_branch" self.args_tc.commitId = "123456" self.args_tc.gitUrl = "url" self.args_tc.buildUrl = "url2" self.args_tc.campaign = "campaign" self.args_tc.jobId = "test_job" self.args_tc.toolchain = "toolchain" self.args_tc.buildDate = "today" pass_result.build_result_metadata(args=self.args_tc) self.assertEqual(pass_result.build_branch, "test_branch") self.assertEqual(pass_result.buildcommit, "123456") self.assertEqual(pass_result.build_git_url, "url") self.assertEqual(pass_result.build_url, "url2") self.assertEqual(pass_result.campaign, "campaign") self.assertEqual(pass_result.job_id, "test_job") self.assertEqual(pass_result.toolchain, "toolchain") self.assertEqual(pass_result.build_date, "today")