コード例 #1
0
ファイル: test_src_scan.py プロジェクト: mnidza/u-boot-public
 def test_driver(self):
     """Test the Driver class"""
     drv1 = src_scan.Driver('fred')
     drv2 = src_scan.Driver('mary')
     drv3 = src_scan.Driver('fred')
     self.assertEqual("Driver(name='fred')", str(drv1))
     self.assertEqual(drv1, drv3)
     self.assertNotEqual(drv1, drv2)
     self.assertNotEqual(drv2, drv3)
コード例 #2
0
 def test_driver(self):
     """Test the Driver class"""
     i2c = 'I2C_UCLASS'
     compat = {'rockchip,rk3288-grf': 'ROCKCHIP_SYSCON_GRF',
               'rockchip,rk3288-srf': None}
     drv1 = src_scan.Driver('fred', 'fred.c')
     drv2 = src_scan.Driver('mary', 'mary.c')
     drv3 = src_scan.Driver('fred', 'fred.c')
     drv1.uclass_id = i2c
     drv1.compat = compat
     drv2.uclass_id = i2c
     drv2.compat = compat
     drv3.uclass_id = i2c
     drv3.compat = compat
     self.assertEqual(
         "Driver(name='fred', used=False, uclass_id='I2C_UCLASS', "
         "compat={'rockchip,rk3288-grf': 'ROCKCHIP_SYSCON_GRF', "
         "'rockchip,rk3288-srf': None}, priv=)", str(drv1))
     self.assertEqual(drv1, drv3)
     self.assertNotEqual(drv1, drv2)
     self.assertNotEqual(drv2, drv3)
コード例 #3
0
    def test_normalized_name(self):
        """Test operation of get_normalized_compat_name()"""
        prop = FakeProp()
        prop.name = 'compatible'
        prop.value = 'rockchip,rk3288-grf'
        node = FakeNode()
        node.props = {'compatible': prop}

        # get_normalized_compat_name() uses this to check for root node
        node.parent = FakeNode()

        scan = src_scan.Scanner(None, None)
        with test_util.capture_sys_output() as (stdout, _):
            name, aliases = scan.get_normalized_compat_name(node)
        self.assertEqual('rockchip_rk3288_grf', name)
        self.assertEqual([], aliases)
        self.assertEqual(1, len(scan._missing_drivers))
        self.assertEqual({'rockchip_rk3288_grf'}, scan._missing_drivers)
        self.assertEqual('', stdout.getvalue().strip())
        self.assertEqual(EXPECT_WARN, scan._warnings)

        i2c = 'I2C_UCLASS'
        compat = {
            'rockchip,rk3288-grf': 'ROCKCHIP_SYSCON_GRF',
            'rockchip,rk3288-srf': None
        }
        drv = src_scan.Driver('fred', 'fred.c')
        drv.uclass_id = i2c
        drv.compat = compat
        scan._drivers['rockchip_rk3288_grf'] = drv

        scan._driver_aliases['rockchip_rk3288_srf'] = 'rockchip_rk3288_grf'

        with test_util.capture_sys_output() as (stdout, _):
            name, aliases = scan.get_normalized_compat_name(node)
        self.assertEqual('', stdout.getvalue().strip())
        self.assertEqual('rockchip_rk3288_grf', name)
        self.assertEqual([], aliases)
        self.assertEqual(EXPECT_WARN, scan._warnings)

        prop.value = 'rockchip,rk3288-srf'
        with test_util.capture_sys_output() as (stdout, _):
            name, aliases = scan.get_normalized_compat_name(node)
        self.assertEqual('', stdout.getvalue().strip())
        self.assertEqual('rockchip_rk3288_grf', name)
        self.assertEqual(['rockchip_rk3288_srf'], aliases)
        self.assertEqual(EXPECT_WARN, scan._warnings)