[PATCH v2 7/7] commandtest: Use virTestCompareToFile() in checkoutput()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In the commandtest there is checkoutput() function which checks
the latest log of commandhelper (containing things like cmd line
arguments, env vars, FDs, CWD, etc.) and compares that against
expected output. Well, the way this function implements that is
effectively by open coding virTestCompareToFile() except for the
nice feature that the virTestCompareToFile() has:
VIR_TEST_OUTPUT_REGENERATE.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 tests/commandtest.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/tests/commandtest.c b/tests/commandtest.c
index 573a4f250d..60daf6e48f 100644
--- a/tests/commandtest.c
+++ b/tests/commandtest.c
@@ -60,29 +60,18 @@ static int checkoutput(const char *testname)
 {
     int ret = -1;
     g_autofree char *expectname = NULL;
-    g_autofree char *expectlog = NULL;
     g_autofree char *actualname = NULL;
     g_autofree char *actuallog = NULL;
 
     expectname = g_strdup_printf("%s/commanddata/%s.log", abs_srcdir, testname);
     actualname = g_strdup_printf("%s/commandhelper.log", abs_builddir);
 
-    if (virFileReadAll(expectname, 1024*64, &expectlog) < 0) {
-        fprintf(stderr, "cannot read %s\n", expectname);
-        goto cleanup;
-    }
-
     if (virFileReadAll(actualname, 1024*64, &actuallog) < 0) {
         fprintf(stderr, "cannot read %s\n", actualname);
         goto cleanup;
     }
 
-    if (STRNEQ(expectlog, actuallog)) {
-        virTestDifference(stderr, expectlog, actuallog);
-        goto cleanup;
-    }
-
-    ret = 0;
+    ret = virTestCompareToFile(actuallog, expectname);
 
  cleanup:
     if (actualname)
@@ -1281,6 +1270,7 @@ mymain(void)
      * since we're about to reset 'environ' */
     ignore_value(virTestGetDebug());
     ignore_value(virTestGetVerbose());
+    ignore_value(virTestGetRegenerate());
 
     /* Make sure to not leak fd's */
     virinitret = virInitialize();
-- 
2.34.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux