[libvirt] [PATCH 0/2] cputest: Update python scripts for parsing CPU data

Jiri Denemark (2): cputest: Adapt scripts to split cpu_map cputest: Use python3 in CPU parser scripts tests/cputestdata/cpu-cpuid.py | 24 +++++++++++------------- tests/cputestdata/cpu-reformat.py | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-) -- 2.20.1

The tests/cputestdata/cpu-parse.sh script has been broken since the cpu_map.xml file was split into several XMLs. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- tests/cputestdata/cpu-cpuid.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/cputestdata/cpu-cpuid.py b/tests/cputestdata/cpu-cpuid.py index c45118512d..9ee83e0cd2 100755 --- a/tests/cputestdata/cpu-cpuid.py +++ b/tests/cputestdata/cpu-cpuid.py @@ -301,15 +301,13 @@ def parseFeature(data): def parseMap(): path = os.path.dirname(sys.argv[0]) - path = os.path.join(path, "..", "..", "src", "cpu", "cpu_map.xml") + path = os.path.join(path, "..", "..", "src", "cpu_map", "x86_features.xml") with open(path, "r") as f: data = xmltodict.parse(f) cpuMap = {} - for arch in data["cpus"]["arch"]: - if arch["@name"] == "x86": - for feature in arch["feature"]: - cpuMap[feature["@name"]] = parseFeature(feature["cpuid"]) + for feature in data["cpus"]["feature"]: + cpuMap[feature["@name"]] = parseFeature(feature["cpuid"]) return cpuMap -- 2.20.1

Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- tests/cputestdata/cpu-cpuid.py | 16 ++++++++-------- tests/cputestdata/cpu-reformat.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/cputestdata/cpu-cpuid.py b/tests/cputestdata/cpu-cpuid.py index 9ee83e0cd2..f532475702 100755 --- a/tests/cputestdata/cpu-cpuid.py +++ b/tests/cputestdata/cpu-cpuid.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 import os import sys @@ -259,7 +259,7 @@ def parseQemu(path, features): with open(path, "r") as f: data, pos = json.JSONDecoder().raw_decode(f.read()) - for (prop, val) in data["return"]["model"]["props"].iteritems(): + for (prop, val) in data["return"]["model"]["props"].items(): if val and prop in features: cpuidAdd(cpuid, features[prop]) @@ -268,7 +268,7 @@ def parseQemu(path, features): def parseCpuid(path): cpuid = {} - with open(path, "r") as f: + with open(path, "rb") as f: data = xmltodict.parse(f) for leaf in data["cpudata"]["cpuid"]: @@ -302,7 +302,7 @@ def parseFeature(data): def parseMap(): path = os.path.dirname(sys.argv[0]) path = os.path.join(path, "..", "..", "src", "cpu_map", "x86_features.xml") - with open(path, "r") as f: + with open(path, "rb") as f: data = xmltodict.parse(f) cpuMap = {} @@ -313,7 +313,7 @@ def parseMap(): def formatCpuid(cpuid, path, comment): - print path + print(path) with open(path, "w") as f: f.write("<!-- " + comment + " -->\n") f.write("<cpudata arch='x86'>\n") @@ -337,7 +337,7 @@ def convert(path): for name in feature["names"]: props[name] = value - print path + print(path) with open(path, "w") as f: json.dump({"return": {"model": {"name": "base", "props": props}}, "id": "model-expansion"}, @@ -373,7 +373,7 @@ def diff(cpuMap, path): if len(sys.argv) < 3: - print "Usage: %s convert|diff json_file..." % sys.argv[0] + print("Usage: %s convert|diff json_file..." % sys.argv[0]) sys.exit(1) action = sys.argv[1] @@ -387,5 +387,5 @@ elif action == "diff": for path in args: diff(cpuMap, path) else: - print "Unknown action: " + action + print("Unknown action: %s" % action) sys.exit(1) diff --git a/tests/cputestdata/cpu-reformat.py b/tests/cputestdata/cpu-reformat.py index d4ed8d8118..2c7bbde262 100755 --- a/tests/cputestdata/cpu-reformat.py +++ b/tests/cputestdata/cpu-reformat.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys import json -- 2.20.1

On Thu, Feb 21, 2019 at 09:45:31PM +0100, Jiri Denemark wrote:
Jiri Denemark (2): cputest: Adapt scripts to split cpu_map cputest: Use python3 in CPU parser scripts
tests/cputestdata/cpu-cpuid.py | 24 +++++++++++------------- tests/cputestdata/cpu-reformat.py | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Jiri Denemark
-
Ján Tomko