glibc/scripts/cross-test-ssh.sh
Paul Eggert 5a82c74822 Prefer https to http for gnu.org and fsf.org URLs
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
2019-09-07 02:43:31 -07:00

136 lines
3.8 KiB
Bash
Executable File

#!/bin/bash
# Run a testcase on a remote system, via ssh.
# Copyright (C) 2012-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/>.
# usage: cross-test-ssh.sh [--ssh SSH] HOST COMMAND ...
# Run with --help flag to get more detailed help.
progname="$(basename $0)"
usage="usage: ${progname} [--ssh SSH] HOST COMMAND ..."
help="Run a glibc test COMMAND on the remote machine HOST, via ssh,
preserving the current working directory, and respecting quoting.
If the '--ssh SSH' flag is present, use SSH as the SSH command,
instead of ordinary 'ssh'.
If the '--timeoutfactor FACTOR' flag is present, set TIMEOUTFACTOR on
the remote machine to the specified FACTOR.
To use this to run glibc tests, invoke the tests as follows:
$ make test-wrapper='ABSPATH/cross-test-ssh.sh HOST' tests
where ABSPATH is the absolute path to this script, and HOST is the
name of the machine to connect to via ssh.
If you need to connect to the test machine as a different user, you
may specify that just as you would to SSH:
$ make test-wrapper='ABSPATH/cross-test-ssh.sh USER@HOST' tests
Naturally, the remote user must have an appropriate public key, and
you will want to ensure that SSH does not prompt interactively for a
password on each connection.
HOST and the build machines (on which 'make check' is being run) must
share a filesystem; all files needed by the tests must be visible at
the same paths on both machines.
${progname} runs COMMAND in the same directory on the HOST that
${progname} itself is run in on the build machine.
The command and arguments are passed to the remote host in a way that
avoids any further shell substitution or expansion, on the assumption
that the shell on the build machine has already done them
appropriately."
ssh='ssh'
timeoutfactor=$TIMEOUTFACTOR
while [ $# -gt 0 ]; do
case "$1" in
"--ssh")
shift
if [ $# -lt 1 ]; then
break
fi
ssh="$1"
;;
"--timeoutfactor")
shift
if [ $# -lt 1 ]; then
break
fi
timeoutfactor="$1"
;;
"--help")
echo "$usage"
echo "$help"
exit 0
;;
*)
break
;;
esac
shift
done
if [ $# -lt 1 ]; then
echo "$usage" >&2
echo "Type '${progname} --help' for more detailed help." >&2
exit 1
fi
host="$1"; shift
# Print the sequence of arguments as strings properly quoted for the
# Bourne shell, separated by spaces.
bourne_quote ()
{
local arg qarg
for arg in "$@"; do
qarg=${arg//\'/\'\\\'\'}
echo -n "'$qarg' "
done
}
# Transform the current argument list into a properly quoted Bourne shell
# command string.
command="$(bourne_quote "$@")"
# Add command to set the current directory.
command="cd $(bourne_quote "$PWD")
${command}"
# Add command to set the timeout factor, if required.
if [ "$timeoutfactor" ]; then
command="export TIMEOUTFACTOR=$(bourne_quote "$timeoutfactor")
${command}"
fi
# HOST's sshd simply concatenates its arguments with spaces and
# passes them to some shell. We want to force the use of /bin/sh,
# so we need to re-quote the whole command to ensure it appears as
# the sole argument of the '-c' option.
full_command="$(bourne_quote "${command}")"
$ssh "$host" /bin/sh -c "$full_command"