summaryrefslogtreecommitdiff
path: root/tools/buildman/func_test.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2024-11-08 08:23:42 -0700
committerTom Rini <trini@konsulko.com>2024-11-19 10:04:47 -0600
commita63fcdb9a44b786e8a2ea0653356b092b8ac63e6 (patch)
tree451b43f0e2007ffbb2ef832a38b78c2010045f12 /tools/buildman/func_test.py
parent895b54998e57a5d099c09915341dd9312e0ad7a7 (diff)
buildman: Add a lower-level test for KconfigScanner
This code is tested by test_scan_defconfigs() but it is useful to have some specific tests for the KconfigScanner's operation in U-Boot. Add a test which checks that the values are obtained correctly. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/buildman/func_test.py')
-rw-r--r--tools/buildman/func_test.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index 0ac9fc7e44f..db3c9d63ec4 100644
--- a/tools/buildman/func_test.py
+++ b/tools/buildman/func_test.py
@@ -1067,3 +1067,54 @@ endif
result = self._RunControl('--print-arch', 'board0')
self.assertEqual('arm\n', stdout.getvalue())
self.assertEqual('', stderr.getvalue())
+
+ def test_kconfig_scanner(self):
+ """Test using the kconfig scanner to determine important values
+
+ Note that there is already a test_scan_defconfigs() which checks the
+ higher-level scan_defconfigs() function. This test checks just the
+ scanner itself
+ """
+ src = self._git_dir
+ scanner = boards.KconfigScanner(src)
+
+ # First do a simple sanity check
+ norm = os.path.join(src, 'board0_defconfig')
+ tools.write_file(norm, 'CONFIG_TARGET_BOARD0=y', False)
+ res = scanner.scan(norm, True)
+ self.assertEqual(({
+ 'arch': 'arm',
+ 'cpu': 'armv7',
+ 'soc': '-',
+ 'vendor': 'Tester',
+ 'board': 'ARM Board 0',
+ 'config': 'config0',
+ 'target': 'board0'}, []), res)
+
+ # Check that the SoC cannot be changed and the filename does not affect
+ # the resulting board
+ tools.write_file(norm, '''CONFIG_TARGET_BOARD2=y
+CONFIG_SOC="fred"
+''', False)
+ res = scanner.scan(norm, True)
+ self.assertEqual(({
+ 'arch': 'powerpc',
+ 'cpu': 'ppc',
+ 'soc': 'mpc85xx',
+ 'vendor': 'Tester',
+ 'board': 'PowerPC board 1',
+ 'config': 'config2',
+ 'target': 'board0'}, []), res)
+
+ # Check handling of missing information
+ tools.write_file(norm, '', False)
+ res = scanner.scan(norm, True)
+ self.assertEqual(({
+ 'arch': '-',
+ 'cpu': '-',
+ 'soc': '-',
+ 'vendor': '-',
+ 'board': '-',
+ 'config': '-',
+ 'target': 'board0'},
+ ['WARNING: board0_defconfig: No TARGET_BOARD0 enabled']), res)