diff --git a/qemu/cfg/unittests.cfg b/qemu/cfg/unittests.cfg index cdb8678af266664ec7103d61bcb468259293581d..fae7b7ca68020a6d2b4b06a9392730da53245864 100644 --- a/qemu/cfg/unittests.cfg +++ b/qemu/cfg/unittests.cfg @@ -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 diff --git a/qemu/tests/unittest.py b/qemu/tests/unittest.py index 8bb3eb7dbff8f065c854cb46770b5d920937e4b5..449a08dd069d08762f2672881cc410f0d10970fe 100644 --- a/qemu/tests/unittest.py +++ b/qemu/tests/unittest.py @@ -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")