Skip to content

Commit

Permalink
kunit: test: Improve error messages for kunit_tool when kunitconfig i…
Browse files Browse the repository at this point in the history
…s invalid

Previous error message for invalid kunitconfig was vague. Added to it so
that it lists invalid fields and prompts for them to be removed.  Added
validate_config function returning whether or not this kconfig is valid.

Signed-off-by: Heidi Fahim <[email protected]>
Reviewed-by: Brendan Higgins <[email protected]>
Tested-by: Brendan Higgins <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
  • Loading branch information
Heidifahim authored and shuahkh committed Feb 19, 2020
1 parent e20d8e8 commit dde54b9
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions tools/testing/kunit/kunit_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ def clean(self):
return False
return True

def validate_config(self, build_dir):
kconfig_path = get_kconfig_path(build_dir)
validated_kconfig = kunit_config.Kconfig()
validated_kconfig.read_from_file(kconfig_path)
if not self._kconfig.is_subset_of(validated_kconfig):
invalid = self._kconfig.entries() - validated_kconfig.entries()
message = 'Provided Kconfig is not contained in validated .config. Following fields found in kunitconfig, ' \
'but not in .config: %s' % (
', '.join([str(e) for e in invalid])
)
logging.error(message)
return False
return True

def build_config(self, build_dir):
kconfig_path = get_kconfig_path(build_dir)
if build_dir and not os.path.exists(build_dir):
Expand All @@ -103,12 +117,7 @@ def build_config(self, build_dir):
except ConfigError as e:
logging.error(e)
return False
validated_kconfig = kunit_config.Kconfig()
validated_kconfig.read_from_file(kconfig_path)
if not self._kconfig.is_subset_of(validated_kconfig):
logging.error('Provided Kconfig is not contained in validated .config!')
return False
return True
return self.validate_config(build_dir)

def build_reconfig(self, build_dir):
"""Creates a new .config if it is not a subset of the .kunitconfig."""
Expand All @@ -133,12 +142,7 @@ def build_um_kernel(self, jobs, build_dir):
except (ConfigError, BuildError) as e:
logging.error(e)
return False
used_kconfig = kunit_config.Kconfig()
used_kconfig.read_from_file(get_kconfig_path(build_dir))
if not self._kconfig.is_subset_of(used_kconfig):
logging.error('Provided Kconfig is not contained in final config!')
return False
return True
return self.validate_config(build_dir)

def run_kernel(self, args=[], timeout=None, build_dir=''):
args.extend(['mem=256M'])
Expand Down

0 comments on commit dde54b9

Please sign in to comment.