示例#1
0
    def test_build_reconfig_existing_config(self):
        with tempfile.TemporaryDirectory('') as build_dir:
            # Existing .config is a superset, should not touch it
            with open(kunit_kernel.get_kunitconfig_path(build_dir), 'w') as f:
                f.write('CONFIG_KUNIT=y')
            with open(kunit_kernel.get_old_kunitconfig_path(build_dir),
                      'w') as f:
                f.write('CONFIG_KUNIT=y')
            with open(kunit_kernel.get_kconfig_path(build_dir), 'w') as f:
                f.write('CONFIG_KUNIT=y\nCONFIG_KUNIT_TEST=y')

            tree = kunit_kernel.LinuxSourceTree(build_dir)
            mock_build_config = mock.patch.object(tree, 'build_config').start()

            self.assertTrue(tree.build_reconfig(build_dir, make_options=[]))
            self.assertEqual(mock_build_config.call_count, 0)
示例#2
0
    def test_build_reconfig_remove_option(self):
        with tempfile.TemporaryDirectory('') as build_dir:
            # We removed CONFIG_KUNIT_TEST=y from our .kunitconfig...
            with open(kunit_kernel.get_kunitconfig_path(build_dir), 'w') as f:
                f.write('CONFIG_KUNIT=y')
            with open(kunit_kernel.get_old_kunitconfig_path(build_dir),
                      'w') as f:
                f.write('CONFIG_KUNIT=y\nCONFIG_KUNIT_TEST=y')
            with open(kunit_kernel.get_kconfig_path(build_dir), 'w') as f:
                f.write('CONFIG_KUNIT=y\nCONFIG_KUNIT_TEST=y')

            tree = kunit_kernel.LinuxSourceTree(build_dir)
            mock_build_config = mock.patch.object(tree, 'build_config').start()

            # ... so we should trigger a call to build_config()
            self.assertTrue(tree.build_reconfig(build_dir, make_options=[]))
            mock_build_config.assert_called_once_with(build_dir, [])
示例#3
0
    def test_build_reconfig_existing_config(self):
        with tempfile.TemporaryDirectory('') as build_dir:
            # Existing .config is a superset, should not touch it
            with open(kunit_kernel.get_kunitconfig_path(build_dir), 'w') as f:
                f.write('CONFIG_KUNIT=y')
            with open(kunit_kernel.get_old_kunitconfig_path(build_dir),
                      'w') as f:
                f.write('CONFIG_KUNIT=y')
            with open(kunit_kernel.get_kconfig_path(build_dir), 'w') as f:
                f.write('CONFIG_KUNIT=y\nCONFIG_KUNIT_TEST=y')

            tree = kunit_kernel.LinuxSourceTree(build_dir)
            # Stub out the source tree operations, so we don't have
            # the defaults for any given architecture get in the
            # way.
            tree._ops = kunit_kernel.LinuxSourceTreeOperations('none', None)
            mock_build_config = mock.patch.object(tree, 'build_config').start()

            self.assertTrue(tree.build_reconfig(build_dir, make_options=[]))
            self.assertEqual(mock_build_config.call_count, 0)
示例#4
0
    def test_build_reconfig_remove_option(self):
        with tempfile.TemporaryDirectory('') as build_dir:
            # We removed CONFIG_KUNIT_TEST=y from our .kunitconfig...
            with open(kunit_kernel.get_kunitconfig_path(build_dir), 'w') as f:
                f.write('CONFIG_KUNIT=y')
            with open(kunit_kernel.get_old_kunitconfig_path(build_dir),
                      'w') as f:
                f.write('CONFIG_KUNIT=y\nCONFIG_KUNIT_TEST=y')
            with open(kunit_kernel.get_kconfig_path(build_dir), 'w') as f:
                f.write('CONFIG_KUNIT=y\nCONFIG_KUNIT_TEST=y')

            tree = kunit_kernel.LinuxSourceTree(build_dir)
            # Stub out the source tree operations, so we don't have
            # the defaults for any given architecture get in the
            # way.
            tree._ops = kunit_kernel.LinuxSourceTreeOperations('none', None)
            mock_build_config = mock.patch.object(tree, 'build_config').start()

            # ... so we should trigger a call to build_config()
            self.assertTrue(tree.build_reconfig(build_dir, make_options=[]))
            mock_build_config.assert_called_once_with(build_dir, [])