]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
testutils: remove now unused virTestCaptureProgramOutput
authorJán Tomko <jtomko@redhat.com>
Sun, 9 Feb 2020 01:04:13 +0000 (02:04 +0100)
committerJán Tomko <jtomko@redhat.com>
Tue, 11 Feb 2020 15:30:18 +0000 (16:30 +0100)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
tests/testutils.c
tests/testutils.h

index a7a8a19fffc5ef9f3372e8aa135572aae9403ca7..8326602c9c0f14307bc424f316d36dd5c3cf07e7 100644 (file)
@@ -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)
 {
index c1b365ab0d89da69b9439bbfdbd16035825698b3..3f32aa720024079ab8737995cf2605a269775f7b 100644 (file)
@@ -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,