mirror of
git://sourceware.org/git/glibc.git
synced 2024-12-15 04:20:28 +08:00
5a82c74822
Also, change sources.redhat.com to sourceware.org. This patch was automatically generated by running the following shell script, which uses GNU sed, and which avoids modifying files imported from upstream: sed -ri ' s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g ' \ $(find $(git ls-files) -prune -type f \ ! -name '*.po' \ ! -name 'ChangeLog*' \ ! -path COPYING ! -path COPYING.LIB \ ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \ ! -path manual/texinfo.tex ! -path scripts/config.guess \ ! -path scripts/config.sub ! -path scripts/install-sh \ ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \ ! -path INSTALL ! -path locale/programs/charmap-kw.h \ ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \ ! '(' -name configure \ -execdir test -f configure.ac -o -f configure.in ';' ')' \ ! '(' -name preconfigure \ -execdir test -f preconfigure.ac ';' ')' \ -print) and then by running 'make dist-prepare' to regenerate files built from the altered files, and then executing the following to cleanup: chmod a+x sysdeps/unix/sysv/linux/riscv/configure # Omit irrelevant whitespace and comment-only changes, # perhaps from a slightly-different Autoconf version. git checkout -f \ sysdeps/csky/configure \ sysdeps/hppa/configure \ sysdeps/riscv/configure \ sysdeps/unix/sysv/linux/csky/configure # Omit changes that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines git checkout -f \ sysdeps/powerpc/powerpc64/ppc-mcount.S \ sysdeps/unix/sysv/linux/s390/s390-64/syscall.S # Omit change that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
99 lines
3.3 KiB
C
99 lines
3.3 KiB
C
/* Verify capture output from a subprocess.
|
|
Copyright (C) 2017-2019 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, see
|
|
<https://www.gnu.org/licenses/>. */
|
|
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <support/capture_subprocess.h>
|
|
#include <support/check.h>
|
|
#include <sys/wait.h>
|
|
|
|
static void
|
|
print_context (const char *context, bool *failed)
|
|
{
|
|
if (*failed)
|
|
/* Do not duplicate message. */
|
|
return;
|
|
support_record_failure ();
|
|
printf ("error: subprocess failed: %s\n", context);
|
|
}
|
|
|
|
static void
|
|
print_actual_status (struct support_capture_subprocess *proc)
|
|
{
|
|
if (WIFEXITED (proc->status))
|
|
printf ("error: actual exit status: %d [0x%x]\n",
|
|
WEXITSTATUS (proc->status), proc->status);
|
|
else if (WIFSIGNALED (proc->status))
|
|
printf ("error: actual termination signal: %d [0x%x]\n",
|
|
WTERMSIG (proc->status), proc->status);
|
|
else
|
|
printf ("error: actual undecoded exit status: [0x%x]\n", proc->status);
|
|
}
|
|
|
|
void
|
|
support_capture_subprocess_check (struct support_capture_subprocess *proc,
|
|
const char *context, int status_or_signal,
|
|
int allowed)
|
|
{
|
|
TEST_VERIFY ((allowed & sc_allow_none)
|
|
|| (allowed & sc_allow_stdout)
|
|
|| (allowed & sc_allow_stderr));
|
|
TEST_VERIFY (!((allowed & sc_allow_none)
|
|
&& ((allowed & sc_allow_stdout)
|
|
|| (allowed & sc_allow_stderr))));
|
|
|
|
bool failed = false;
|
|
if (status_or_signal >= 0)
|
|
{
|
|
/* Expect regular termination. */
|
|
if (!(WIFEXITED (proc->status)
|
|
&& WEXITSTATUS (proc->status) == status_or_signal))
|
|
{
|
|
print_context (context, &failed);
|
|
printf ("error: expected exit status: %d\n", status_or_signal);
|
|
print_actual_status (proc);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
/* status_or_signal < 0. Expect termination by signal. */
|
|
if (!(WIFSIGNALED (proc->status)
|
|
&& WTERMSIG (proc->status) == -status_or_signal))
|
|
{
|
|
print_context (context, &failed);
|
|
printf ("error: expected termination signal: %d\n",
|
|
-status_or_signal);
|
|
print_actual_status (proc);
|
|
}
|
|
}
|
|
if (!(allowed & sc_allow_stdout) && proc->out.length != 0)
|
|
{
|
|
print_context (context, &failed);
|
|
printf ("error: unexpected output from subprocess\n");
|
|
fwrite (proc->out.buffer, proc->out.length, 1, stdout);
|
|
puts ("\n");
|
|
}
|
|
if (!(allowed & sc_allow_stderr) && proc->err.length != 0)
|
|
{
|
|
print_context (context, &failed);
|
|
printf ("error: unexpected error output from subprocess\n");
|
|
fwrite (proc->err.buffer, proc->err.length, 1, stdout);
|
|
puts ("\n");
|
|
}
|
|
}
|