[libvirt PATCH 7/7] testutils: remove now unused virTestCaptureProgramOutput

Ján Tomko jtomko at redhat.com
Sun Feb 9 01:32:37 UTC 2020


Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 tests/testutils.c | 84 -----------------------------------------------
 tests/testutils.h |  2 --
 2 files changed, 86 deletions(-)

diff --git a/tests/testutils.c b/tests/testutils.c
index a7a8a19fff..8326602c9c 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -329,90 +329,6 @@ virTestLoadFileJSON(const char *p, ...)
 }
 
 
-#ifndef WIN32
-static
-void virTestCaptureProgramExecChild(const char *const argv[],
-                                    int pipefd)
-{
-    size_t i;
-    int open_max;
-    int stdinfd = -1;
-    const char *const env[] = {
-        "LANG=C",
-        NULL
-    };
-
-    if ((stdinfd = open("/dev/null", O_RDONLY)) < 0)
-        goto cleanup;
-
-    open_max = sysconf(_SC_OPEN_MAX);
-    if (open_max < 0)
-        goto cleanup;
-
-    for (i = 0; i < open_max; i++) {
-        if (i != stdinfd &&
-            i != pipefd) {
-            int tmpfd;
-            tmpfd = i;
-            VIR_FORCE_CLOSE(tmpfd);
-        }
-    }
-
-    if (dup2(stdinfd, STDIN_FILENO) != STDIN_FILENO)
-        goto cleanup;
-    if (dup2(pipefd, STDOUT_FILENO) != STDOUT_FILENO)
-        goto cleanup;
-    if (dup2(pipefd, STDERR_FILENO) != STDERR_FILENO)
-        goto cleanup;
-
-    /* SUS is crazy here, hence the cast */
-    execve(argv[0], (char *const*)argv, (char *const*)env);
-
- cleanup:
-    VIR_FORCE_CLOSE(stdinfd);
-}
-
-int
-virTestCaptureProgramOutput(const char *const argv[], char **buf, int maxlen)
-{
-    int pipefd[2];
-    int len;
-
-    if (virPipeQuiet(pipefd) < 0)
-        return -1;
-
-    pid_t pid = fork();
-    switch (pid) {
-    case 0:
-        VIR_FORCE_CLOSE(pipefd[0]);
-        virTestCaptureProgramExecChild(argv, pipefd[1]);
-
-        VIR_FORCE_CLOSE(pipefd[1]);
-        _exit(EXIT_FAILURE);
-
-    case -1:
-        return -1;
-
-    default:
-        VIR_FORCE_CLOSE(pipefd[1]);
-        len = virFileReadLimFD(pipefd[0], maxlen, buf);
-        VIR_FORCE_CLOSE(pipefd[0]);
-        if (virProcessWait(pid, NULL, false) < 0)
-            return -1;
-
-        return len;
-    }
-}
-#else /* !WIN32 */
-int
-virTestCaptureProgramOutput(const char *const argv[] G_GNUC_UNUSED,
-                            char **buf G_GNUC_UNUSED,
-                            int maxlen G_GNUC_UNUSED)
-{
-    return -1;
-}
-#endif /* !WIN32 */
-
 static int
 virTestRewrapFile(const char *filename)
 {
diff --git a/tests/testutils.h b/tests/testutils.h
index c1b365ab0d..3f32aa7200 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -46,8 +46,6 @@ char *virTestLoadFilePath(const char *p, ...)
 virJSONValuePtr virTestLoadFileJSON(const char *p, ...)
     G_GNUC_NULL_TERMINATED;
 
-int virTestCaptureProgramOutput(const char *const argv[], char **buf, int maxlen);
-
 void virTestClearCommandPath(char *cmdset);
 
 int virTestDifference(FILE *stream,
-- 
2.21.1




More information about the libvir-list mailing list