@@ -559,6 +559,7 @@ def __init__(self, instance, type_str):
559
559
self .asan = False
560
560
self .ubsan = False
561
561
self .coverage = False
562
+ self .seed = None
562
563
563
564
def try_kill_process_by_pid (self ):
564
565
if self .pid_fn :
@@ -637,6 +638,10 @@ def handle(self):
637
638
] + command
638
639
run_valgrind = True
639
640
641
+ # Only valid for native_posix
642
+ if self .seed is not None :
643
+ command = command + ["--seed=" + str (self .seed )]
644
+
640
645
logger .debug ("Spawning process: " +
641
646
" " .join (shlex .quote (word ) for word in command ) + os .linesep +
642
647
"in directory: " + self .build_dir )
@@ -2563,6 +2568,7 @@ def __init__(self, suite, instance, **kwargs):
2563
2568
self .warnings_as_errors = kwargs .get ('warnings_as_errors' , True )
2564
2569
self .overflow_as_errors = kwargs .get ('overflow_as_errors' , False )
2565
2570
self .suite_name_check = kwargs .get ('suite_name_check' , True )
2571
+ self .seed = kwargs .get ('seed' , 0 )
2566
2572
2567
2573
@staticmethod
2568
2574
def log_info (filename , inline_logs ):
@@ -2851,6 +2857,11 @@ def report_out(self, results):
2851
2857
else :
2852
2858
more_info = "build"
2853
2859
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
+
2854
2865
logger .info ("{:>{}}/{} {:<25} {:<50} {} ({})" .format (
2855
2866
results .done + results .skipped_filter , total_tests_width , total_to_do , instance .platform .name ,
2856
2867
instance .testcase .name , status , more_info ))
@@ -2927,6 +2938,12 @@ def run(self):
2927
2938
if instance .handler .type_str == "device" :
2928
2939
instance .handler .suite = self .suite
2929
2940
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
+
2930
2947
instance .handler .handle ()
2931
2948
2932
2949
sys .stdout .flush ()
@@ -2988,7 +3005,8 @@ class TestSuite(DisablePyTestCollectionMixin):
2988
3005
"toolchain_allow" : {"type" : "set" },
2989
3006
"filter" : {"type" : "str" },
2990
3007
"harness" : {"type" : "str" },
2991
- "harness_config" : {"type" : "map" , "default" : {}}
3008
+ "harness_config" : {"type" : "map" , "default" : {}},
3009
+ "seed" : {"type" : "int" , "default" : 0 }
2992
3010
}
2993
3011
2994
3012
RELEASE_DATA = os .path .join (ZEPHYR_BASE , "scripts" , "release" ,
@@ -3030,6 +3048,7 @@ def __init__(self, board_root_list=[], testcase_roots=[], outdir=None):
3030
3048
self .quarantine_verify = False
3031
3049
self .retry_build_errors = False
3032
3050
self .suite_name_check = True
3051
+ self .seed = 0
3033
3052
3034
3053
# Keep track of which test cases we've filtered out and why
3035
3054
self .testcases = {}
@@ -3361,6 +3380,7 @@ def add_testcases(self, testcase_filter=[]):
3361
3380
tc .min_flash = tc_dict ["min_flash" ]
3362
3381
tc .extra_sections = tc_dict ["extra_sections" ]
3363
3382
tc .integration_platforms = tc_dict ["integration_platforms" ]
3383
+ tc .seed = tc_dict ["seed" ]
3364
3384
3365
3385
tc .parse_subcases (tc_path )
3366
3386
@@ -3752,7 +3772,8 @@ def pipeline_mgr(self, pipeline, done_queue, lock, results):
3752
3772
verbose = self .verbose ,
3753
3773
warnings_as_errors = self .warnings_as_errors ,
3754
3774
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
3756
3777
)
3757
3778
pb .process (pipeline , done_queue , task , lock , results )
3758
3779
0 commit comments