Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion scripts/pylib/twister/twisterlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,15 @@ def __init__(self, instance, type_str):
self.ignore_qemu_crash = False
self.ignore_unexpected_eof = False

@staticmethod
def _is_qemu_executable(qemu_binary):
cmd = [qemu_binary, "-h"]
try:
_ = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as _:
return False
return True

@staticmethod
def _get_cpu_time(pid):
"""get process CPU time.
Expand Down Expand Up @@ -1075,6 +1084,12 @@ def _thread(handler, timeout, outdir, logfile, fifo_fn, pid_fn, results, harness

def handle(self):
self.results = {}
qemu_executable = self.instance.platform.filter_data.get("QEMU")
Copy link
Contributor

@hakehuang hakehuang May 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in what situation qemu binary is not exist or not executable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, to get the SDK, I copied it directly from another machine. In which case twister would hang forever without any error message, I spent a lot of time to find out the root cause ( I didn't try to run case with west), finanlly I found qemu binary didn't work. So I think it's necessay to verify the qemu binary in twister

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case, it is a false operation, it is better to return error, not skip

if not (qemu_executable and QEMUHandler._is_qemu_executable(qemu_executable)):
logger.debug(f"Test failed, QEMU binary {qemu_executable} is unexecutable")
self.set_state("failed", 0)
self.instance.reason = f"QEMU is unexecutable"
return
self.run = True

# We pass this to QEMU which looks for fifos with .in and .out
Expand Down Expand Up @@ -2160,6 +2175,8 @@ def parse_generated(self):
filter_data.update(self.defconfig)
filter_data.update(self.cmake_cache)

self.platform.filter_data = filter_data

edt_pickle = os.path.join(self.build_dir, "zephyr", "edt.pickle")
if self.testcase and self.testcase.tc_filter:
try:
Expand All @@ -2180,7 +2197,6 @@ def parse_generated(self):
else:
return {os.path.join(self.platform.name, self.testcase.name): False}
else:
self.platform.filter_data = filter_data
return filter_data


Expand Down