@@ -1814,17 +1814,17 @@ class TestInstance:
18141814 def create_overlay (self , platform ):
18151815 file = os .path .join (self .outdir , "overlay.conf" )
18161816 os .makedirs (self .outdir , exist_ok = True )
1817- f = open (file , "w" )
1818- content = ""
1817+ with open (file , "w" ) as f :
1818+ content = ""
18191819
1820- if len (self .test .extra_configs ) > 0 :
1821- content = "\n " .join (self .test .extra_configs )
1822- if options .enable_coverage :
1823- if platform in options .coverage_platform :
1824- content = content + "\n CONFIG_COVERAGE=y"
1820+ if len (self .test .extra_configs ) > 0 :
1821+ content = "\n " .join (self .test .extra_configs )
18251822
1826- f .write (content )
1827- f .close ()
1823+ if options .enable_coverage :
1824+ if platform in options .coverage_platform :
1825+ content = content + "\n CONFIG_COVERAGE=y"
1826+
1827+ f .write (content )
18281828
18291829 def calculate_sizes (self ):
18301830 """Get the RAM/ROM sizes of a test case.
@@ -1942,8 +1942,15 @@ class TestSuite:
19421942
19431943 self .instances = {}
19441944
1945- def get_last_failed (self ):
1945+ def get_platform (self , name ):
1946+ selected_platform = None
1947+ for platform in self .platforms :
1948+ if platform .name == name :
1949+ selected_platform = platform
1950+ break
1951+ return selected_platform
19461952
1953+ def get_last_failed (self ):
19471954 try :
19481955 if not os .path .exists (LAST_SANITY ):
19491956 raise SanityRuntimeError ("Couldn't find last sanity run." )
@@ -1954,13 +1961,16 @@ class TestSuite:
19541961 result = []
19551962 with open (LAST_SANITY , "r" ) as fp :
19561963 cr = csv .DictReader (fp )
1964+ instance_list = []
19571965 for row in cr :
19581966 if row ["passed" ] == "True" :
19591967 continue
19601968 test = row ["test" ]
1961- platform = row ["platform" ]
1962- result .append ((test , platform ))
1963- return result
1969+ platform = self .get_platform (row ["platform" ])
1970+ instance = TestInstance (self .testcases [test ], platform , self .outdir )
1971+ instance .create_overlay (platform .name )
1972+ instance_list .append (instance )
1973+ self .add_instances (instance_list )
19641974
19651975 def load_from_file (self , file ):
19661976 try :
@@ -1976,14 +1986,9 @@ class TestSuite:
19761986 instance_list = []
19771987 for row in cr :
19781988 name = os .path .join (row [0 ], row [1 ])
1979- platforms = self .arches [row [3 ]].platforms
1980- myp = None
1981- for platform in platforms :
1982- if platform .name == row [2 ]:
1983- selected_platform = platform
1984- break
1985- instance = TestInstance (self .testcases [name ], selected_platform , self .outdir )
1986- instance .create_overlay (selected_platform .name )
1989+ platform = self .get_platform (row [2 ])
1990+ instance = TestInstance (self .testcases [name ], platform , self .outdir )
1991+ instance .create_overlay (platform .name )
19871992 instance_list .append (instance )
19881993 self .add_instances (instance_list )
19891994
@@ -2007,7 +2012,6 @@ class TestSuite:
20072012 instances = []
20082013 discards = {}
20092014 platform_filter = options .platform
2010- last_failed = options .only_failed
20112015 testcase_filter = run_individual_tests
20122016 arch_filter = options .arch
20132017 tag_filter = options .tag
@@ -2022,9 +2026,6 @@ class TestSuite:
20222026 verbose (" exclude_tag: " + str (exclude_tag ))
20232027 verbose (" config_filter: " + str (config_filter ))
20242028
2025- if last_failed :
2026- failed_tests = self .get_last_failed ()
2027-
20282029 default_platforms = False
20292030
20302031 if all_plats :
@@ -2062,10 +2063,6 @@ class TestSuite:
20622063 if testcase_filter and tc_name not in testcase_filter :
20632064 continue
20642065
2065- if last_failed and (
2066- tc .name , plat .name ) not in failed_tests :
2067- continue
2068-
20692066 if arch_filter and arch_name not in arch_filter :
20702067 continue
20712068
@@ -2214,11 +2211,6 @@ class TestSuite:
22142211 discards [instance ] = "Testcase name filter"
22152212 continue
22162213
2217- if last_failed and (
2218- tc .name , plat .name ) not in failed_tests :
2219- discards [instance ] = "Passed or skipped during last run"
2220- continue
2221-
22222214 if arch_filter and arch_name not in arch_filter :
22232215 discards [instance ] = "Command line testcase arch filter"
22242216 continue
@@ -3240,6 +3232,8 @@ def main():
32403232 discards = []
32413233 if options .load_tests :
32423234 ts .load_from_file (options .load_tests )
3235+ elif options .only_failed :
3236+ ts .get_last_failed ()
32433237 else :
32443238 discards = ts .apply_filters ()
32453239
0 commit comments