def _start_rv_smartcard(): def _rv_connection_check(): rv_pid = process.getoutput("pidof %s" % rv_binary) cmd = 'netstat -ptn | grep "^tcp.*127.0.0.1:%s.*ESTABLISHED %s.*"' cmd = cmd % (spice_port, rv_pid) s, o = process.getstatusoutput(cmd) if s: return False test.log.info("netstat output:\n%s", o) return True status = True err_msg = '' rv_binary_path = utils_misc.get_binary(rv_binary, params) spice_port = vm.get_spice_var('spice_port') rv_args = rv_binary_path + " spice://localhost:%s " % spice_port rv_args += "--spice-smartcard --spice-smartcard-db %s " % sc_db_dst rv_args += "--spice-smartcard-certificates cert1,cert2,cert3" rv_args += " > /dev/null 2>&1" rv_thread = utils_misc.InterruptedThread(os.system, (rv_args, )) rv_thread.start() if not utils_misc.wait_for(_rv_connection_check, timeout, 60): status = False err_msg = "Fail to establish %s connection" % rv_binary return (status, err_msg)
def run_test(qemu_src_dir): """ run QEMU I/O test suite :qemu_src_dir: path of qemu source code """ iotests_root = params.get("iotests_root", "tests/qemu-iotests") extra_options = params.get("qemu_io_extra_options", "") image_format = params.get("qemu_io_image_format") result_pattern = params.get("iotests_result_pattern") error_context.context("running qemu-iotests for image format %s" % image_format, logging.info) os.environ["QEMU_PROG"] = utils_misc.get_qemu_binary(params) os.environ["QEMU_IMG_PROG"] = utils_misc.get_qemu_img_binary(params) os.environ["QEMU_IO_PROG"] = utils_misc.get_qemu_io_binary(params) os.environ["QEMU_NBD_PROG"] = utils_misc.get_binary('qemu-nbd', params) os.chdir(os.path.join(qemu_src_dir, iotests_root)) cmd = './check' if extra_options: cmd += " %s" % extra_options cmd += " -%s" % image_format output = process.system_output(cmd, ignore_status=True, shell=True) match = re.search(result_pattern, output, re.I | re.M) if match: iotests_log_file = "qemu_iotests_%s.log" % image_format iotests_log_file = utils_misc.get_path(test.debugdir, iotests_log_file) with open(iotests_log_file, 'w+') as log: log.write(output) log.flush() msg = "Total test %s cases, %s failed" raise exceptions.TestFail(msg % (match.group(2), match.group(1)))
def _start_spice_redirection(): def _rv_connection_check(): rv_pid = process.getoutput("pidof %s" % rv_binary) spice_port = vm.get_spice_var('spice_port') cmd = 'netstat -ptn | grep "^tcp.*127.0.0.1:%s.*ESTABLISHED %s.*"' cmd = cmd % (spice_port, rv_pid) s, o = process.getstatusoutput(cmd) if s: return False logging.info("netstat output:\n%s", o) return True status = True err_msg = '' rv_binary_path = utils_misc.get_binary(rv_binary, params) spice_port = vm.get_spice_var('spice_port') rv_args = rv_binary_path + " spice://localhost:%s " % spice_port rv_args += "--spice-usbredir-redirect-on-connect=" rv_args += "'-1,0x%s,0x%s,-1,1'" % (vendorid, productid) rv_args += " > /dev/null 2>&1" rv_thread = utils_misc.InterruptedThread(os.system, (rv_args, )) rv_thread.start() if not utils_misc.wait_for(_rv_connection_check, timeout, 60): status = False err_msg = "Fail to establish %s connection" % rv_binary return (status, err_msg)
def _start_usbredir_server(): process.getoutput("killall usbredirserver") usbredir_server = utils_misc.get_binary('usbredirserver', params) usbredirserver_args = usbredir_server + " -p %s " % free_port usbredirserver_args += " %s:%s" % (vendorid, productid) usbredirserver_args += " > /dev/null 2>&1" rv_thread = utils_misc.InterruptedThread(os.system, (usbredirserver_args, )) rv_thread.start()