From faae15d83860045e0fce8e801a985aa777bd8607 Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Tue, 18 Aug 2020 10:13:35 -0700 Subject: [PATCH] sanitycheck: allow QEMU to crash without failing Adds some code to allow QEMU to crash without failing the test. This is required for testing coredump code as it will certainly cause QEMU to crash. Signed-off-by: Daniel Leung --- scripts/sanity_chk/sanitylib.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/sanity_chk/sanitylib.py b/scripts/sanity_chk/sanitylib.py index 06cbd5cfd9..b767af935a 100644 --- a/scripts/sanity_chk/sanitylib.py +++ b/scripts/sanity_chk/sanitylib.py @@ -762,6 +762,13 @@ class QEMUHandler(Handler): self.pid_fn = os.path.join(instance.build_dir, "qemu.pid") + if "ignore_qemu_crash" in instance.testcase.tags: + self.ignore_qemu_crash = True + self.ignore_unexpected_eof = True + else: + self.ignore_qemu_crash = False + self.ignore_unexpected_eof = False + @staticmethod def _get_cpu_time(pid): """get process CPU time. @@ -775,7 +782,8 @@ class QEMUHandler(Handler): return cpu_time.user + cpu_time.system @staticmethod - def _thread(handler, timeout, outdir, logfile, fifo_fn, pid_fn, results, harness): + def _thread(handler, timeout, outdir, logfile, fifo_fn, pid_fn, results, harness, + ignore_unexpected_eof=False): fifo_in = fifo_fn + ".in" fifo_out = fifo_fn + ".out" @@ -840,7 +848,8 @@ class QEMUHandler(Handler): if c == "": # EOF, this shouldn't happen unless QEMU crashes - out_state = "unexpected eof" + if not ignore_unexpected_eof: + out_state = "unexpected eof" break line = line + c if c != "\n": @@ -925,7 +934,8 @@ class QEMUHandler(Handler): self.thread = threading.Thread(name=self.name, target=QEMUHandler._thread, args=(self, self.timeout, self.build_dir, self.log_fn, self.fifo_fn, - self.pid_fn, self.results, harness)) + self.pid_fn, self.results, harness, + self.ignore_unexpected_eof)) self.instance.results = harness.tests self.thread.daemon = True @@ -974,7 +984,7 @@ class QEMUHandler(Handler): logger.debug(f"return code from qemu: {self.returncode}") - if self.returncode != 0 or not harness.state: + if (self.returncode != 0 and not self.ignore_qemu_crash) or not harness.state: self.set_state("failed", 0) self.instance.reason = "Exited with {}".format(self.returncode)