def download_test_provider(provider, update=False): """ Download a test provider defined on a .ini file inside test-providers.d. This function will only download test providers that are in git repos. Local filesystems don't need this functionality. :param provider: Test provider name, such as 'io-github-autotest-qemu'. """ provider_info = get_test_provider_info(provider) uri = provider_info.get('uri') if not uri.startswith('file://'): uri = provider_info.get('uri') branch = provider_info.get('branch') ref = provider_info.get('ref') pubkey = provider_info.get('pubkey') download_dst = data_dir.get_test_provider_dir(provider) repo_downloaded = os.path.isdir(os.path.join(download_dst, '.git')) original_dir = os.getcwd() if not repo_downloaded or update: download_dst = git.get_repo(uri=uri, branch=branch, commit=ref, destination_dir=download_dst) os.chdir(download_dst) try: utils.run('git remote add origin %s' % uri) except error.CmdError: pass utils.run('git pull origin %s' % branch) os.chdir(download_dst) utils.system('git log -1') os.chdir(original_dir)
def download_test_provider(provider, update=False): """ Download a test provider defined on a .ini file inside test-providers.d. This function will only download test providers that are in git repos. Local filesystems don't need this functionality. :param provider: Test provider name, such as 'io-github-autotest-qemu'. """ provider_info = get_test_provider_info(provider) uri = provider_info.get('uri') if not uri.startswith('file://'): uri = provider_info.get('uri') branch = provider_info.get('branch') ref = provider_info.get('ref') pubkey = provider_info.get('pubkey') download_dst = data_dir.get_test_provider_dir(provider) repo_downloaded = os.path.isdir(os.path.join(download_dst, '.git')) if not repo_downloaded or update: download_dst = git.get_repo(uri=uri, branch=branch, commit=ref, destination_dir=download_dst) os.chdir(download_dst) try: utils.run('git remote add origin %s' % uri) except error.CmdError: pass utils.run('git pull origin %s' % branch) os.chdir(download_dst) utils.system('git log -1')
def run_qemu_iotests(test, params, env): """ Fetch from git and run qemu-iotests using the qemu binaries under test. 1) Fetch qemu-io from git 3) Run test for the file format detected 4) Report any errors found to autotest @param test: KVM test object. @param params: Dictionary with the test parameters. @param env: Dictionary with test environment. """ # First, let's get qemu-io std = "git://git.kernel.org/pub/scm/linux/kernel/git/hch/qemu-iotests.git" uri = params.get("qemu_io_uri", std) branch = params.get("qemu_io_branch", 'master') lbranch = params.get("qemu_io_lbranch", 'master') commit = params.get("qemu_io_commit", None) base_uri = params.get("qemu_io_base_uri", None) destination_dir = os.path.join(test.srcdir, "qemu_io_tests") git.get_repo(uri=uri, branch=branch, lbranch=lbranch, commit=commit, destination_dir=destination_dir, base_uri=base_uri) # Then, set the qemu paths for the use of the testsuite os.environ["QEMU_PROG"] = utils_misc.get_path( test.bindir, params.get("qemu_binary", "qemu")) os.environ["QEMU_IMG_PROG"] = utils_misc.get_path( test.bindir, params.get("qemu_img_binary", "qemu-img")) os.environ["QEMU_IO_PROG"] = utils_misc.get_path( test.bindir, params.get("qemu_io_binary", "qemu-io")) os.chdir(destination_dir) image_format = params.get("qemu_io_image_format") extra_options = params.get("qemu_io_extra_options", "") cmd = './check' if extra_options: cmd += extra_options error.context("running qemu-iotests for image format %s" % image_format) utils.system("%s -%s" % (cmd, image_format))
def _kernel_install_git(self, repo, config, repo_base=None, branch="master", commit=None, config_list=None, patch_list=None, need_reboot=True): repodir = os.path.join("/tmp", 'kernel_src') repodir = git.get_repo(uri=repo, branch=branch, destination_dir=repodir, commit=commit, base_uri=repo_base) self._kernel_install_src(repodir, config, config_list, patch_list, need_reboot)
def setup(self, source_type, source_location, disk_addr, patches, **kwargs): if source_type == "tar": tarball = utils.unmap_url(self.bindir, source_location, self.tmpdir) self.repodir = os.path.join(self.tmpdir, "scsi_testsuite") utils.extract_tarball_to_dir(tarball, self.repodir) elif source_type == "git": self.repodir = git.get_repo(source_location) else: raise UnknownSourceType(source_type) sm = software_manager.SoftwareManager() for utility in ['/usr/bin/sg_raw', '/usr/bin/lsscsi']: if not os.access(utility, os.X_OK): logging.debug("%s missing - trying to install", utility) pkg = sm.provides(utility) if pkg is None: raise SCSIUtilNotAvailable(utility) else: sm.install(pkg) self.devname = "" if disk_addr[0] == "scsi": addr = (disk_addr[1]["host"], disk_addr[1]["channel"], disk_addr[1]["target"], disk_addr[1]["lun"]) self.devname = utils.system_output( "lsscsi %d %d %d %d | sed -n 's,.*/dev,/dev,p' " % addr) elif disk_addr[0] == "serial": disklist = os.listdir("/dev/disk/by-id/") for diskfile in disklist: if re.match("scsi-.*%s$" % disk_addr[1], diskfile) is not None: self.devname = os.path.join("/dev/disk/by-id", diskfile) break elif disk_addr[0] == "file": if os.access(disk_addr[1], os.F_OK): self.devname = disk_addr[1] if self.devname == "": output = utils.system_output("lsscsi") logging.debug(output) raise error.TestFail("Disk not found, cannot execute tests") try: cf = open(self.scsi_testsuite_config, "w") cf.write("export TEST_DEV=%s" % self.devname) cf.close() except IOError: logging.warning("Can't write configuration file. Using defaults") for patch in patches: utils.system("cd %s; patch -p1 < %s/%s" % (self.repodir, self.bindir, patch))
def run(test, params, env): """ Fetch from git and run qemu-iotests using the qemu binaries under test. 1) Fetch qemu-io from git 3) Run test for the file format detected 4) Report any errors found to autotest :param test: QEMU test object. :param params: Dictionary with the test parameters. :param env: Dictionary with test environment. """ # First, let's get qemu-io std = "http://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git" uri = params.get("qemu_io_uri", std) branch = params.get("qemu_io_branch", 'master') lbranch = params.get("qemu_io_lbranch", 'master') commit = params.get("qemu_io_commit", None) base_uri = params.get("qemu_io_base_uri", None) iotests_dir = params.get("qemu_iotests_dir", "tests/qemu-iotests") destination_dir = os.path.join(test.srcdir, "qemu_io_tests") git.get_repo(uri=uri, branch=branch, lbranch=lbranch, commit=commit, destination_dir=destination_dir, base_uri=base_uri) # Then, set the qemu paths for the use of the testsuite 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) # qemu-iotests has merged into tests/qemu_iotests folder os.chdir(os.path.join(destination_dir, iotests_dir)) image_format = params["qemu_io_image_format"] extra_options = params.get("qemu_io_extra_options", "") cmd = './check' if extra_options: cmd += extra_options error.context("running qemu-iotests for image format %s" % image_format) utils.system("%s -%s" % (cmd, image_format))
def run_qemu_iotests(test, params, env): """ Fetch from git and run qemu-iotests using the qemu binaries under test. 1) Fetch qemu-io from git 3) Run test for the file format detected 4) Report any errors found to autotest @param test: QEMU test object. @param params: Dictionary with the test parameters. @param env: Dictionary with test environment. """ # First, let's get qemu-io std = "git://git.kernel.org/pub/scm/linux/kernel/git/hch/qemu-iotests.git" uri = params.get("qemu_io_uri", std) branch = params.get("qemu_io_branch", 'master') lbranch = params.get("qemu_io_lbranch", 'master') commit = params.get("qemu_io_commit", None) base_uri = params.get("qemu_io_base_uri", None) destination_dir = os.path.join(test.srcdir, "qemu_io_tests") git.get_repo(uri=uri, branch=branch, lbranch=lbranch, commit=commit, destination_dir=destination_dir, base_uri=base_uri) # Then, set the qemu paths for the use of the testsuite os.environ["QEMU_PROG"] = utils_misc.get_path(test.bindir, params.get("qemu_binary", "qemu")) os.environ["QEMU_IMG_PROG"] = utils_misc.get_path(test.bindir, params.get("qemu_img_binary", "qemu-img")) os.environ["QEMU_IO_PROG"] = utils_misc.get_path(test.bindir, params.get("qemu_io_binary", "qemu-io")) os.chdir(destination_dir) image_format = params.get("qemu_io_image_format") extra_options = params.get("qemu_io_extra_options", "") cmd = './check' if extra_options: cmd += extra_options error.context("running qemu-iotests for image format %s" % image_format) utils.system("%s -%s" % (cmd, image_format))