@@ -785,6 +785,9 @@ def _check_result(self, line):
785
785
class Test (Harness ):
786
786
__test__ = False # for pytest to skip this class when collects tests
787
787
788
+ # Ztest log patterns don't require to match the line start exactly: there are platforms
789
+ # where there is some logging prefix at each console line whereas on other platforms
790
+ # without prefixes the leading space is stripped.
788
791
test_suite_start_pattern = re .compile (r"Running TESTSUITE (?P<suite_name>\S*)" )
789
792
test_suite_end_pattern = re .compile (
790
793
r"TESTSUITE (?P<suite_name>\S*)\s+(?P<suite_status>succeeded|failed)"
@@ -798,7 +801,7 @@ class Test(Harness):
798
801
r" .* duration = (\d*[.,]?\d*) seconds"
799
802
)
800
803
test_case_summary_pattern = re .compile (
801
- r" - (PASS|FAIL|SKIP) - \[([^\.]*).(test_)?(\S*)\] duration = (\d*[.,]?\d*) seconds"
804
+ r".* - (PASS|FAIL|SKIP) - \[([^\.]*).(test_)?(\S*)\] duration = (\d*[.,]?\d*) seconds"
802
805
)
803
806
804
807
@@ -896,17 +899,16 @@ def end_case(self, tc_name, phase='TC_END'):
896
899
elif phase != 'TS_SUM' :
897
900
logger .warning (f"{ phase } : END case '{ tc_name } ' without START detected" )
898
901
899
-
900
902
def handle (self , line ):
901
903
testcase_match = None
902
904
if self ._match :
903
905
self .testcase_output += line + "\n "
904
-
905
906
if test_suite_start_match := re .search (self .test_suite_start_pattern , line ):
906
907
self .start_suite (test_suite_start_match .group ("suite_name" ))
907
908
elif test_suite_end_match := re .search (self .test_suite_end_pattern , line ):
908
909
suite_name = test_suite_end_match .group ("suite_name" )
909
910
self .end_suite (suite_name )
911
+ self .ztest = True
910
912
elif testcase_match := re .search (self .test_case_start_pattern , line ):
911
913
tc_name = testcase_match .group (2 )
912
914
tc = self .get_testcase (tc_name , 'TC_START' )
@@ -947,6 +949,11 @@ def handle(self, line):
947
949
tc_name = test_case_summary_match .group (4 )
948
950
tc = self .get_testcase (tc_name , 'TS_SUM' , suite_name )
949
951
self .end_case (tc .name , 'TS_SUM' )
952
+ if tc .status not in [TwisterStatus .NONE , TwisterStatus [matched_status ]]:
953
+ # TestCase miss its END log entry, so its status is from the Suite summary.
954
+ logger .warning (
955
+ f"TS_SUM: { tc .name } force status: { tc .status } ->{ TwisterStatus [matched_status ]} "
956
+ )
950
957
tc .status = TwisterStatus [matched_status ]
951
958
if tc .status == TwisterStatus .SKIP :
952
959
tc .reason = "ztest skip"
@@ -960,7 +967,7 @@ def handle(self, line):
960
967
self .process_test (line )
961
968
962
969
if not self .ztest and self .status != TwisterStatus .NONE :
963
- logger .debug (f"not a ztest and no state for { self .id } " )
970
+ logger .debug (f"{ self . id } is not a Ztest, status: { self .status } " )
964
971
tc = self .instance .get_case_or_create (self .id )
965
972
if self .status == TwisterStatus .PASS :
966
973
tc .status = TwisterStatus .PASS
0 commit comments