1#!/usr/bin/env python3 2 3from __future__ import print_function 4 5import os 6import sys 7sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) 8 9import unittest 10 11from vndk_definition_tool import BA_WARN, BannedLibDict 12 13 14class BannedLibDictTest(unittest.TestCase): 15 def test_add(self): 16 d = BannedLibDict() 17 d.add('libfoo.so', 'test', BA_WARN) 18 x = d.get('libfoo.so') 19 20 self.assertIsNotNone(x) 21 self.assertEqual('libfoo.so', x.name) 22 self.assertEqual('test', x.reason) 23 self.assertEqual(BA_WARN, x.action) 24 25 def test_get(self): 26 d = BannedLibDict.create_default() 27 self.assertIsNotNone(d.get('libbinder.so')) 28 self.assertIsNotNone(d.get('libselinux.so')) 29 self.assertIsNone(d.get('libc.so')) 30 31 def test_is_banned(self): 32 d = BannedLibDict.create_default() 33 self.assertTrue(d.is_banned('/system/lib/libbinder.so')) 34 self.assertTrue(d.is_banned('/system/lib/libselinux.so')) 35 self.assertTrue(d.is_banned('/system/lib64/libbinder.so')) 36 self.assertTrue(d.is_banned('/system/lib64/libselinux.so')) 37 self.assertFalse(d.is_banned('/system/lib64/libc.so')) 38 39 40if __name__ == '__main__': 41 unittest.main() 42 43