示例#1
0
    def test_select_ABAT(self):
        job = object()
        self.god.stub_class(harness_ABAT, "harness_ABAT")

        harness_args = ''
        harness_ABAT.harness_ABAT.expect_new(job, harness_args)
        harness.select('ABAT', job, harness_args)
        self.god.check_playback()
示例#2
0
    def test_select_standalone(self):
        job = object()
        self.god.stub_class(harness_standalone, "harness_standalone")

        harness_args = ''
        harness_standalone.harness_standalone.expect_new(job, harness_args)
        harness.select('standalone', job, harness_args)
        self.god.check_playback()
示例#3
0
    def test_select_standalone(self):
        job = object()
        self.god.stub_class(harness_standalone, "harness_standalone")

        harness_args = ''
        harness_standalone.harness_standalone.expect_new(job, harness_args)
        harness.select('standalone', job, harness_args)
        self.god.check_playback()
示例#4
0
    def test_select_ABAT(self):
        job = object()
        self.god.stub_class(harness_ABAT, "harness_ABAT")

        harness_args = ''
        harness_ABAT.harness_ABAT.expect_new(job, harness_args)
        harness.select('ABAT', job, harness_args)
        self.god.check_playback()
示例#5
0
    def bootstrap(self, args, options):
        """
        Bootstrap autotest by fetching the control file first and pass it back

        Currently this relies on a harness to retrieve the file
        """
        def harness_env():
            try:
                return os.environ['AUTOTEST_HARNESS']
            except KeyError:
                return None

        def harness_args_env():
            try:
                return os.environ['AUTOTEST_HARNESS_ARGS']
            except KeyError:
                return None

        class stub_job(object):

            def config_set(self, name, value):
                return

        if not options.harness and not harness_env():
            self.help()

        if options.harness:
            harness_name = options.harness
        elif harness_env():
            harness_name = harness_env()
            options.harness = harness_name

        if options.harness_args:
            harness_args = options.harness_args
        else:
            harness_args = harness_args_env()
            options.harness_args = harness_args

        myjob = stub_job()

        # let harness initialize itself
        try:
            myharness = harness.select(harness_name, myjob, harness_args)
            if not getattr(myharness, 'bootstrap'):
                raise error.HarnessError("Does not support bootstrapping\n")
        except Exception, error_detail:
            if DEBUG:
                raise
            sys.stderr.write("Harness %s failed to initialize -> %s\n" % (harness_name, error_detail))
            self.help()
            sys.exit(1)
示例#6
0
文件: job.py 项目: royxu1972/autotest
    def _pre_record_init(self, control, options):
        """
        Initialization function that should peform ONLY the required
        setup so that the self.record() method works.

        As of now self.record() needs self.resultdir, self._group_level,
        self.harness and of course self._logger.
        """
        if not options.cont:
            self._cleanup_debugdir_files()
            self._cleanup_results_dir()

        logging_manager.configure_logging(
            client_logging_config.ClientLoggingConfig(), results_dir=self.resultdir, verbose=options.verbose
        )
        logging.info("Writing results to %s", self.resultdir)

        # init_group_level needs the state
        self.control = os.path.realpath(control)
        self._is_continuation = options.cont
        self._current_step_ancestry = []
        self._next_step_index = 0
        self._load_state()

        _harness = self.handle_persistent_option(options, "harness")
        _harness_args = self.handle_persistent_option(options, "harness_args")

        self.harness = harness.select(_harness, self, _harness_args)

        # set up the status logger
        def client_job_record_hook(entry):
            msg_tag = ""
            if "." in self._logger.global_filename:
                msg_tag = self._logger.global_filename.split(".", 1)[1]
            # send the entry to the job harness
            message = "\n".join([entry.message] + entry.extra_message_lines)
            rendered_entry = self._logger.render_entry(entry)
            self.harness.test_status_detail(
                entry.status_code, entry.subdir, entry.operation, message, msg_tag, entry.fields
            )
            self.harness.test_status(rendered_entry, msg_tag)
            # send the entry to stdout, if it's enabled
            logging.info(rendered_entry)

        self._logger = base_job.status_logger(
            self, status_indenter(self), record_hook=client_job_record_hook, tap_writer=self._tap
        )
