From 10a41a8cbdf4bcaba0039e97704afda8220cd8e0 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Mon, 17 Oct 2022 11:55:08 +0200 Subject: [PATCH] cpu-data.py: Allow for more than child in feature nodes cpu-data.py assumes that all "feature" nodes have exactly one child. This assumption will no longer be true when the cpumap includes alias- names for features. Signed-off-by: Tim Wiederhake Reviewed-by: Jiri Denemark --- tests/cputestdata/cpu-data.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/cputestdata/cpu-data.py b/tests/cputestdata/cpu-data.py index 0200db7a78..498e07b2f7 100755 --- a/tests/cputestdata/cpu-data.py +++ b/tests/cputestdata/cpu-data.py @@ -445,12 +445,15 @@ def parseMap(): cpuMap = dict() for f in xml.etree.ElementTree.parse(path).getroot().iter("feature"): - if f[0].tag not in ("cpuid", "msr"): + data = f.find("cpuid") + if data is None: + data = f.find("msr") + if data is None: continue - feature = {"type": f[0].tag} - for reg in _KEYS[f[0].tag] + _REGS[f[0].tag]: - feature[reg] = int(f[0].attrib.get(reg, "0"), 0) + feature = {"type": data.tag} + for reg in _KEYS[data.tag] + _REGS[data.tag]: + feature[reg] = int(data.attrib.get(reg, "0"), 0) cpuMap[f.attrib["name"]] = feature return cpuMap