示例#1
0
 def _record_reboot_failure(self, subdir, operation, status,
                            running_id=None):
     self.record("ABORT", subdir, operation, status)
     if not running_id:
         running_id = utils.running_os_ident()
     kernel = {"kernel": running_id.split("::")[0]}
     self.record("END ABORT", subdir, 'reboot', optional_fields=kernel)
示例#2
0
 def _record_reboot_failure(self, subdir, operation, status,
                            running_id=None):
     self.record("ABORT", subdir, operation, status)
     if not running_id:
         running_id = utils.running_os_ident()
     kernel = {"kernel": running_id.split("::")[0]}
     self.record("END ABORT", subdir, 'reboot', optional_fields=kernel)
示例#3
0
文件: job.py 项目: royxu1972/autotest
    def end_reboot_and_verify(self, expected_when, expected_id, subdir, type="src", patches=[]):
        """ Check the passed kernel identifier against the command line
            and the running kernel, abort the job on missmatch. """

        logging.info(
            "POST BOOT: checking booted kernel " "mark=%d identity='%s' type='%s'", expected_when, expected_id, type
        )

        running_id = utils.running_os_ident()

        cmdline = utils.read_one_line("/proc/cmdline")

        find_sum = re.compile(r".*IDENT=(\d+)")
        m = find_sum.match(cmdline)
        cmdline_when = -1
        if m:
            cmdline_when = int(m.groups()[0])

        # We have all the facts, see if they indicate we
        # booted the requested kernel or not.
        bad = False
        if (
            type == "src"
            and expected_id != running_id
            or type == "rpm"
            and not running_id.startswith(expected_id + "::")
        ):
            logging.error("Kernel identifier mismatch")
            bad = True
        if expected_when != cmdline_when:
            logging.error("Kernel command line mismatch")
            bad = True

        if bad:
            logging.error("   Expected Ident: " + expected_id)
            logging.error("    Running Ident: " + running_id)
            logging.error("    Expected Mark: %d", expected_when)
            logging.error("Command Line Mark: %d", cmdline_when)
            logging.error("     Command Line: " + cmdline)

            self._record_reboot_failure(subdir, "reboot.verify", "boot failure", running_id=running_id)
            raise error.JobError("Reboot returned with the wrong kernel")

        self.record("GOOD", subdir, "reboot.verify", utils.running_os_full_version())
        self.end_reboot(subdir, expected_id, patches, running_id=running_id)
示例#4
0
    def end_reboot_and_verify(self, expected_when, expected_id, subdir,
                              type='src', patches=[]):
        """ Check the passed kernel identifier against the command line
            and the running kernel, abort the job on missmatch. """

        logging.info("POST BOOT: checking booted kernel "
                     "mark=%d identity='%s' type='%s'",
                     expected_when, expected_id, type)

        running_id = utils.running_os_ident()

        cmdline = utils.read_one_line("/proc/cmdline")

        find_sum = re.compile(r'.*IDENT=(\d+)')
        m = find_sum.match(cmdline)
        cmdline_when = -1
        if m:
            cmdline_when = int(m.groups()[0])

        # We have all the facts, see if they indicate we
        # booted the requested kernel or not.
        bad = False
        if (type == 'src' and expected_id != running_id or
            type == 'rpm' and
                not running_id.startswith(expected_id + '::')):
            logging.error("Kernel identifier mismatch")
            bad = True
        if expected_when != cmdline_when:
            logging.error("Kernel command line mismatch")
            bad = True

        if bad:
            logging.error("   Expected Ident: " + expected_id)
            logging.error("    Running Ident: " + running_id)
            logging.error("    Expected Mark: %d", expected_when)
            logging.error("Command Line Mark: %d", cmdline_when)
            logging.error("     Command Line: " + cmdline)

            self._record_reboot_failure(subdir, "reboot.verify", "boot failure",
                                        running_id=running_id)
            raise error.JobError("Reboot returned with the wrong kernel")

        self.record('GOOD', subdir, 'reboot.verify',
                    utils.running_os_full_version())
        self.end_reboot(subdir, expected_id, patches, running_id=running_id)