]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cpu-parse: Move file name generation to new script
authorTim Wiederhake <twiederh@redhat.com>
Tue, 15 Dec 2020 16:25:05 +0000 (17:25 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 18 Dec 2020 22:20:35 +0000 (23:20 +0100)
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/cputestdata/cpu-gather.py
tests/cputestdata/cpu-parse.sh

index 0b1019456c50225d57f7f371d120cf1a13ba223f..1a15cc1ff03d401e414f764e3a6eed2f4ef4e9e9 100755 (executable)
@@ -4,6 +4,7 @@ import argparse
 import fcntl
 import json
 import os
+import re
 import struct
 import subprocess
 import sys
@@ -192,11 +193,28 @@ def gather(args):
     return result
 
 
+def parse_filename(data):
+    filename = data["name"].strip()
+    filename = re.sub("[ -]+ +", " ", filename)
+    filename = re.sub("\\(([Rr]|[Tt][Mm])\\)", "", filename)
+    filename = re.sub(".*(Intel|AMD) ", "", filename)
+    filename = re.sub(" (Duo|Quad|II X[0-9]+)", " ", filename)
+    filename = re.sub(" (CPU|Processor)", "", filename)
+    filename = re.sub(" @.*", "", filename)
+    filename = re.sub(" APU .*", "", filename)
+    filename = re.sub(" SE$", "", filename)
+    filename = re.sub(" ", "-", filename)
+    return "x86_64-cpuid-{}".format(filename)
+
+
 def parse(args):
     data = json.load(sys.stdin)
 
+    filename = parse_filename(data)
+
     os.environ["CPU_GATHER_PY"] = "true"
     os.environ["model"] = data["name"]
+    os.environ["fname"] = filename
     output = subprocess.check_output(
         "./cpu-parse.sh",
         input=output_to_text(data),
index 5b8e57e427b41b5b31b92023484721b71b80b794..2a4189753853e636778aa37d8db0208c75c05dee 100755 (executable)
@@ -7,19 +7,6 @@ fi
 
 data=`cat`
 
-fname=`sed -e 's/^ *//;
-               s/ *$//;
-               s/[ -]\+ \+/ /g;
-               s/(\([Rr]\|[Tt][Mm]\))//g;
-               s/.*\(Intel\|AMD\) //;
-               s/ \(Duo\|Quad\|II X[0-9]\+\) / /;
-               s/ \(CPU\|Processor\)\>//;
-               s/ @.*//;
-               s/ APU .*//;
-               s/ SE$//;
-               s/ /-/g' <<<"$model"`
-fname="x86_64-cpuid-$fname"
-
 xml()
 {
     hex='\(0x[0-9a-f]\+\)'