This commit replaces remove_dep() with hide_dep() so that the dependencies can be kept in deps-insight command. Before this commit, system-to-vendor dependencies will be removed and won't be present in the output of deps-insight command. Test: ./tests/test_vndk.py Test: ./tests/test_command_deps_insight.py Change-Id: I377a81f98a726219e241e79ae6274e9b124de035
89 lines
2.8 KiB
Python
Executable File
89 lines
2.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
from __future__ import print_function
|
|
|
|
import os
|
|
import sys
|
|
import unittest
|
|
|
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
from compat import StringIO, patch
|
|
from vndk_definition_tool import (
|
|
DepsInsightCommand, ModuleInfo, PT_SYSTEM, PT_VENDOR)
|
|
from utils import GraphBuilder
|
|
|
|
|
|
class DepsInsightCommandTest(unittest.TestCase):
|
|
_PATH_FIELD = 0
|
|
_ELF_CLASS_FIELD = 1
|
|
_TAGS_FIELD = 2
|
|
_DEPS_FIELD = 3
|
|
_USERS_FIELD = 4
|
|
_SOURCE_DIRS_FIELD = 5
|
|
|
|
|
|
@classmethod
|
|
def _get_module(cls, strs, mods, path):
|
|
for mod in mods:
|
|
if strs[mod[cls._PATH_FIELD]] == path:
|
|
return mod
|
|
return None
|
|
|
|
|
|
@classmethod
|
|
def _get_module_deps(cls, strs, mods, path):
|
|
mod = cls._get_module(strs, mods, path)
|
|
result = set()
|
|
for deps in mod[cls._DEPS_FIELD]:
|
|
result.update(strs[mods[x][cls._PATH_FIELD]] for x in deps)
|
|
return result
|
|
|
|
|
|
@classmethod
|
|
def _get_module_users(cls, strs, mods, path):
|
|
mod = cls._get_module(strs, mods, path)
|
|
users = mod[cls._USERS_FIELD]
|
|
return set(strs[mods[x][cls._PATH_FIELD]] for x in users)
|
|
|
|
|
|
def test_serialize_data_with_all_deps(self):
|
|
"""compute_degenerated_vndk() should not remove bad dependencies from
|
|
the output of deps-insight. This test checks the existance of bad
|
|
dependencies."""
|
|
|
|
gb = GraphBuilder()
|
|
libfwk = gb.add_lib32(PT_SYSTEM, 'libfwk')
|
|
libvndk = gb.add_lib32(PT_SYSTEM, 'libvndk',
|
|
dt_needed=['libvnd_bad.so'], extra_dir='vndk')
|
|
libvndk_sp = gb.add_lib32(PT_SYSTEM, 'libutils',
|
|
dt_needed=['libvnd_bad.so'],
|
|
extra_dir='vndk-sp')
|
|
libvnd = gb.add_lib32(PT_VENDOR, 'libvnd',
|
|
dt_needed=['libvndk.so', 'libutils.so'])
|
|
libvnd_bad = gb.add_lib32(PT_VENDOR, 'libvnd_bad', extra_dir='vndk-sp')
|
|
gb.resolve()
|
|
|
|
with patch('sys.stderr', StringIO()):
|
|
vndk_sets = gb.graph.compute_degenerated_vndk(set(), None)
|
|
|
|
self.assertNotIn(libvnd_bad, libvndk.deps_good)
|
|
self.assertNotIn(libvnd_bad, libvndk_sp.deps_good)
|
|
|
|
strs, mods = DepsInsightCommand.serialize_data(
|
|
list(gb.graph.all_libs()), vndk_sets, ModuleInfo())
|
|
|
|
deps = self._get_module_deps(strs, mods, libvndk.path)
|
|
self.assertIn(libvnd_bad.path, deps)
|
|
|
|
deps = self._get_module_deps(strs, mods, libvndk_sp.path)
|
|
self.assertIn(libvnd_bad.path, deps)
|
|
|
|
users = self._get_module_users(strs, mods, libvnd_bad.path)
|
|
self.assertIn(libvndk.path, users)
|
|
self.assertIn(libvndk_sp.path, users)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|