示例#1
0
    def __init__(self, sequence_file, loops=1):
        self.seq_file = sequence_file  # sequence file
        if LOG_ENABLED:
            logfile = utils.new_log_path(sequence_file.split(os.sep)[-1])
            self.logfile = open(logfile, mode='w')  # logging file handler
        else:
            self.logfile = None
        self.errordump = None  # error obj dumped to errordump file when worker stops unexpectly
        self.errordumpfile = None  # errordump file handler to record errordump obj
        self.seq_loops = loops  # loop count that we run the sequence
        self.loop_failures = []  # failure info queue for current test loop
        self.uds = get_this_uds()  # unix domain socket for ipc to master
        self.agent = AgentWrapper(logfile=self.logfile)
        # read sequence file, to get the sequence of commands
        try:
            seqreader = SequenceReader(sequence_file)
            seqreader.parse_lines()
            self.sequence = seqreader.sequence
            self.subsequences = seqreader.subsequences
        except Exception as error:
            global WIN_DISPLAY_EN
            if WIN_DISPLAY_EN is not None:
                WIN_DISPLAY_EN.value = 0
            self.logging_error(error)
            raise error
        # running arguments that we really use
        self.running_sequence = self.sequence  # running sequence, by default the whole sequence
        self.running_loops = self.seq_loops  # running sequence loops
        self.cmplt_running_loops = 0  # how many loops that has completed
        self.running_command = 0  # running command running sequence

        self.spawned_workers = []  # workers spawned by current worker
示例#2
0
    def logging_failure(self, data):
        if self.failure_logfile is None:
            log_header = '********FAILURE LOGGING********' + '\n\n'
            filename = utils.new_log_path(
                sequence=self.init_sequence_file.split(os.sep)[-1],
                suffix='failure')
            self.failure_logfile = open(filename, mode='w')
            self.failure_logfile.write(log_header)
            self.failure_logfile.flush()

        if self.failure_logfile and not self.failure_logfile.closed:
            self.failure_logfile.write(data)
            self.failure_logfile.flush()
示例#3
0
    def failure_logging(self, data):
        if not self.failure_logfile:
            log_header = '********FAILURE LOG********' + newline + newline
            self.failure_logfile = open(utils.new_log_path(
                sequence=self.init_sequence_file.split(os.sep)[-1],
                suffix='failure'),
                                        mode='w')
            self.failure_logfile.write(log_header)
            self.failure_logfile.flush()

        if self.failure_logfile and not self.failure_logfile.closed:
            self.failure_logfile.write(data)
            self.failure_logfile.flush()
示例#4
0
    def logging_error(self, errorinfo):
        if not self.errordumpfile:
            error_header = '******ERROR DUMP MESSAGE******\n\n'
            error_title = 'TEST SEQUENCE: %s\n\n' % (self.seq_file)
            errordumpfile = utils.new_log_path(sequence=self.seq_file.split(
                os.sep)[-1],
                                               suffix='errordump')
            self.errordumpfile = open(errordumpfile, mode='w')
            self.errordumpfile.write(error_header + error_title)
            self.errordumpfile.flush()

        if self.errordumpfile and not self.errordumpfile.closed:
            if not isinstance(errorinfo, str): errorinfo = repr(errorinfo)
            self.errordumpfile.write(errorinfo)
            self.errordumpfile.flush()
示例#5
0
 def __init__(self, global_display_control, sequence_file, loops=1):
     self.sequence_file = sequence_file
     self.logfile = open(utils.new_log_path(
         sequence=sequence_file.split(os.sep)[-1]),
                         mode='w') if log_enabled else None
     self.display_control = global_display_control
     self.errordumpfile = None
     self.test_loops = loops
     self.complt_loops = 0
     self.errordump = None
     self.spawned_workers = []
     self.agent = UCSAgentWrapper(local_prompt=local_shell_prompt,
                                  logfile=self.logfile)
     try:
         self.test_sequence = sequence_reader(sequence_file)
     except Exception as err:
         self.stop_display_refresh()
         self.error_logging(err)
         raise err