-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_guest.sh
72 lines (58 loc) · 1.62 KB
/
run_guest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
#
# usage:
# run standard testcases on VM (called from host user)
# run_guest.sh <VM> <RUNNAME> <WORKDIR>
#
show_help() {
sed -n 2,$[$BASH_LINENO-4]p $BASH_SOURCE | grep "^#" | sed 's/^#/ /'
exit
}
cd $(dirname $BASH_SOURCE)
FAILRETRY=${FAILRETRY:=3}
PRIORITY=${PRIORITY:=0-15}
TIMEOUT=${TIMEOUT:=150}
VM=$1
RUNNAME=$2
WDIR=$3
[ ! "$VM" ] && echo "no VM given" && show_help
[ ! "$RUNNAME" ] && echo "no RUNNAME given" && show_help
[ ! "$WDIR" ] && echo "no WDIR given" && show_help
mkdir -p /tmp/run_guest.sh
TMPD=$(mktemp -d /tmp/run_guest.sh/XXXXXX)
ruby test_core/lib/vm_serial_setting.rb $VM > $TMPD/serial
if grep -q file-based $TMPD/serial ; then
echo file
SERIALFILE=$(sed -n 2p $TMPD/serial)
else
echo "WARNING: serial console of guest $VM is not file log based, so you will not have serial console output during testing."
echo "Try to use test_core/lib/vm_serial_setting.rb for serial setting."
fi
check_finished() {
true
}
rsync -ae ssh ./ $VM:$WDIR || exit 1
ssh $VM \
RUNNAME=$RUNNAME \
FAILRETRY=$FAILRETRY \
RUN_MODE=normal,devel \
LOGLEVEL=1 \
PRIOIRTY=$PRIORITY \
BACKGROUND=true \
bash $WDIR/run.sh
# wait for test to finish.
for i in $(seq $TIMEOUT) ; do
sleep 60
if ssh $VM stat $WDIR/work/$RUNNAME/$FAILRETRY/__finished 2>&1 > /dev/null ; then
break
else
echo "$(date +'%y%m%d %H:%M:%S') ($i/$TIMEOUT) testing on vm $VM still running..."
fi
done
# save serial output
mkdir -p $TMPD/work/$RUNNAME/
rsync -ae ssh $VM:$WDIR/work/$RUNNAME/ $TMPD/work/$RUNNAME/
if [ -f "$SERIALFILE" ] ; then
mv $SERIALFILE $TMPD/work/$RUNNAME/console.log
fi
echo "Done, output data is put under $TMPD/work."