From b28b6a06870f0fc43bb22d7ce2e601ddd69e2b98 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Thu, 17 Aug 2023 16:42:42 -0400 Subject: [PATCH] twister: print dut name when testing on hardware When using the hardware map and testing on device, print out the name of the dut (from the hardware map) on the script and report it in the json output as well. Signed-off-by: Anas Nashif --- scripts/pylib/twister/twisterlib/handlers.py | 2 ++ scripts/pylib/twister/twisterlib/reports.py | 2 ++ scripts/pylib/twister/twisterlib/runner.py | 2 ++ scripts/pylib/twister/twisterlib/testinstance.py | 1 + 4 files changed, 7 insertions(+) diff --git a/scripts/pylib/twister/twisterlib/handlers.py b/scripts/pylib/twister/twisterlib/handlers.py index a89e82b1bb1..d9f1943e1c3 100755 --- a/scripts/pylib/twister/twisterlib/handlers.py +++ b/scripts/pylib/twister/twisterlib/handlers.py @@ -467,6 +467,8 @@ class DeviceHandler(Handler): def handle(self, harness): runner = None hardware = self.get_hardware() + if hardware: + self.instance.dut = hardware.id if not hardware: return diff --git a/scripts/pylib/twister/twisterlib/reports.py b/scripts/pylib/twister/twisterlib/reports.py index 0d93eaf6227..bd005d4319a 100644 --- a/scripts/pylib/twister/twisterlib/reports.py +++ b/scripts/pylib/twister/twisterlib/reports.py @@ -273,6 +273,8 @@ class Reporting: suite['retries'] = instance.retries + if instance.dut: + suite["dut"] = instance.dut if available_ram: suite["available_ram"] = available_ram if available_rom: diff --git a/scripts/pylib/twister/twisterlib/runner.py b/scripts/pylib/twister/twisterlib/runner.py index 2d880590334..28b920e077c 100644 --- a/scripts/pylib/twister/twisterlib/runner.py +++ b/scripts/pylib/twister/twisterlib/runner.py @@ -932,6 +932,8 @@ class ProjectBuilder(FilterBuilder): if instance.handler.ready and instance.run: more_info = instance.handler.type_str htime = instance.execution_time + if instance.dut: + more_info += f": {instance.dut}," if htime: more_info += " {:.3f}s".format(htime) else: diff --git a/scripts/pylib/twister/twisterlib/testinstance.py b/scripts/pylib/twister/twisterlib/testinstance.py index 4632de8c2b6..ccfc3cd06d4 100644 --- a/scripts/pylib/twister/twisterlib/testinstance.py +++ b/scripts/pylib/twister/twisterlib/testinstance.py @@ -54,6 +54,7 @@ class TestInstance: self.name = os.path.join(platform.name, testsuite.name) self.run_id = self._get_run_id() + self.dut = None self.build_dir = os.path.join(outdir, platform.name, testsuite.name) self.domains = None