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 <sjg@chromium.org>
This commit is contained in:
Simon Glass 2023-07-19 17:48:15 -06:00
parent b27e989197
commit 3350d34fb5
4 changed files with 111 additions and 0 deletions

View file

@ -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'])

View file

@ -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

View file

@ -0,0 +1 @@
CONFIG_TARGET_BOARD0=y

View file

@ -0,0 +1 @@
CONFIG_TARGET_BOARD2=y