@@ -559,6 +559,7 @@ def __init__(self, instance, type_str):
559559 self .asan = False
560560 self .ubsan = False
561561 self .coverage = False
562+ self .seed = None
562563
563564 def try_kill_process_by_pid (self ):
564565 if self .pid_fn :
@@ -637,6 +638,10 @@ def handle(self):
637638 ] + command
638639 run_valgrind = True
639640
641+ # Only valid for native_posix
642+ if self .seed is not None :
643+ command = command + ["--seed=" + str (self .seed )]
644+
640645 logger .debug ("Spawning process: " +
641646 " " .join (shlex .quote (word ) for word in command ) + os .linesep +
642647 "in directory: " + self .build_dir )
@@ -2563,6 +2568,7 @@ def __init__(self, suite, instance, **kwargs):
25632568 self .warnings_as_errors = kwargs .get ('warnings_as_errors' , True )
25642569 self .overflow_as_errors = kwargs .get ('overflow_as_errors' , False )
25652570 self .suite_name_check = kwargs .get ('suite_name_check' , True )
2571+ self .seed = kwargs .get ('seed' , 0 )
25662572
25672573 @staticmethod
25682574 def log_info (filename , inline_logs ):
@@ -2851,6 +2857,11 @@ def report_out(self, results):
28512857 else :
28522858 more_info = "build"
28532859
2860+ if ( instance .status in ["error" , "failed" , "timeout" , "flash_error" ]
2861+ and hasattr (self .instance .handler , 'seed' )
2862+ and self .instance .handler .seed is not None ):
2863+ more_info += "/seed: " + str (self .seed )
2864+
28542865 logger .info ("{:>{}}/{} {:<25} {:<50} {} ({})" .format (
28552866 results .done + results .skipped_filter , total_tests_width , total_to_do , instance .platform .name ,
28562867 instance .testcase .name , status , more_info ))
@@ -2927,6 +2938,12 @@ def run(self):
29272938 if instance .handler .type_str == "device" :
29282939 instance .handler .suite = self .suite
29292940
2941+ if (self .seed is not None and instance .platform .name .startswith ("native_posix" )):
2942+ self .parse_generated ()
2943+ if ('CONFIG_FAKE_ENTROPY_NATIVE_POSIX' in self .defconfig and
2944+ self .defconfig ['CONFIG_FAKE_ENTROPY_NATIVE_POSIX' ] == 'y' ):
2945+ instance .handler .seed = self .seed
2946+
29302947 instance .handler .handle ()
29312948
29322949 sys .stdout .flush ()
@@ -2988,7 +3005,8 @@ class TestSuite(DisablePyTestCollectionMixin):
29883005 "toolchain_allow" : {"type" : "set" },
29893006 "filter" : {"type" : "str" },
29903007 "harness" : {"type" : "str" },
2991- "harness_config" : {"type" : "map" , "default" : {}}
3008+ "harness_config" : {"type" : "map" , "default" : {}},
3009+ "seed" : {"type" : "int" , "default" : 0 }
29923010 }
29933011
29943012 RELEASE_DATA = os .path .join (ZEPHYR_BASE , "scripts" , "release" ,
@@ -3030,6 +3048,7 @@ def __init__(self, board_root_list=[], testcase_roots=[], outdir=None):
30303048 self .quarantine_verify = False
30313049 self .retry_build_errors = False
30323050 self .suite_name_check = True
3051+ self .seed = 0
30333052
30343053 # Keep track of which test cases we've filtered out and why
30353054 self .testcases = {}
@@ -3361,6 +3380,7 @@ def add_testcases(self, testcase_filter=[]):
33613380 tc .min_flash = tc_dict ["min_flash" ]
33623381 tc .extra_sections = tc_dict ["extra_sections" ]
33633382 tc .integration_platforms = tc_dict ["integration_platforms" ]
3383+ tc .seed = tc_dict ["seed" ]
33643384
33653385 tc .parse_subcases (tc_path )
33663386
@@ -3752,7 +3772,8 @@ def pipeline_mgr(self, pipeline, done_queue, lock, results):
37523772 verbose = self .verbose ,
37533773 warnings_as_errors = self .warnings_as_errors ,
37543774 overflow_as_errors = self .overflow_as_errors ,
3755- suite_name_check = self .suite_name_check
3775+ suite_name_check = self .suite_name_check ,
3776+ seed = self .seed
37563777 )
37573778 pb .process (pipeline , done_queue , task , lock , results )
37583779
0 commit comments