diff --git a/tests/nicdriver_unload.py b/tests/nicdriver_unload.py index 580acebbe122ace57790102523e15c1636049ce3..8f75cd23f4b0b57e7496346a0cae6ac83f581330 100644 --- a/tests/nicdriver_unload.py +++ b/tests/nicdriver_unload.py @@ -1,27 +1,32 @@ import logging, os, time from autotest.client import utils +from autotest.client.shared import error from virttest import utils_test, utils_net +@error.context_aware def run_nicdriver_unload(test, params, env): """ - Test nic driver. + Test nic driver load/unload. 1) Boot a VM. 2) Get the NIC driver name. - 3) Repeatedly unload/load NIC driver. - 4) Multi-session TCP transfer on test interface. + 3) Multi-session TCP transfer on test interface. + 4) Repeatedly unload/load NIC driver during file transfer. 5) Check whether the test interface should still work. @param test: QEMU test object. @param params: Dictionary with the test parameters. @param env: Dictionary with test environment. """ + + timeout = int(params.get("login_timeout", 360)) vm = env.get_vm(params["main_vm"]) vm.verify_alive() session_serial = vm.wait_for_serial_login(timeout=timeout) + error.context("Get NIC interface name in guest.", logging.info) ethname = utils_net.get_linux_ifname(session_serial, vm.get_mac_address(0)) @@ -39,18 +44,25 @@ def run_nicdriver_unload(test, params, env): try: threads = [] - for _ in range(int(params.get("sessions_num", "10"))): + for i in range(int(params.get("sessions_num", "10"))): + txt = "File transfer on test interface. Thread %s" % i + error.context(txt, logging.info) thread = utils.InterruptedThread(utils_test.run_file_transfer, (test, params, env)) thread.start() threads.append(thread) time.sleep(10) + logging.info("Repeatedly unload/load NIC driver during file transfer.") while threads[0].isAlive(): session_serial.cmd("sleep 10") + error.context("Shutdown the driver for NIC interface.", logging.info) session_serial.cmd("ifconfig %s down" % ethname) + error.context("Unload NIC driver.", logging.info) session_serial.cmd("modprobe -r %s" % driver) + error.context("Load NIC driver.", logging.info) session_serial.cmd("modprobe %s" % driver) + error.context("Activate NIC driver.", logging.info) session_serial.cmd("ifconfig %s up" % ethname) except Exception: for thread in threads: