]> xenbits.xensource.com Git - libvirt.git/commitdiff
cputest: Avoid calling json_reformat in cpu-parse.sh
authorJiri Denemark <jdenemar@redhat.com>
Tue, 26 Sep 2017 21:02:48 +0000 (23:02 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 16 Oct 2017 07:23:20 +0000 (09:23 +0200)
Various version of json_reformat use different number of spaces for
indenting. Let's use a simple python reformatter to gain full control
over the formatting for consistent results.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
tests/cputestdata/cpu-parse.sh
tests/cputestdata/cpu-reformat.py [new file with mode: 0755]

index cd1ab024b33cf61ac249b84b3ccf7e71e79d57c3..96ff1074e0bfe0b8a2e7423b1ef2b56f33fef261 100755 (executable)
@@ -42,7 +42,7 @@ json()
     while read; do
         $first || echo
         first=false
-        json_reformat <<<"$REPLY" | tr -s '\n'
+        $(dirname $0)/cpu-reformat.py <<<"$REPLY"
     done
 }
 
diff --git a/tests/cputestdata/cpu-reformat.py b/tests/cputestdata/cpu-reformat.py
new file mode 100755 (executable)
index 0000000..999ef16
--- /dev/null
@@ -0,0 +1,9 @@
+#!/usr/bin/env python2
+
+import sys
+import json
+
+dec = json.JSONDecoder()
+data, pos = dec.raw_decode(sys.stdin.read())
+json.dump(data, sys.stdout, indent = 2, separators = (',', ': '))
+print