1 #!/usr/bin/env python3 2 3 from __future__ import print_function 4 5 import os 6 import sys 7 sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) 8 9 import unittest 10 11 from vndk_definition_tool import ModuleInfo 12 13 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) 14 15 16 class ModuleInfoTest(unittest.TestCase): 17 def test_default(self): 18 m = ModuleInfo.load_from_path_or_default(None) 19 self.assertEqual([], m.get_module_path('/system/lib64/libA.so')) 20 21 def test_get_module_path(self): 22 json_path = os.path.join(SCRIPT_DIR, 'testdata', 'test_module_info', 23 'module-info.json') 24 m = ModuleInfo.load_from_path_or_default(json_path) 25 26 self.assertEqual(['system/core/libA'], 27 m.get_module_path('/system/lib64/libA.so')) 28 self.assertEqual(['frameworks/base/libB'], 29 m.get_module_path('/system/lib64/libB.so')) 30 self.assertEqual(['frameworks/base/libC'], 31 m.get_module_path('/system/lib64/libC.so')) 32 self.assertEqual(['frameworks/base/libC'], 33 m.get_module_path('/system/lib64/hw/libC.so')) 34 35 self.assertEqual( 36 [], m.get_module_path('/system/lib64/libdoes_not_exist.so')) 37 38 39 if __name__ == '__main__': 40 unittest.main() 41