Esempio n. 1
0
    def _board_on_and_validate(self):
        self.board.log("\n=!= BOARD ON AND VALIDATE =!=", bold=True)

        try:
            boot_time = self.board.reboot_and_validate()
        except BoardBootValidationError as e:
            # If boot failed, save this info and backup logfile
            self.data['boot_success'] = False
            self.data['boot_log'] = os.path.join(
                self.settings['failed_bootlogs_dir'],
                '{}_failed_boot_{}.log'.format(
                    self.board.name,
                    datetime_to_timestamp(datetime.datetime.now())))

            try:
                if not os.path.exists(self.settings['failed_bootlogs_dir']):
                    os.makedirs(self.settings['failed_bootlogs_dir'])
                shutil.copy2(self.board.console.log_file,
                             self.data['boot_log'])
            except Exception as ex:
                self.data['boot_log'] = None
                raise ex

            self.board.error('Boot failed! Saving console log to {}'.format(
                self.data['boot_log']))
            raise e

        # If boot succeeded save this info
        self.data['boot_success'] = True
        self.data['boot_time'] = boot_time
    def _finalise_iteration(self, success):
        # Create copies of all TestRunner data
        self.results[-1]['TestRunner'] = deepcopy(self.testrunner.data)

        # Update stats
        self.results[-1]['end'] = datetime_to_timestamp(datetime.now())
        self.results[-1]['success'] = success
        self.results[-1]['ran'] = True
        if self.testrunner.sequential:
            self.results[-1]['test_order'] = 'sequential'
        else:
            self.results[-1]['test_order'] = 'parallel'

        num_tests_run = len(
            [k for k, v in self.testrunner.data.items() if v['tasks']['ran']])
        num_tests_pass = len([
            k for k, v in self.testrunner.data.items()
            if v['tasks']['ran'] and not v['tasks']['failed']
        ])

        if success:
            self.stats['num_iterations_pass'] += 1

        self.stats['num_tests_run'] += num_tests_run
        self.stats['num_tests_pass'] += num_tests_pass
        self.stats['num_tests_total'] += self.testrunner.num_tests

        self.stats['num_iterations_run'] += 1

        self.results_summary = self.get_results_summary()
        self.test_settings = self.collect_test_settings()
 def log_file(self) -> str:
     if not hasattr(self, "_log_file"):
         # Default logfile for all hardwarebasees lives in /tmp
         self._log_file = os.path.join(
             '/tmp', 'pluma', '{}_{}.log'.format(
                 self.__class__.__name__,
                 datetime_to_timestamp(datetime.datetime.now())))
     return self._log_file
    def _init_iteration(self):
        skeleton = {
            'iteration': self.stats['num_iterations_run'],
            'start': datetime_to_timestamp(datetime.now()),
            'end': None,
            'success': None,
            'test_order': None,
            'TestRunner': self.testrunner.data
        }
        self.results.append(skeleton)

        return self.results[-1]
Esempio n. 5
0
    def __init__(self,
                 linesep: Optional[str] = None,
                 encoding: Optional[str] = None,
                 raw_logfile: Optional[str] = None):
        timestamp = datetime_to_timestamp(datetime.now())
        default_raw_logfile = os.path.join(
            '/tmp', 'pluma', f'{self.__class__.__name__}_raw_{timestamp}.log')

        self.linesep = linesep or '\n'
        self.encoding = encoding or 'ascii'
        self.raw_logfile = raw_logfile or default_raw_logfile
        self._raw_logfile_io = None
        self._console_type = None
        self._reception_buffer = ''
Esempio n. 6
0
    def __init__(self,
                 encoding: str = None,
                 linesep: str = None,
                 raw_logfile: str = None,
                 system: SystemContext = None):
        if not hasattr(self, '_pex'):
            raise AttributeError(
                "Variable '_pex' must be created by inheriting class")

        timestamp = datetime_to_timestamp(datetime.now())
        default_raw_logfile = os.path.join(
            '/tmp', 'pluma', f'{self.__class__.__name__}_raw_{timestamp}.log')

        self.encoding = encoding or 'ascii'
        self.linesep = linesep or '\n'
        self.raw_logfile = raw_logfile or default_raw_logfile
        self.system = system or SystemContext()

        self._buffer = ''
        self._last_received = ''
        self._raw_logfile_fd = None
        self._pex = None
        self._requires_login = True