From patchwork Sat Jan 10 23:56:24 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1483 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768089473; bh=HpeR0/bt/1AVpMDUucKfoN4BsHiiN5YZA23CAiOH81c=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=n8CAx+BPIhjQdVElISfQdr6Lce+i+dbjUU6jf3QoxRWV0pbk+rHbiY96IvT/6A7dm mofSajiqgRUUJhAaRAjdqUx1SbKngWXrhiPbiSDtfwvbiyeWJ69XLkFMnZDhqtxzo6 ekg07fSkZWXCcbphQAiaq8rQIbXciO5i9S6WY0ihJaknKLe2z1dvY7aKv9Vl2JF7tw 3MEraBOHMEPyUclrBbRWNzh6rySG3u+ofVFNaDnUpAGR42G+fhE5yrXfdLbCS0L7SH OwT/gK6FTYVCTnKm+0EH6GijY26bv99Ty8qs+sFOJqGGL/Szx4KWD36PzMW4pV5z9v L3W/3/SI/XyVg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1E817692B9 for ; Sat, 10 Jan 2026 16:57:53 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id QAajZb8lHBzm for ; Sat, 10 Jan 2026 16:57:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768089473; bh=HpeR0/bt/1AVpMDUucKfoN4BsHiiN5YZA23CAiOH81c=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=n8CAx+BPIhjQdVElISfQdr6Lce+i+dbjUU6jf3QoxRWV0pbk+rHbiY96IvT/6A7dm mofSajiqgRUUJhAaRAjdqUx1SbKngWXrhiPbiSDtfwvbiyeWJ69XLkFMnZDhqtxzo6 ekg07fSkZWXCcbphQAiaq8rQIbXciO5i9S6WY0ihJaknKLe2z1dvY7aKv9Vl2JF7tw 3MEraBOHMEPyUclrBbRWNzh6rySG3u+ofVFNaDnUpAGR42G+fhE5yrXfdLbCS0L7SH OwT/gK6FTYVCTnKm+0EH6GijY26bv99Ty8qs+sFOJqGGL/Szx4KWD36PzMW4pV5z9v L3W/3/SI/XyVg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0F1BF692B5 for ; Sat, 10 Jan 2026 16:57:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768089472; bh=qctso0NX9pqlzpEH5GQU8NuTrbR4BMTZwZL4qxcnxKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y8VhSbpIJ2yf/0pUj0XtaA/2vLCteg5S2RsPG1Nm/dXiqmWsLYaS5064XKkhwL5O4 BaXJ0vDOG46MLUQzIgFGd6ir9I6GvHlWP34ftorweOfz2GwbtECs9cCrbQfl3lRLsr G7TY2NLDXs9nzrBb5aOpKpZVc+FnUCdGbeeb8izuX/V55CgP3OITNM8sr+pcGJj3ha 86ub8VnHzQ596xtKDmCNfzMrpPt2hRSqxhQcVWO+929OnaAhYHT2lqjiciBIFb8y+1 6l8PamLsWHMO7idqOtCPC5j6Qmj1ahLgbd76OB0RC7mpUqF6tRycnSHj8el9ALEwud Wi6dmGdOmO4nA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3204169186; Sat, 10 Jan 2026 16:57:52 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id mKPg9fqpg0vG; Sat, 10 Jan 2026 16:57:52 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768089468; bh=8Imnvv4MGM8A6qd2QenXHmeeTRz0hq1c8J81Ge6/VBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GtpYIoKs5+uBT1JjbIlBxR93HfvBmRs6gQpmZd9rSGi3yyAulUOCoZ2i7rjVHAsR3 8lJiYeD0+xxUivEMOzxectYrvBAl5wgozE+DUIe/Ug/mLvDDZyNq+V9FTOO8FY5JIX abA8a3hZHoGtsYDTkjkabcNCQc57gNdDeSMNrVdY3nDAAjWjNzBXkIV2SicQkCSqGZ gDDUXQGhNYkTTNoZDEvp+EoJcx5GYbqRD8R+52MXcxHZH+hkdy3EXJvFfYoAU2ORdK SWPagDjWoyUiGScfiiINdBIPdRCLKyy7oZCWLIsTioIjVHSwopwKxM2hKv6L9x1yvx Rrx+Bz14sjm/g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D37D4692B9; Sat, 10 Jan 2026 16:57:47 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sat, 10 Jan 2026 16:56:24 -0700 Message-ID: <20260110235633.1064859-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260110235633.1064859-1-sjg@u-boot.org> References: <20260110235633.1064859-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 6ANLPUERJGZZGPQRUFONHWVOGD263MTH X-Message-ID-Hash: 6ANLPUERJGZZGPQRUFONHWVOGD263MTH X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 11/14] buildman: Fix attribute and line-length warnings in func_test List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Fix pylint warnings: - W0201 (attribute-defined-outside-init): Initialise _builder, _nm_calls, _size_calls, and _captured_make_args in setUp() rather than setting them dynamically - C0301 (line-too-long): Break long lines to stay within 80 characters Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- tools/buildman/func_test.py | 71 ++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py index e9bcd954b5b..4112cde9a7b 100644 --- a/tools/buildman/func_test.py +++ b/tools/buildman/func_test.py @@ -52,8 +52,10 @@ chromeos_peach=VBOOT=${chroot}/build/peach_pit/usr ${vboot} BOARDS = [ ['Active', 'arm', 'armv7', '', 'Tester', 'ARM Board 0', 'board0', ''], ['Active', 'arm', 'armv7', '', 'Tester', 'ARM Board 1', 'board1', ''], - ['Active', 'powerpc', 'powerpc', '', 'Tester', 'PowerPC board 1', 'board2', ''], - ['Active', 'sandbox', 'sandbox', '', 'Tester', 'Sandbox board', 'board4', ''], + ['Active', 'powerpc', 'powerpc', '', 'Tester', 'PowerPC board 1', 'board2', + ''], + ['Active', 'sandbox', 'sandbox', '', 'Tester', 'Sandbox board', 'board4', + ''], ] COMMIT_SHORTLOG = """4aca821 patman: Avoid changing the order of tags @@ -221,6 +223,16 @@ class TestFunctional(unittest.TestCase): # Set to True to report missing blobs self._missing = False + # Builder instance from control module (set by _run_control) + self._builder = None + + # Counters for mock command handlers + self._nm_calls = 0 + self._size_calls = 0 + + # Captured make arguments for testing + self._captured_make_args = [] + self._buildman_dir = os.path.dirname(os.path.realpath(sys.argv[0])) self._test_dir = os.path.join(self._buildman_dir, 'test') @@ -252,11 +264,11 @@ class TestFunctional(unittest.TestCase): args: List of arguments to pass brds: Boards object, or False to pass self._boards, or None to pass None - clean_dir: Used for tests only, indicates that the existing output_dir - should be removed before starting the build - test_thread_exceptions: Uses for tests only, True to make the threads - raise an exception instead of reporting their result. This simulates - a failure in the code somewhere + clean_dir: Used for tests only, indicates that the existing + output_dir should be removed before starting the build + test_thread_exceptions: Uses for tests only, True to make the + threads raise an exception instead of reporting their result. + This simulates a failure in the code somewhere get_builder (bool): Set self._builder to the resulting builder Returns: @@ -376,7 +388,7 @@ class TestFunctional(unittest.TestCase): def _handle_command_nm(self, _args): # Return nm --size-sort output with function sizes that vary between # calls to simulate changes between commits - self._nm_calls = getattr(self, '_nm_calls', 0) + 1 + self._nm_calls += 1 base = self._nm_calls * 0x10 stdout = f'''{0x100 + base:08x} T main {0x80 + base:08x} T board_init @@ -404,7 +416,7 @@ Idx Name Size VMA LMA File off Algn def _handle_command_size(self, args): # Return size output - vary the size based on call count to simulate # changes between commits - self._size_calls = getattr(self, '_size_calls', 0) + 1 + self._size_calls += 1 text = 10000 + self._size_calls * 100 data = 1000 bss = 500 @@ -524,12 +536,15 @@ Idx Name Size VMA LMA File off Algn # Handle missing blobs if self._missing: if 'BINMAN_ALLOW_MISSING=1' in args: - stderr = '''+Image 'main-section' is missing external blobs and is non-functional: intel-descriptor intel-ifwi intel-fsp-m intel-fsp-s intel-vbt -Image 'main-section' has faked external blobs and is non-functional: descriptor.bin fsp_m.bin fsp_s.bin vbt.bin - -Some images are invalid''' + stderr = ("+Image 'main-section' is missing external " + 'blobs and is non-functional: intel-descriptor ' + 'intel-ifwi intel-fsp-m intel-fsp-s intel-vbt\n' + "Image 'main-section' has faked external blobs " + 'and is non-functional: descriptor.bin fsp_m.bin ' + 'fsp_s.bin vbt.bin\n\nSome images are invalid') else: - stderr = "binman: Filename 'fsp.bin' not found in input path" + stderr = ("binman: Filename 'fsp.bin' not found in " + 'input path') elif type(commit) is not str: stderr = self._error.get((brd.target, commit.sequence)) else: @@ -581,8 +596,9 @@ Some images are invalid''' lines = terminal.get_print_test_lines() # Buildman always builds the upstream commit as well - self.assertIn(f'Building {self._commits} commits for {len(BOARDS)} boards', - lines[0].text) + self.assertIn( + f'Building {self._commits} commits for {len(BOARDS)} boards', + lines[0].text) self.assertEqual(self._builder.count, self._total_builds) # Only sandbox should succeed, the others don't have toolchains @@ -824,7 +840,8 @@ Some images are invalid''' # Each board has a mrproper, config, and then one make per commit self.assertEqual(self._make_calls, len(BOARDS) * (self._commits + 1)) self._make_calls = 0 - self._run_control('-b', TEST_BRANCH, '-o', self._output_dir, clean_dir=False) + self._run_control('-b', TEST_BRANCH, '-o', self._output_dir, + clean_dir=False) self.assertEqual(self._make_calls, 0) self.assertEqual(self._builder.count, self._total_builds) self.assertEqual(self._builder.fail, 0) @@ -833,7 +850,8 @@ Some images are invalid''' """The -f flag should force a rebuild""" self._run_control('-b', TEST_BRANCH, '-o', self._output_dir) self._make_calls = 0 - self._run_control('-b', TEST_BRANCH, '-f', '-o', self._output_dir, clean_dir=False) + self._run_control('-b', TEST_BRANCH, '-f', '-o', self._output_dir, + clean_dir=False) # Each board has a config and one make per commit self.assertEqual(self._make_calls, len(BOARDS) * (self._commits + 1)) @@ -860,13 +878,15 @@ Some images are invalid''' # not be rebuilt del self._error['board2', 1] self._make_calls = 0 - self._run_control('-b', TEST_BRANCH, '-o', self._output_dir, clean_dir=False) + self._run_control('-b', TEST_BRANCH, '-o', self._output_dir, + clean_dir=False) self.assertEqual(self._builder.count, self._total_builds) self.assertEqual(self._make_calls, 0) self.assertEqual(self._builder.fail, 1) # Now use the -F flag to force rebuild of the bad commit - self._run_control('-b', TEST_BRANCH, '-o', self._output_dir, '-F', clean_dir=False) + self._run_control('-b', TEST_BRANCH, '-o', self._output_dir, '-F', + clean_dir=False) self.assertEqual(self._builder.count, self._total_builds) self.assertEqual(self._builder.fail, 0) self.assertEqual(self._make_calls, 2) @@ -1072,9 +1092,10 @@ Some images are invalid''' # Multiple fragments passed as comma-separated list extra_args = ['board0', '--fragments', 'f1.config,f2.config'] lines, _cfg_data = self.check_command(*extra_args) - self.assertRegex(lines[0].decode('utf-8'), - r'make O=/.*board0_defconfig\s+f1\.config\s+f2\.config', - 'Test multiple fragments') + self.assertRegex( + lines[0].decode('utf-8'), + r'make O=/.*board0_defconfig\s+f1\.config\s+f2\.config', + 'Test multiple fragments') def test_reproducible(self): """Test that the -r flag works""" @@ -1283,8 +1304,8 @@ endif warn_targets=True) self.assertEqual(2, len(params_list)) self.assertEqual( - ['WARNING: board2_defconfig: Duplicate TARGET_xxx: board2 and other'], - warnings) + ['WARNING: board2_defconfig: Duplicate TARGET_xxx: ' + 'board2 and other'], warnings) # Remove the TARGET_BOARD0 Kconfig option lines = [b'' if line == b'config TARGET_BOARD2\n' else line