Fix 'make check' errors
v3 cover Fix 'make check' errors
Various tests can be run using 'make check', 'make qcheck' and 'make tcheck'. These have become broken and need fixing to be useful again.
Running 'make qcheck' fails on the binman test to check the version numbers of the tools are found as expected. Update the code for the tools that have been updated and no longer have their version numbers found by the code.
There are also failures in buildman. First add code to understand 'gcc -E' as an alternative to cpp. Second add the code to accept an empty CROSS_COMPILE variable in the environment when testing that CROSS_COMPILE is not set by the toolchain selection.
dtoc was not achieving 100% code coverage so add a new test to rectify that.
Disable event_dump tests that are broken on newer versions of binutils.
Build mkeficapsule in the tree that is used for testing the tools.
'make tcheck' was not achieving 100% code coverage and needs to know the location of the built tools to resolve.
'make check' tests of the file system had errors due to ext4 file systems being created with an orphaned file but were marked clean.
---
Changes in v3:
- Split fix of test_basic tests into two.
- Just remove the empty arg from lzma_alone version check instead of messing with run_cmd_result() and move this commit to become 2/15
- Add explanation and error log to commit message of 9/15
- Update commit to accept more preprocessor possibilities. 13/15
- Update the commit message for 11/15 and remove the change of PATH that fails to address this same issue.
- In 4/15 update the buildman test to cope if DTC is set externally.
- In 8/15 minor update to test file
- Add 5/15 and 6/15 to insulate binman and buildman tests from a DTC variable being set externally
- Picked up tags and trimmed Cc list
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- Added commit 7/12 to address intermittent failure for binman to get version string from lzma_alone.
- Added commit 8/12 to address a test failure due to the build tree not containing the built version of mkeficapsule and using the system version instead.
- Dropped a space from the beginning of a line in a new file in 5/12 to quiet checkpatch warning and remove most of the content as not needed for test as suggested by Simon Glass.
- Fix 'make tcheck' binman code coverage test by passing in location of tools built from this tree in 9/12.
- Fix typo in tools/Kconfig for TOOLS_MKEFICAPSULE config item in 10/12
- Cope with CPP="gcc -E" in buildman in 11/12
- Ensure fsck can be run and use it to force clean ext4 file systems on creation to remove orphaned file. 12/12
- Picked up some rb tags from Simon Glass
- Link to v1: https://patch.msgid.link/[email protected]
To: [email protected]
To: Kory Maincent <[email protected]>
To: Linus Walleij <[email protected]>
To: Ilias Apalodimas <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Andrew Goodbody <[email protected]>
Cc: Anshul Dalal <[email protected]>
Cc: Alexey Charkov <[email protected]>
Cc: Heinrich Schuchardt <[email protected]>
Cc: Mattijs Korpershoek <[email protected]>
Cc: Carlo Caione <[email protected]>
Cc: Yao Zi <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: Quentin Schulz <[email protected]>
Cc: Marek Vasut <[email protected]>
---
Andrew Goodbody (15):
binman: btool: lz4: Update version regex
binman: bintool: Do not add empty argument
binman: btool: lzma_alone: Update version function
test: Do not set DTC environment variable
buildman: Use mock environment to ignore DTC variable
binman: Use mock environment to ignore DTC variable
buildman: Cope with empty CROSS_COMPILE in tests
dtoc: test: Fix coverage by adding test
test: Disable running event_dump test for make check
test: Build mkeficapsule in tree used by tests
test: Pass location of built tools to binman code coverage test
tools: Fix typo in name of command mkeficapsule
buildman: Cope with CPP="gcc -E"
test: Fix test_basic file system tests
test: Ensure ext4 file system is truly clean on creation
configs/sandbox_spl_defconfig | 1 + test/py/tests/fs_helper.py | 4 ++++ test/py/tests/test_fs/fstest_helpers.py | 12 +++++++++--- test/run | 10 +++++----- tools/Kconfig | 2 +- tools/binman/btool/lz4.py | 2 +- tools/binman/btool/lzma_alone.py | 2 +- tools/binman/ftest.py | 16 ++++++++++++---- tools/buildman/boards.py | 4 ++-- tools/buildman/func_test.py | 11 +++++++++-- tools/buildman/test.py | 12 ++++++------ tools/dtoc/test/dtoc_test_include.dts | 13 +++++++++++++ tools/dtoc/test/newinclude/dtoc_test_include_file.dtsi | 7 +++++++ tools/dtoc/test_fdt.py | 7 +++++++ 14 files changed, 78 insertions(+), 25 deletions(-)
---
base-commit: 3cb2cbbc75aa7fe2391f662607d6b2f46c1292a7
change-id: 20261029-qcheck_fix-af97ed0d895b
Best regards,
Signature · 1 line
Andrew Goodbody <[email protected]>
PATCH v3 1/15 binman: btool: lz4: Update version regex
With the update to lz4 v1.10.x the version string has changed format. Previously the string looked like
"*** LZ4 command line interface 64-bits v1.9.2, by Yann Collet ***" and now it is
"*** lz4 v1.10.0 64-bit multithread, by Yann Collet ***" The ',' following the version number is no longer present so remove it from the regex used to match the version number. The regex will now match the version number in both of the forms so will continue to work with older versions of lz4 as well as newer ones.
--- tools/binman/btool/lz4.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/binman/btool/lz4.py +1 -1
@@ -76,7 +76,7 @@ class Bintoollz4(bintool.Bintool): man lz4 """ def __init__(self, name): - super().__init__(name, 'lz4 compression', r'.* (v[0-9.]*),.*') + super().__init__(name, 'lz4 compression', r'.* (v[0-9.]*).*') def compress(self, indata): """Compress data with lz4
Signature · 1 line
2.47.3
PATCH v3 2/15 binman: bintool: Do not add empty argument
In reply to Andrew GoodbodyIf lzma_alone is invoked with an empty argument it will emit a message to stderr. When 'combined' is used to examine the output of this command the content is not deterministic in that stdout and stderr may appear out of order on occasions. To prevent this situation do not add an argument list to the command when it is empty. In this situation no error message is emitted only the usage and this is always sent to only stdout or only to stderr depending on the version of lzma_alone.
--- tools/binman/btool/lzma_alone.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/binman/btool/lzma_alone.py +1 -1
@@ -116,7 +116,7 @@ class Bintoollzma_alone(bintool.Bintool): Returns: str: Version number of lzma_alone """ - out = self.run_cmd_result('', raise_on_error=False).stderr.strip() + out = self.run_cmd_result(raise_on_error=False).stderr.strip() lines = out.splitlines() if not lines: return super().version()
Signature · 1 line
2.47.3
Re: [PATCH v3 02/15] binman: bintool: Do not add empty argument
Hi Andrew,
Quoted 8 lines · Andrew Goodbody
If
lzma_aloneis invoked with an empty argument it will emit a message to stderr. When 'combined' is used to examine the output of this command the content is not deterministic in that stdout and stderr may appear out of order on occasions. To prevent this situation do not add an argument list to the command when it is empty. In this situation no error message is emitted only the usage and this is always sent to only stdout or only to stderr depending on the version oflzma_alone.
Thanks!
Quentin
PATCH v3 3/15 binman: btool: lzma_alone: Update version function
In reply to Andrew Goodbodylzma_alone 24.08 now prints its version string to stdout instead of stderr which means the current version function will not find it as it only looks in stderr. Instead look in 'combined' which contains both stdout and stderr and so will work with older and newer versions of lzma_alone.
--- tools/binman/btool/lzma_alone.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/binman/btool/lzma_alone.py +1 -1
@@ -116,7 +116,7 @@ class Bintoollzma_alone(bintool.Bintool): Returns: str: Version number of lzma_alone """ - out = self.run_cmd_result(raise_on_error=False).stderr.strip() + out = self.run_cmd_result(raise_on_error=False).combined.strip() lines = out.splitlines() if not lines: return super().version()
Signature · 1 line
2.47.3
PATCH v3 4/15 test: Do not set DTC environment variable
In reply to Andrew GoodbodyThe presence of the DTC environment variable breaks binman tests that attempt to execute dtc from a temporary directory using the value of DTC but that is a relative directory path based on the source tree not this temporary directory and so fail. The tests are testFitFdtListDir and testFitFdtListDirDefault.
It also breaks a buildman test that checks the environment and asserts that DTC is not present. The test is test_skip_dtc.
Remove the setting of DTC as it is not needed.
--- test/run | 1 - 1 file changed, 1 deletion(-)
test/run +0 -1
@@ -76,7 +76,6 @@ fi # to tools build by the build. DTC_DIR=build-sandbox_spl/scripts/dtc export PYTHONPATH=${DTC_DIR}/pylibfdt -export DTC=${DTC_DIR}/dtc TOOLS_DIR=build-sandbox_spl/tools run_test "binman" ./tools/binman/binman --toolpath ${TOOLS_DIR} test
Signature · 1 line
2.47.3
PATCH v3 5/15 buildman: Use mock environment to ignore DTC variable
In reply to Andrew GoodbodyWhen testing the toolchain setting of DTC in buildman, use a mock environment to avoid making changes to the environment and give the test more control over the environment in use. This avoids test failures due to being passed an unexpected value for DTC.
--- tools/buildman/test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/buildman/test.py +4 -4
@@ -1012,8 +1012,10 @@ class TestBuild(unittest.TestCase): def test_skip_dtc(self): """Test skipping building the dtc tool""" - old_path = os.getenv('PATH') - try: + local_env = os.environ.copy() + if 'DTC' in local_env: + local_env.pop('DTC') + with unittest.mock.patch.dict('os.environ', local_env, clear=True): os.environ['PATH'] = self.base_dir # Check a missing tool
@@ -1038,8 +1040,6 @@ class TestBuild(unittest.TestCase): toolchain = self.toolchains.Select('arm') env = build.make_environment(toolchain) self.assertNotIn(b'DTC', env) - finally: - os.environ['PATH'] = old_path def testHomedir(self): """Test using ~ in a toolchain or toolchain-prefix section"""
Signature · 1 line
2.47.3
Re: [PATCH v3 05/15] buildman: Use mock environment to ignore DTC variable
Hi Andrew,
Quoted 15 lines · Andrew Goodbody
When testing the toolchain setting of DTC in buildman, use a mock environment to avoid making changes to the environment and give the test more control over the environment in use. This avoids test failures due to being passed an unexpected value for DTC.
Signed-off-by Andrew Goodbody <[email protected]>--- tools/buildman/test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)tools/buildman/test.py +0
-0
tools/buildman/test.py class TestBuild(unittest.TestCase): · line 1017
Quoted 8 lines
tools/buildman/test.py +3
-2@@ -1012,8 +1012,10 @@ class TestBuild(unittest.TestCase): def test_skip_dtc(self): """Test skipping building the dtc tool""" - old_path = os.getenv('PATH') - try: + local_env = os.environ.copy() + if 'DTC' in local_env: + local_env.pop('DTC')
suggestion: non-optimal
local_env.pop('DTC', None)
or
if 'DTC' in local_env:
del local_env['DTC']
pop() returns the value associated with the key (which we don't care). If default (second argument) is passed, then a non-existing keys won't raise an exception.
del removes the key from the dict, and you've checked for its existence before so that's safe.
Not necessary though, so:
Thanks!
Quentin
PATCH v3 6/15 binman: Use mock environment to ignore DTC variable
In reply to Andrew GoodbodyIf the environment contains the DTC variable and it is set to a relative path this can cause the tests testFitFdtListDir and testFitFdtListDirDefault to fail as they change the current working directory so that the value of DTC no longer points to a valid dtc binary and so the tests fail. Instead create a mock environment that has the DTC variable removed from it just for the duration of the test.
--- tools/binman/ftest.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
tools/binman/ftest.py +12 -4
@@ -7984,18 +7984,26 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testFitFdtListDir(self): """Test an image with an FIT with FDT images using fit,fdt-list-dir""" old_dir = os.getcwd() + local_env = os.environ.copy() + if 'DTC' in local_env: + local_env.pop('DTC') try: - os.chdir(self._indir) - self.CheckFitFdt('fit/fdt_dir.dts', False) + with unittest.mock.patch.dict('os.environ', local_env, clear=True): + os.chdir(self._indir) + self.CheckFitFdt('fit/fdt_dir.dts', False) finally: os.chdir(old_dir) def testFitFdtListDirDefault(self): """Test an FIT fit,fdt-list-dir where the default DT in is a subdir""" old_dir = os.getcwd() + local_env = os.environ.copy() + if 'DTC' in local_env: + local_env.pop('DTC') try: - os.chdir(self._indir) - self.CheckFitFdt('fit/fdt_dir.dts', False, + with unittest.mock.patch.dict('os.environ', local_env, clear=True): + os.chdir(self._indir) + self.CheckFitFdt('fit/fdt_dir.dts', False, default_dt='rockchip/test-fdt2') finally: os.chdir(old_dir)
Signature · 1 line
2.47.3
Re: [PATCH v3 06/15] binman: Use mock environment to ignore DTC variable
Hi Andrew,
Quoted 38 lines · Andrew Goodbody
If the environment contains the DTC variable and it is set to a relative path this can cause the tests testFitFdtListDir and testFitFdtListDirDefault to fail as they change the current working directory so that the value of DTC no longer points to a valid dtc binary and so the tests fail. Instead create a mock environment that has the DTC variable removed from it just for the duration of the test.
Signed-off-by Andrew Goodbody <[email protected]>--- tools/binman/ftest.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)tools/binman/ftest.py +8
-2@@ -7984,18 +7984,26 @@ fdt fdtmap Extract the devicetree blob from the fdtmap def testFitFdtListDir(self): """Test an image with an FIT with FDT images using fit,fdt-list-dir""" old_dir = os.getcwd() + local_env = os.environ.copy() + if 'DTC' in local_env: + local_env.pop('DTC') try: - os.chdir(self._indir) - self.CheckFitFdt('fit/fdt_dir.dts', False) + with unittest.mock.patch.dict('os.environ', local_env, clear=True): + os.chdir(self._indir) + self.CheckFitFdt('fit/fdt_dir.dts', False) finally: os.chdir(old_dir) def testFitFdtListDirDefault(self): """Test an FIT fit,fdt-list-dir where the default DT in is a subdir""" old_dir = os.getcwd() + local_env = os.environ.copy() + if 'DTC' in local_env:
tools/binman/ftest.py fdt fdtmap Extract the devicetree blob from the fdtmap · line 8009
Quoted 10 lines
tools/binman/ftest.py +4
-2+ local_env.pop('DTC') try: - os.chdir(self._indir) - self.CheckFitFdt('fit/fdt_dir.dts', False, + with unittest.mock.patch.dict('os.environ', local_env, clear=True): + os.chdir(self._indir) + self.CheckFitFdt('fit/fdt_dir.dts', False, default_dt='rockchip/test-fdt2') finally: os.chdir(old_dir)
os.chdir() is not thread-safe as it changes the cwd for the whole process, c.f. https://www.man7.org/linux/man-pages/man2/chdir.2.html
Nothing your fault though, and I don't know how to properly fix that.
For this patch, here:
I'm wondering though, do we actually need patch 4 which removes DTC from the env if we properly patch the env such that it doesn't matter whether it's present? If we really need it, maybe moving it after this patch here with justification that it's not actually used anymore (and was not working before anyway), would make more sense to me. Just nitpicking though.
Thanks!
Quentin
Re: [PATCH v3 06/15] binman: Use mock environment to ignore DTC variable
Quoted 58 lines · Quentin Schulz
Hi Andrew,
Quoted 41 lines · Andrew Goodbody
If the environment contains the DTC variable and it is set to a relative path this can cause the tests testFitFdtListDir and testFitFdtListDirDefault to fail as they change the current working directory so that the value of DTC no longer points to a valid dtc binary and so the tests fail. Instead create a mock environment that has the DTC variable removed from it just for the duration of the test.
Signed-off-by Andrew Goodbody <[email protected]>---
tools/binman/ftest.py| 16 ++++++++++++----1 file changed, 12 insertions(+), 4 deletions(-)tools/binman/ftest.py +0
-0@@ -7984,18 +7984,26 @@ fdt fdtmap Extract thedevicetree blob from the fdtmap
def testFitFdtListDir(self):
"""Test an image with an FIT with FDT images using fit,fdt- list-dir"""old_dir=os.getcwd()
+local_env=os.environ.copy()
+ if 'DTC' inlocal_env:
+local_env.pop('DTC')
try:
-os.chdir(self._indir)
-self.CheckFitFdt('fit/fdt_dir.dts', False)
+ withunittest.mock.patch.dict('os.environ', local_env, clear=True):
+os.chdir(self._indir)
+self.CheckFitFdt('fit/fdt_dir.dts', False)
finally:
os.chdir(old_dir)
def testFitFdtListDirDefault(self):
"""Test an FIT fit,fdt-list-dir where the default DT in is a subdir"""old_dir=os.getcwd()
+local_env=os.environ.copy()
+ if 'DTC' inlocal_env:
+local_env.pop('DTC')
try:
-os.chdir(self._indir)Quoted 9 lines
- self.CheckFitFdt('fit/fdt_dir.dts', False, + with
unittest.mock.patch.dict('os.environ', local_env, clear=True):
+os.chdir(self._indir)
+self.CheckFitFdt('fit/fdt_dir.dts', False, default_dt='rockchip/test-fdt2')finally:
os.chdir(old_dir)
os.chdir()is not thread-safe as it changes the cwd for the whole process, c.f. https://www.man7.org/linux/man-pages/man2/chdir.2.htmlNothing your fault though, and I don't know how to properly fix that.
Quoted 8 lines
For this patch, here:
Reviewed-by Quentin Schulz <[email protected]>I'm wondering though, do we actually need patch 4 which removes DTC from the env if we properly patch the env such that it doesn't matter whether it's present? If we really need it, maybe moving it after this patch here with justification that it's not actually used anymore (and was not working before anyway), would make more sense to me. Just nitpicking though.
Thanks!
Quentin
I am happy to just drop 4/15. The patch was only there so that nobody would think that the DTC env variable was needed and in general stuff that is not needed is best off removed. As for ordering, to me it felt better to remove it first, which fixes both issues, then make the tests more robust. But I have no strong views on it.
If you would like a V4 then please let me know which you would prefer, to drop or move or just leave as is. While the rest of the series has some minor optimisations that could be picked up, 4/15 is the last thing in need of any change.
Thanks,
Andrew
Re: [PATCH v3 06/15] binman: Use mock environment to ignore DTC variable
Quoted 65 lines · Andrew Goodbody
Quoted 62 lines · Quentin Schulz
Hi Andrew,
Quoted 41 lines · Andrew Goodbody
If the environment contains the DTC variable and it is set to a relative path this can cause the tests testFitFdtListDir and testFitFdtListDirDefault to fail as they change the current working directory so that the value of DTC no longer points to a valid dtc binary and so the tests fail. Instead create a mock environment that has the DTC variable removed from it just for the duration of the test.
Signed-off-by Andrew Goodbody <[email protected]>---
tools/binman/ftest.py| 16 ++++++++++++----1 file changed, 12 insertions(+), 4 deletions(-)tools/binman/ftest.py +0
-0@@ -7984,18 +7984,26 @@ fdt fdtmap Extract thedevicetree blob from the fdtmap
def testFitFdtListDir(self):
"""Test an image with an FIT with FDT images using fit,fdt- list-dir"""old_dir=os.getcwd()
+local_env=os.environ.copy()
+ if 'DTC' inlocal_env:
+local_env.pop('DTC')
try:
-os.chdir(self._indir)
-self.CheckFitFdt('fit/fdt_dir.dts', False)
+ withunittest.mock.patch.dict('os.environ', local_env, clear=True):
+os.chdir(self._indir)
+self.CheckFitFdt('fit/fdt_dir.dts', False)
finally:
os.chdir(old_dir)
def testFitFdtListDirDefault(self):
"""Test an FIT fit,fdt-list-dir where the default DT in is a subdir"""old_dir=os.getcwd()
+local_env=os.environ.copy()
+ if 'DTC' inlocal_env:
+local_env.pop('DTC')
try:
-os.chdir(self._indir)Quoted 9 lines
- self.CheckFitFdt('fit/fdt_dir.dts', False, + with
unittest.mock.patch.dict('os.environ', local_env, clear=True):
+os.chdir(self._indir)
+self.CheckFitFdt('fit/fdt_dir.dts', False, default_dt='rockchip/test-fdt2')finally:
os.chdir(old_dir)
os.chdir()is not thread-safe as it changes the cwd for the whole process, c.f. https://eur02.safelinks.protection.outlook.com/? url=https%3A%2F%2Fwww.man7.org%2Flinux%2Fman- pages%2Fman2%2Fchdir.2.html&data=05%7C02%7Cquentin.schulz%40cherry.de%7Cf621cc8cf9734ea26e5408df46691921%7C5e0e1b5221b54e7b83bb514ec460677e%7C0%7C0%7C639307089341557615%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=WFtKIrZp%2FF8VWj2ks8w%2Fnx9%2BSHBhs2j%2F1Iybs6b3RLA%3D&reserved=0Nothing your fault though, and I don't know how to properly fix that.
For this patch, here:
Reviewed-by Quentin Schulz <[email protected]>
Quoted 8 lines
Quoted 4 lines
I'm wondering though, do we actually need patch 4 which removes DTC from the env if we properly patch the env such that it doesn't matter whether it's present? If we really need it, maybe moving it after this patch here with justification that it's not actually used anymore (and was not working before anyway), would make more sense to me. Just nitpicking though.
Thanks!
QuentinI am happy to just drop 4/15. The patch was only there so that nobody would think that the DTC env variable was needed and in general stuff that is not needed is best off removed. As for ordering, to me it felt better to remove it first, which fixes both issues, then make the tests more robust. But I have no strong views on it.
If you would like a V4 then please let me know which you would prefer, to drop or move or just leave as is. While the rest of the series has some minor optimisations that could be picked up, 4/15 is the last thing in need of any change.
No, I don't think it's worth spinning a v4 just for that.
Cheers,
Quentin
PATCH v3 7/15 buildman: Cope with empty CROSS_COMPILE in tests
In reply to Andrew GoodbodyWhen the buildman tests are run through the Makefile with eg 'make qcheck' the Makefile will export an empty CROSS_COMPILE variable into the environment. Add the code to the test that will accept this as OK.
--- tools/buildman/test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/buildman/test.py +2 -2
@@ -656,7 +656,7 @@ class TestBuild(unittest.TestCase): tc = self.toolchains.Select('sandbox') env = tc.MakeEnvironment(False) - self.assertTrue(b'CROSS_COMPILE' not in env) + self.assertTrue(b'CROSS_COMPILE' not in env or env[b'CROSS_COMPILE'] == b'') # Test config with ccache wrapper bsettings.setup(None)
@@ -668,7 +668,7 @@ class TestBuild(unittest.TestCase): tc = self.toolchains.Select('sandbox') env = tc.MakeEnvironment(False) - self.assertTrue(b'CROSS_COMPILE' not in env) + self.assertTrue(b'CROSS_COMPILE' not in env or env[b'CROSS_COMPILE'] == b'') def testPrepareOutputSpace(self): def _Touch(fname):
Signature · 1 line
2.47.3
PATCH v3 8/15 dtoc: test: Fix coverage by adding test
In reply to Andrew GoodbodyUse of 'indir' in EnsureCompiled() was not being tested and resulted in less than 100% code coverage. Add a test and supporting files that depends on the use of 'indir' by placing an included file in a new directory. The dts file will fail to compile if the new directory is not added to the search path with the use of 'indir'.
--- tools/dtoc/test/dtoc_test_include.dts | 13 +++++++++++++ tools/dtoc/test/newinclude/dtoc_test_include_file.dtsi | 7 +++++++ tools/dtoc/test_fdt.py | 7 +++++++ 3 files changed, 27 insertions(+)
tools/dtoc/test/dtoc_test_include.dts new file +13 -0
@@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test device tree file for dtoc + * + * Copyright 2017 Google, Inc + */ + +/dts-v1/; + +#include "dtoc_test_include_file.dtsi" + +/ { +};
tools/dtoc/test/newinclude/dtoc_test_include_file.dtsi new file +7 -0
@@ -0,0 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0-only + +/ { + new_node { + intval = <2>; + }; +};
tools/dtoc/test_fdt.py +7 -0
@@ -1105,6 +1105,13 @@ class TestFdtUtil(unittest.TestCase): finally: tools.outdir = old_outdir + def test_ensure_compiled_indir(self): + """Test providing directory as indir""" + indir = os.path.dirname(find_dtb_file('dtoc_test_include.dts')) + indir = os.path.join(indir, 'newinclude') + dtb = fdt_util.EnsureCompiled(find_dtb_file('dtoc_test_include.dts'), indir=[indir]) + self.assertEqual(dtb, fdt_util.EnsureCompiled(dtb)) + def test_get_phandle_name_offset(self): val = fdt_util.GetPhandleNameOffset(self.node, 'missing') self.assertIsNone(val)
Signature · 1 line
2.47.3
PATCH v3 9/15 test: Disable running event_dump test for make check
In reply to Andrew GoodbodyThe event dump script does not work on more recent versions of binutils so disable it from running for the moment.
This is a known issue and was already addressed in CI last year.
commit 9420160a0d14 ("CI: Move to Ubuntu 24.04 'Noble' as the base")
The error is that in recent versions of binutils addr2line cannot get the source reference for static functions. Whether the information is missing from the debug data or is just a failure of addr2line is not known.
Below is the error log from running the test.
__________________________________________________________ test_event_dump ___________________________________________________________ test/py/tests/test_event_dump.py:26: in test_event_dump
assert re.match(expect, out, re.MULTILINE) is not None
E AssertionError: assert None is not None
E + where None = <function match at 0x7f0798574e00>('.*Event type Id Source location\n-------------------- ----------------------...check .*arch/sandbox/cpu/start.c:.*\nEVT_TEST h_adder_simple .*test/common/event.c:', 'Event type Id Source location\n-------------------- ------------------------...pt_check build-sandbox/../arch/sandbox/cpu/start.c:61\nEVT_TEST h_adder_simple :?\n', re.MULTILINE)
E + where <function match at 0x7f0798574e00> = re.match
E + and re.MULTILINE = re.MULTILINE
-------------------------------------------------------- Captured stdout call --------------------------------------------------------
+scripts/event_dump.py /home/andrew/src/work/u-boot/build-sandbox/u-boot
Event type Id Source location
-------------------- ------------------------------ ------------------------------
EVT_DM_PRE_REMOVE dm_mdio_mux_parent_pre_remove :?
EVT_FT_FIXUP bootmeth_vbe_ft_fixup :?
EVT_FT_FIXUP bootmeth_vbe_simple_ft_fixup :?
EVT_LAST_STAGE_INIT alloc_write_acpi_tables :?
EVT_LAST_STAGE_INIT efi_block_device_create :?
EVT_LAST_STAGE_INIT install_smbios_table :?
EVT_LAST_STAGE_INIT tpm_evt_autostart :?
EVT_MISC_INIT_F sandbox_early_getopt_check build-sandbox/../arch/sandbox/cpu/start.c:61
EVT_TEST h_adder_simple :?====================================================== short test summary info ======================================================= FAILED test/py/tests/test_event_dump.py::test_event_dump - AssertionError: assert None is not None ========================= 1 failed, 1151 passed, 170 skipped, 345 deselected, 1 xfailed in 147.30s (0:02:27) =========================
--- test/run | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
test/run +3 -2
@@ -15,8 +15,9 @@ run_test() { # Select test attributes ut_mark_expr=test_ut +mark_expr="not event_dump" if [ "$1" = "quick" ]; then - mark_expr="not slow" + mark_expr="not slow and not event_dump" ut_mark_expr="test_ut and not slow" skip=--skip-net-tests fi
@@ -32,7 +33,7 @@ if [ "$1" = "parallel" ]; then para="-n${jobs} -q" prompt="Building and..." skip=--skip-net-tests - mark_expr="not slow and not bootstd and not spi_flash" + mark_expr="not slow and not bootstd and not spi_flash and not event_dump" ut_mark_expr="test_ut and not slow and not bootstd and not spi_flash" echo "Note: test log is garbled with parallel tests" fi
Signature · 1 line
2.47.3
PATCH v3 10/15 test: Build mkeficapsule in tree used by tests
In reply to Andrew GoodbodySince the commit to only build mkeficapsule when needed rather than by default, the build tree build-sandbox_spl no longer contains the built version of mkeficapsule and this can lead to a binman test failure. Add the config line to the defconfig so that mkeficapsule is built and the tests will now work. 'make savedefconfig' was used to generate the new defconfig file.
Building mkeficapsule in sandbox_spl is needed because that is the tree used to run binman tests due to it being built for both 'make qcheck' and also 'make tcheck'. The sandbox tree, which already builds mkeficapsule, is not built for 'make tcheck' and building it would just add extra time to the run.
--- configs/sandbox_spl_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/sandbox_spl_defconfig +1 -0
@@ -242,3 +242,4 @@ CONFIG_UNIT_TEST=y CONFIG_SPL_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y +CONFIG_TOOLS_MKEFICAPSULE=y
Signature · 1 line
2.47.3
Re: [PATCH v3 10/15] test: Build mkeficapsule in tree used by tests
Hi Andrew,
Quoted 24 lines · Andrew Goodbody
Since the commit to only build mkeficapsule when needed rather than by default, the build tree build-sandbox_spl no longer contains the built version of mkeficapsule and this can lead to a binman test failure. Add the config line to the defconfig so that mkeficapsule is built and the tests will now work. 'make savedefconfig' was used to generate the new defconfig file.
Building mkeficapsule insandbox_splis needed because that is the tree used to run binman tests due to it being built for both 'make qcheck' and also 'make tcheck'. The sandbox tree, which already builds mkeficapsule, is not built for 'make tcheck' and building it would just add extra time to the run.Fixes 2f736e8e3f4b ("tools: build mkeficapsule for CONFIG_EFI_HAVE_CAPSULE_SUPPORT=y")Signed-off-by Andrew Goodbody <[email protected]>--- configs/sandbox_spl_defconfig | 1 + 1 file changed, 1 insertion(+)configs/sandbox_spl_defconfig +0
-0
configs/sandbox_spl_defconfig CONFIG_UNIT_TEST=y · line 245
Quoted 4 lines
configs/sandbox_spl_defconfig +1
-0@@ -242,3 +242,4 @@ CONFIG_UNIT_TEST=y CONFIG_SPL_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y +CONFIG_TOOLS_MKEFICAPSULE=y
Let's see if this breaks somebody's CI because they don't have the necessary tools installed and do build sandbox_spl. We can worry about this when it happens I think :)
Thanks!
Quentin
PATCH v3 11/15 test: Pass location of built tools to binman code coverage test
In reply to Andrew GoodbodyWhen running binman for code coverage tests and invoked by 'make tcheck' some tests can fail if they use system installed versions of tools instead of ones built from the tree under test. Use the toolpath option to point at the locally built tools so that these built versions are chosen before system ones and to match the prior invocation of binman. Drop the change to PATH which did not work as it put the TOOLS_DIR at the end not the start.
--- test/run | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
test/run +2 -2
@@ -92,8 +92,8 @@ run_test "dtoc" ./tools/dtoc/dtoc -t # Code-coverage tests cannot run in parallel, so skip them in that case if [ -z "${para}" ]; then - export PATH=$PATH:${TOOLS_DIR} - run_test "binman code coverage" ./tools/binman/binman test -T + run_test "binman code coverage" ./tools/binman/binman \ + --toolpath ${TOOLS_DIR} test -T run_test "dtoc code coverage" ./tools/dtoc/dtoc -T run_test "fdt code coverage" ./tools/dtoc/test_fdt -T fi
Signature · 1 line
2.47.3
Re: [PATCH v3 11/15] test: Pass location of built tools to binman code coverage test
Hi Andrew,
Quoted 8 lines · Andrew Goodbody
When running binman for code coverage tests and invoked by 'make tcheck' some tests can fail if they use system installed versions of tools instead of ones built from the tree under test. Use the toolpath option to point at the locally built tools so that these built versions are chosen before system ones and to match the prior invocation of binman. Drop the change to PATH which did not work as it put the
TOOLS_DIRat the end not the start.
Thanks!
Quentin
PATCH v3 12/15 tools: Fix typo in name of command mkeficapsule
In reply to Andrew GoodbodyThe description for the config item TOOLS_MKEFICAPSULE has a typo, fix it. efimkcapsule -> mkeficapsule
--- tools/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/Kconfig +1 -1
@@ -107,7 +107,7 @@ config TOOLS_SHA512 Enable SHA512 support in the tools builds config TOOLS_MKEFICAPSULE - bool "Build efimkcapsule command" + bool "Build mkeficapsule command" default y if EFI_HAVE_CAPSULE_SUPPORT help This command allows users to create a UEFI capsule file and,
Signature · 1 line
2.47.3
PATCH v3 13/15 buildman: Cope with CPP="gcc -E"
In reply to Andrew GoodbodyAllow the use of "gcc -E" as an alternative to "cpp" when set in the environment as the value of CPP. Accept it as a valid command for running the preprocessor and adjust the test to not depend on a fixed number of arguments. Also split it into parts for constructing the command list so that the validation for running a command does not fail when it tries to find an executable named "gcc -E".
As well as -E accept --preprocess. Also accept clang instead of gcc.
--- tools/buildman/boards.py | 4 ++-- tools/buildman/func_test.py | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-)
tools/buildman/boards.py +2 -2
@@ -12,6 +12,7 @@ import glob import multiprocessing import os import re +import shlex import sys import tempfile import time
@@ -244,8 +245,7 @@ class KconfigScanner: temp = None if b'#include' in tools.read_file(defconfig): - cmd = [ - os.getenv('CPP', 'cpp'), + cmd = shlex.split(os.getenv('CPP', 'cpp')) + [ '-nostdinc', '-P', '-I', self._srctree, '-undef',
tools/buildman/func_test.py +9 -2
@@ -378,7 +378,12 @@ class TestFunctional(unittest.TestCase): def _HandleCommandCpp(self, args): # args ['-nostdinc', '-P', '-I', '/tmp/tmp7f17xk_o/src', '-undef', # '-x', 'assembler-with-cpp', fname] - fname = args[7] + # If 'gcc -E' is defined as the preprocessor then the args list will + # have an additional item, '-E', at the beginning which changes the + # number of items in the argument list. In order to guarantee picking + # up the filename use -1 as the position which will always be the last + # item + fname = args[-1] buf = io.StringIO() for line in tools.read_file(fname, False).splitlines(): if line.startswith('#include'):
@@ -424,7 +429,9 @@ class TestFunctional(unittest.TestCase): return self._HandleCommandObjcopy(args) elif cmd.endswith( 'size'): return self._HandleCommandSize(args) - elif cmd.endswith( 'cpp'): + elif cmd.endswith('cpp') \ + or ((cmd.endswith('gcc') or cmd.endswith('clang')) \ + and ('-E' in pipe_list[0] or '--preprocess' in pipe_list[0])): return self._HandleCommandCpp(args) if not result:
Signature · 1 line
2.47.3
Re: [PATCH v3 13/15] buildman: Cope with CPP="gcc -E"
Hi Andrew,
Quoted 55 lines · Andrew Goodbody
Allow the use of "gcc -E" as an alternative to "cpp" when set in the environment as the value of CPP. Accept it as a valid command for running the preprocessor and adjust the test to not depend on a fixed number of arguments. Also split it into parts for constructing the command list so that the validation for running a command does not fail when it tries to find an executable named "gcc -E".
As well as -E accept --preprocess. Also accept clang instead of gcc.Signed-off-by Andrew Goodbody <[email protected]>--- tools/buildman/boards.py | 4 ++-- tools/buildman/func_test.py | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-)tools/buildman/boards.py +2
-2@@ -12,6 +12,7 @@ import glob import multiprocessing import os import re +import shlex import sys import tempfile import time@@ -244,8 +245,7 @@ class KconfigScanner: temp = None if b'#include' in tools.read_file(defconfig): - cmd = [ - os.getenv('CPP', 'cpp'), + cmd = shlex.split(os.getenv('CPP', 'cpp')) + [ '-nostdinc', '-P', '-I', self._srctree, '-undef',tools/buildman/func_test.py +6
-1@@ -378,7 +378,12 @@ class TestFunctional(unittest.TestCase): def _HandleCommandCpp(self, args): # args ['-nostdinc', '-P', '-I', '/tmp/tmp7f17xk_o/src', '-undef', # '-x', 'assembler-with-cpp', fname] - fname = args[7] + # If 'gcc -E' is defined as the preprocessor then the args list will + # have an additional item, '-E', at the beginning which changes the + # number of items in the argument list. In order to guarantee picking + # up the filename use -1 as the position which will always be the last + # item + fname = args[-1] buf = io.StringIO() for line in tools.read_file(fname, False).splitlines(): if line.startswith('#include'):
tools/buildman/func_test.py class TestFunctional(unittest.TestCase): · line 433
Quoted 6 lines
tools/buildman/func_test.py +2
-1@@ -424,7 +429,9 @@ class TestFunctional(unittest.TestCase): return self._HandleCommandObjcopy(args) elif cmd.endswith( 'size'): return self._HandleCommandSize(args) - elif cmd.endswith( 'cpp'): + elif cmd.endswith('cpp') \ + or ((cmd.endswith('gcc') or cmd.endswith('clang')) \
suggestion: combine for shorter line
c.f. https://docs.python.org/3/builtins/stdtypes.html#str.endswith
cmd.endswith(('gcc', 'clang'))
In any case:
Thanks!
Quentin
PATCH v3 14/15 test: Fix test_basic file system tests
In reply to Andrew GoodbodyEnsure that /sbin is on the path so that distributions that do not have it will still be able to successfully run these tests that need fsck.
--- test/py/tests/test_fs/fstest_helpers.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
test/py/tests/test_fs/fstest_helpers.py +9 -3
@@ -3,15 +3,21 @@ # Author: JJ Hiblot <[email protected]> # +import os from subprocess import check_call, CalledProcessError def assert_fs_integrity(fs_type, fs_img): + # Some distributions do not add /sbin to the default PATH, where fsck lives + local_env = os.environ.copy() + if '/sbin' not in local_env["PATH"].split(os.pathsep): + local_env["PATH"] += os.pathsep + '/sbin' + try: if fs_type == 'ext4': - check_call('fsck.ext4 -n -f %s' % fs_img, shell=True) + check_call('fsck.ext4 -n -f %s' % fs_img, shell=True, env=local_env) elif fs_type == 'exfat': - check_call('fsck.exfat -n %s' % fs_img, shell=True) + check_call('fsck.exfat -n %s' % fs_img, shell=True, env=local_env) elif fs_type in ['fat12', 'fat16', 'fat32']: - check_call('fsck.fat -n %s' % fs_img, shell=True) + check_call('fsck.fat -n %s' % fs_img, shell=True, env=local_env) except CalledProcessError: raise
Signature · 1 line
2.47.3
Re: [PATCH v3 14/15] test: Fix test_basic file system tests
Hi Andrew,
Quoted 3 lines · Andrew Goodbody
Ensure that /sbin is on the path so that distributions that do not have it will still be able to successfully run these tests that need fsck.
Thanks!
Quentin
PATCH v3 15/15 test: Ensure ext4 file system is truly clean on creation
In reply to Andrew GoodbodyForce a run of fsck on the newly created ext4 file system to remove the orphaned file that is present despite being marked clean. If this is not done the integrity tests will fail as they will detect the presence of this orphaned file.
--- test/py/tests/fs_helper.py | 4 ++++ 1 file changed, 4 insertions(+)
test/py/tests/fs_helper.py +4 -0
@@ -250,6 +250,10 @@ def mk_fs(config, fs_type, size, prefix, src_dir=None, fs_img=None, quiet=False) shell=True).decode() if 'metadata_csum' in sb_content: check_call(f'tune2fs -O ^metadata_csum {fs_img}', shell=True) + # Cannot use check_call here as it will return an exit code of 1 + # as it modifies the file system. The -f is needed as although the + # fs is marked clean, it is not really. + call(f'fsck.ext4 -f -y {fs_img}', shell=True) elif fs_lnxtype == 'vfat' and src_dir: flags = f"-smpQ{'' if quiet else 'v'}" check_call(f'mcopy -i {fs_img} {flags} {src_dir}/* ::/',
Signature · 1 line
2.47.3
Re: [PATCH v3 15/15] test: Ensure ext4 file system is truly clean on creation
Hi Andrew,
Quoted 15 lines · Andrew Goodbody
Force a run of fsck on the newly created ext4 file system to remove the orphaned file that is present despite being marked clean. If this is not done the integrity tests will fail as they will detect the presence of this orphaned file.
Signed-off-by Andrew Goodbody <[email protected]>--- test/py/tests/fs_helper.py | 4 ++++ 1 file changed, 4 insertions(+)test/py/tests/fs_helper.py +0
-0
test/py/tests/fs_helper.py def mk_fs(config, fs_type, size, prefix, src_dir=None, fs_img=None, quiet=False) · line 256
Quoted 7 lines
test/py/tests/fs_helper.py +4
-0@@ -250,6 +250,10 @@ def mk_fs(config, fs_type, size, prefix, src_dir=None, fs_img=None, quiet=False) shell=True).decode() if 'metadata_csum' in sb_content: check_call(f'tune2fs -O ^metadata_csum {fs_img}', shell=True) + # Cannot use check_call here as it will return an exit code of 1 + # as it modifies the file system. The -f is needed as although the + # fs is marked clean, it is not really. + call(f'fsck.ext4 -f -y {fs_img}', shell=True)
I would have preferred an array as argument, to avoid shell=True, but considering all the other instances of call/check_call also don't do that, a clean-up for later.
Thanks!
Quentin