Re: [PATCH v4 09/83] buildman: Add a partial test for ensure_board_list()

2023-07-24 Thread Simon Glass
Create a new function which has the non-UI parts of ensure_board_list().
Add some tests for everything except the N: tag.

While we are here, fix the confusing usage of fname inside a loops that
also uses fname.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Add new patch with a partial test for ensure_board_list()

 tools/buildman/board.py   |  6 +-
 tools/buildman/boards.py  | 58 
 tools/buildman/func_test.py   | 66 +++
 tools/buildman/test/boards/board0/MAINTAINERS |  5 ++
 tools/buildman/test/boards/board2/MAINTAINERS |  5 ++
 5 files changed, 126 insertions(+), 14 deletions(-)
 create mode 100644 tools/buildman/test/boards/board0/MAINTAINERS
 create mode 100644 tools/buildman/test/boards/board2/MAINTAINERS

Applied to u-boot-dm, thanks!


[PATCH v4 09/83] buildman: Add a partial test for ensure_board_list()

2023-07-19 Thread Simon Glass
Create a new function which has the non-UI parts of ensure_board_list().
Add some tests for everything except the N: tag.

While we are here, fix the confusing usage of fname inside a loops that
also uses fname.

Signed-off-by: Simon Glass 
---

(no changes since v3)

Changes in v3:
- Add new patch with a partial test for ensure_board_list()

 tools/buildman/board.py   |  6 +-
 tools/buildman/boards.py  | 58 
 tools/buildman/func_test.py   | 66 +++
 tools/buildman/test/boards/board0/MAINTAINERS |  5 ++
 tools/buildman/test/boards/board2/MAINTAINERS |  5 ++
 5 files changed, 126 insertions(+), 14 deletions(-)
 create mode 100644 tools/buildman/test/boards/board0/MAINTAINERS
 create mode 100644 tools/buildman/test/boards/board2/MAINTAINERS

diff --git a/tools/buildman/board.py b/tools/buildman/board.py
index 8ef905b8ce1b..248d8bfff188 100644
--- a/tools/buildman/board.py
+++ b/tools/buildman/board.py
@@ -17,14 +17,14 @@ class Board:
 vendor: Name of vendor (e.g. armltd)
 board_name: Name of board (e.g. integrator)
 target: Target name (use make _defconfig to configure)
-cfg_name: Config name
+cfg_name: Config-file name (in includes/configs/)
 """
 self.target = target
 self.arch = arch
 self.cpu = cpu
-self.board_name = board_name
-self.vendor = vendor
 self.soc = soc
+self.vendor = vendor
+self.board_name = board_name
 self.cfg_name = cfg_name
 self.props = [self.target, self.arch, self.cpu, self.board_name,
   self.vendor, self.soc, self.cfg_name]
diff --git a/tools/buildman/boards.py b/tools/buildman/boards.py
index daf1f037b60a..541c82ff9960 100644
--- a/tools/buildman/boards.py
+++ b/tools/buildman/boards.py
@@ -328,13 +328,21 @@ class MaintainersDatabase:
 
 return ':'.join(self.database[target][1])
 
-def parse_file(self, fname):
+def parse_file(self, srcdir, fname):
 """Parse a MAINTAINERS file.
 
 Parse a MAINTAINERS file and accumulate board status and maintainers
 information in the self.database dict.
 
+defconfig files are used to specify the target, e.g. xxx_defconfig is
+used for target 'xxx'. If there is no defconfig file mentioned in the
+MAINTAINERS file F: entries, then this function does nothing.
+
+The N: name entries can be used to specify a defconfig file using
+wildcards.
+
 Args:
+srcdir (str): Directory containing source code (Kconfig files)
 fname (str): MAINTAINERS file to be parsed
 """
 targets = []
@@ -350,9 +358,12 @@ class MaintainersDatabase:
 maintainers.append(rest)
 elif tag == 'F:':
 # expand wildcard and filter by 'configs/*_defconfig'
-for item in glob.glob(rest):
+glob_path = os.path.join(srcdir, rest)
+for item in glob.glob(glob_path):
 front, match, rear = item.partition('configs/')
-if not front and match:
+if front.endswith('/'):
+front = front[:-1]
+if front == srcdir and match:
 front, match, rear = rear.rpartition('_defconfig')
 if match and not rear:
 targets.append(front)
@@ -361,9 +372,10 @@ class MaintainersDatabase:
 elif tag == 'N:':
 # Just scan the configs directory since that's all we care
 # about
-for dirpath, _, fnames in os.walk('configs'):
-for fname in fnames:
-path = os.path.join(dirpath, fname)
+walk_path = os.walk(os.path.join(srcdir, 'configs'))
+for dirpath, _, fnames in walk_path:
+for cfg in fnames:
+path = os.path.join(dirpath, cfg)
 front, match, rear = path.partition('configs/')
 if not front and match:
 front, match, rear = 
rear.rpartition('_defconfig')
@@ -693,7 +705,7 @@ class Boards:
 return params_list
 
 @classmethod
-def insert_maintainers_info(cls, params_list):
+def insert_maintainers_info(cls, srcdir, params_list):
 """Add Status and Maintainers information to the board parameters list.
 
 Args:
@@ -703,9 +715,10 @@ class Boards:
 list of str: List of warnings collected due to missing status, etc.
 """
 database = MaintainersDatabase()
-for (dirpath, _, filenames) in os.walk('.'):
+for (dirpath, _, filenames) in os.walk(srcdir):
 if 'M