This changes the invocation from
./cpu-gather.py | ./cpu-parse.sh
to
./cpu-gather.py [--gather] | ./cpu-gather.py --parse
Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
tests/cputestdata/cpu-gather.py | 29 +++++++++++++++++++++++++++--
tests/cputestdata/cpu-parse.sh | 6 ++++--
2 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/tests/cputestdata/cpu-gather.py b/tests/cputestdata/cpu-gather.py
index 005d1019b6..83f175d342 100755
--- a/tests/cputestdata/cpu-gather.py
+++ b/tests/cputestdata/cpu-gather.py
@@ -192,6 +192,15 @@ def gather(args):
return result
+def parse(args):
+ os.environ["CPU_GATHER_PY"] = "true"
+ output = subprocess.check_output(
+ "./cpu-parse.sh",
+ stderr=subprocess.STDOUT,
+ universal_newlines=True)
+ print(output)
+
+
def output_to_text(data):
output = list()
@@ -231,8 +240,21 @@ def main():
"If unset, will try '/usr/bin/qemu-system-x86_64', "
"'/usr/bin/qemu-kvm', and '/usr/libexec/qemu-kvm'.")
+ mode = parser.add_mutually_exclusive_group()
+ mode.add_argument(
+ "--gather",
+ action="store_true",
+ help="Acquire data on target system. This is the default.")
+ mode.add_argument(
+ "--parse",
+ action="store_true",
+ help="Parse data for libvirt use.")
+
args = parser.parse_args()
+ if not args.gather and not args.parse:
+ args.gather = True
+
if not args.path_to_qemu:
args.path_to_qemu = "qemu-system-x86_64"
search = [
@@ -243,8 +265,11 @@ def main():
if os.path.isfile(f):
args.path_to_qemu = f
- data = gather(args)
- print(output_to_text(data))
+ if args.gather:
+ data = gather(args)
+ print(output_to_text(data))
+ else:
+ parse(args)
if __name__ == "__main__":
diff --git a/tests/cputestdata/cpu-parse.sh b/tests/cputestdata/cpu-parse.sh
index 7501c57cba..fa4344b6ad 100755
--- a/tests/cputestdata/cpu-parse.sh
+++ b/tests/cputestdata/cpu-parse.sh
@@ -1,7 +1,9 @@
#!/bin/bash
-# Usage:
-# ./cpu-gather.sh | ./cpu-parse.sh
+if [ -z "${CPU_GATHER_PY}" ]; then
+ echo >&2 "Do not call this script directly. Use 'cpu-gather.py'
instead."
+ exit 1
+fi
data=`cat`
--
2.26.2