]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: introduce qemucapsfixreplies helper
authorPavel Hrdina <phrdina@redhat.com>
Thu, 1 Mar 2018 14:25:05 +0000 (15:25 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Thu, 1 Mar 2018 18:04:19 +0000 (19:04 +0100)
Sometimes we don't regenerate QEMU capabilities replies using QEMU
binary but we simply add a new entry manually.  In that case you need
to manually fix all the replies ids.  This helper will do that for you.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
tests/qemucapabilitiestest.c
tests/qemucapsfixreplies [new file with mode: 0755]

index 87807b413509d37ee6cfe01202205425a910cbcc..acfa1106e40839f960ff0e237d5efb52ec790299 100644 (file)
@@ -192,6 +192,9 @@ mymain(void)
     /*
      * Run "tests/qemucapsprobe /path/to/qemu/binary >foo.replies"
      * to generate updated or new *.replies data files.
+     *
+     * If you manually edit replies files you can run
+     * "tests/qemucapsfixreplies foo.replies" to fix the replies ids.
      */
 
     qemuTestDriverFree(&driver);
diff --git a/tests/qemucapsfixreplies b/tests/qemucapsfixreplies
new file mode 100755 (executable)
index 0000000..4e3371a
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if [ "$#" -ne 1 ] || [ "$1" = "--help" ] || [ ! -f "$1" ]; then
+    echo "This script fixes replies ids in QEMU replies files."
+    echo ""
+    echo "      Usage: $0 path/to/qemu.replies"
+    exit 0
+fi
+
+awk -i inplace \
+    'BEGIN {count=1; pattern="libvirt-[0-9]+"}
+    {
+        if (match($0, "libvirt-1[^0-9]")) {
+            count=1;
+        }
+        if (match($0, pattern)) {
+            str="libvirt-" count;
+            sub(pattern, str, $0);
+            count++;
+        }
+        print
+    }' "$1"