-#! /bin/bash
+#!/bin/bash
# Run a testcase on a remote system, via ssh.
-# Copyright (C) 2012 Free Software Foundation, Inc.
+# 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
# Run with --help flag to get more detailed help.
progname="$(basename $0)"
-env_blacklist='HOME LOGNAME MAIL PATH SHELL SHLVL SSH_CLIENT SSH_CONNECTION
-USER TERM TERMCAP PWD'
usage="usage: ${progname} [--ssh SSH] HOST COMMAND ..."
help="Run a glibc test COMMAND on the remote machine HOST, via ssh,
-passing environment variables, preserving the current working directory,
-and respecting quoting.
+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
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.
-
-${progname} propagates the values all environment variables through to
-the remote target, except the following:
-${env_blacklist}"
+appropriately."
ssh='ssh'
+timeoutfactor=$TIMEOUTFACTOR
while [ $# -gt 0 ]; do
case "$1" in
ssh="$1"
;;
+ "--timeoutfactor")
+ shift
+ if [ $# -lt 1 ]; then
+ break
+ fi
+ timeoutfactor="$1"
+ ;;
+
"--help")
echo "$usage"
echo "$help"
done
}
-# Remove unnecessary newlines from a Bourne shell command sequence.
-remove_newlines ()
-{
- sed -n \
- -e '1h' \
- -e '2,$H' \
- -e '${g
- s/\([^\]\)\n/\1; /g
- p
- }'
-}
-
-# Unset all variables from the blacklist. Then echo all exported
-# variables. The 'export -p' command adds backslashes for environment
-# variables which contain newlines.
-blacklist_exports ()
-{
- (unset ${env_blacklist}; export -p) | remove_newlines
-}
-
-# Produce properly quoted Bourne shell arguments for 'env' to carry
-# over the current environment, less blacklisted variables.
-exports="$(blacklist_exports)"
-exports="${exports:+${exports}; }"
-
# Transform the current argument list into a properly quoted Bourne shell
# command string.
command="$(bourne_quote "$@")"
-# Add commands to set environment variables and the current directory.
-command="${exports}cd $PWD; ${command}"
+# 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,