diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2022-10-19 09:26:56 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2022-10-19 09:26:56 +0200 |
commit | 7d14ef14dbb31657e7754138fb099551ad016aab (patch) | |
tree | d762a572cd3312138c05c100017e20a5cdd4db0d | |
parent | a28ec3514edc292ecb81b63447f9aac9e1dd3599 (diff) |
--export-dref: add kconfig feature types if known
-rwxr-xr-x | bin/analyze-kconfig.py | 5 | ||||
-rw-r--r-- | lib/loader/kconfig.py | 32 |
2 files changed, 37 insertions, 0 deletions
diff --git a/bin/analyze-kconfig.py b/bin/analyze-kconfig.py index 4775181..4dd9a9c 100755 --- a/bin/analyze-kconfig.py +++ b/bin/analyze-kconfig.py @@ -249,6 +249,11 @@ def main(): # show-failing-symbols, show-nop-symbols, DFATOOL_KCONF_WITH_CHOICE_NODES, DFATOOL_KCONF_IGNORE_NUMERIC, and DFATOOL_KCONF_IGNORE_STRING have no effect # in this branch. + if os.path.exists(args.kconfig_path): + attributes = KConfigAttributes(args.kconfig_path, None) + if args.export_dref: + dref.update(attributes.to_dref()) + if args.model.endswith("xz"): import lzma diff --git a/lib/loader/kconfig.py b/lib/loader/kconfig.py index 575d617..0724a45 100644 --- a/lib/loader/kconfig.py +++ b/lib/loader/kconfig.py @@ -132,3 +132,35 @@ class KConfigAttributes: ) sha256sum = status.stdout.split()[0] return sha256sum + + def to_dref(self) -> dict: + type_count = { + "bool": 0, + "tristate": 0, + "numeric": 0, + "string": 0, + "enum": 0, + } + for param_name in self.param_names: + if param_name in self.symbol: + str_type = kconfiglib.TYPE_TO_STR[self.symbol[param_name].type] + if str_type in type_count: + type_count[str_type] += 1 + elif str_type in ("int", "hex"): + type_count["numeric"] += 1 + else: + raise RuntimeError( + f"param {param_name} has unknown type: {str_type}" + ) + else: + type_count["enum"] += 1 + return { + "raw measurements/valid": len(self.configs), + "raw measurements/total": len(self.configs) + len(self.failures), + "kconfig/num_features/total": len(self.param_names), + "kconfig/num_features/bool": type_count["bool"], + "kconfig/num_features/tristate": type_count["tristate"], + "kconfig/num_features/string": type_count["string"], + "kconfig/num_features/numeric": type_count["numeric"], + "kconfig/num_features/enum": type_count["enum"], + } |