Пример #1
0
    def build(self, make_opts='', logfile='', extraversion='autotest'):
        """build the kernel

        make_opts
                additional options to make, if any
        """
        os_dep.commands('gcc', 'make')
        if logfile == '':
            logfile = os.path.join(self.log_dir, 'kernel_build')
        os.chdir(self.build_dir)
        if extraversion:
            self.extraversion(extraversion)
        self.set_cross_cc()
        # setup_config_file(config_file, config_overrides)

        # Not needed on 2.6, but hard to tell -- handle failure
        utils.system('make dep', ignore_status=True)
        threads = 2 * utils.count_cpus()
        build_string = 'make -j %d %s %s' % (threads, make_opts,
                                             self.build_target)
        # eg make bzImage, or make zImage
        print build_string
        utils.system(build_string)
        if kernel_config.modules_needed('.config'):
            utils.system('make -j %d %s modules' % (threads, make_opts))

        kernel_version = self.get_kernel_build_ver()
        kernel_version = re.sub('-autotest', '', kernel_version)
        self.logfile.write('BUILD VERSION: %s\n' % kernel_version)

        utils.force_copy(self.build_dir + '/System.map', self.results_dir)
Пример #2
0
    def _run_sub_test(self, test):
        os.chdir(self.srcdir)
        output = utils.system_output('./check %s' % test,
                                     ignore_status=True,
                                     retain_output=True)
        lines = output.split('\n')
        result_line = lines[-1]
        
        log_list = ['%s.full' % test, '%s.out' % test, '%s.out.bad']

        for log in log_list:
            if os.path.exists(log):
                utils.force_copy(log, self.resultsdir)

        if self.NA_RE.match(result_line):
            detail_line = lines[-3]
            match = self.NA_DETAIL_RE.match(detail_line)
            if match is not None:
                error_msg = match.groups()[2]
            else:
                error_msg = 'Test dependency failed, test not run'
            raise error.TestNAError(error_msg)

        elif self.FAILED_RE.match(result_line):
            raise error.TestError('Test error, check debug logs for complete '
                                  'test output')

        elif self.PASSED_RE.match(result_line):
            return

        else:
            raise error.TestError('Could not assert test success or failure, '
                                  'assuming failure. Please check debug logs')
Пример #3
0
    def build(self, make_opts='', logfile='', extraversion='autotest'):
        """build the kernel

        make_opts
                additional options to make, if any
        """
        os_dep.commands('gcc', 'make')
        if logfile == '':
            logfile = os.path.join(self.log_dir, 'kernel_build')
        os.chdir(self.build_dir)
        if extraversion:
            self.extraversion(extraversion)
        self.set_cross_cc()
        # setup_config_file(config_file, config_overrides)

        # Not needed on 2.6, but hard to tell -- handle failure
        utils.system('make dep', ignore_status=True)
        threads = 2 * utils.count_cpus()
        build_string = 'make -j %d %s %s' % (threads, make_opts,
                                             self.build_target)
        # eg make bzImage, or make zImage
        print build_string
        utils.system(build_string)
        if kernel_config.modules_needed('.config'):
            utils.system('make -j %d %s modules' % (threads, make_opts))

        kernel_version = self.get_kernel_build_ver()
        kernel_version = re.sub('-autotest', '', kernel_version)
        self.logfile.write('BUILD VERSION: %s\n' % kernel_version)

        utils.force_copy(self.build_dir + '/System.map', self.results_dir)
Пример #4
0
    def build(self, make_opts="", logfile="", extraversion="autotest"):
        """build the kernel

        make_opts
                additional options to make, if any
        """
        os_dep.commands("gcc", "make")
        if logfile == "":
            logfile = os.path.join(self.log_dir, "kernel_build")
        os.chdir(self.build_dir)
        if extraversion:
            self.extraversion(extraversion)
        self.set_cross_cc()
        # setup_config_file(config_file, config_overrides)

        # Not needed on 2.6, but hard to tell -- handle failure
        utils.system("make dep", ignore_status=True)
        threads = 2 * utils.count_cpus()
        build_string = "make -j %d %s %s" % (threads, make_opts, self.build_target)
        # eg make bzImage, or make zImage
        print build_string
        utils.system(build_string)
        if kernel_config.modules_needed(".config"):
            utils.system("make -j %d %s modules" % (threads, make_opts))

        kernel_version = self.get_kernel_build_ver()
        kernel_version = re.sub("-autotest", "", kernel_version)
        self.logfile.write("BUILD VERSION: %s\n" % kernel_version)

        utils.force_copy(self.build_dir + "/System.map", self.results_dir)
