From: Tim Wiederhake Date: Tue, 15 Dec 2020 16:24:48 +0000 (+0100) Subject: cpu-gather: Create python wrapper for shell script X-Git-Tag: v7.0.0-rc1~168 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=34c9db5a4ab7be99011c41bc5b5b4133e63d555f;p=thirdparty%2Flibvirt.git cpu-gather: Create python wrapper for shell script This changes the invocation from ./cpu-gather.sh | ./cpu-parse.sh to ./cpu-gather.py | ./cpu-parse.sh Signed-off-by: Tim Wiederhake Signed-off-by: Michal Privoznik Reviewed-by: Michal Privoznik --- diff --git a/tests/cputestdata/cpu-gather.py b/tests/cputestdata/cpu-gather.py new file mode 100755 index 0000000000..f7030eb48b --- /dev/null +++ b/tests/cputestdata/cpu-gather.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import os +import subprocess + + +def main(): + os.environ["CPU_GATHER_PY"] = "true" + subprocess.check_call("./cpu-gather.sh") + + +if __name__ == "__main__": + main() diff --git a/tests/cputestdata/cpu-gather.sh b/tests/cputestdata/cpu-gather.sh index 7574324d1c..cd65d74da5 100755 --- a/tests/cputestdata/cpu-gather.sh +++ b/tests/cputestdata/cpu-gather.sh @@ -4,6 +4,11 @@ # distro does not provide such package, you can find the sources or binary # packages at https://www.etallen.com/cpuid.html +if [ -z "${CPU_GATHER_PY}" ]; then + echo >&2 "Do not call this script directly. Use 'cpu-gather.py' instead." + exit 1 +fi + grep 'model name' /proc/cpuinfo | head -n1 cpuid -1r diff --git a/tests/cputestdata/cpu-parse.sh b/tests/cputestdata/cpu-parse.sh index 7501c57cba..2981e9193c 100755 --- a/tests/cputestdata/cpu-parse.sh +++ b/tests/cputestdata/cpu-parse.sh @@ -1,7 +1,7 @@ #!/bin/bash # Usage: -# ./cpu-gather.sh | ./cpu-parse.sh +# ./cpu-gather.py | ./cpu-parse.sh data=`cat`