]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: use PYTHON detected from configure
authorCole Robinson <crobinso@redhat.com>
Mon, 9 Dec 2019 14:30:10 +0000 (09:30 -0500)
committerCole Robinson <crobinso@redhat.com>
Tue, 10 Dec 2019 14:55:45 +0000 (09:55 -0500)
Extend configure to pass the detect python binary to C code, and
use it in the test suite, rather than searching PATH

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
configure.ac
tests/testutils.c

index 2e5af075eab7a632868fdfdbaa69f1072b429e84..6c7c186d18e75b4ca6d4202118b732953c5cde64 100644 (file)
@@ -705,6 +705,7 @@ AC_PATH_PROGS([PYTHON], [python3])
 if test -z "$PYTHON"; then
     AC_MSG_ERROR(['python3' binary is required to build libvirt])
 fi
+AC_DEFINE_UNQUOTED([PYTHON], "$PYTHON", [path to python binary])
 AC_PATH_PROG([FLAKE8], [flake8])
 if test -z "$FLAKE8"; then
     AC_MSG_WARN(['flake8' binary is required to check python code style])
index a8215afa425b2780712078da9ef110aafa264fad..6efc877d0c7b1148d32c99c6001dcee8be7ee859 100644 (file)
@@ -58,7 +58,6 @@ static size_t testCounter;
 static virBitmapPtr testBitmap;
 
 char *progname;
-static char *python;
 
 virArch virTestHostArch = VIR_ARCH_X86_64;
 
@@ -428,14 +427,9 @@ virTestRewrapFile(const char *filename)
           virStringHasSuffix(filename, ".ldargs")))
         return 0;
 
-    if (!python) {
-        fprintf(stderr, "cannot rewrap %s: unable to find python in path", filename);
-        return -1;
-    }
-
     script = g_strdup_printf("%s/scripts/test-wrap-argv.py", abs_top_srcdir);
 
-    cmd = virCommandNewArgList(python, script, "--in-place", filename, NULL);
+    cmd = virCommandNewArgList(PYTHON, script, "--in-place", filename, NULL);
     if (virCommandRun(cmd, NULL) < 0)
         goto cleanup;
 
@@ -919,9 +913,6 @@ int virTestMain(int argc,
         }
     }
 
-    /* Find python early because some tests override PATH */
-    python = virFindFileInPath("python");
-
     ret = (func)();
 
     virResetLastError();
@@ -931,7 +922,6 @@ int virTestMain(int argc,
         fprintf(stderr, " %-3zu %s\n", testCounter, ret == 0 ? "OK" : "FAIL");
     }
     virLogReset();
-    VIR_FREE(python);
     return ret;
 }