def __init__(self, workdir, labfile, cfgfile, logfilen, verbose): ## enable verbose output self.verbose = verbose self.cfgfile = cfgfile self.workdir = workdir self.power_state = 'undef' self.tc_stack = [] self.tc_stack_arg = [] self.donotlog = False print("CUR WORK PATH: ", self.workdir) print("CFGFILE ", self.cfgfile) # add config to sys path sys.path.append(self.workdir + '/config') # load board config try: self.config = importlib.import_module(cfgfile) except ImportError: print("board cfg file %s not found" % cfgfile) sys.exit(1) # load lab settigs ... self.overwrite_config(labfile) # load default settigs ... self.overwrite_config('default_vars') # test if we have a lab specific board setup call_specific = False try: self.config.set_labspecific call_specific = True except: print("no set_labspecfic") if call_specific: try: self.config.set_labspecific(self) except: type, value, traceback = sys.exc_info() print("type ", type) print("value ", value) sys.exit(1) now = datetime.datetime.now() # load config file if logfilen == 'default': self.logfilen = 'log/' + now.strftime("%Y-%m-%d-%H-%M") + '.log' else: self.logfilen = logfilen if self.logfilen[0] != '/': # not absolute path, add workdir self.logfilen = self.workdir + '/' + self.logfilen print("LOGFILE ", self.logfilen) sys.path.append(self.workdir + "/src/lab_api") from state_uboot import u_boot_set_board_state from state_linux import linux_set_board_state self.setboardstate_uboot = locals()['u_boot_set_board_state'] self.setboardstate_linux = locals()['linux_set_board_state'] try: self.tc_dir except AttributeError: self.tc_dir = self.workdir + '/src/tc' self._main = 0 self._ret = False self.con_loglevel = 25 logging.addLevelName(self.con_loglevel, "CON") if (self.config.loglevel == 'CON'): logformat = '# %(message)s' else: logformat = '%(asctime)s:%(levelname)-7s:%(module)-10s# %(message)s' logging.basicConfig(format=logformat, filename=self.logfilen, filemode='w') l = logging.getLogger() l.setLevel(self.config.loglevel) logging.info("*****************************************") logging.info('Started logging @ %s', now.strftime("%Y-%m-%d %H:%M")) logging.info('working directory %s', self.workdir) logging.info('testcase directory %s', self.tc_dir) sys.path.append(self.workdir) # create connection handles self.c_con = Connection(self, "tb_con") self.c_ctrl = Connection(self, "tb_ctrl") self.event = events(self, 'log/event.log') self.event.create_event('main', self.config.boardname, "Boardname", True) self.wdtdir = self.workdir + "/wdt" if not os.path.exists(self.wdtdir): os.makedirs(self.wdtdir) self.wdtfile = self.wdtdir + "/" + self.cfgfile + ".wdt" self.tbot_start_wdt() # try to connect with ssh self.check_open_fd(self.c_ctrl) self.check_open_fd(self.c_con) # try to get the console of the board ret = self.connect_to_board(self.config.boardname) if ret == False: sys.exit(1)