def setUpClass(self):
        """Creates a mirror and turns on the framework-layer NFC service."""
        self.dut = self.registerController(android_device)[0]

        self.getUserParams(opt_param_names=[PASSTHROUGH_MODE_KEY])

        self.dut.shell.InvokeTerminal("one")
        self.dut.shell.one.Execute("setenforce 0")  # SELinux permissive mode
        if not precondition_utils.CanRunHidlHalTest(self, self.dut,
                                                    self.dut.shell.one):
            self._skip_all_testcases = True
            return

        self.dut.shell.one.Execute("svc nfc disable")  # Turn off
        time.sleep(5)

        if getattr(self, PASSTHROUGH_MODE_KEY, True):
            self.dut.shell.one.Execute(
                "setprop vts.hal.vts.hidl.get_stub true")
        else:
            self.dut.shell.one.Execute(
                "setprop vts.hal.vts.hidl.get_stub false")

        self.dut.hal.InitHidlHal(target_type="nfc",
                                 target_basepaths=self.dut.libPaths,
                                 target_version=1.0,
                                 target_package="android.hardware.nfc",
                                 target_component_name="INfc",
                                 bits=int(self.abi_bitness))

        if self.coverage.enabled:
            self.coverage.LoadArtifacts()
            self.coverage.InitializeDeviceCoverage(self._dut)
    def setUpClass(self):
        """Creates a mirror and turns on the framework-layer CONTEXTHUB service."""
        self.dut = self.registerController(android_device)[0]

        self.dut.shell.InvokeTerminal("one")
        self.dut.shell.one.Execute("setenforce 0")  # SELinux permissive mode
        if not precondition_utils.CanRunHidlHalTest(self, self.dut,
                                                    self.dut.shell.one):
            self._skip_all_testcases = True
            return

        if self.profiling.enabled:
            self.profiling.EnableVTSProfiling(self.dut.shell.one)

        # Bring down the Android runtime so it doesn't interfere with the test
        #self.dut.shell.one.Execute("stop")

        self.dut.hal.InitHidlHal(target_type="contexthub",
                                 target_basepaths=self.dut.libPaths,
                                 target_version=1.0,
                                 target_package="android.hardware.contexthub",
                                 target_component_name="IContexthub",
                                 bits=int(self.abi_bitness))

        self.types = self.dut.hal.contexthub.GetHidlTypeInterface("types")
        logging.info("types: %s", self.types)
    def setUpClass(self):
        """Creates a mirror and turns on the framework-layer GNSS service."""
        self.dut = self.android_devices[0]

        self.passthrough_mode = self.getUserParam(
            keys.ConfigKeys.IKEY_PASSTHROUGH_MODE, default_value=True)

        self.dut.shell.Execute("setenforce 0")  # SELinux permissive mode
        if not precondition_utils.CanRunHidlHalTest(self, self.dut,
                                                    self.dut.shell.default):
            self._skip_all_testcases = True
            return

        mode = "true" if self.passthrough_mode else "false"
        self.dut.shell.Execute("setprop %s %s" % (self.SYSPROP_GETSTUB, mode))

        self.dut.hal.InitHidlHal(target_type="gnss",
                                 target_basepaths=self.dut.libPaths,
                                 target_version=1.0,
                                 target_package="android.hardware.gnss",
                                 target_component_name="IGnss",
                                 bits=int(self.abi_bitness))

        if self.coverage.enabled:
            self.coverage.LoadArtifacts()
            self.coverage.InitializeDeviceCoverage(self._dut)
