From 34c9db5a4ab7be99011c41bc5b5b4133e63d555f Mon Sep 17 00:00:00 2001 From: Tim Wiederhake Date: Tue, 15 Dec 2020 17:24:48 +0100 Subject: [PATCH] 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 --- tests/cputestdata/cpu-gather.py | 13 +++++++++++++ tests/cputestdata/cpu-gather.sh | 5 +++++ tests/cputestdata/cpu-parse.sh | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100755 tests/cputestdata/cpu-gather.py 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`