[U-Boot] [PATCH] test.py: Make search for autoconf.mk more permission

Buildman doesn't store this file in the same directory as a normal build. Update the conftest code to handle both cases.
Signed-off-by: Simon Glass sjg@chromium.org ---
test/py/conftest.py | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-)
diff --git a/test/py/conftest.py b/test/py/conftest.py index bffee6b8a3..472dd0545d 100644 --- a/test/py/conftest.py +++ b/test/py/conftest.py @@ -83,6 +83,26 @@ def pytest_configure(config): Returns: Nothing. """ + def parse_config(conf_file): + """Parse a config file, loading it into the ubconfig container + + Args: + conf_file: Filename to load (within build_dir) + + Raises + Exception if the file does not exist + """ + dot_config = build_dir + '/' + conf_file + if not os.path.exists(dot_config): + raise Exception(conf_file + ' does not exist; ' + + 'try passing --build option?') + + with open(dot_config, 'rt') as f: + ini_str = '[root]\n' + f.read() + ini_sio = io.StringIO(ini_str) + parser = configparser.RawConfigParser() + parser.read_file(ini_sio) + ubconfig.buildconfig.update(parser.items('root'))
global log global console @@ -157,18 +177,13 @@ def pytest_configure(config):
ubconfig.buildconfig = dict()
- for conf_file in ('.config', 'include/autoconf.mk'): - dot_config = build_dir + '/' + conf_file - if not os.path.exists(dot_config): - raise Exception(conf_file + ' does not exist; ' + - 'try passing --build option?') - - with open(dot_config, 'rt') as f: - ini_str = '[root]\n' + f.read() - ini_sio = io.StringIO(ini_str) - parser = configparser.RawConfigParser() - parser.read_file(ini_sio) - ubconfig.buildconfig.update(parser.items('root')) + # buildman -k puts autoconf.mk in the rootdir, so handle this as well + # as the standard U-Boot build which leaves it in include/autoconf.mk + parse_config('.config') + if os.path.exists(build_dir + '/' + 'autoconf.mk'): + parse_config('autoconf.mk') + else: + parse_config('include/autoconf.mk')
ubconfig.test_py_dir = test_py_dir ubconfig.source_dir = source_dir

On 12/1/19 7:34 PM, Simon Glass wrote:
Buildman doesn't store this file in the same directory as a normal build. Update the conftest code to handle both cases.
Shouldn't we just fix buildman so that it puts the files in the standard locations? That way, we don't have to separately update every tool that might want to find/interpret this file or archive the build results, but instead just update one tool (buildman).

Hi Stephen,
On Mon, 2 Dec 2019 at 09:04, Stephen Warren swarren@wwwdotorg.org wrote:
On 12/1/19 7:34 PM, Simon Glass wrote:
Buildman doesn't store this file in the same directory as a normal build. Update the conftest code to handle both cases.
Shouldn't we just fix buildman so that it puts the files in the standard locations? That way, we don't have to separately update every tool that might want to find/interpret this file or archive the build results, but instead just update one tool (buildman).
Well we could, but IMO it is better to separate the build process from the output process. With buildman the outputs end up all in the same directory (including spl, for example). I think it becomes confusing if we just leave files where the build system happens to leave them, even worse if we wanted to keep files in include/generated. Also, those locations might change in future.
It is certainly good to have pytests run on a build without preprocessing, though.
Regards, Simon
participants (2)
-
Simon Glass
-
Stephen Warren