Exemplo n.º 4
0
    def setUpClass(self):
        """Creates a mirror and init vehicle hal."""
        self.dut = self.registerController(android_device)[0]

        self.dut.shell.InvokeTerminal("one")
        self.dut.shell.one.Execute("setenforce 0")  # SELinux permissive mode
        if not precondition_utils.CanRunHidlHalTest(self, self.dut,
                                                    self.dut.shell.one):
            self._skip_all_testcases = True
            return

        if self.profiling.enabled:
            self.profiling.EnableVTSProfiling(self.dut.shell.one)

        self.dut.hal.InitHidlHal(target_type="radio",
                                 target_basepaths=self.dut.libPaths,
                                 target_version=1.0,
                                 target_package="android.hardware.radio",
                                 target_component_name="IRadio",
                                 hw_binder_service_name="Radio",
                                 bits=int(self.abi_bitness))

        self.radio = self.dut.hal.radio  # shortcut
        self.radio_types = self.dut.hal.radio.GetHidlTypeInterface("types")
        logging.info("Radio types: %s", self.radio_types)
    def setUpClass(self):
        """Creates a mirror and init tv hdmi cec hal service."""
        self.dut = self.registerController(android_device)[0]

        self.dut.shell.InvokeTerminal("one")
        self.dut.shell.one.Execute("setenforce 0")  # SELinux permissive mode
        if not precondition_utils.CanRunHidlHalTest(self, self.dut,
                                                    self.dut.shell.one):
            self._skip_all_testcases = True
            return

        self.dut.shell.one.Execute("setprop vts.hal.vts.hidl.get_stub true")

        if self.coverage.enabled:
            self.coverage.LoadArtifacts()
            self.coverage.InitializeDeviceCoverage(self.dut)

        if self.profiling.enabled:
            self.profiling.EnableVTSProfiling(self.dut.shell.one)

        self.dut.hal.InitHidlHal(target_type="tv_cec",
                                 target_basepaths=self.dut.libPaths,
                                 target_version=1.0,
                                 target_package="android.hardware.tv.cec",
                                 target_component_name="IHdmiCec",
                                 bits=int(self.abi_bitness))

        time.sleep(1)  # Wait for hal to be ready

        self.vtypes = self.dut.hal.tv_cec.GetHidlTypeInterface("types")
        logging.info("tv_cec types: %s", self.vtypes)
    def setUpClass(self):
        """Checks precondition."""
        self._initial_test_case_cnt = 0
        super(HidlHalGTest, self).setUpClass()
        if not hasattr(self, "_target_hals"):
            self._target_hals = []

        opt_params = [
            keys.ConfigKeys.IKEY_SKIP_IF_THERMAL_THROTTLING,
            keys.ConfigKeys.IKEY_DISABLE_CPU_FREQUENCY_SCALING
        ]
        self.getUserParams(opt_param_names=opt_params)

        self._skip_if_thermal_throttling = self.getUserParam(
            keys.ConfigKeys.IKEY_SKIP_IF_THERMAL_THROTTLING,
            default_value=False)
        self._disable_cpu_frequency_scaling = self.getUserParam(
            keys.ConfigKeys.IKEY_DISABLE_CPU_FREQUENCY_SCALING,
            default_value=True)

        if not self.isSkipAllTests():
            self._cpu_freq = cpu_frequency_scaling.CpuFrequencyScalingController(
                self._dut)
            if self._disable_cpu_frequency_scaling:
                logging.info("Disable CPU frequency scaling")
                self._cpu_freq.DisableCpuScaling()
        else:
            self._cpu_freq = None

        if not self.isSkipAllTests():
            ret = precondition_utils.CanRunHidlHalTest(
                self, self._dut, self.shell, self.run_as_compliance_test)
            if not ret:
                self.skipAllTests("HIDL HAL precondition check failed.")

        # Extend timeout if there are multiple service instance combinations.
        if (not self.isSkipAllTests() and self._initial_test_case_cnt
                and len(self.testcases) > self._initial_test_case_cnt):
            self.resetTimeout(self.timeout * len(self.testcases) /
                              float(self._initial_test_case_cnt))

        if self.sancov.enabled and self._target_hals:
            self.sancov.InitializeDeviceCoverage(self._dut, self._target_hals)
        if self.coverage.enabled and self._target_hals:
            self.coverage.SetHalNames(self._target_hals)
            self.coverage.SetCoverageReportFilePrefix(self.test_module_name +
                                                      self.abi_bitness)
Exemplo n.º 7
0
    def setUpClass(self):
        self.dut = self.registerController(android_device)[0]

        self.dut.shell.InvokeTerminal("one")
        self.dut.shell.one.Execute("setenforce 0")  # SELinux permissive mode
        if not precondition_utils.CanRunHidlHalTest(self, self.dut,
                                                    self.dut.shell.one):
            self._skip_all_testcases = True
            return

        self.dut.hal.InitHidlHal(target_type="media_omx",
                                 target_basepaths=self.dut.libPaths,
                                 target_version=1.0,
                                 target_package="android.hardware.media.omx",
                                 target_component_name="IOmxStore",
                                 bits=int(self.abi_bitness))

        if self.coverage.enabled:
            self.coverage.LoadArtifacts()
            self.coverage.InitializeDeviceCoverage(self._dut)
    def setUpClass(self):
        """Creates a mirror and turns on the framework-layer SENSORS service."""
        self.dut = self.registerController(android_device)[0]

        self.dut.shell.InvokeTerminal("one")
        self.dut.shell.one.Execute("setenforce 0")  # SELinux permissive mode
        if not precondition_utils.CanRunHidlHalTest(self, self.dut,
                                                    self.dut.shell.one):
            self._skip_all_testcases = True
            return

        # Test using the binderized mode
        self.dut.shell.one.Execute("setprop vts.hal.vts.hidl.get_stub true")

        self.dut.hal.InitHidlHal(target_type="sensors",
                                 target_basepaths=self.dut.libPaths,
                                 target_version=1.0,
                                 target_package="android.hardware.sensors",
                                 target_component_name="ISensors",
                                 bits=int(self.abi_bitness))
