]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virbuftest: Increase coverage
authorAndrea Bolognani <abologna@redhat.com>
Fri, 11 Feb 2022 14:48:02 +0000 (15:48 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Mon, 14 Feb 2022 10:31:56 +0000 (11:31 +0100)
Test the behavior of virBufferEscapeShell for different types of
quotes as well as the empty string.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tests/virbuftest.c

index 977e0883a6982e32451aeafdafc063eb10657ed8..79bd0cae8e1a19be9bed879b7f1d5bceb53355c8 100644 (file)
@@ -20,7 +20,8 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUSED)
     g_auto(virBuffer) bufinit = VIR_BUFFER_INITIALIZER;
     virBuffer *buf = &bufinit;
     const char expected[] =
-        "  1\n  2\n  3\n  4\n  5\n  6\n  7\n  &amp;\n  8\n  9\n  10\n  ' 11'\n";
+        "  1\n  2\n  3\n  4\n  5\n  6\n  7\n  &amp;\n  8\n  9\n  10\n"
+        "  ' 11'\n  ''\\''12'\n  '\"13'\n  ''\n";
     g_autofree char *result = NULL;
     int ret = 0;
 
@@ -85,6 +86,12 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUSED)
     virBufferAddChar(buf, '\n');
     virBufferEscapeShell(buf, " 11");
     virBufferAddChar(buf, '\n');
+    virBufferEscapeShell(buf, "'12");
+    virBufferAddChar(buf, '\n');
+    virBufferEscapeShell(buf, "\"13");
+    virBufferAddChar(buf, '\n');
+    virBufferEscapeShell(buf, "");
+    virBufferAddChar(buf, '\n');
 
     result = virBufferContentAndReset(buf);
     if (!result || STRNEQ(result, expected)) {