提交 017dc196 编写于 作者: L Lukáš Doktor 提交者: Lucas Meneghel Rodrigues

virtio_console: FIX the background thread handling

Fail virtio_console subtest when background threads fails.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 ebb2e47c
...@@ -537,7 +537,7 @@ def run_virtio_console(test, params, env): ...@@ -537,7 +537,7 @@ def run_virtio_console(test, params, env):
no_serialports = max(no_serialports, param.count('serialport')) no_serialports = max(no_serialports, param.count('serialport'))
no_consoles = max(no_consoles, param.count('console')) no_consoles = max(no_consoles, param.count('console'))
vm, guest_worker = get_vm_with_worker(no_consoles, no_serialports) vm, guest_worker = get_vm_with_worker(no_consoles, no_serialports)
error_occured = False no_errors = 0
(consoles, serialports) = get_virtio_ports(vm) (consoles, serialports) = get_virtio_ports(vm)
...@@ -630,7 +630,7 @@ def run_virtio_console(test, params, env): ...@@ -630,7 +630,7 @@ def run_virtio_console(test, params, env):
logging.info("test_loopback: %s data received and verified", logging.info("test_loopback: %s data received and verified",
tmp[:-2]) tmp[:-2])
if err: if err:
error_occured = True no_errors += 1
logging.error("test_loopback: error occured in threads: %s.", logging.error("test_loopback: error occured in threads: %s.",
err[:-2]) err[:-2])
...@@ -645,9 +645,9 @@ def run_virtio_console(test, params, env): ...@@ -645,9 +645,9 @@ def run_virtio_console(test, params, env):
del threads[:] del threads[:]
cleanup(vm, guest_worker) cleanup(vm, guest_worker)
if error_occured: if no_errors:
msg = ("test_loopback: Errors occured while executing test, check " msg = ("test_loopback: %d errors occured while executing test, "
"log for details.") "check log for details." % no_errors)
logging.error(msg) logging.error(msg)
raise error.TestFail(msg) raise error.TestFail(msg)
...@@ -690,6 +690,7 @@ def run_virtio_console(test, params, env): ...@@ -690,6 +690,7 @@ def run_virtio_console(test, params, env):
vm, guest_worker = get_vm_with_worker(no_consoles, no_serialports) vm, guest_worker = get_vm_with_worker(no_consoles, no_serialports)
(consoles, serialports) = get_virtio_ports(vm) (consoles, serialports) = get_virtio_ports(vm)
consoles = [consoles, serialports] consoles = [consoles, serialports]
no_errors = 0
for param in test_params.split(';'): for param in test_params.split(';'):
if not param: if not param:
...@@ -738,6 +739,9 @@ def run_virtio_console(test, params, env): ...@@ -738,6 +739,9 @@ def run_virtio_console(test, params, env):
logging.info("\n" + loads.get_mem_status_string()[:-1]) logging.info("\n" + loads.get_mem_status_string()[:-1])
exit_event.set() exit_event.set()
thread.join() thread.join()
if thread.ret_code:
no_errors += 1
logging.error("test_perf: error occured in thread %s", thread)
# Let the guest read-out all the remaining data # Let the guest read-out all the remaining data
while not guest_worker._cmd("virt.poll('%s', %s)" while not guest_worker._cmd("virt.poll('%s', %s)"
...@@ -777,6 +781,9 @@ def run_virtio_console(test, params, env): ...@@ -777,6 +781,9 @@ def run_virtio_console(test, params, env):
guest_worker.cmd("virt.exit_threads()", 10) guest_worker.cmd("virt.exit_threads()", 10)
exit_event.set() exit_event.set()
thread.join() thread.join()
if thread.ret_code:
no_errors += 1
logging.error("test_perf: error occured in thread %s", thread)
if (_time > time_slice): # Deviation is higher than 1 time_slice if (_time > time_slice): # Deviation is higher than 1 time_slice
logging.error( logging.error(
"Test ran %fs longer which is more than one time slice", _time) "Test ran %fs longer which is more than one time slice", _time)
...@@ -790,6 +797,11 @@ def run_virtio_console(test, params, env): ...@@ -790,6 +797,11 @@ def run_virtio_console(test, params, env):
del thread del thread
del exit_event del exit_event
cleanup(vm, guest_worker) cleanup(vm, guest_worker)
if no_errors:
msg = ("test_perf: %d errors occured while executing test, "
"check log for details." % no_errors)
logging.error(msg)
raise error.TestFail(msg)
###################################################################### ######################################################################
# Migration tests # Migration tests
...@@ -929,11 +941,18 @@ def run_virtio_console(test, params, env): ...@@ -929,11 +941,18 @@ def run_virtio_console(test, params, env):
time.sleep(1) time.sleep(1)
i -= 1 i -= 1
tmp = "%d data sent; " % threads[0].idx tmp = "%d data sent; " % threads[0].idx
err = ""
for thread in threads[1:]: for thread in threads[1:]:
thread.join() thread.join()
tmp += "%d, " % thread.idx tmp += "%d, " % thread.idx
if thread.ret_code:
err += "%s, " % thread
logging.info("test_migrate: %s data received and verified during %d " logging.info("test_migrate: %s data received and verified during %d "
"migrations", tmp[:-2], no_migrations) "migrations", tmp[:-2], no_migrations)
if err:
msg = "test_migrate: error occured in threads: %s." % err[:-2]
logging.error(msg)
raise error.TestFail(msg)
# CLEANUP # CLEANUP
guest_worker.safe_exit_loopback_threads([ports[0]], ports[1:]) guest_worker.safe_exit_loopback_threads([ports[0]], ports[1:])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册