def RunTestcase(self, testcase):
        """Runs the given testcase and asserts the result.

        Args:
            testcase: a LinuxKselftestTestcase object, specifies which
                test case to run.
        """
        if not testcase:
            asserts.skip("Test is not supported on this abi.")

        chmod_cmd = "chmod -R 755 %s" % path_utils.JoinTargetPath(
            config.KSFT_DIR, testcase.testsuite)
        cd_cmd = "cd %s" % path_utils.JoinTargetPath(
            config.KSFT_DIR, testcase.testsuite)

        cmd = [
            chmod_cmd,
            "%s && %s" % (cd_cmd, testcase.test_cmd)
        ]
        logging.info("Executing: %s", cmd)

        result = self._shell.Execute(cmd)
        logging.info("EXIT_CODE: %s:", result[const.EXIT_CODE])

        asserts.assertFalse(
            any(result[const.EXIT_CODE]),
            "%s failed." % testcase.testname)
Exemplo n.º 2
0
 def testSyscall_uselib(self):
     """Testcase to verify syscall [uselib] is disabled."""
     if self.dut.is64Bit:
         logging.info("testing syscall: uselib [%d]",
                      self.AARCH64__NR_uselib)
         asserts.assertTrue(self.SyscallDisabled(self.AARCH64__NR_uselib),
                            "syscall [uselib] should be disabled")
     else:
         asserts.skip("32-bit not supported")
Exemplo n.º 3
0
 def testSyscall_open_by_handle_at(self):
     """Testcase to verify syscall [open_by_handle_at] is disabled."""
     if self.dut.is64Bit:
         logging.info("testing syscall: open_by_handle_at [%d]",
                      self.ARCH64__NR_open_by_handle_at)
         asserts.assertTrue(self.SyscallDisabled(self.ARCH64__NR_open_by_handle_at),
                            "syscall [open_by_handle_at] should be disabled")
     else:
         asserts.skip("32-bit not supported")
Exemplo n.º 4
0
    def testCameraNormal(self):
        """A simple testcase which just emulates a normal usage pattern."""
        version = self.dut.hal.camera.common.GetAttributeValue(
            "module_api_version")
        logging.info("version: %s", hex(version))
        if version != self.VERSION_2_1 and version != self.VERSION_2_4:
            asserts.skip("HAL version %s is neither v2.1 nor v2.4" % version)

        result = self.dut.hal.camera.get_number_of_cameras()
        count = result.return_type.scalar_value.int32_t
        logging.info("# of found cameras: %s", count)
        asserts.assertTrue(count > 0, "no camera found")
        for index in range(0, count):
            arg = self.dut.hal.camera.camera_info_t(facing=0)
            logging.info(self.dut.hal.camera.get_camera_info(index, arg))

        # uncomment when undefined function is handled gracefully.
        # self.dut.hal.camera.init()
        def camera_device_status_change(callbacks, camera_id, new_status):
            self.call_count_camera_device_status_change += 1
            logging.info("camera_device_status_change")
            logging.info("camera_device_status_change: camera_id = %s",
                         camera_id)
            logging.info("camera_device_status_change: new_status = %s",
                         new_status)
            logging.info("camera_device_status_change: callbacks = %s",
                         callbacks)

        def torch_mode_status_change(callbacks, camera_id, new_status):
            self.profiling.StopHostProfiling(
                "callback_latency_torch_mode_status_change")
            self.call_count_torch_mode_status_change += 1
            logging.info("torch_mode_status_change")
            logging.info("torch_mode_status_change: camera_id = %s", camera_id)
            logging.info("torch_mode_status_change: new_status = %s",
                         new_status)
            logging.info("torch_mode_status_change: callbacks = %s", callbacks)

        my_callback = self.dut.hal.camera.camera_module_callbacks_t(
            camera_device_status_change, torch_mode_status_change)
        self.dut.hal.camera.set_callbacks(my_callback)
        self.profiling.StartHostProfiling(
            "callback_latency_torch_mode_status_change")
        self.dut.hal.camera.common.methods.open()  # note args are skipped
        retries = 0
        while (self.call_count_torch_mode_status_change < 1
               and retries < self.MAX_RETRIES):
            logging.info("waiting %s %s",
                         self.call_count_camera_device_status_change,
                         self.call_count_torch_mode_status_change)
            time.sleep(1)
            retries += 1
        if self.call_count_torch_mode_status_change < 1:
            # The above callback was not always called (~50% of chance).
            logging.error("Callback not called within %s seconds",
                          self.MAX_RETRIES)
    def testCameraNormal(self):
        """A simple testcase which just emulates a normal usage pattern."""
        version = self.dut.hal.camera.common.GetAttributeValue("version")
        logging.info("version: %s", hex(version))
        if version != self.VERSION_3_4:
            asserts.skip("HAL version != v3.4")

        self.dut.hal.camera.common.module.methods.open()  # note args are skipped

        ops = self.dut.hal.camera.GetAttributeValue("ops")
        logging.info("ops: %s", ops)
        ops.flush(None)
Exemplo n.º 6
0
 def testFirstApiLevel(self):
     """Test that device launched with O or later."""
     try:
         firstApiLevel = self.getProp("ro.product.first_api_level",
                                      required=False)
         if firstApiLevel is None:
             asserts.skip("ro.product.first_api_level undefined")
         firstApiLevel = int(firstApiLevel)
         asserts.assertTrue(
             firstApiLevel >= ANDROID_O_API_VERSION,
             "VTS can only be run for new launches in O or above")
     except ValueError:
         asserts.fail("Unexpected value returned from getprop")
Exemplo n.º 7
0
    def testProcPerUidTimes(self):
        # TODO: make these files mandatory once they're in AOSP
        try:
            filepaths = self.dut.adb.shell("find /proc/uid -name time_in_state")
        except:
            asserts.skip("/proc/uid/ directory does not exist and is optional")

        asserts.skipIf(not filepaths,
                       "per-UID time_in_state files do not exist and are optional")

        filepaths = filepaths.splitlines()
        for filepath in filepaths:
            target_file_utils.assertPermissionsAndExistence(
                self.shell, filepath, target_file_utils.IsReadOnly
            )
            file_content = self.ReadFileContent(filepath)