Exemplo n.º 9
0
    def setUpClass(self):
        """Basic setup process for host-side hidl hal tests.

        Test precondition check, prepare for profiling and coverage measurement
        if enabled.
        """
        # Testability check.
        if not precondition_utils.CanRunHidlHalTest(
                self, self.dut, self.shell, self.run_as_compliance_test):
            self.skipAllTests(
                "precondition check for hidl hal tests didn't pass")
            return

        # Initialization for coverage measurement.
        if self.coverage.enabled and self.coverage.global_coverage:
            self.coverage.InitializeDeviceCoverage(self.dut)
            if self.TEST_HAL_SERVICES:
                self.coverage.SetHalNames(self.TEST_HAL_SERVICES)
                self.coverage.SetCoverageReportFilePrefix(
                    self.test_module_name + self.abi_bitness)

        # Enable profiling.
        if self.profiling.enabled:
            self.profiling.EnableVTSProfiling(self.shell)
    def setUpClass(self):
        """Creates a mirror and init vehicle hal."""
        self.dut = self.registerController(android_device)[0]

        self.dut.shell.InvokeTerminal("one")
        self.dut.shell.one.Execute("setenforce 0")  # SELinux permissive mode
        if not precondition_utils.CanRunHidlHalTest(self, self.dut,
                                                    self.dut.shell.one):
            self._skip_all_testcases = True
            return

        results = self.dut.shell.one.Execute("id -u system")
        system_uid = results[const.STDOUT][0].strip()
        logging.info("system_uid: %s", system_uid)

        if self.coverage.enabled:
            self.coverage.LoadArtifacts()
            self.coverage.InitializeDeviceCoverage(self.dut)

        if self.profiling.enabled:
            self.profiling.EnableVTSProfiling(self.dut.shell.one)

        self.dut.hal.InitHidlHal(
            target_type="vehicle",
            target_basepaths=self.dut.libPaths,
            target_version=2.0,
            target_package="android.hardware.automotive.vehicle",
            target_component_name="IVehicle",
            bits=int(self.abi_bitness))

        self.vehicle = self.dut.hal.vehicle  # shortcut
        self.vehicle.SetCallerUid(system_uid)
        self.vtypes = self.dut.hal.vehicle.GetHidlTypeInterface("types")
        logging.info("vehicle types: %s", self.vtypes)
        asserts.assertEqual(0x00ff0000, self.vtypes.VehiclePropertyType.MASK)
        asserts.assertEqual(0x0f000000, self.vtypes.VehicleArea.MASK)
