binman: test: Fix iMX8 coverage and test-numbering
Subsystems (2)
cover binman: test: Fix iMX8 coverage and test-numbering
From: Simon Glass <[email protected]>
A long-standard niggle with Binman is that the iMX8 integration does not have full test coverage. Recent work has made a significant improvement but there is still a special exception for this code.
This series adds some extra tests to get to 100% code coverage.
It also tidies up the test-file numbering, which has rotted a little.
Simon Glass (6):
binman: test: Renumber duplicate test-file prefixes
binman: test: Drop the number prefix from non-dts test files
binman: test: Capture output from tests with warnings
binman: test: Fix code coverage for iMX8 and cst bintool
binman: Remove the coverage allow_failures list
binman: Drop the allow_failures parameter from run_test_coverage()
tools/binman/ftest.py | 156 +++++++++++++++---
tools/binman/main.py | 7 +-
tools/binman/test/339_nxp_imx8.dts | 3 +
.../test/{225_ti_dm.dts => 351_ti_dm.dts} | 0
...g_phony.dts => 352_ti_board_cfg_phony.dts} | 0
...drfw_imx95.dts => 353_nxp_ddrfw_imx95.dts} | 0
.../binman/test/{347_bl1.dts => 354_bl1.dts} | 0
...> 355_key_name_hint_dir_fit_signature.dts} | 0
... 356_key_name_hint_dir_spl_pubkey_dtb.dts} | 0
...car4_sa0.dts => 357_renesas_rcar4_sa0.dts} | 0
...ize.dts => 358_renesas_rcar4_sa0_size.dts} | 0
.../{350_nxp_imx95.dts => 359_nxp_imx95.dts} | 0
...ngine.dts => 360_fit_signature_engine.dts} | 0
...s => 361_fit_signature_engine_encrypt.dts} | 0
...ts => 362_fit_signature_engine_pkcs11.dts} | 0
...63_fit_signature_engine_pkcs11_object.dts} | 0
tools/binman/test/364_nxp_imx8_csf.dts | 26 +++
.../test/365_nxp_imx8_csf_fast_auth.dts | 21 +++
tools/binman/test/366_nxp_imx8_imagename.dts | 27 +++
...40_dummy-rsa4096.crt => dummy-rsa4096.crt} | 0
.../test/{340_openssl.conf => openssl.conf} | 0
.../test/{340_rsa2048.key => rsa2048.key} | 0
.../test/{340_softhsm2.conf => softhsm2.conf} | 0
tools/u_boot_pylib/test_util.py | 15 +-
24 files changed, 212 insertions(+), 43 deletions(-)
rename tools/binman/test/{225_ti_dm.dts => 351_ti_dm.dts} (100%)
rename tools/binman/test/{323_ti_board_cfg_phony.dts => 352_ti_board_cfg_phony.dts} (100%)
rename tools/binman/test/{346_nxp_ddrfw_imx95.dts => 353_nxp_ddrfw_imx95.dts} (100%)
rename tools/binman/test/{347_bl1.dts => 354_bl1.dts} (100%)
rename tools/binman/test/{347_key_name_hint_dir_fit_signature.dts => 355_key_name_hint_dir_fit_signature.dts} (100%)
rename tools/binman/test/{348_key_name_hint_dir_spl_pubkey_dtb.dts => 356_key_name_hint_dir_spl_pubkey_dtb.dts} (100%)
rename tools/binman/test/{348_renesas_rcar4_sa0.dts => 357_renesas_rcar4_sa0.dts} (100%)
rename tools/binman/test/{349_renesas_rcar4_sa0_size.dts => 358_renesas_rcar4_sa0_size.dts} (100%)
rename tools/binman/test/{350_nxp_imx95.dts => 359_nxp_imx95.dts} (100%)
rename tools/binman/test/{340_fit_signature_engine.dts => 360_fit_signature_engine.dts} (100%)
rename tools/binman/test/{340_fit_signature_engine_encrypt.dts => 361_fit_signature_engine_encrypt.dts} (100%)
rename tools/binman/test/{340_fit_signature_engine_pkcs11.dts => 362_fit_signature_engine_pkcs11.dts} (100%)
rename tools/binman/test/{340_fit_signature_engine_pkcs11_object.dts => 363_fit_signature_engine_pkcs11_object.dts} (100%)
create mode 100644 tools/binman/test/364_nxp_imx8_csf.dts
create mode 100644 tools/binman/test/365_nxp_imx8_csf_fast_auth.dts
create mode 100644 tools/binman/test/366_nxp_imx8_imagename.dts
rename tools/binman/test/{340_dummy-rsa4096.crt => dummy-rsa4096.crt} (100%)
rename tools/binman/test/{340_openssl.conf => openssl.conf} (100%)
rename tools/binman/test/{340_rsa2048.key => rsa2048.key} (100%)
rename tools/binman/test/{340_softhsm2.conf => softhsm2.conf} (100%)Signature · 4 lines
2.43.0 base-commit: 8fd76675efbe7af785ccc1ba1ac8b9f7e10f6715 branch: binh-us
PATCH 1/6 binman: test: Renumber duplicate test-file prefixes
From: Simon Glass <[email protected]>
Quite a few test files reuse number prefixes that already exist in the test numbering. Test .dts files are supposed to start with unique numbers.
Renumber conflicting files and update the references in ftest.py
---
tools/binman/ftest.py | 26 +++++++++----------
.../test/{225_ti_dm.dts => 351_ti_dm.dts} | 0
...g_phony.dts => 352_ti_board_cfg_phony.dts} | 0
...drfw_imx95.dts => 353_nxp_ddrfw_imx95.dts} | 0
.../binman/test/{347_bl1.dts => 354_bl1.dts} | 0
...> 355_key_name_hint_dir_fit_signature.dts} | 0
... 356_key_name_hint_dir_spl_pubkey_dtb.dts} | 0
...car4_sa0.dts => 357_renesas_rcar4_sa0.dts} | 0
...ize.dts => 358_renesas_rcar4_sa0_size.dts} | 0
.../{350_nxp_imx95.dts => 359_nxp_imx95.dts} | 0
...ngine.dts => 360_fit_signature_engine.dts} | 0
...s => 361_fit_signature_engine_encrypt.dts} | 0
...ts => 362_fit_signature_engine_pkcs11.dts} | 0
...63_fit_signature_engine_pkcs11_object.dts} | 0
14 files changed, 13 insertions(+), 13 deletions(-)
rename tools/binman/test/{225_ti_dm.dts => 351_ti_dm.dts} (100%)
rename tools/binman/test/{323_ti_board_cfg_phony.dts => 352_ti_board_cfg_phony.dts} (100%)
rename tools/binman/test/{346_nxp_ddrfw_imx95.dts => 353_nxp_ddrfw_imx95.dts} (100%)
rename tools/binman/test/{347_bl1.dts => 354_bl1.dts} (100%)
rename tools/binman/test/{347_key_name_hint_dir_fit_signature.dts => 355_key_name_hint_dir_fit_signature.dts} (100%)
rename tools/binman/test/{348_key_name_hint_dir_spl_pubkey_dtb.dts => 356_key_name_hint_dir_spl_pubkey_dtb.dts} (100%)
rename tools/binman/test/{348_renesas_rcar4_sa0.dts => 357_renesas_rcar4_sa0.dts} (100%)
rename tools/binman/test/{349_renesas_rcar4_sa0_size.dts => 358_renesas_rcar4_sa0_size.dts} (100%)
rename tools/binman/test/{350_nxp_imx95.dts => 359_nxp_imx95.dts} (100%)
rename tools/binman/test/{340_fit_signature_engine.dts => 360_fit_signature_engine.dts} (100%)
rename tools/binman/test/{340_fit_signature_engine_encrypt.dts => 361_fit_signature_engine_encrypt.dts} (100%)
rename tools/binman/test/{340_fit_signature_engine_pkcs11.dts => 362_fit_signature_engine_pkcs11.dts} (100%)
rename tools/binman/test/{340_fit_signature_engine_pkcs11_object.dts => 363_fit_signature_engine_pkcs11_object.dts} (100%)tools/binman/ftest.py +13 -13
@@ -5578,22 +5578,22 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testPackTiDm(self): """Test that an image with a TI DM binary can be created""" - data = self._DoReadFile('225_ti_dm.dts') + data = self._DoReadFile('351_ti_dm.dts') self.assertEqual(TI_DM_DATA, data[:len(TI_DM_DATA)]) def testPackBl1(self): """test if an image with a bl1 binary can be created""" - data = self._DoReadFile('347_bl1.dts') + data = self._DoReadFile('354_bl1.dts') self.assertEqual(ATF_BL1_DATA, data[:len(ATF_BL1_DATA)]) def testRenesasRCarGen4SA0Image(self): """Test that binman can produce an Renesas R-Car Gen4 SA0 image""" - self._DoTestFile('348_renesas_rcar4_sa0.dts') + self._DoTestFile('357_renesas_rcar4_sa0.dts') def testRenesasRCarGen4SA0ImageSize(self): """Test that binman can not produce large Renesas R-Car Gen4 SA0 image""" with self.assertRaises(ValueError) as exc: - self._DoTestFile('349_renesas_rcar4_sa0_size.dts') + self._DoTestFile('358_renesas_rcar4_sa0_size.dts') self.assertIn("Node '/binman/renesas-rcar4-sa0': SRAM data longer than 966656 Bytes", str(exc.exception))
@@ -7181,7 +7181,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testTIBoardConfigLint(self): """Test that an incorrectly linted config file would generate error""" with self.assertRaises(ValueError) as e: - data = self._DoReadFile('323_ti_board_cfg_phony.dts') + data = self._DoReadFile('352_ti_board_cfg_phony.dts') self.assertIn("Yamllint error", str(e.exception)) def testTIBoardConfigCombined(self):
@@ -7324,7 +7324,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testKeyNameHintIsPathSplPubkeyDtb(self): """Test that binman errors out on key-name-hint being a path""" with self.assertRaises(ValueError) as e: - self._DoReadFile('348_key_name_hint_dir_spl_pubkey_dtb.dts') + self._DoReadFile('356_key_name_hint_dir_spl_pubkey_dtb.dts') self.assertIn( 'Node \'/binman/u-boot-spl-pubkey-dtb\': \'keys/key\' is a path not a filename', str(e.exception))
@@ -7901,7 +7901,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testNxpHeaderDdrfw(self): """Test that binman can add a header to DDR PHY firmware images""" - data = self._DoReadFile('346_nxp_ddrfw_imx95.dts') + data = self._DoReadFile('353_nxp_ddrfw_imx95.dts') self.assertEqual(len(IMX_LPDDR_IMEM_DATA).to_bytes(4, 'little') + len(IMX_LPDDR_DMEM_DATA).to_bytes(4, 'little') + IMX_LPDDR_IMEM_DATA + IMX_LPDDR_DMEM_DATA, data)
@@ -7915,7 +7915,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap container_path = os.path.join(testdir, 'mx95b0-ahab-container.img') with open(container_path, 'w') as f: f.write(bytes([0x87]).decode('latin1') * 32768) - self._DoTestFile('350_nxp_imx95.dts', output_dir=testdir) + self._DoTestFile('359_nxp_imx95.dts', output_dir=testdir) def testFitSignSimple(self): """Test that image with FIT and signature nodes can be signed"""
@@ -7973,7 +7973,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap with unittest.mock.patch.dict('os.environ', {'OPENSSL_ENGINES': ossl_engines_path}): data = self._DoReadFileDtb( - '340_fit_signature_engine.dts', + '360_fit_signature_engine.dts', entry_args=entry_args, extra_indirs=[test_subdir])[0]
@@ -8014,7 +8014,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap with self.assertRaises(ValueError) as e: self._DoReadFileDtb( - '340_fit_signature_engine_encrypt.dts', + '361_fit_signature_engine_encrypt.dts', entry_args=entry_args, extra_indirs=[test_subdir])
@@ -8074,7 +8074,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap {'OPENSSL_CONF': ossl_conf, 'SOFTHSM2_CONF': softhsm2_conf}): data = self._DoReadFileDtb( - '340_fit_signature_engine_pkcs11.dts', + '362_fit_signature_engine_pkcs11.dts', entry_args=entry_args, extra_indirs=[test_subdir])[0]
@@ -8152,7 +8152,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap 'SOFTHSM2_CONF': softhsm2_conf, 'MKIMAGE_SIGN_PIN': '1234'}): data = self._DoReadFileDtb( - '340_fit_signature_engine_pkcs11_object.dts', + '363_fit_signature_engine_pkcs11_object.dts', entry_args=entry_args, extra_indirs=[test_subdir])[0]
@@ -8247,7 +8247,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap test_subdir = os.path.join(self._indir, TEST_FDT_SUBDIR) with self.assertRaises(ValueError) as e: self._DoReadFileDtb( - '347_key_name_hint_dir_fit_signature.dts', + '355_key_name_hint_dir_fit_signature.dts', entry_args=entry_args, extra_indirs=[test_subdir]) self.assertIn(
tools/binman/test/351_ti_dm.dts renamed from tools/binman/test/225_ti_dm.dts +0 -0
tools/binman/test/352_ti_board_cfg_phony.dts renamed from tools/binman/test/323_ti_board_cfg_phony.dts +0 -0
tools/binman/test/353_nxp_ddrfw_imx95.dts renamed from tools/binman/test/346_nxp_ddrfw_imx95.dts +0 -0
tools/binman/test/354_bl1.dts renamed from tools/binman/test/347_bl1.dts +0 -0
tools/binman/test/355_key_name_hint_dir_fit_signature.dts renamed from tools/binman/test/347_key_name_hint_dir_fit_signature.dts +0 -0
tools/binman/test/356_key_name_hint_dir_spl_pubkey_dtb.dts renamed from tools/binman/test/348_key_name_hint_dir_spl_pubkey_dtb.dts +0 -0
tools/binman/test/357_renesas_rcar4_sa0.dts renamed from tools/binman/test/348_renesas_rcar4_sa0.dts +0 -0
tools/binman/test/358_renesas_rcar4_sa0_size.dts renamed from tools/binman/test/349_renesas_rcar4_sa0_size.dts +0 -0
tools/binman/test/359_nxp_imx95.dts renamed from tools/binman/test/350_nxp_imx95.dts +0 -0
tools/binman/test/360_fit_signature_engine.dts renamed from tools/binman/test/340_fit_signature_engine.dts +0 -0
tools/binman/test/361_fit_signature_engine_encrypt.dts renamed from tools/binman/test/340_fit_signature_engine_encrypt.dts +0 -0
tools/binman/test/362_fit_signature_engine_pkcs11.dts renamed from tools/binman/test/340_fit_signature_engine_pkcs11.dts +0 -0
tools/binman/test/363_fit_signature_engine_pkcs11_object.dts renamed from tools/binman/test/340_fit_signature_engine_pkcs11_object.dts +0 -0
Signature · 1 line
2.43.0
Re: [PATCH 1/6] binman: test: Renumber duplicate test-file prefixes
Quoted 9 lines · Simon Glass
From: Simon Glass <[email protected]>
Quite a few test files reuse number prefixes that already exist in the test numbering. Test .dts files are supposed to start with unique numbers.
Renumber conflicting files and update the references in
ftest.pySigned-off-by Simon Glass <[email protected]>
Since the numbering does not seem to matter, can we move forward with some other scheme perhaps?
Signature · 1 line
Tom
Re: [PATCH 1/6] binman: test: Renumber duplicate test-file prefixes
Hi Tom,
Quoted 9 lines · Tom Rini
Quoted 6 lines · Simon Glass
From: Simon Glass <[email protected]>
Quite a few test files reuse number prefixes that already exist in the test numbering. Test .dts files are supposed to start with unique numbers.
Quoted 6 lines
Quoted 3 lines
Renumber conflicting files and update the references in
ftest.pySigned-off-by Simon Glass <[email protected]>Since the numbering does not seem to matter, can we move forward with some other scheme perhaps?
With so many files, the numbers are the only way I can easily tell them apart.
Regards,
Simon
Re: [PATCH 1/6] binman: test: Renumber duplicate test-file prefixes
Quoted 12 lines · Simon Glass
Hi Tom,
Quoted 9 lines · Tom Rini
Quoted 6 lines · Simon Glass
From: Simon Glass <[email protected]>
Quite a few test files reuse number prefixes that already exist in the test numbering. Test .dts files are supposed to start with unique numbers.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Renumber conflicting files and update the references in
ftest.pySigned-off-by Simon Glass <[email protected]>Since the numbering does not seem to matter, can we move forward with some other scheme perhaps?
With so many files, the numbers are the only way I can easily tell them apart.
Sounds like we need another scheme then, as collisions over numbers has happened too many times. Some subdirs might help instead.
Signature · 1 line
Tom
Re: [PATCH 1/6] binman: test: Renumber duplicate test-file prefixes
Hi Tom,
Quoted 18 lines · Tom Rini
Quoted 16 lines · Simon Glass
Hi Tom,
Quoted 13 lines · Tom Rini
Quoted 9 lines · Simon Glass
From: Simon Glass <[email protected]>
Quite a few test files reuse number prefixes that already exist in the test numbering. Test .dts files are supposed to start with unique numbers.
Renumber conflicting files and update the references in
ftest.pySigned-off-by Simon Glass <[email protected]>
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Since the numbering does not seem to matter, can we move forward with some other scheme perhaps?
With so many files, the numbers are the only way I can easily tell them apart.
Sounds like we need another scheme then, as collisions over numbers has happened too many times. Some subdirs might help instead.
OK I can try subdirs and dropping the numbers.
- Simon
PATCH 2/6 binman: test: Drop the number prefix from non-dts test files
In reply to Simon GlassFrom: Simon Glass <[email protected]>
The non-dts files should not be numbered. Remove the 340_ prefix from several fies and update ftest.py to match.
---
tools/binman/ftest.py | 16 ++++++++--------
.../{340_dummy-rsa4096.crt => dummy-rsa4096.crt} | 0
.../test/{340_openssl.conf => openssl.conf} | 0
.../binman/test/{340_rsa2048.key => rsa2048.key} | 0
.../test/{340_softhsm2.conf => softhsm2.conf} | 0
5 files changed, 8 insertions(+), 8 deletions(-)
rename tools/binman/test/{340_dummy-rsa4096.crt => dummy-rsa4096.crt} (100%)
rename tools/binman/test/{340_openssl.conf => openssl.conf} (100%)
rename tools/binman/test/{340_rsa2048.key => rsa2048.key} (100%)
rename tools/binman/test/{340_softhsm2.conf => softhsm2.conf} (100%)tools/binman/ftest.py +8 -8
@@ -7926,7 +7926,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap 'default-dt': 'test-fdt1', 'atf-bl31-path': 'bl31.elf', } - data = tools.read_file(self.TestFile("340_rsa2048.key")) + data = tools.read_file(self.TestFile("rsa2048.key")) self._MakeInputFile("keys/rsa2048.key", data) test_subdir = os.path.join(self._indir, TEST_FDT_SUBDIR)
@@ -7963,7 +7963,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap 'atf-bl31-path': 'bl31.elf', } - x509_pubkey = '340_dummy-rsa4096.crt' + x509_pubkey = 'dummy-rsa4096.crt' data = tools.read_file(self.TestFile(x509_pubkey)) self._MakeInputFile('dev.crt', data)
@@ -8038,7 +8038,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap prefix = "testFitSignPKCS11Simple." # Configure SoftHSMv2 - data = tools.read_file(self.TestFile('340_softhsm2.conf')) + data = tools.read_file(self.TestFile('softhsm2.conf')) softhsm2_conf = self._MakeInputFile(f'{prefix}softhsm2.conf', data) softhsm2_tokens_dir = self._MakeInputDir(f'{prefix}softhsm2.tokens')
@@ -8069,7 +8069,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap test_subdir = os.path.join(self._indir, TEST_FDT_SUBDIR) # Make OpenSSL use softhsm2 engine - ossl_conf = self.TestFile('340_openssl.conf') + ossl_conf = self.TestFile('openssl.conf') with unittest.mock.patch.dict('os.environ', {'OPENSSL_CONF': ossl_conf, 'SOFTHSM2_CONF': softhsm2_conf}):
@@ -8113,7 +8113,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap prefix = "testFitSignPKCS11Object." # Configure SoftHSMv2 - data = tools.read_file(self.TestFile('340_softhsm2.conf')) + data = tools.read_file(self.TestFile('softhsm2.conf')) softhsm2_conf = self._MakeInputFile(f'{prefix}softhsm2.conf', data) softhsm2_tokens_dir = self._MakeInputDir(f'{prefix}softhsm2.tokens')
@@ -8146,7 +8146,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap # Make OpenSSL use softhsm2 engine and configure PIN for token # The PIN is incorrect on purpose, the correct one will be passed by # MKIMAGE_SIGN_PIN - ossl_conf = self.TestFile('340_openssl.conf') + ossl_conf = self.TestFile('openssl.conf') with unittest.mock.patch.dict('os.environ', {'OPENSSL_CONF': ossl_conf, 'SOFTHSM2_CONF': softhsm2_conf,
@@ -8203,9 +8203,9 @@ fdt fdtmap Extract the devicetree blob from the fdtmap 'default-dt': 'test-fdt1', 'atf-bl31-path': 'bl31.elf', } - data = tools.read_file(self.TestFile("340_rsa2048.key")) + data = tools.read_file(self.TestFile("rsa2048.key")) self._MakeInputFile("keys1/rsa2048.key", data) - data = tools.read_file(self.TestFile("340_rsa2048.key")) + data = tools.read_file(self.TestFile("rsa2048.key")) self._MakeInputFile("keys2/conf-rsa2048.key", data) test_subdir = os.path.join(self._indir, TEST_FDT_SUBDIR)
tools/binman/test/dummy-rsa4096.crt renamed from tools/binman/test/340_dummy-rsa4096.crt +0 -0
tools/binman/test/openssl.conf renamed from tools/binman/test/340_openssl.conf +0 -0
tools/binman/test/rsa2048.key renamed from tools/binman/test/340_rsa2048.key +0 -0
tools/binman/test/softhsm2.conf renamed from tools/binman/test/340_softhsm2.conf +0 -0
Signature · 1 line
2.43.0
Re: [PATCH 2/6] binman: test: Drop the number prefix from non-dts test files
Hi Simon,
Quoted 3 lines · Simon Glass
From: Simon Glass <[email protected]>
The non-dts files should not be numbered. Remove the 340_ prefix from
Why not? Now it's more difficult for me to know which files are supposed to be used with which dts/test.
What do we do once we have a name collision? Start another numbering scheme?
Honestly, I'm wondering if we shouldn't improve ftest to better split tests. Or maybe split ftest.py into multiple files. I very much dislike how we handle input files also. They are set at the class level and any test can modify them. I *guess* it could be fine to have a shared input directory among all tests, but it must be read-only so we don't have side effects (we can then have a per-test rw input directory if necessary).
I guess we could have a subdir per new ftest split which contains all files that pertain to this test. We can group them by theme for example to not have to have a subdir per test and overwhelm the user (though that makes it very explicit what's to be used with what).
The change seems fine so I won't fight against merging it but I don't see a clear benefit for it so I'll refrain from giving this a reviewer tag.
Cheers,
Quentin
Re: [PATCH 2/6] binman: test: Drop the number prefix from non-dts test files
Hi Quentin,
Quoted 10 lines · Quentin Schulz
Hi Simon,
Quoted 3 lines · Simon Glass
From: Simon Glass <[email protected]>
The non-dts files should not be numbered. Remove the 340_ prefix from
Why not? Now it's more difficult for me to know which files are supposed to be used with which dts/test.
Becuase the numbering is sequential and if two files have the number it is confusing.
Quoted 2 lines
What do we do once we have a name collision? Start another numbering scheme?
There are very few non-dts files, so just renaming it should be good enough.
Quoted 3 lines
Honestly, I'm wondering if we shouldn't improve ftest to better split tests. Or maybe split
ftest.pyinto multiple files.
Yes it is quite long. We could create a shared class for the common functionality and then put groups of tests in separate files.
Quoted 5 lines
I very much dislike
how we handle input files also. They are set at the class level and any test can modify them. I *guess* it could be fine to have a shared input directory among all tests, but it must be read-only so we don't have side effects (we can then have a per-test rw input directory if necessary).
Having the input dir be read-only seems good to me. Yes we have a per-test rw (output) directory (from memory, have not checked).
Quoted 5 lines
I guess we could have a subdir per new ftest split which contains all files that pertain to this test. We can group them by theme for example to not have to have a subdir per test and overwhelm the user (though that makes it very explicit what's to be used with what).
Yes
Quoted 3 lines
The change seems fine so I won't fight against merging it but I don't see a clear benefit for it so I'll refrain from giving this a reviewer tag.
OK
Regards,
Simon
PATCH 3/6 binman: test: Capture output from tests with warnings
In reply to Simon GlassFrom: Simon Glass <[email protected]>
Tests are supposed to run silently and capture any output produced.
Fix testRemoveTemplate() so that the message about the missing openssl is captured, along with the invalid-images message.
Fix testNxpImx9Image() as well, since it is expected that container.img and bl31.bin are missing.
---
tools/binman/ftest.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
tools/binman/ftest.py +7 -3
@@ -7915,7 +7915,8 @@ fdt fdtmap Extract the devicetree blob from the fdtmap container_path = os.path.join(testdir, 'mx95b0-ahab-container.img') with open(container_path, 'w') as f: f.write(bytes([0x87]).decode('latin1') * 32768) - self._DoTestFile('359_nxp_imx95.dts', output_dir=testdir) + with terminal.capture(): + self._DoTestFile('359_nxp_imx95.dts', output_dir=testdir) def testFitSignSimple(self): """Test that image with FIT and signature nodes can be signed"""
@@ -8307,8 +8308,11 @@ fdt fdtmap Extract the devicetree blob from the fdtmap """Test whether template is removed""" TestFunctional._MakeInputFile('my-blob.bin', b'blob') TestFunctional._MakeInputFile('my-blob2.bin', b'other') - self._DoTestFile('346_remove_template.dts', - force_missing_bintools='openssl',) + with terminal.capture() as (_, stderr): + self._DoTestFile('346_remove_template.dts', + force_missing_bintools='openssl',) + err = stderr.getvalue() + self.assertRegex(err, "Image 'file2'.*missing bintools.*: openssl") def testBootphPropagation(self): """Test that bootph-* properties are propagated correctly to supernodes"""
Signature · 1 line
2.43.0
Re: [PATCH 3/6] binman: test: Capture output from tests with warnings
Hi Simon,
Quoted 4 lines · Simon Glass
From: Simon Glass <[email protected]>
Tests are supposed to run silently and capture any output produced.
Fair enough. But how about making _DoTestFile() and other various function calls actually eat stdout/stderr by default such that test implementers don't have to remember doing that?
We can always return stderr, stdout to the caller of _DoTestFile() if we wanted to be able to parse the output.
What do you think?
Quoted 6 lines
Fix
testRemoveTemplate()so that the message about the missing openssl is captured, along with the invalid-images message.Fix
testNxpImx9Image()as well, since it is expected that container.img and bl31.bin are missing.
Thanks!
Quentin
Re: [PATCH 3/6] binman: test: Capture output from tests with warnings
Hi Quentin,
Quoted 9 lines · Quentin Schulz
Hi Simon,
Quoted 4 lines · Simon Glass
From: Simon Glass <[email protected]>
Tests are supposed to run silently and capture any output produced.
Quoted 8 lines
Fair enough. But how about making
_DoTestFile()and other various function calls actually eat stdout/stderr by default such that test implementers don't have to remember doing that?We can always return stderr, stdout to the caller of
_DoTestFile()if we wanted to be able to parse the output.What do you think?
It's actually quite painful to develop tests when output is captured. You cannot print state or see errors. So I try to capture it for the smallest possible code area.
I did actually add a 'patman test -N' flag to help with this but have not plumbed it into binman. I'm not sure if that would make the tool even harder to develop in.
Quoted 9 lines
Quoted 7 lines
Fix
testRemoveTemplate()so that the message about the missing openssl is captured, along with the invalid-images message.Fix
testNxpImx9Image()as well, since it is expected that container.img and bl31.bin are missing.Tested-by Quentin Schulz <[email protected]>
Regards,
Simon
PATCH 4/6 binman: test: Fix code coverage for iMX8 and cst bintool
In reply to Simon GlassFrom: Simon Glass <[email protected]>
Three files are currently missing test coverage: nxp_imx8mcst, nxp_imx8mimage and cst
Add test methods to cover all missing code paths, trying to reuse the same .dts files where possible.
This brings all three files to 100% coverage.
---
tools/binman/ftest.py | 106 ++++++++++++++++++ tools/binman/test/339_nxp_imx8.dts | 3 + tools/binman/test/364_nxp_imx8_csf.dts | 26 +++++ .../test/365_nxp_imx8_csf_fast_auth.dts | 21 ++++ tools/binman/test/366_nxp_imx8_imagename.dts | 27 +++++ 5 files changed, 183 insertions(+) create mode 100644 tools/binman/test/364_nxp_imx8_csf.dts create mode 100644 tools/binman/test/365_nxp_imx8_csf_fast_auth.dts create mode 100644 tools/binman/test/366_nxp_imx8_imagename.dts
tools/binman/ftest.py +106 -0
@@ -7899,6 +7899,112 @@ fdt fdtmap Extract the devicetree blob from the fdtmap """Test that binman can produce an iMX8 image""" self._DoTestFile('339_nxp_imx8.dts') + def testNxpImx8ImageMissing(self): + """Test that binman produces an iMX8 image if mkimage is missing""" + with terminal.capture() as (_, stderr): + self._DoTestFile('339_nxp_imx8.dts', + force_missing_bintools='mkimage') + err = stderr.getvalue() + self.assertRegex(err, "Image 'image'.*missing bintools.*: mkimage") + + def testNxpImx8ImagePos(self): + """Test SetImagePos for iMX8 image""" + with terminal.capture() as (_, stderr): + self._DoTestFile('339_nxp_imx8.dts', update_dtb=True, + force_missing_bintools='mkimage') + err = stderr.getvalue() + self.assertRegex(err, "Image 'image'.*missing bintools.*: mkimage") + + def testNxpImx8mCSTNormal(self): + """Test CST signing with IVT-format input (normal auth, no unlock)""" + # Create fake IVT blob: magic(4) + padding(20) + signsize_addr(4) + # + padding(36) = 64 bytes + ivt_data = struct.pack('<I', 0x412000d1) + ivt_data += b'\x00' * 20 + ivt_data += struct.pack('<I', 0) + ivt_data += b'\x00' * 36 + self._MakeInputFile('imx8m-ivt.bin', ivt_data) + with terminal.capture() as (_, stderr): + self._DoTestFile('364_nxp_imx8_csf.dts', + force_missing_bintools='cst') + err = stderr.getvalue() + self.assertRegex(err, "Image 'image'.*missing bintools.*: cst") + + def testNxpImx8mCSTFastAuth(self): + """Test CST signing with fast-auth mode, unlock, and FIT format""" + # FIT magic covers the FIT-signing path; fast-auth/unlock cover the + # ReadNode() and config-generation branches + fit_data = struct.pack('<I', 0xedfe0dd0) + fit_data += b'\x00' * 60 + self._MakeInputFile('imx8m-fit.bin', fit_data) + with terminal.capture() as (_, stderr): + self._DoTestFile('365_nxp_imx8_csf_fast_auth.dts', + force_missing_bintools='cst') + err = stderr.getvalue() + self.assertRegex(err, "Image 'image'.*missing bintools.*: cst") + + def testNxpImx8mCSTUnknownMagic(self): + """Test CST with unknown input magic passes data through""" + # Trigger the pass-through path use data with neither IVT nor FIT magic + data = b'\x00' * 64 + self._MakeInputFile('imx8m-ivt.bin', data) + self._DoTestFile('364_nxp_imx8_csf.dts', force_missing_bintools='cst') + + def testNxpImx8ImageSizeNone(self): + """Test SetImagePos() early return when an entry has no size""" + # The imagename entry is in GetEntries() but not packed, so has + # size=None, which triggers the early-return guard in SetImagePos() + with terminal.capture() as (_, stderr): + self._DoTestFile('366_nxp_imx8_imagename.dts', + force_missing_bintools='mkimage') + + def testNxpImx8mCSTSigned(self): + """Test CST-signing-success path with mocked cst invocation""" + ivt_data = struct.pack('<I', 0x412000d1) + ivt_data += b'\x00' * 20 + ivt_data += struct.pack('<I', 0) + ivt_data += b'\x00' * 36 + self._MakeInputFile('imx8m-ivt.bin', ivt_data) + + # Mock run_cmd() so that when cst is invoked, it creates a fake output + # blob and returns success, thus covering the signing path + original = bintool.Bintool.run_cmd + + def fake_cst_run_cmd(self_tool, *args, binary=False): + if self_tool.name == 'cst': + arg_list = list(args) + if '-o' in arg_list: + idx = arg_list.index('-o') + tools.write_file(arg_list[idx + 1], b'\x00' * 32) + return 'fake cst output' + return original(self_tool, *args, binary=binary) + + with unittest.mock.patch.object(bintool.Bintool, 'run_cmd', + new=fake_cst_run_cmd): + self._DoTestFile('364_nxp_imx8_csf.dts') + + def testNxpImx8mCSTBintool(self): + """Test the cst bintool run() and fetch() methods""" + cst = bintool.Bintool.create('cst') + self.assertEqual('cst', cst.name) + + # Mark cst as missing so run() exercises the code without needing the + # real tool (which fails without valid signing keys) + old_missing = bintool.Bintool.missing_list + bintool.Bintool.set_missing_list(['cst']) + try: + self.assertIsNone(cst.run('test.bin')) + finally: + bintool.Bintool.set_missing_list(old_missing) + # fetch() only supports FETCH_BUILD; other methods return None + self.assertIsNone(cst.fetch(bintool.FETCH_BIN)) + + # fetch(FETCH_BUILD) calls build_from_git() so mock it + with unittest.mock.patch.object( + bintool.Bintool, 'build_from_git', return_value=('cst', None)): + result = cst.fetch(bintool.FETCH_BUILD) + self.assertEqual(('cst', None), result) + def testNxpHeaderDdrfw(self): """Test that binman can add a header to DDR PHY firmware images""" data = self._DoReadFile('353_nxp_ddrfw_imx95.dts')
tools/binman/test/339_nxp_imx8.dts +3 -0
@@ -12,6 +12,9 @@ nxp,boot-from = "sd"; nxp,rom-version = <1>; nxp,loader-address = <0x10>; + + u-boot { + }; }; }; };
tools/binman/test/364_nxp_imx8_csf.dts new file +26 -0
@@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + nxp-imx8mcst { + args; + nxp,loader-address = <0x10>; + + blob { + filename = "imx8m-ivt.bin"; + }; + + imagename { + type = "section"; + + u-boot { + }; + }; + }; + }; +};
tools/binman/test/365_nxp_imx8_csf_fast_auth.dts new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + nxp-imx8mcst { + args; + nxp,loader-address = <0x10>; + nxp,fast-auth; + nxp,unlock; + + blob { + filename = "imx8m-fit.bin"; + }; + }; + }; +};
tools/binman/test/366_nxp_imx8_imagename.dts new file +27 -0
@@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + nxp-imx8mimage { + args; /* TODO: Needed by mkimage etype superclass */ + nxp,boot-from = "sd"; + nxp,rom-version = <1>; + nxp,loader-address = <0x10>; + + u-boot { + }; + + imagename { + type = "section"; + + u-boot { + }; + }; + }; + }; +};
Signature · 1 line
2.43.0
PATCH 5/6 binman: Remove the coverage allow_failures list
In reply to Simon GlassFrom: Simon Glass <[email protected]>
Now that iMX8 has full coverage the allow_failures list in RunTestCoverage() is no longer needed.
Drop the list.
---
tools/binman/main.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
tools/binman/main.py +1 -6
@@ -95,15 +95,10 @@ def RunTestCoverage(toolpath, build_dir, args): for path in toolpath: extra_args += ' --toolpath %s' % path - # Some files unfortunately don't thave the required test coverage. This will - # eventually be fixed, but exclude them for now test_util.run_test_coverage('tools/binman/binman', None, ['*test*', '*main.py', 'tools/patman/*', 'tools/dtoc/*', 'tools/u_boot_pylib/*'], - build_dir, all_set, extra_args or None, args=args, - allow_failures=['tools/binman/btool/cst.py', - 'tools/binman/etype/nxp_imx8mcst.py', - 'tools/binman/etype/nxp_imx8mimage.py']) + build_dir, all_set, extra_args or None, args=args) def RunBinman(args): """Main entry point to binman once arguments are parsed
Signature · 1 line
2.43.0
PATCH 6/6 binman: Drop the allow_failures parameter from run_test_coverage()
In reply to Simon GlassFrom: Simon Glass <[email protected]>
The allow_failures parameter in run_test_coverage() is no longer used by any caller.
Drop it.
---
tools/u_boot_pylib/test_util.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
tools/u_boot_pylib/test_util.py +1 -14
@@ -24,7 +24,7 @@ except: def run_test_coverage(prog, filter_fname, exclude_list, build_dir, required=None, extra_args=None, single_thread='-P1', - args=None, allow_failures=None): + args=None): """Run tests and check that we get 100% coverage Args:
@@ -95,19 +95,6 @@ def run_test_coverage(prog, filter_fname, exclude_list, build_dir, print('Coverage error: %s, but should be 100%%' % coverage) ok = False if not ok: - if allow_failures: - # for line in lines: - # print('.', line, re.match(r'^(tools/.*py) *\d+ *(\d+) *(\d+)%$', line)) - lines = [re.match(r'^(tools/.*py) *\d+ *(\d+) *\d+%$', line) - for line in stdout.splitlines()] - bad = [] - for mat in lines: - if mat and mat.group(2) != '0': - fname = mat.group(1) - if fname not in allow_failures: - bad.append(fname) - if not bad: - return raise ValueError('Test coverage failure')
Signature · 1 line
2.43.0