summaryrefslogtreecommitdiffstats
path: root/utils/bugpoint
diff options
context:
space:
mode:
authorViktor Kutuzov <vkutuzov@accesssoftek.com>2009-07-14 20:08:45 +0000
committerViktor Kutuzov <vkutuzov@accesssoftek.com>2009-07-14 20:08:45 +0000
commita266b5f22811480a65e65a08c8a5d92fe9be8a3b (patch)
tree6f817541af11a8c60f8d95fea7fd3143e192fabf /utils/bugpoint
parent9e3152b381f8ca819c076d1b9436c393bd41304f (diff)
downloadexternal_llvm-a266b5f22811480a65e65a08c8a5d92fe9be8a3b.zip
external_llvm-a266b5f22811480a65e65a08c8a5d92fe9be8a3b.tar.gz
external_llvm-a266b5f22811480a65e65a08c8a5d92fe9be8a3b.tar.bz2
Helper script to use bugpoint with a remote target.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75669 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/bugpoint')
-rw-r--r--utils/bugpoint/RemoteRunSafely.sh108
1 files changed, 108 insertions, 0 deletions
diff --git a/utils/bugpoint/RemoteRunSafely.sh b/utils/bugpoint/RemoteRunSafely.sh
new file mode 100644
index 0000000..543a225
--- /dev/null
+++ b/utils/bugpoint/RemoteRunSafely.sh
@@ -0,0 +1,108 @@
+#!/bin/sh
+#
+# Program: RemoteRunSafely.sh
+#
+# Synopsis: This script simply runs another program remotely using rsh.
+# It always returns the another program exit code.
+#
+# (?) only exit statuses that indicates that the program could not be executed
+# normally is considered to indicate a test failure.
+#
+# Syntax:
+#
+# RemoteRunSafely.sh <hostname> [-l <login_name>] [-p <port>]
+# <program> <args...>
+#
+# where:
+# <hostname> is the remote host to execute the program,
+# <login_name> is the username on the remote host,
+# <port> is the port used by the remote client,
+# <program> is the path to the program to run,
+# <args...> are the arguments to pass to the program.
+#
+
+printUsageAndExit()
+{
+ echo "Usage:"
+ echo "./RemoteRunSafely.sh <hostname> [-l <login_name>] [-p <port>] " \
+ "[cd <working_dir>] <program> <args...>"
+ exit 1
+}
+
+moreArgsExpected()
+{
+ # $1 - remaining number of arguments
+ # $2 - number of arguments to shift
+ if [ $1 -lt $2 ]
+ then
+ echo "Error: Wrong number of argumants."
+ printUsageAndExit
+ fi
+}
+
+# Save a copy of the original arguments in a string before we
+# clobber them with the shift command.
+ORIG_ARGS="$*"
+#DEBUG: echo 'GOT: '$ORIG_ARGS
+
+moreArgsExpected $# 1
+RHOST=$1
+shift 1
+
+RUSER=`id -un`
+RCLIENT=ssh
+RPORT=
+WORKING_DIR=
+
+moreArgsExpected $# 1
+if [ $1 = "-l" ]; then
+ moreArgsExpected $# 2
+ RUSER=$2
+ shift 2
+fi
+moreArgsExpected $# 1
+if [ $1 = "-p" ]; then
+ moreArgsExpected $# 2
+ RPORT="-p $2"
+ shift 2
+fi
+
+moreArgsExpected $# 1
+PROGRAM=$(basename $1)
+WORKING_DIR=$(dirname $1)
+shift 1
+
+#DEBUG: echo 'DIR='${0%%`basename $0`}
+#DEBUG: echo 'RHOST='$RHOST
+#DEBUG: echo 'RUSER='$RUSER
+#DEBUG: echo 'PROGRAM='$PROGRAM
+#DEBUG: echo 'WORKING_DIR='$WORKING_DIR
+#DEBUG: echo 'ARGS='$*
+
+# Sanity check
+if [ "$RHOST" = "" -o "$PROGRAM" = "" ]; then
+ printUsageAndExit
+fi
+
+# Local program file must exist and be execuatble
+local_program=$WORKING_DIR"/"$PROGRAM
+if [ ! -x "$local_program" ]; then
+ echo "File "$local_program" does not exist or is not an executable.."
+ exit 2
+fi
+
+connection=$RUSER'@'$RHOST
+remote="./"$PROGRAM
+(
+ cat $local_program | \
+ $RCLIENT $connection $RPORT \
+ 'rm -f '$remote' ; ' \
+ 'cat > '$remote' ; chmod +x '$remote' ; '$remote' '$*' ; ' \
+ 'echo exit $? ; ' \
+ 'rm -f '$remote
+)
+
+#DEBUG: err=$?
+#DEBUG: echo script exit $err
+#DEBUG: exit $err
+