Exemplo n.º 11
0
    def setUpClass(self):
        '''Prepare class, push binaries, set permission, create test cases.'''
        required_params = [
            keys.ConfigKeys.IKEY_DATA_FILE_PATH,
        ]
        opt_params = [
            keys.ConfigKeys.IKEY_BINARY_TEST_SOURCE,
            keys.ConfigKeys.IKEY_BINARY_TEST_WORKING_DIRECTORY,
            keys.ConfigKeys.IKEY_BINARY_TEST_ENVP,
            keys.ConfigKeys.IKEY_BINARY_TEST_ARGS,
            keys.ConfigKeys.IKEY_BINARY_TEST_LD_LIBRARY_PATH,
            keys.ConfigKeys.IKEY_BINARY_TEST_PROFILING_LIBRARY_PATH,
            keys.ConfigKeys.IKEY_BINARY_TEST_DISABLE_FRAMEWORK,
            keys.ConfigKeys.IKEY_BINARY_TEST_STOP_NATIVE_SERVERS,
            keys.ConfigKeys.IKEY_NATIVE_SERVER_PROCESS_NAME,
        ]
        self.getUserParams(req_param_names=required_params,
                           opt_param_names=opt_params)

        # test-module-name is required in binary tests.
        self.getUserParam(keys.ConfigKeys.KEY_TESTBED_NAME,
                          error_if_not_found=True)

        logging.info("%s: %s", keys.ConfigKeys.IKEY_DATA_FILE_PATH,
                     self.data_file_path)

        self.binary_test_source = self.getUserParam(
            keys.ConfigKeys.IKEY_BINARY_TEST_SOURCE, default_value=[])

        self.working_directory = {}
        if hasattr(self, keys.ConfigKeys.IKEY_BINARY_TEST_WORKING_DIRECTORY):
            self.binary_test_working_directory = map(
                str, self.binary_test_working_directory)
            for token in self.binary_test_working_directory:
                tag = ''
                path = token
                if self.TAG_DELIMITER in token:
                    tag, path = token.split(self.TAG_DELIMITER)
                self.working_directory[tag] = path

        self.envp = {}
        if hasattr(self, keys.ConfigKeys.IKEY_BINARY_TEST_ENVP):
            self.binary_test_envp = map(str, self.binary_test_envp)
            for token in self.binary_test_envp:
                tag = ''
                path = token
                split = token.find(self.TAG_DELIMITER)
                if split >= 0:
                    tag, arg = token[:split], token[split +
                                                    len(self.TAG_DELIMITER):]
                if tag in self.envp:
                    self.envp[tag] += ' %s' % path
                else:
                    self.envp[tag] = path

        self.args = {}
        if hasattr(self, keys.ConfigKeys.IKEY_BINARY_TEST_ARGS):
            self.binary_test_args = map(str, self.binary_test_args)
            for token in self.binary_test_args:
                tag = ''
                arg = token
                split = token.find(self.TAG_DELIMITER)
                if split >= 0:
                    tag, arg = token[:split], token[split +
                                                    len(self.TAG_DELIMITER):]
                if tag in self.args:
                    self.args[tag] += ' %s' % arg
                else:
                    self.args[tag] = arg

        self.ld_library_path = {
            self.DEFAULT_TAG_32: self.DEFAULT_LD_LIBRARY_PATH_32,
            self.DEFAULT_TAG_64: self.DEFAULT_LD_LIBRARY_PATH_64,
        }
        if hasattr(self, keys.ConfigKeys.IKEY_BINARY_TEST_LD_LIBRARY_PATH):
            self.binary_test_ld_library_path = map(
                str, self.binary_test_ld_library_path)
            for token in self.binary_test_ld_library_path:
                tag = ''
                path = token
                if self.TAG_DELIMITER in token:
                    tag, path = token.split(self.TAG_DELIMITER)
                if tag in self.ld_library_path:
                    self.ld_library_path[tag] = '{}:{}'.format(
                        path, self.ld_library_path[tag])
                else:
                    self.ld_library_path[tag] = path

        self.profiling_library_path = {
            self.DEFAULT_TAG_32: self.DEFAULT_PROFILING_LIBRARY_PATH_32,
            self.DEFAULT_TAG_64: self.DEFAULT_PROFILING_LIBRARY_PATH_64,
        }
        if hasattr(self,
                   keys.ConfigKeys.IKEY_BINARY_TEST_PROFILING_LIBRARY_PATH):
            self.binary_test_profiling_library_path = map(
                str, self.binary_test_profiling_library_path)
            for token in self.binary_test_profiling_library_path:
                tag = ''
                path = token
                if self.TAG_DELIMITER in token:
                    tag, path = token.split(self.TAG_DELIMITER)
                self.profiling_library_path[tag] = path

        self._dut = self.android_devices[0]
        self.shell = self._dut.shell

        if self.coverage.enabled and self.coverage.global_coverage:
            self.coverage.LoadArtifacts()
            self.coverage.InitializeDeviceCoverage(self._dut)

        # TODO: only set permissive mode for userdebug and eng build.
        self.shell.Execute("setenforce 0")  # SELinux permissive mode

        if not precondition_utils.CanRunHidlHalTest(self, self._dut,
                                                    self.shell):
            self._skip_all_testcases = True

        self.testcases = []
        self.tags = set()
        self.CreateTestCases()
        cmd = list(
            set('chmod 755 %s' % test_case.path
                for test_case in self.testcases))
        cmd_results = self.shell.Execute(cmd)
        if any(cmd_results[const.EXIT_CODE]):
            logging.error(
                'Failed to set permission to some of the binaries:\n'
                '%s\n%s', cmd, cmd_results)

        stop_requested = False

        if getattr(self, keys.ConfigKeys.IKEY_BINARY_TEST_DISABLE_FRAMEWORK,
                   False):
            # Stop Android runtime to reduce interference.
            logging.debug("Stops the Android framework.")
            self._dut.stop()
            stop_requested = True

        if getattr(self, keys.ConfigKeys.IKEY_BINARY_TEST_STOP_NATIVE_SERVERS,
                   False):
            logging.debug("Stops all properly configured native servers.")
            results = self._dut.setProp(self.SYSPROP_VTS_NATIVE_SERVER, "1")
            stop_requested = True

        if stop_requested:
            native_server_process_names = getattr(
                self, keys.ConfigKeys.IKEY_NATIVE_SERVER_PROCESS_NAME, [])
            if native_server_process_names:
                for native_server_process_name in native_server_process_names:
                    while True:
                        cmd_result = self.shell.Execute("ps -A")
                        if cmd_result[const.EXIT_CODE][0] != 0:
                            logging.error("ps command failed (exit code: %s",
                                          cmd_result[const.EXIT_CODE][0])
                            break
                        if (native_server_process_name
                                not in cmd_result[const.STDOUT][0]):
                            logging.info("Process %s not running",
                                         native_server_process_name)
                            break
                        logging.info("Checking process %s",
                                     native_server_process_name)
                        time.sleep(1)