[prev in list] [next in list] [prev in thread] [next in thread] 

List:       libvir-list
Subject:    [PATCH 03/35] virshtest: Filter multiple occurences of string to drop in testFilterLine
From:       Peter Krempa <pkrempa () redhat ! com>
Date:       2024-03-28 13:22:25
Message-ID: 2314e62e486ca6e488fcb48c5b466c04d8a1c8f6.1711129973.git.pkrempa () redhat ! com
[Download RAW message or body]

Upcoming patches will require that possibly multiple occurences of the
string to drop are present in the output string thus we need to adapt
testFilterLine to handle them.

Additionally we drop the unused return value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 tests/virshtest.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/tests/virshtest.c b/tests/virshtest.c
index 4097c1d427..e0b5cd3150 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -90,21 +90,20 @@ device_read_bytes_sec: " SET_BLKIO_PARAMETER "\n\
 device_write_bytes_sec: " SET_BLKIO_PARAMETER "\n\
 \n";

-static int testFilterLine(char *buffer,
-                          const char *toRemove)
+static void testFilterLine(char *buffer,
+                           const char *toRemove)
 {
     char *start;
-    char *end;

-    if (!(start = strstr(buffer, toRemove)))
-      return -1;
+    while ((start = strstr(buffer, toRemove))) {
+        char *end;

-    if (!(end = strstr(start+1, "\n"))) {
-      *start = '\0';
-    } else {
-      memmove(start, end, strlen(end)+1);
+        if (!(end = strstr(start+1, "\n"))) {
+            *start = '\0';
+        } else {
+            memmove(start, end, strlen(end)+1);
+        }
     }
-    return 0;
 }

 static int
@@ -134,8 +133,8 @@ testCompareOutputLit(const char *expectFile,
         actual = g_strdup_printf("%s\n## Exit code: %d\n", tmp, exitstatus);
     }

-    if (filter && testFilterLine(actual, filter) < 0)
-        return -1;
+    if (filter)
+        testFilterLine(actual, filter);

     if (expectData) {
         if (virTestCompareToString(expectData, actual) < 0)
-- 
2.44.0
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic