def _TestNotInVndkDirecotory(self, vndk_dir, vndk_list_names, except_libs):
        """Verifies that VNDK directory doesn't contain specific files.

        Args:
            vndk_dir, The path to the VNDK directory on device.
            vndk_list_names: A list of strings, the categories of the VNDK
                             libraries that should not be in the directory.
            except_libs: A set of strings, the file names of the libraries that
                         are exceptions to this test.
        """
        vndk_lists = vndk_data.LoadVndkLibraryLists(self.data_file_path,
                                                    self._vndk_version,
                                                    *vndk_list_names)
        asserts.assertTrue(vndk_lists, "Cannot load VNDK library lists.")
        vndk_set = set()
        for vndk_list in vndk_lists:
            vndk_set.update(path_utils.TargetBaseName(x) for x in vndk_list)
        vndk_set.difference_update(except_libs)
        logging.debug("vndk set: %s", vndk_set)
        unexpected = [
            x for x in self._ListFiles(vndk_dir)
            if path_utils.TargetBaseName(x) in vndk_set
        ]
        if unexpected:
            logging.error("Unexpected files:\n%s", "\n".join(unexpected))
            asserts.fail("Total number of errors: %d" % len(unexpected))
Ejemplo n.º 2
0
    def output_file_path(self, output_file_path):
        """Set output_file_path.

        Lengths of both file name and path will be checked. If longer than
        maximum allowance, file name will be set to a random name, and
        directory will be set to relative directory.

        Args:
            output_file_path: string, intended path of output xml file
        """
        output_file_path = path_utils.TargetNormPath(output_file_path.strip())
        output_base_name = path_utils.TargetBaseName(output_file_path)
        output_dir_name = path_utils.TargetDirName(output_file_path)

        if len(output_base_name) > utils.MAX_FILENAME_LEN:
            logging.warn(
                'File name of output file "{}" is longer than {}.'.format(
                    output_file_path, utils.MAX_FILENAME_LEN))
            output_base_name = '{}.xml'.format(uuid.uuid4())
            output_file_path = path_utils.JoinTargetPath(
                output_dir_name, output_base_name)
            logging.debug('Output file path is set as "%s".', output_file_path)

        if len(output_file_path) > utils.MAX_PATH_LEN:
            logging.warn(
                'File path of output file "{}" is longer than {}.'.format(
                    output_file_path, utils.MAX_PATH_LEN))
            output_file_path = output_base_name
            logging.debug('Output file path is set as "%s".', output_file_path)

        self._output_file_path = output_file_path
Ejemplo n.º 3
0
    def CreateTestCase(self, path, tag=''):
        '''Create a list of TestCase objects from a binary path.

        Args:
            path: string, absolute path of a binary on device
            tag: string, a tag that will be appended to the end of test name

        Returns:
            A list of BinaryTestCase objects
        '''
        working_directory = self.working_directory[
            tag] if tag in self.working_directory else None
        envp = self.envp[tag] if tag in self.envp else ''
        args = self.args[tag] if tag in self.args else ''
        ld_library_path = self.ld_library_path[
            tag] if tag in self.ld_library_path else None
        profiling_library_path = self.profiling_library_path[
            tag] if tag in self.profiling_library_path else None

        return binary_test_case.BinaryTestCase('',
                                               path_utils.TargetBaseName(path),
                                               path,
                                               tag,
                                               self.PutTag,
                                               working_directory,
                                               ld_library_path,
                                               profiling_library_path,
                                               envp=envp,
                                               args=args)
    def setUpClass(self):
        """Initializes device, temporary directory, and VNDK lists."""
        required_params = [keys.ConfigKeys.IKEY_DATA_FILE_PATH]
        self.getUserParams(required_params)
        self._dut = self.android_devices[0]
        self._temp_dir = tempfile.mkdtemp()
        for target_dir in (self._TARGET_ODM_DIR, self._TARGET_VENDOR_DIR):
            if target_file_utils.IsDirectory(target_dir, self._dut.shell):
                logging.info("adb pull %s %s", target_dir, self._temp_dir)
                self._dut.adb.pull(target_dir, self._temp_dir)
            else:
                logging.info("Skip adb pull %s", target_dir)

        vndk_lists = vndk_data.LoadVndkLibraryLists(
            self.data_file_path, self._dut.vndk_version, vndk_data.SP_HAL,
            vndk_data.LL_NDK, vndk_data.VNDK, vndk_data.VNDK_SP)
        asserts.assertTrue(vndk_lists, "Cannot load VNDK library lists.")

        sp_hal_strings = vndk_lists[0]
        self._sp_hal = [re.compile(x) for x in sp_hal_strings]
        (self._ll_ndk, self._vndk, self._vndk_sp) = (set(
            path_utils.TargetBaseName(path)
            for path in vndk_list) for vndk_list in vndk_lists[1:])

        logging.debug("LL_NDK: %s", self._ll_ndk)
        logging.debug("SP_HAL: %s", sp_hal_strings)
        logging.debug("VNDK: %s", self._vndk)
        logging.debug("VNDK_SP: %s", self._vndk_sp)
Ejemplo n.º 5
0
    def _testSpHalDependency(self, bitness, objs):
        """Scans same-process HAL dependency on vendor partition.

        Returns:
            List of tuples (path, dependency_names). The library with
            disallowed dependencies and list of the dependencies.
        """
        vndk_sp_dir = self._getTargetVndkSpDir(bitness)
        vndk_sp_paths = file_utils.FindFiles(self._shell, vndk_sp_dir, "*.so")
        vndk_sp_names = set(
            path_utils.TargetBaseName(x) for x in vndk_sp_paths)
        logging.info("%s libraries: %s" %
                     (vndk_sp_dir, ", ".join(vndk_sp_names)))
        # map file names to libraries which can be linked to same-process HAL
        linkable_libs = dict()
        for obj in [
                x for x in objs
                if x.bitness == bitness and self._isInSpHalLinkPaths(x)
        ]:
            if obj.name not in linkable_libs:
                linkable_libs[obj.name] = obj
            else:
                linkable_libs[obj.name] = min(linkable_libs[obj.name],
                                              obj,
                                              key=self._spHalLinkOrder)
        # find same-process HAL and dependencies
        sp_hal_libs = set()
        for file_name, obj in linkable_libs.iteritems():
            if any([x.match(file_name) for x in self._SAME_PROCESS_HAL]):
                self._dfsDependencies(obj, sp_hal_libs, linkable_libs)
        logging.info("%d-bit SP HAL libraries: %s" %
                     (bitness, ", ".join([x.name for x in sp_hal_libs])))
        # check disallowed dependencies
        dep_errors = []
        for obj in sp_hal_libs:
            disallowed_libs = [
                x for x in obj.deps if not self._isAllowedSpHalDependency(
                    x, vndk_sp_names, linkable_libs)
            ]
            if disallowed_libs:
                dep_errors.append((obj.target_path, disallowed_libs))
        return dep_errors
Ejemplo n.º 6
0
 def __init__(self, target_path, bitness, deps):
     self.target_path = target_path
     self.name = path_utils.TargetBaseName(target_path)
     self.target_dir = path_utils.TargetDirName(target_path)
     self.bitness = bitness
     self.deps = deps