diff options
-rw-r--r-- | meta/lib/oeqa/selftest/cases/runqemu.py | 9 | ||||
-rw-r--r-- | meta/lib/oeqa/utils/qemurunner.py | 12 |
2 files changed, 15 insertions, 6 deletions
diff --git a/meta/lib/oeqa/selftest/cases/runqemu.py b/meta/lib/oeqa/selftest/cases/runqemu.py index 7e676bcb41..da22f77b27 100644 --- a/meta/lib/oeqa/selftest/cases/runqemu.py +++ b/meta/lib/oeqa/selftest/cases/runqemu.py | |||
@@ -163,12 +163,11 @@ class QemuTest(OESelftestTestCase): | |||
163 | bitbake(cls.recipe) | 163 | bitbake(cls.recipe) |
164 | 164 | ||
165 | def _start_qemu_shutdown_check_if_shutdown_succeeded(self, qemu, timeout): | 165 | def _start_qemu_shutdown_check_if_shutdown_succeeded(self, qemu, timeout): |
166 | # Allow the runner's LoggingThread instance to exit without errors | ||
167 | # (such as the exception "Console connection closed unexpectedly") | ||
168 | # as qemu will disappear when we shut it down | ||
169 | qemu.runner.allowexit() | ||
166 | qemu.run_serial("shutdown -h now") | 170 | qemu.run_serial("shutdown -h now") |
167 | # Stop thread will stop the LoggingThread instance used for logging | ||
168 | # qemu through serial console, stop thread will prevent this code | ||
169 | # from facing exception (Console connection closed unexpectedly) | ||
170 | # when qemu was shutdown by the above shutdown command | ||
171 | qemu.runner.stop_thread() | ||
172 | time_track = 0 | 171 | time_track = 0 |
173 | try: | 172 | try: |
174 | while True: | 173 | while True: |
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py index 278904ba0b..84f7c5e76d 100644 --- a/meta/lib/oeqa/utils/qemurunner.py +++ b/meta/lib/oeqa/utils/qemurunner.py | |||
@@ -471,6 +471,10 @@ class QemuRunner: | |||
471 | self.thread.stop() | 471 | self.thread.stop() |
472 | self.thread.join() | 472 | self.thread.join() |
473 | 473 | ||
474 | def allowexit(self): | ||
475 | if self.thread: | ||
476 | self.thread.allowexit() | ||
477 | |||
474 | def restart(self, qemuparams = None): | 478 | def restart(self, qemuparams = None): |
475 | self.logger.warning("Restarting qemu process") | 479 | self.logger.warning("Restarting qemu process") |
476 | if self.runqemu.poll() is None: | 480 | if self.runqemu.poll() is None: |
@@ -564,6 +568,7 @@ class LoggingThread(threading.Thread): | |||
564 | self.logger = logger | 568 | self.logger = logger |
565 | self.readsock = None | 569 | self.readsock = None |
566 | self.running = False | 570 | self.running = False |
571 | self.canexit = False | ||
567 | 572 | ||
568 | self.errorevents = select.POLLERR | select.POLLHUP | select.POLLNVAL | 573 | self.errorevents = select.POLLERR | select.POLLHUP | select.POLLNVAL |
569 | self.readevents = select.POLLIN | select.POLLPRI | 574 | self.readevents = select.POLLIN | select.POLLPRI |
@@ -597,6 +602,9 @@ class LoggingThread(threading.Thread): | |||
597 | self.close_ignore_error(self.writepipe) | 602 | self.close_ignore_error(self.writepipe) |
598 | self.running = False | 603 | self.running = False |
599 | 604 | ||
605 | def allowexit(self): | ||
606 | self.canexit = True | ||
607 | |||
600 | def eventloop(self): | 608 | def eventloop(self): |
601 | poll = select.poll() | 609 | poll = select.poll() |
602 | event_read_mask = self.errorevents | self.readevents | 610 | event_read_mask = self.errorevents | self.readevents |
@@ -653,7 +661,9 @@ class LoggingThread(threading.Thread): | |||
653 | # happened. But for this code it counts as an | 661 | # happened. But for this code it counts as an |
654 | # error since the connection shouldn't go away | 662 | # error since the connection shouldn't go away |
655 | # until qemu exits. | 663 | # until qemu exits. |
656 | raise Exception("Console connection closed unexpectedly") | 664 | if not self.canexit: |
665 | raise Exception("Console connection closed unexpectedly") | ||
666 | return '' | ||
657 | 667 | ||
658 | return data | 668 | return data |
659 | 669 | ||