sanitycheck: make artifact cleanup for device-testing usable
If we specify --device-testing and -M make it so that the resulting
artifacts are usable to run with device-testing again. This means
keeping around the zephyr binary images (zephyr.{bin, hex, elf}) and
a few files so 'west' can function for flashing (CMakeCache.txt and
zephyr/runners.yaml).
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
diff --git a/scripts/sanity_chk/sanitylib.py b/scripts/sanity_chk/sanitylib.py
index ddbccf9..d372d25 100644
--- a/scripts/sanity_chk/sanitylib.py
+++ b/scripts/sanity_chk/sanitylib.py
@@ -2139,9 +2139,12 @@
})
elif op == "cleanup":
- self.cleanup_artifacts()
+ if self.device_testing:
+ self.cleanup_device_testing_artifacts()
+ else:
+ self.cleanup_artifacts()
- def cleanup_artifacts(self):
+ def cleanup_artifacts(self, additional_keep=None):
logger.debug("Cleaning up {}".format(self.instance.build_dir))
allow = [
'zephyr/.config',
@@ -2150,6 +2153,9 @@
'device.log',
'recording.csv',
]
+
+ allow += additional_keep
+
allow = [os.path.join(self.instance.build_dir, file) for file in allow]
for dirpath, dirnames, filenames in os.walk(self.instance.build_dir, topdown=False):
@@ -2165,6 +2171,19 @@
elif not os.listdir(path):
os.rmdir(path)
+ def cleanup_device_testing_artifacts(self):
+ logger.debug("Cleaning up for Device Testing {}".format(self.instance.build_dir))
+
+ keep = [
+ 'CMakeCache.txt',
+ 'zephyr/runners.yaml',
+ 'zephyr/zephyr.hex',
+ 'zephyr/zephyr.bin',
+ 'zephyr/zephyr.elf',
+ ]
+
+ self.cleanup_artifacts(keep)
+
def report_out(self):
total_tests_width = len(str(self.suite.total_to_do))
self.suite.total_done += 1