def _download_crashtooluploader(self):
        """
        Download CrashToolUploader from official url and return the destination path.

        :return: path to CrashToolUploader. In case of errors returns an empty string
        """
        crashtooluploader_path = ""
        try:
            art_mgr = EquipmentManager().get_artifact_manager(
                "ARTIFACT_MANAGER")
            crashtooluploader_path = art_mgr.get_artifact(
                self.CRASHTOOLUPLOADER_NAME, self.CRASHTOOLUPLOADER_URI)
        except Exception as artmgr_exception:
            self.logger.debug("Unable to download {0} ! ({1})".format(
                self.CRASHTOOLUPLOADER_NAME, str(artmgr_exception)))
            self.logger.debug("Use crashtooluploader from {0} !".format(
                self.CRASHTOOLUPLOADER_DEFAULT_PATH))
            crashtooluploader_path = self.CRASHTOOLUPLOADER_DEFAULT_PATH
        return crashtooluploader_path
Пример #2
0
    def set_up(self):
        """
        Initialize the test

        :rtype: tuple
        :return: ACS verdict and msg output
        """
        verdict = Global.SUCCESS
        msg = ""

        UseCaseBase.set_up(self)

        if self._its_package_name is None:
            return (Global.FAILURE, "You need to specify a ITS_NAME value.")

        if self._artifactory_uri is None:
            self._logger.info("Default artifactory path will be used")

        if self._test_timeout is None:
            self._test_timeout = 360000
            self._logger.info("Default test timeout will be used: %s.",
                              self._test_timeout)

        art_mgr = EquipmentManager().get_artifact_manager("ARTIFACT_MANAGER")

        # Download ITS package
        self._ITS_path = art_mgr.get_artifact(self._its_package_name,
                                              self._artifactory_uri)

        # Check if zipfile or local cache
        fileName, fileExtension = os.path.splitext(self._ITS_path)
        if fileExtension.lower() == ".zip":
            # Unzip CTS package
            self._ITS_path = art_mgr.unzip_artifact(self._ITS_path)
            self._logger.debug("Unzip with ArtifactoryManager in: %s",
                               self._ITS_path)

        #Set python path for the subprocesses created for the actual tests
        os.environ['PYTHONPATH'] = os.path.join(
            self._ITS_path, 'android-cts-verifier/CameraITS/pymodules')
        #Set the path for this python script
        sys.path.append(
            os.path.join(self._ITS_path,
                         'android-cts-verifier/CameraITS/pymodules'))

        #Install CTSVerifier and set permissions.
        self._logger.info("Installing CtsVerifier.apk")
        cmd = [
            'adb', 'install',
            os.path.join(self._ITS_path,
                         'android-cts-verifier/CtsVerifier.apk')
        ]
        subprocess.call(cmd, stdout=self.devnull, stderr=self.devnull)
        self._logger.info("Granting permissions for CtsVerifier")
        cmd = [
            'adb', 'shell', 'pm', 'grant',
            'com.android.cts.verifier android.permission.CAMERA'
        ]
        subprocess.call(cmd, stdout=self.devnull, stderr=self.devnull)
        self._logger.info("starting CtsVerifier")
        cmd = [
            'adb', 'shell', 'am', 'start',
            'com.android.cts.verifier/.camera.its.ItsTestActivity'
        ]
        subprocess.call(cmd, stdout=self.devnull, stderr=self.devnull)

        #turn on stay awake on the device
        cmd = ['adb', 'shell', 'svc', 'power', 'stayon', 'usb']
        subprocess.call(cmd, stdout=self.devnull, stderr=self.devnull)

        #Find out how many cams the device has
        import its.device
        its_session = its.device.ItsSession()
        self.camids = its_session.get_camera_ids()

        #build a dictionary with lists of tests.
        self.testroot = os.path.join(self._ITS_path,
                                     'android-cts-verifier/CameraITS/tests')
        for s in self._scenes:
            self._tests[s] = []
            files = os.listdir(os.path.join(self.testroot, s))
            for f in files:
                if f[-3:] == '.py':
                    self._tests[s].append(f)

        return verdict, msg