]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
buildman: Add a test for Boards.scan_defconfigs()
authorSimon Glass <sjg@chromium.org>
Wed, 19 Jul 2023 23:48:15 +0000 (17:48 -0600)
committerSimon Glass <sjg@chromium.org>
Mon, 24 Jul 2023 15:34:10 +0000 (09:34 -0600)
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>
tools/buildman/func_test.py
tools/buildman/test/Kconfig [new file with mode: 0644]
tools/buildman/test/configs/board0_defconfig [new file with mode: 0644]
tools/buildman/test/configs/board2_defconfig [new file with mode: 0644]

index aa7f69a546915cf71a813904fe099a6fabad913a..d423457ea24a9a3124a0a2f461e8b0b729f9fd89 100644 (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'])
+
diff --git a/tools/buildman/test/Kconfig b/tools/buildman/test/Kconfig
new file mode 100644 (file)
index 0000000..a87660c
--- /dev/null
@@ -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 (file)
index 0000000..50e562e
--- /dev/null
@@ -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 (file)
index 0000000..8b76c0a
--- /dev/null
@@ -0,0 +1 @@
+CONFIG_TARGET_BOARD2=y