testutils: remove now unused virTestCaptureProgramOutput

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Ján Tomko 2020-02-09 02:04:13 +01:00
parent cf17015fde
commit 090ad3cf39
2 changed files with 0 additions and 86 deletions

View 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)
{

View 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,