Пример #5
0
    def install(self, tag='autotest', prefix='/', install_vmlinux=True):
        """make install in the kernel tree"""

        # Record that we have installed the kernel, and
        # the tag under which we installed it.
        self.installed_as = tag

        os.chdir(self.build_dir)

        if not os.path.isdir(prefix):
            os.mkdir(prefix)
        self.boot_dir = os.path.join(prefix, 'boot')
        if not os.path.isdir(self.boot_dir):
            os.mkdir(self.boot_dir)

        if not self.build_image:
            images = glob.glob('arch/*/boot/' + self.build_target)
            if len(images):
                self.build_image = images[0]
            else:
                self.build_image = self.build_target

        # remember installed files
        self.vmlinux = self.boot_dir + '/vmlinux-' + tag
        if (self.build_image != 'vmlinux'):
            self.image = self.boot_dir + '/vmlinuz-' + tag
        else:
            self.image = self.vmlinux
            install_vmlinux = True
        self.system_map = self.boot_dir + '/System.map-' + tag
        self.config_file = self.boot_dir + '/config-' + tag
        self.initrd = ''

        # copy to boot dir
        if install_vmlinux:
            utils.force_copy('vmlinux', self.vmlinux)
        if (self.build_image != 'vmlinux'):
            utils.force_copy(self.build_image, self.image)
        utils.force_copy('System.map', self.system_map)
        utils.force_copy('.config', self.config_file)

        if not kernel_config.modules_needed('.config'):
            return

        utils.system('make modules_install INSTALL_MOD_PATH=%s' % prefix)
        if prefix == '/':
            self.initrd = self.boot_dir + '/initrd-' + tag
            self.mkinitrd(self.get_kernel_build_ver(), self.image,
                          self.system_map, self.initrd)
Пример #6
0
    def install(self, tag='autotest', prefix='/', install_vmlinux=True):
        """make install in the kernel tree"""

        # Record that we have installed the kernel, and
        # the tag under which we installed it.
        self.installed_as = tag

        os.chdir(self.build_dir)

        if not os.path.isdir(prefix):
            os.mkdir(prefix)
        self.boot_dir = os.path.join(prefix, 'boot')
        if not os.path.isdir(self.boot_dir):
            os.mkdir(self.boot_dir)

        if not self.build_image:
            images = glob.glob('arch/*/boot/' + self.build_target)
            if len(images):
                self.build_image = images[0]
            else:
                self.build_image = self.build_target

        # remember installed files
        self.vmlinux = self.boot_dir + '/vmlinux-' + tag
        if (self.build_image != 'vmlinux'):
            self.image = self.boot_dir + '/vmlinuz-' + tag
        else:
            self.image = self.vmlinux
            install_vmlinux = True
        self.system_map = self.boot_dir + '/System.map-' + tag
        self.config_file = self.boot_dir + '/config-' + tag
        self.initrd = ''

        # copy to boot dir
        if install_vmlinux:
            utils.force_copy('vmlinux', self.vmlinux)
        if (self.build_image != 'vmlinux'):
            utils.force_copy(self.build_image, self.image)
        utils.force_copy('System.map', self.system_map)
        utils.force_copy('.config', self.config_file)

        if not kernel_config.modules_needed('.config'):
            return

        utils.system('make modules_install INSTALL_MOD_PATH=%s' % prefix)
        if prefix == '/':
            self.initrd = self.boot_dir + '/initrd-' + tag
            self.mkinitrd(self.get_kernel_build_ver(), self.image,
                          self.system_map, self.initrd)
