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