Bug 590977 followup: remove debug set -x statement (r=cpeyer)
[tamarin-stm.git] / build / buildbot / slaves / all / ssh-shell.sh
blobbcaf0c1d4c6d54225c71d41bbea9c7fde5b70f6f
1 #!/bin/bash
2 # ***** BEGIN LICENSE BLOCK *****
3 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 # The contents of this file are subject to the Mozilla Public License Version
6 # 1.1 (the "License"); you may not use this file except in compliance with
7 # the License. You may obtain a copy of the License at
8 # http://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an "AS IS" basis,
11 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 # for the specific language governing rights and limitations under the
13 # License.
15 # The Original Code is [Open Source Virtual Machine.].
17 # The Initial Developer of the Original Code is
18 # Adobe System Incorporated.
19 # Portions created by the Initial Developer are Copyright (C) 2010
20 # the Initial Developer. All Rights Reserved.
22 # Contributor(s):
23 # Adobe AS3 Team
25 # Alternatively, the contents of this file may be used under the terms of
26 # either the GNU General Public License Version 2 or later (the "GPL"), or
27 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 # in which case the provisions of the GPL or the LGPL are applicable instead
29 # of those above. If you wish to allow use of your version of this file only
30 # under the terms of either the GPL or the LGPL, and not to allow others to
31 # use your version of this file under the terms of the MPL, indicate your
32 # decision by deleting the provisions above and replace them with the notice
33 # and other provisions required by the GPL or the LGPL. If you do not delete
34 # the provisions above, a recipient may use your version of this file under
35 # the terms of any one of the MPL, the GPL or the LGPL.
37 # ***** END LICENSE BLOCK ***** */
38 # acts as a proxy to remotely run abc files via a ssh call to the remote machine
39 # usage: ./ssh_shell.sh <vmargs> file.abc
40 # assumes the shell is deployed to $SSH_SHELL_REMOTE_DIR/avmshell
43 if [ "$SSH_SHELL_REMOTE_USER" = "" ] ||
44 [ "$SSH_SHELL_REMOTE_HOST" = "" ] ||
45 [ "$SSH_SHELL_REMOTE_DIR" = "" ];
46 then
47 echo "missing environment variable: "
48 echo "SSH_SHELL_REMOTE_USER" = "$SSH_SHELL_REMOTE_USER"
49 echo "SSH_SHELL_REMOTE_HOST" = "$SSH_SHELL_REMOTE_HOST"
50 echo "SSH_SHELL_REMOTE_DIR" = "$SSH_SHELL_REMOTE_DIR"
51 exit 1
54 filelist=""
55 flatfilelist=""
56 if [ "$1" = "" ]
57 then
58 ssh $SSH_SHELL_REMOTE_USER@$SSH_SHELL_REMOTE_HOST "cd $SSH_SHELL_REMOTE_DIR;./avmshell"
59 else
60 # Note that testfiles are copied to the SSH_SHELL_REMOTE_DIR directly and
61 # run one at a time. No dir structure is preserved when copying the files.
62 args=""
63 for a in $*
65 # look for an .abc file
66 echo "$a" | grep ".*\.abc" > /dev/null
67 res=$?
68 if [ "$res" = "0" ]
69 then
70 file=$a
71 flatfile=`basename $a`
72 # check to see if flatfile is already in filelist
73 echo "$filelist" | grep "$flatfile" > /dev/null
74 res=$?
75 if [ "$res" = "1" ]; then
76 # flatfile is not in filelist; add it
77 filelist="$filelist $flatfile"
78 # copy file to device
79 scp $file $SSH_SHELL_REMOTE_USER@$SSH_SHELL_REMOTE_HOST:$SSH_SHELL_REMOTE_DIR/$flatfile > /dev/null
81 # even if flatfile is already in filelist, add to args
82 args="$args $flatfile"
83 else
84 args="$args $a"
86 done
87 # workaround for not returning exit code, run a shell script and print exit code to stdout
88 ssh $SSH_SHELL_REMOTE_USER@$SSH_SHELL_REMOTE_HOST "cd $SSH_SHELL_REMOTE_DIR;./ssh-shell-runner.sh $args" > ./stdout
89 ret=`cat ./stdout | grep "EXITCODE=" | awk -F= '{printf("%d",$2)}'`
90 # clean up copied over files
91 for a in $filelist
93 ssh $SSH_SHELL_REMOTE_USER@$SSH_SHELL_REMOTE_HOST "cd $SSH_SHELL_REMOTE_DIR;rm $a"
94 done
95 # remove the EXITCODE from the stdout before returning it so that exact output matching will be fine
96 cat ./stdout | sed 's/^EXITCODE=[0-9][0-9]*$//g' > ./stdout_clean
97 cat ./stdout_clean
98 rm -f ./stdout ./stdout_clean
99 exit $ret