Пример #7
0
    def install(self, tag="autotest", prefix="/", install_vmlinux=True):
        """make install in the kernel tree"""

        # Record that we have installed the kernel, and
        # the tag under which we installed it.
        self.installed_as = tag

        os.chdir(self.build_dir)

        if not os.path.isdir(prefix):
            os.mkdir(prefix)
        self.boot_dir = os.path.join(prefix, "boot")
        if not os.path.isdir(self.boot_dir):
            os.mkdir(self.boot_dir)

        if not self.build_image:
            images = glob.glob("arch/*/boot/" + self.build_target)
            if len(images):
                self.build_image = images[0]
            else:
                self.build_image = self.build_target

        # remember installed files
        self.vmlinux = self.boot_dir + "/vmlinux-" + tag
        if self.build_image != "vmlinux":
            self.image = self.boot_dir + "/vmlinuz-" + tag
        else:
            self.image = self.vmlinux
            install_vmlinux = True
        self.system_map = self.boot_dir + "/System.map-" + tag
        self.config_file = self.boot_dir + "/config-" + tag
        self.initrd = ""

        # copy to boot dir
        if install_vmlinux:
            utils.force_copy("vmlinux", self.vmlinux)
        if self.build_image != "vmlinux":
            utils.force_copy(self.build_image, self.image)
        utils.force_copy("System.map", self.system_map)
        utils.force_copy(".config", self.config_file)

        if not kernel_config.modules_needed(".config"):
            return

        utils.system("make modules_install INSTALL_MOD_PATH=%s" % prefix)
        if prefix == "/":
            self.initrd = self.boot_dir + "/initrd-" + tag
            self.mkinitrd(self.get_kernel_build_ver(), self.image, self.system_map, self.initrd)
Пример #8
0
    def apply_patches(self, local_patches):
        """apply the list of patches, in order"""
        builddir = self.build_dir
        os.chdir(builddir)

        if not local_patches:
            return None
        for (spec, local, md5sum) in local_patches:
            if local.endswith('.bz2') or local.endswith('.gz'):
                ref = spec
            else:
                ref = utils.force_copy(local, self.results_dir)
                ref = self.job.relative_path(ref)
            patch_id = "%s %s %s" % (spec, ref, md5sum)
            log = "PATCH: " + patch_id + "\n"
            print log
            utils.cat_file_to_cmd(local, 'patch -p1 > /dev/null')
            self.logfile.write(log)
            self.applied_patches.append(patch_id)
Пример #9
0
    def apply_patches(self, local_patches):
        """apply the list of patches, in order"""
        builddir = self.build_dir
        os.chdir(builddir)

        if not local_patches:
            return None
        for (spec, local, md5sum) in local_patches:
            if local.endswith('.bz2') or local.endswith('.gz'):
                ref = spec
            else:
                ref = utils.force_copy(local, self.results_dir)
                ref = self.job.relative_path(ref)
            patch_id = "%s %s %s" % (spec, ref, md5sum)
            log = "PATCH: " + patch_id + "\n"
            print log
            utils.cat_file_to_cmd(local, 'patch -p1 > /dev/null')
            self.logfile.write(log)
            self.applied_patches.append(patch_id)
Пример #10
0
 def cp_linux_kernel(self):
     '''
     Copying Linux kernel to target path
     '''
     os.chdir(self.source)
     utils.force_copy(self.build_image, self.kernel_path)
Пример #11
0
    def netload_kill_problem(session_serial):
        setup_cmd = params.get("setup_cmd")
        clean_cmd = params.get("clean_cmd")
        firewall_flush = params.get("firewall_flush", "service iptables stop")
        error.context("Stop firewall in guest and host.", logging.info)
        try:
            utils.run(firewall_flush)
        except Exception:
            logging.warning("Could not stop firewall in host")

        try:
            session_serial.cmd(firewall_flush)
        except Exception:
            logging.warning("Could not stop firewall in guest")

        netperf_links = params["netperf_links"].split()
        remote_dir = params.get("remote_dir", "/var/tmp")
        # netperf_links support multi links. In case we need apply patchs to
        # netperf or need copy other files.
        for netperf_link in netperf_links:
            if utils.is_url(netperf_link):
                download_dir = data_dir.get_download_dir()
                netperf_link = utils.unmap_url_cache(download_dir,
                                                     netperf_link)
                netperf_dir = download_dir
            elif netperf_link:
                netperf_link = utils_misc.get_path(data_dir.get_deps_dir(),
                                                   netperf_link)
            vm.copy_files_to(netperf_link, remote_dir)
            utils.force_copy(netperf_link, remote_dir)

        guest_ip = vm.get_address(0)
        server_ip = utils_net.get_correspond_ip(guest_ip)

        error.context("Setup and run netperf server in host and guest",
                      logging.info)
        session_serial.cmd(setup_cmd % remote_dir, timeout=200)
        utils.run(setup_cmd % remote_dir, timeout=200)

        try:
            session_serial.cmd(clean_cmd)
        except Exception:
            pass
        session_serial.cmd(params.get("netserver_cmd") % remote_dir)

        utils.run(clean_cmd, ignore_status=True)
        utils.run(params.get("netserver_cmd") % remote_dir)
        p_size = params.get("packet_size", "1500")
        host_netperf_cmd = params.get("netperf_cmd") % (
            remote_dir, "TCP_STREAM", guest_ip, p_size)
        guest_netperf_cmd = params.get("netperf_cmd") % (
            remote_dir, "TCP_STREAM", server_ip, p_size)
        try:
            error.context("Start heavy network load host <=> guest.",
                          logging.info)
            session_serial.sendline(guest_netperf_cmd)
            utils.BgJob(host_netperf_cmd)

            # Wait for create big network usage.
            time.sleep(10)
            msg = "During netperf running, Check that we can kill VM with signal 0"
            error.context(msg, logging.info)
            kill_and_check(vm)

        finally:
            error.context("Clean up netperf server in host and guest.",
                          logging.info)
            utils.run(clean_cmd, ignore_status=True)
            try:
                session_serial.cmd(clean_cmd)
            except Exception:
                pass
