1414import time
1515import multiprocessing
1616import traceback
17+ import scl
1718from colorama import Fore
1819from multiprocessing import Lock , Process , Value
1920from multiprocessing .managers import BaseManager
@@ -285,7 +286,6 @@ def run_cmake(self, args=""):
285286 logger .debug ("Running cmake on %s for %s" % (self .source_dir , self .platform .name ))
286287 cmake_args = [
287288 f'-B{ self .build_dir } ' ,
288- f'-S{ self .source_dir } ' ,
289289 f'-DTC_RUNID={ self .instance .run_id } ' ,
290290 f'-DEXTRA_CFLAGS={ cflags } ' ,
291291 f'-DEXTRA_AFLAGS={ aflags } ' ,
@@ -294,6 +294,18 @@ def run_cmake(self, args=""):
294294 f'-G{ self .env .generator } '
295295 ]
296296
297+ if self .testsuite .sysbuild :
298+ logger .debug ("Building %s using sysbuild" % (self .source_dir ))
299+ source_args = [
300+ f'-S{ canonical_zephyr_base } /share/sysbuild' ,
301+ f'-DAPP_DIR={ self .source_dir } '
302+ ]
303+ else :
304+ source_args = [
305+ f'-S{ self .source_dir } '
306+ ]
307+ cmake_args .extend (source_args )
308+
297309 cmake_args .extend (args )
298310
299311 cmake_opts = ['-DBOARD={}' .format (self .platform .name )]
@@ -351,8 +363,24 @@ def parse_generated(self):
351363 if self .platform .name == "unit_testing" :
352364 return {}
353365
354- cmake_cache_path = os .path .join (self .build_dir , "CMakeCache.txt" )
355- defconfig_path = os .path .join (self .build_dir , "zephyr" , ".config" )
366+ if self .testsuite .sysbuild :
367+ # We must parse the domains.yaml file to determine the
368+ # default sysbuild application
369+ domain_path = os .path .join (self .build_dir , "domains.yaml" )
370+ domain_yaml = scl .yaml_load (domain_path )
371+ logger .debug ("Loaded sysbuild domain data from %s" % (domain_path ))
372+ default_domain = domain_yaml ['default' ]
373+ for domain in domain_yaml ['domains' ]:
374+ if domain ['name' ] == default_domain :
375+ domain_build = domain ['build_dir' ]
376+ cmake_cache_path = os .path .join (domain_build , "CMakeCache.txt" )
377+ defconfig_path = os .path .join (domain_build , "zephyr" , ".config" )
378+ edt_pickle = os .path .join (domain_build , "zephyr" , "edt.pickle" )
379+ else :
380+ cmake_cache_path = os .path .join (self .build_dir , "CMakeCache.txt" )
381+ defconfig_path = os .path .join (self .build_dir , "zephyr" , ".config" )
382+ edt_pickle = os .path .join (self .build_dir , "zephyr" , "edt.pickle" )
383+
356384
357385 with open (defconfig_path , "r" ) as fp :
358386 defconfig = {}
@@ -385,7 +413,21 @@ def parse_generated(self):
385413 filter_data .update (self .defconfig )
386414 filter_data .update (self .cmake_cache )
387415
388- edt_pickle = os .path .join (self .build_dir , "zephyr" , "edt.pickle" )
416+ if self .testsuite .sysbuild and self .env .options .device_testing :
417+ # Verify that twister's arguments support sysbuild.
418+ # Twister sysbuild flashing currently only works with west, so
419+ # --west-flash must be passed. Additionally, erasing the DUT
420+ # before each test with --west-flash=--erase will inherently not
421+ # work with sysbuild.
422+ if self .env .options .west_flash is None :
423+ logger .warning ("Sysbuild test will be skipped. " +
424+ "West must be used for flashing." )
425+ return {os .path .join (self .platform .name , self .testsuite .name ): True }
426+ elif "--erase" in self .env .options .west_flash :
427+ logger .warning ("Sysbuild test will be skipped, " +
428+ "--erase is not supported with --west-flash" )
429+ return {os .path .join (self .platform .name , self .testsuite .name ): True }
430+
389431 if self .testsuite and self .testsuite .filter :
390432 try :
391433 if os .path .exists (edt_pickle ):
0 commit comments