示例#7
0
    def _pre_record_init(self, control, options):
        """
        Initialization function that should peform ONLY the required
        setup so that the self.record() method works.

        As of now self.record() needs self.resultdir, self._group_level,
        self.harness and of course self._logger.
        """
        if not options.cont:
            self._cleanup_debugdir_files()
            self._cleanup_results_dir()

        logging_manager.configure_logging(
            client_logging_config.ClientLoggingConfig(),
            results_dir=self.resultdir,
            verbose=options.verbose)
        logging.info('Writing results to %s', self.resultdir)

        # init_group_level needs the state
        self.control = os.path.realpath(control)
        self._is_continuation = options.cont
        self._current_step_ancestry = []
        self._next_step_index = 0
        self._load_state()

        _harness = self.handle_persistent_option(options, 'harness')
        _harness_args = self.handle_persistent_option(options, 'harness_args')

        self.harness = harness.select(_harness, self, _harness_args)

        # set up the status logger
        def client_job_record_hook(entry):
            msg_tag = ''
            if '.' in self._logger.global_filename:
                msg_tag = self._logger.global_filename.split('.', 1)[1]
            # send the entry to the job harness
            message = '\n'.join([entry.message] + entry.extra_message_lines)
            rendered_entry = self._logger.render_entry(entry)
            self.harness.test_status_detail(entry.status_code, entry.subdir,
                                            entry.operation, message, msg_tag,
                                            entry.fields)
            self.harness.test_status(rendered_entry, msg_tag)
            # send the entry to stdout, if it's enabled
            logging.info(rendered_entry)
        self._logger = base_job.status_logger(
            self, status_indenter(self), record_hook=client_job_record_hook,
            tap_writer=self._tap)
示例#8
0
文件: job.py 项目: royxu1972/autotest
 def harness_select(self, which, harness_args):
     self.harness = harness.select(which, self, harness_args)
示例#9
0
 def harness_select(self, which, harness_args):
     self.harness = harness.select(which, self, harness_args)
示例#10
0
    def bootstrap(self, args, options):
        """
        Bootstrap autotest by fetching the control file first and pass it back

        Currently this relies on a harness to retrieve the file
        """
        def harness_env():
            try:
                return os.environ['AUTOTEST_HARNESS']
            except KeyError:
                return None

        def harness_args_env():
            try:
                return os.environ['AUTOTEST_HARNESS_ARGS']
            except KeyError:
                return None

        class stub_job(object):
            def config_set(self, name, value):
                return

        if not options.harness and not harness_env():
            self.help()

        if options.harness:
            harness_name = options.harness
        elif harness_env():
            harness_name = harness_env()
            options.harness = harness_name

        if options.harness_args:
            harness_args = options.harness_args
        else:
            harness_args = harness_args_env()
            options.harness_args = harness_args

        myjob = stub_job()

        # let harness initialize itself
        try:
            myharness = harness.select(harness_name, myjob, harness_args)
            if not getattr(myharness, 'bootstrap'):
                raise error.HarnessError("Does not support bootstrapping\n")
        except Exception as error_detail:
            if DEBUG:
                raise
            sys.stderr.write("Harness %s failed to initialize -> %s\n" %
                             (harness_name, error_detail))
            self.help()
            sys.exit(1)

        # get remote control file and stick it in FETCHDIRTEST
        try:
            control = myharness.bootstrap(FETCHDIRTEST)
        except Exception as ex:
            sys.stderr.write("bootstrap failed -> %s\n" % ex)
            raise SystemExit(1)
        logging.debug("bootstrap passing control file %s to run" % control)

        if not control:
            # nothing to do politely abort
            # trick to work around various harness quirks
            raise SystemExit(0)

        args.append(control)

        return args