Пример #12
0
 def cp_linux_kernel(self):
     '''
     Copying Linux kernel to target path
     '''
     os.chdir(self.source)
     utils.force_copy(self.build_image, self.kernel_path)
Пример #13
0
    def netload_kill_problem(session_serial):
        setup_cmd = params.get("setup_cmd")
        clean_cmd = params.get("clean_cmd")
        firewall_flush = params.get("firewall_flush", "service iptables stop")
        error.context("Stop firewall in guest and host.", logging.info)
        try:
            utils.run(firewall_flush)
        except Exception:
            logging.warning("Could not stop firewall in host")

        try:
            session_serial.cmd(firewall_flush)
        except Exception:
            logging.warning("Could not stop firewall in guest")

        netperf_links = params["netperf_links"].split()
        remote_dir = params.get("remote_dir", "/var/tmp")
        # netperf_links support multi links. In case we need apply patchs to
        # netperf or need copy other files.
        for netperf_link in netperf_links:
            if utils.is_url(netperf_link):
                download_dir = data_dir.get_download_dir()
                netperf_link = utils.unmap_url_cache(download_dir,
                                                     netperf_link)
                netperf_dir = download_dir
            elif netperf_link:
                netperf_link = utils_misc.get_path(data_dir.get_deps_dir(),
                                                   netperf_link)
            vm.copy_files_to(netperf_link, remote_dir)
            utils.force_copy(netperf_link, remote_dir)

        guest_ip = vm.get_address(0)
        server_ip = utils_net.get_correspond_ip(guest_ip)

        error.context("Setup and run netperf server in host and guest",
                      logging.info)
        session_serial.cmd(setup_cmd % remote_dir, timeout=200)
        utils.run(setup_cmd % remote_dir, timeout=200)

        try:
            session_serial.cmd(clean_cmd)
        except Exception:
            pass
        session_serial.cmd(params.get("netserver_cmd") % remote_dir)

        utils.run(clean_cmd, ignore_status=True)
        utils.run(params.get("netserver_cmd") % remote_dir)
        p_size = params.get("packet_size", "1500")
        host_netperf_cmd = params.get("netperf_cmd") % (remote_dir,
                                                        "TCP_STREAM",
                                                        guest_ip,
                                                        p_size)
        guest_netperf_cmd = params.get("netperf_cmd") % (remote_dir,
                                                         "TCP_STREAM",
                                                         server_ip,
                                                         p_size)
        try:
            error.context("Start heavy network load host <=> guest.",
                          logging.info)
            session_serial.sendline(guest_netperf_cmd)
            utils.BgJob(host_netperf_cmd)

            # Wait for create big network usage.
            time.sleep(10)
            msg = "During netperf running, Check that we can kill VM with signal 0"
            error.context(msg, logging.info)
            kill_and_check(vm)

        finally:
            error.context("Clean up netperf server in host and guest.",
                          logging.info)
            utils.run(clean_cmd, ignore_status=True)
            try:
                session_serial.cmd(clean_cmd)
            except Exception:
                pass