qemu: unittests - Handle running on qemu upstream new testdevs

The implementation of the devices needed for KVM unit
testing changed a bit on qemu:

1) There's no need for a testlog anymore (as kvm-unit-tests
   now writes to the standard serial port)
2) Now there's a shared new device, called isa-debug-exit,
   that when written to, causes qemu to exit
3) Due to the new behavior of the isa-debug-exit device,
   the new known good behavior for qemu at the end of the
   unit test is to return 1.

Take that all into account, while still keeping backwards
compatibility. Also, document how one can run the unittests
with the new virt-tests runner both in the config file
and the wiki.
Signed-off-by: NLucas Meneghel Rodrigues <lmr@redhat.com>
上级 1608d6cd
......@@ -74,8 +74,11 @@ variants:
type = unittest
vms = ''
start_vm = no
unittest_timeout = 600
unittest_timeout = 240
testdev = yes
isa_debugexit = yes
isa_debugexit_iobase = 0xf4
isa_debugexit_iosize = 0x04
extra_params += " -S"
# In case you want to execute only a subset of the tests defined on the
# unittests.cfg file on qemu-kvm, uncomment and edit test_list
......@@ -83,4 +86,18 @@ variants:
# In case you want to excluse just some of the tests, use a blacklist
#unittest_test_blacklist = access apic emulator
only build unittest
# If you want to run the unittest with the test runner, you could do:
# 1) Check out the kvm-unit-tests suite
# 2) Compile it:
# ./configure
# make
# 3) link the x86 subdir of your kvm-unit-tests suite in your qemu/ subdir
# in virt-test
# ln -s /path/to/kvm-unit-tests/x86 /path/to/virt-test/qemu/
# 4) On virt-test directory, execute the runner:
# ./run -c qemu/cfg/unittests.cfg --qemu-bin /path/to/your/qemu
# If you want to run the build test together with unittest
#only build unittest
# If you want to run only the unittest
only unittest
......@@ -90,8 +90,10 @@ def run_unittest(test, params, env):
vm_name = params.get("main_vm")
params['kernel'] = os.path.join(unittest_dir, flat_file)
testlog_path = os.path.join(test.debugdir, "%s.log" % t)
testlog = None
try:
try:
vm_name = params.get('main_vm')
......@@ -99,26 +101,45 @@ def run_unittest(test, params, env):
vm = env.get_vm(vm_name)
vm.create()
vm.resume()
logging.info("Waiting for unittest %s to complete, timeout %s, "
"output in %s", t, timeout,
vm.get_testlog_filename())
testlog = vm.get_testlog_filename()
msg = ("Waiting for unittest %s to complete, timeout %s" %
(t, timeout))
if os.path.isfile(testlog):
msg += (", output in %s" % testlog)
else:
testlog = None
logging.info(msg)
if not utils_misc.wait_for(vm.is_dead, timeout):
raise error.TestFail("Timeout elapsed (%ss)" % timeout)
# Check qemu's exit status
status = vm.process.get_status()
if status != 0:
# Check whether there's an isa_debugexit device in the vm
isa_debugexit = 'isa-debug-exit' in vm.qemu_command
if isa_debugexit:
good_status = 1
else:
good_status = 0
if status != good_status:
nfail += 1
tests_failed.append(t)
logging.error("Unit test %s failed", t)
except Exception, e:
nfail += 1
tests_failed.append(t)
logging.error('Exception happened during %s: %s', t, str(e))
finally:
try:
shutil.copy(vm.get_testlog_filename(), testlog_path)
logging.info("Unit test log collected and available under %s",
testlog_path)
if testlog is not None:
shutil.copy(vm.get_testlog_filename(), testlog_path)
logging.info("Unit test log collected and available "
"under %s", testlog_path)
except (NameError, IOError):
logging.error("Not possible to collect logs")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册