2
# Lets try for /bin/sh but bashisms will sneak in.
4
# partial bash strict mode
10
if [ -f ~/.skiboot_boot_tests ]; then
11
source ~/.skiboot_boot_tests
17
if [ ! -z "$target" ]; then
18
echo "$target: $*" >&2
28
if [ ! -z "$target" ]; then
38
FUNCTIONS_NEEDED="sshpass ssh ipmitool md5sum rsync expect";
41
if [ $STRIP_CONTROL -eq 1 ]; then
42
STRIPCOMMAND="col -b -l 1"
47
#Everyone is going to forget to disconnect - force them off
48
ipmiresult=$($IPMI_COMMAND sol deactivate 2>&1);
50
if [ $retval -ne 0 -a "$ipmiresult" != "Info: SOL payload already de-activated" ]; then
51
msg "IPMI sol deactivate failed; IPMI may have stalled, may just be IPMI. Good luck."
54
LINUXBOOT_LOG=$(mktemp --tmpdir builder-2.XXXXXX);
55
cat <<EOF | expect > $LINUXBOOT_LOG
57
spawn $IPMI_COMMAND sol activate
59
timeout { send_user "\nTimeout waiting for petitboot\n"; exit 1 }
60
eof { send_user "\nUnexpected EOF\n;" exit 1 }
61
"Welcome to Petitboot"
68
$IPMI_COMMAND sol deactivate > /dev/null;
69
if [ $retval -ne 0 ]; then
70
msg "Waiting for linux has timed out"
71
msg "Boot log follows:"
82
# The functions called (e.g. flash, boot) are from the *_support files
83
if [ $bootonly -ne 1 ]; then
84
msg "Flashing ${target}..."
88
msg "Booting $target..."
90
msg "firmware looks good, waiting for linux";
93
if [ $? -ne 0 ] ; then
94
error "Couldn't reach petitboot on $target";
96
msg "$target has booted";
100
function sanity_test {
102
if [ $? -ne 0 ]; then
103
echo "$target: Failed to SSH to $target..."
104
echo "$target: Command was: $SSHCMD true"
105
error "Try connecting manually to diagnose the issue."
108
$IPMI_COMMAND chassis power status > /dev/null;
109
if [ $? -ne 0 ]; then
110
echo "$target: Failed to connect to $target with IPMI..."
111
echo "$target: Command was: $IPMI_COMMAND chassis power status"
112
error "Try connecting manually to diagnose the issue."
115
# do further machine-type specific tests
121
boot_test.sh tests the bootability of a given target, optionally after
122
flashing new firmware onto the target.
124
There are three usage modes.
129
2) boot_test.sh [-vdp] -t target -B -b (fsp|bmc)
130
Boot test the target without flashing. Specify the type of machine
131
(FSP or BMC) with the -b option.
133
3) boot_test.sh [-vdp] -b bmc -t target -P pnor
134
boot_test.sh [-vdp] -b bmc -t target [-1 PAYLOAD] [-2 BOOTKERNEL]
135
boot_test.sh [-vdp] -b fsp -t target [-1 lid1] [-2 lid2] [-3 lid3]
137
Flash the given firmware before boot testing.
139
For a BMC target, -P specifies a full PNOR.
141
For a BMC target, -1/-2 specify the PAYLOAD and BOOTKERNEL PNOR partitions
142
respectively. Only the given partitions will be flashed.
144
For an FSP target, -1/-2/-3 specify lids. Any combination of lids is
149
-p powers off the machine if it is running. Without -p, a running machine
150
will cause the script to error out.
152
-v makes the script print some progress messages. Recommended.
154
-d makes the script print lots of things (set -vx).
155
Only use this for debugging the script: it's highly likely that
156
successful booting into Petitboot will not be detected with this option.
158
-b BMC type (bmc or fsp).
163
## 'Main' script begins
166
for func in $FUNCTIONS_NEEDED ; do
167
if ! command -v "$func" &> /dev/null ; then
168
error "I require command $func but it is not in \$PATH ($PATH)";
183
while getopts "hvdpB1:2:3:P:t:b:" OPT; do
196
if [ $firmware_supplied -eq 1 ]; then
208
if [ ! -e "$OPTARG" ] ; then
209
error "Couldn't stat $OPTARG";
211
LID[$(expr ${OPT} - 1)]="$OPTARG"
215
if [ ! -e "$OPTARG" ] ; then
216
error "Couldn't stat $OPTARG";
229
shift $(expr $OPTIND - 1);
231
# Pull out the target and test
232
if [ "$target" = "" ]; then
236
if ! ping -c 1 "$target" &> /dev/null ; then
237
error "Couldn't ping $target";
240
if [ "$#" -ne 0 ]; then
245
# pull in the relevant config file and set things up
246
source $(dirname $(readlink -f $0))/${method}_support.sh
247
IPMI_COMMAND="ipmitool -I lanplus -H $target $IPMI_AUTH"
249
msg "Running sanity test"
253
# check the target is down
254
# (pulls in is_off from ${method}_support.sh)
256
if [ $powerdown -eq 1 ]; then
259
error "$target is not turned off";
263
force_primary_side # ensure we're booting from side we flash.
266
echo "$target: Boot testing $target";
270
echo "$target: Done in $(expr $(date +%s) - $begin_t ) seconds";