From 3350d34fb5d65c1f6c2e47b4d8d955de8cea8658 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 19 Jul 2023 17:48:15 -0600 Subject: [PATCH] buildman: Add a test for Boards.scan_defconfigs() Add a test for this code. It requires some defconfig files and a test Kconfig to work with, so copy these into the temporary directory at the start. Signed-off-by: Simon Glass --- tools/buildman/func_test.py | 37 ++++++++++ tools/buildman/test/Kconfig | 72 ++++++++++++++++++++ tools/buildman/test/configs/board0_defconfig | 1 + tools/buildman/test/configs/board2_defconfig | 1 + 4 files changed, 111 insertions(+) create mode 100644 tools/buildman/test/Kconfig create mode 100644 tools/buildman/test/configs/board0_defconfig create mode 100644 tools/buildman/test/configs/board2_defconfig diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py index aa7f69a546..d423457ea2 100644 --- a/tools/buildman/func_test.py +++ b/tools/buildman/func_test.py @@ -209,6 +209,12 @@ class TestFunctional(unittest.TestCase): # Set to True to report missing blobs self._missing = False + self._buildman_dir = os.path.dirname(os.path.realpath(sys.argv[0])) + self._test_dir = os.path.join(self._buildman_dir, 'test') + + # Set up some fake source files + shutil.copytree(self._test_dir, self._git_dir) + # Avoid sending any output and clear all terminal output terminal.set_print_test_mode() terminal.get_print_test_lines() @@ -779,3 +785,34 @@ Some images are invalid''' CONFIG_LOCALVERSION=y ''', cfg_data) self.assertIn('Not dropping LOCALVERSION_AUTO', stdout.getvalue()) + + def test_scan_defconfigs(self): + """Test scanning the defconfigs to obtain all the boards""" + src = self._git_dir + + # Scan the test directory which contains a Kconfig and some *_defconfig + # files + params = self._boards.scan_defconfigs(src, src) + + # We should get two boards + self.assertEquals(2, len(params)) + first = 0 if params[0]['target'] == 'board0' else 1 + board0 = params[first] + board2 = params[1 - first] + + self.assertEquals('arm', board0['arch']) + self.assertEquals('armv7', board0['cpu']) + self.assertEquals('-', board0['soc']) + self.assertEquals('Tester', board0['vendor']) + self.assertEquals('ARM Board 0', board0['board']) + self.assertEquals('config0', board0['config']) + self.assertEquals('board0', board0['target']) + + self.assertEquals('powerpc', board2['arch']) + self.assertEquals('ppc', board2['cpu']) + self.assertEquals('mpc85xx', board2['soc']) + self.assertEquals('Tester', board2['vendor']) + self.assertEquals('PowerPC board 1', board2['board']) + self.assertEquals('config2', board2['config']) + self.assertEquals('board2', board2['target']) + diff --git a/tools/buildman/test/Kconfig b/tools/buildman/test/Kconfig new file mode 100644 index 0000000000..a87660ce45 --- /dev/null +++ b/tools/buildman/test/Kconfig @@ -0,0 +1,72 @@ +# Board properties +config SYS_ARCH + string + +config SYS_CPU + string + +config SYS_SOC + string + +config SYS_VENDOR + string + +config SYS_BOARD + string + +config SYS_CONFIG_NAME + string + + +# Available targets +config TARGET_BOARD0 + bool "board 9" + +config TARGET_BOARD2 + bool "board 2" + + +# Settings for each board +if TARGET_BOARD0 + +config SYS_ARCH + default "arm" + +config SYS_CPU + default "armv7" + +#config SYS_SOC +# string + +config SYS_VENDOR + default "Tester" + +config SYS_BOARD + default "ARM Board 0" + +config SYS_CONFIG_NAME + default "config0" + +endif + +if TARGET_BOARD2 + +config SYS_ARCH + default "powerpc" + +config SYS_CPU + default "ppc" + +config SYS_SOC + default "mpc85xx" + +config SYS_VENDOR + default "Tester" + +config SYS_BOARD + default "PowerPC board 1" + +config SYS_CONFIG_NAME + default "config2" + +endif diff --git a/tools/buildman/test/configs/board0_defconfig b/tools/buildman/test/configs/board0_defconfig new file mode 100644 index 0000000000..50e562e53b --- /dev/null +++ b/tools/buildman/test/configs/board0_defconfig @@ -0,0 +1 @@ +CONFIG_TARGET_BOARD0=y diff --git a/tools/buildman/test/configs/board2_defconfig b/tools/buildman/test/configs/board2_defconfig new file mode 100644 index 0000000000..8b76c0ae1d --- /dev/null +++ b/tools/buildman/test/configs/board2_defconfig @@ -0,0 +1 @@ +CONFIG_TARGET_BOARD2=y -- 2.39.5