support/testing: check if the defconfig provided for testing is valid

Currently, the build continue even if some symbols disapear from
the generated dot config file (.config).

This patch add a new check in order to stop the test if one
of the provided symbol is missing. This must be treated as error.

For example, if a symbol disapear due to new dependency constraints.

Inspired by is_toolchain_usable() function from genrandconfig:
https://git.busybox.net/buildroot/tree/utils/genrandconfig?h=2020.02#n164

Signed-off-by: Romain Naour <romain.naour@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
Romain Naour 2020-04-06 01:04:14 +02:00 committed by Thomas Petazzoni
parent 8e217262a8
commit 50b747f212
1 changed files with 20 additions and 0 deletions

View File

@ -12,6 +12,23 @@ class Builder(object):
self.builddir = builddir self.builddir = builddir
self.logfile = infra.open_log_file(builddir, "build", logtofile) self.logfile = infra.open_log_file(builddir, "build", logtofile)
def is_defconfig_valid(self, configfile, defconfig):
"""Check if the .config is contains all lines present in the defconfig."""
with open(configfile) as configf:
configlines = configf.readlines()
defconfiglines = defconfig.split("\n")
# Check that all the defconfig lines are still present
for defconfigline in defconfiglines:
if defconfigline + "\n" not in configlines:
self.logfile.write("WARN: defconfig can't be used\n")
self.logfile.write(" Missing: %s\n" % defconfigline.strip())
self.logfile.flush()
return False
return True
def configure(self, make_extra_opts=[], make_extra_env={}): def configure(self, make_extra_opts=[], make_extra_env={}):
"""Configure the build. """Configure the build.
@ -47,6 +64,9 @@ class Builder(object):
if ret != 0: if ret != 0:
raise SystemError("Cannot olddefconfig") raise SystemError("Cannot olddefconfig")
if not self.is_defconfig_valid(config_file, self.config):
raise SystemError("The defconfig is not valid")
def build(self, make_extra_opts=[], make_extra_env={}): def build(self, make_extra_opts=[], make_extra_env={}):
"""Perform the build. """Perform the build.