From 58a1ad721f6cbcd2fc5aa49437bab635d3fcfca9 Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Tue, 15 Dec 2020 17:25:06 +0100 Subject: [PATCH] cpu-parse: Move xml output to new script Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- tests/cputestdata/cpu-gather.py | 40 +++++++++++++++++++++++++++++++++ tests/cputestdata/cpu-parse.sh | 18 --------------- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/tests/cputestdata/cpu-gather.py b/tests/cputestdata/cpu-gather.py index 1a15cc1ff0..bc5c7dbb15 100755 --- a/tests/cputestdata/cpu-gather.py +++ b/tests/cputestdata/cpu-gather.py @@ -207,10 +207,50 @@ def parse_filename(data): return "x86_64-cpuid-{}".format(filename) +def output_xml(data, filename): + leave_pattern = re.compile( + "^\\s*" + "(0x[0-9a-f]+)\\s*" + "(0x[0-9a-f]+):\\s*" + "eax=(0x[0-9a-f]+)\\s*" + "ebx=(0x[0-9a-f]+)\\s*" + "ecx=(0x[0-9a-f]+)\\s*" + "edx=(0x[0-9a-f]+)\\s*$") + + leave_template = \ + " \n" + + msr_template = " \n" + + print(filename) + with open(filename, "wt") as f: + f.write("\n".format(data["name"])) + f.write("\n") + for line in data["leaves"]: + match = leave_pattern.match(line) + f.write(leave_template.format(*match.groups())) + for key, value in sorted(data["msr"].items()): + f.write(msr_template.format( + int(key), + 0xffffffff & (value >> 32), + 0xffffffff & (value >> 0))) + f.write("\n") + + def parse(args): data = json.load(sys.stdin) filename = parse_filename(data) + filename_xml = "{}.xml".format(filename) + + output_xml(data, filename_xml) os.environ["CPU_GATHER_PY"] = "true" os.environ["model"] = data["name"] diff --git a/tests/cputestdata/cpu-parse.sh b/tests/cputestdata/cpu-parse.sh index 2a41897538..84d37d0df4 100755 --- a/tests/cputestdata/cpu-parse.sh +++ b/tests/cputestdata/cpu-parse.sh @@ -7,21 +7,6 @@ fi data=`cat` -xml() -{ - hex='\(0x[0-9a-f]\+\)' - matchCPUID="$hex $hex: eax=$hex ebx=$hex ecx=$hex edx=$hex" - substCPUID="" - - matchMSR="$hex: $hex\(.......[0-9a-f]\)" - substMSR="" - - echo "" - echo "" - sed -ne "s/^ *$matchCPUID$/ $substCPUID/p; s/^ *$matchMSR$/ $substMSR/p" - echo "" -} - json() { first=true @@ -36,9 +21,6 @@ json() done } -xml <<<"$data" >$fname.xml -echo $fname.xml - json <<<"$data" >$fname.json if [[ -s $fname.json ]]; then echo $fname.json