[libvirt] [PATCH 0/2] tests: VIR_TEST_REGENERATE_OUTPUT fixes

First fix is straightforward, the test-wrap-argv.py path needs to be adjusted. Second bit fixes an issue I hit with: VIR_TEST_REGENERATE_OUTPUT=1 ./build/tests/qemuxml2argvtest Where it reported not finding a python binary. I assume this is due to some preload PATH alteration, like the comment suggests, but I didn't investigate it. The patch sidesteps the issue and seems worth doing anyways Cole Robinson (2): tests: fix REGENERATE test-wrap-argv.py usage tests: use PYTHON detected from configure configure.ac | 1 + tests/testutils.c | 14 ++------------ 2 files changed, 3 insertions(+), 12 deletions(-) -- 2.23.0

The path needs to be adjusted for the new script location Signed-off-by: Cole Robinson <crobinso@redhat.com> --- tests/testutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testutils.c b/tests/testutils.c index 9312ff761e..a8215afa42 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -433,7 +433,7 @@ virTestRewrapFile(const char *filename) return -1; } - script = g_strdup_printf("%s/test-wrap-argv.py", abs_srcdir); + script = g_strdup_printf("%s/scripts/test-wrap-argv.py", abs_top_srcdir); cmd = virCommandNewArgList(python, script, "--in-place", filename, NULL); if (virCommandRun(cmd, NULL) < 0) -- 2.23.0

Extend configure to pass the detect python binary to C code, and use it in the test suite, rather than searching PATH Signed-off-by: Cole Robinson <crobinso@redhat.com> --- configure.ac | 1 + tests/testutils.c | 12 +----------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index 2e5af075ea..6c7c186d18 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) diff --git a/tests/testutils.c b/tests/testutils.c index a8215afa42..6efc877d0c 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -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; } -- 2.23.0

On Mon, Dec 09, 2019 at 09:30:08AM -0500, Cole Robinson wrote:
First fix is straightforward, the test-wrap-argv.py path needs to be adjusted.
Second bit fixes an issue I hit with:
VIR_TEST_REGENERATE_OUTPUT=1 ./build/tests/qemuxml2argvtest
Where it reported not finding a python binary. I assume this is due to some preload PATH alteration, like the comment suggests, but I didn't investigate it.
The real reason is "python" being a symlink - virFindFileInPath calls virFileIsExecutable which contains a check for S_ISREG.
The patch sidesteps the issue and seems worth doing anyways
Cole Robinson (2): tests: fix REGENERATE test-wrap-argv.py usage tests: use PYTHON detected from configure
configure.ac | 1 + tests/testutils.c | 14 ++------------ 2 files changed, 3 insertions(+), 12 deletions(-)
Yay, less lines! Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Cole Robinson
-
Ján Tomko