Esempio n. 1
0
 def __init__(self, test_configs, run_list):
     self.test_run_info = {}
     self.test_run_info[keys.ConfigKeys.IKEY_DATA_FILE_PATH] = getattr(
         test_configs, keys.ConfigKeys.IKEY_DATA_FILE_PATH, "./")
     self.test_configs = test_configs
     self.testbed_configs = self.test_configs[keys.ConfigKeys.KEY_TESTBED]
     self.testbed_name = self.testbed_configs[
         keys.ConfigKeys.KEY_TESTBED_NAME]
     start_time = logger.getLogFileTimestamp()
     self.id = "{}@{}".format(self.testbed_name, start_time)
     # log_path should be set before parsing configs.
     l_path = os.path.join(self.test_configs[keys.ConfigKeys.KEY_LOG_PATH],
                           self.testbed_name, start_time)
     self.log_path = os.path.abspath(l_path)
     self.log_severity = self.test_configs.get(
         keys.ConfigKeys.KEY_LOG_SEVERITY, "INFO").upper()
     logger.setupTestLogger(self.log_path,
                            self.testbed_name,
                            filename="test_run_details.txt",
                            log_severity=self.log_severity)
     self.controller_registry = {}
     self.controller_destructors = {}
     self.run_list = run_list
     self.results = records.TestResult()
     self.running = False
     self.test_cls_instances = []
Esempio n. 2
0
    def __init__(self,
                 vti_endpoint_client,
                 tfc,
                 pab,
                 host_controllers,
                 vti_address=None,
                 in_file=sys.stdin,
                 out_file=sys.stdout,
                 job_pool=False,
                 password=None):
        """Initializes the attributes and the parsers."""
        # cmd.Cmd is old-style class.
        cmd.Cmd.__init__(self, stdin=in_file, stdout=out_file)
        self._build_provider = {}
        self._build_provider["pab"] = pab
        self._build_provider["gcs"] = build_provider_gcs.BuildProviderGCS()
        self._job_pool = job_pool
        if not self._job_pool:
            self._build_provider[
                "local_fs"] = build_provider_local_fs.BuildProviderLocalFS()
            self._build_provider["ab"] = build_provider_ab.BuildProviderAB()
            self._manager = multiprocessing.Manager()
            self._device_status = shared_dict.SharedDict(self._manager)
            self._password = self._manager.Value(ctypes.c_char_p, password)
            try:
                with open(common._VTSLAB_VERSION_TXT, "r") as file:
                    self._vtslab_version = file.readline().strip()
                    file.close()
                    logging.info("VTSLAB version: %s" % self._vtslab_version)
            except IOError as e:
                logging.exception(e)
                logging.error("Version info missing in vtslab package. "
                              "Setting version as %s",
                              common._VTSLAB_VERSION_DEFAULT_VALUE)
                self._vtslab_version = common._VTSLAB_VERSION_DEFAULT_VALUE

        self._vti_endpoint_client = vti_endpoint_client
        self._vti_address = vti_address
        self._tfc_client = tfc
        self._hosts = host_controllers
        self._in_file = in_file
        self._out_file = out_file
        self.prompt = "> "
        self.command_processors = {}
        self.device_image_info = build_info.BuildInfo()
        self.test_result = {}
        self.test_suite_info = build_info.BuildInfo()
        self.tools_info = build_info.BuildInfo()
        self.fetch_info = {}
        self._detailed_fetch_info = {}
        self.test_results = {}
        self._file_lock = file_lock.FileLock()

        if common._ANDROID_SERIAL in os.environ:
            self._serials = [os.environ[common._ANDROID_SERIAL]]
        else:
            self._serials = []

        self.InitCommandModuleParsers()
        self.SetUpCommandProcessors()

        tempdir_base = os.path.join(os.getcwd(), "tmp")
        if not os.path.exists(tempdir_base):
            os.mkdir(tempdir_base)
        self._tmpdir_default = tempfile.mkdtemp(dir=tempdir_base)
        self._tmp_logdir = tempfile.mkdtemp(dir=tempdir_base)
        if not self._job_pool:
            self._logfile_path = logger.setupTestLogger(
                self._tmp_logdir, create_symlink=False)