2013-11-02 03:37:44 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# This file is part of the coreboot project.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2013 Google Inc.
|
2014-07-10 23:00:35 +02:00
|
|
|
# Copyright (C) 2014 Sage Electronic Engineering, LLC.
|
2013-11-07 11:03:05 +01:00
|
|
|
#
|
2013-11-02 03:37:44 +01:00
|
|
|
|
|
|
|
EXIT_SUCCESS=0
|
|
|
|
EXIT_FAILURE=1
|
|
|
|
|
|
|
|
# Stuff from command-line switches
|
2015-11-19 22:04:27 +01:00
|
|
|
COREBOOT_IMAGE="build/coreboot.rom"
|
2013-11-02 03:37:44 +01:00
|
|
|
REMOTE_HOST=""
|
2016-05-10 17:43:53 +02:00
|
|
|
REMOTE_PORT_OPTION=""
|
2013-11-02 03:37:44 +01:00
|
|
|
CLOBBER_OUTPUT=0
|
|
|
|
UPLOAD_RESULTS=0
|
2014-07-10 23:00:35 +02:00
|
|
|
SERIAL_PORT_SPEED=115200
|
2013-11-02 03:37:44 +01:00
|
|
|
|
2013-11-12 03:44:05 +01:00
|
|
|
# Used to specify whether a command should always be run locally or
|
|
|
|
# if command should be run remoteley when a remote host is specified.
|
|
|
|
LOCAL=0
|
|
|
|
REMOTE=1
|
2014-06-23 05:46:24 +02:00
|
|
|
FATAL=0
|
|
|
|
NONFATAL=1
|
2013-11-12 03:44:05 +01:00
|
|
|
|
2017-09-16 21:59:23 +02:00
|
|
|
# Used if cbmem is not in default $PATH, e.g. not installed or when using `sudo`
|
|
|
|
CBMEM_PATH=""
|
|
|
|
|
2013-11-02 03:37:44 +01:00
|
|
|
# test a command
|
|
|
|
#
|
2014-07-10 23:02:19 +02:00
|
|
|
# $1: 0 ($LOCAL) to run command locally,
|
|
|
|
# 1 ($REMOTE) to run remotely if remote host defined
|
2013-11-02 03:37:44 +01:00
|
|
|
# $2: command to test
|
2014-06-23 05:46:24 +02:00
|
|
|
# $3: 0 ($FATAL) Exit with an error if the command fails
|
|
|
|
# 1 ($NONFATAL) Don't exit on command test failure
|
2013-11-02 03:37:44 +01:00
|
|
|
test_cmd()
|
|
|
|
{
|
|
|
|
local rc
|
|
|
|
|
|
|
|
if [ -e "$2" ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2014-01-21 02:39:46 +01:00
|
|
|
if [ "$1" -eq "$REMOTE" ] && [ -n "$REMOTE_HOST" ]; then
|
2016-05-10 17:43:53 +02:00
|
|
|
ssh $REMOTE_PORT_OPTION root@${REMOTE_HOST} command -v "$2" > /dev/null
|
2013-11-02 03:37:44 +01:00
|
|
|
rc=$?
|
|
|
|
else
|
2015-08-10 10:21:14 +02:00
|
|
|
command -v "$2" >/dev/null
|
2013-11-02 03:37:44 +01:00
|
|
|
rc=$?
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $rc -eq 0 ]; then
|
2014-06-23 05:46:24 +02:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2014-08-10 15:44:04 +02:00
|
|
|
if [ "$3" = "1" ]; then
|
2014-06-23 05:46:24 +02:00
|
|
|
return 1
|
2013-11-02 03:37:44 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$2 not found"
|
|
|
|
exit $EXIT_FAILURE
|
|
|
|
}
|
|
|
|
|
2013-11-13 02:24:42 +01:00
|
|
|
_cmd()
|
2013-11-02 03:37:44 +01:00
|
|
|
{
|
|
|
|
if [ -e "$2" ]; then
|
2013-11-13 02:24:42 +01:00
|
|
|
return $EXIT_FAILURE
|
2013-11-02 03:37:44 +01:00
|
|
|
fi
|
|
|
|
|
2014-07-10 22:57:34 +02:00
|
|
|
if [ -n "$3" ]; then
|
|
|
|
pipe_location="${3}"
|
|
|
|
else
|
|
|
|
pipe_location="/dev/null"
|
|
|
|
fi
|
|
|
|
|
2014-01-21 02:39:46 +01:00
|
|
|
if [ "$1" -eq "$REMOTE" ] && [ -n "$REMOTE_HOST" ]; then
|
2016-05-10 17:43:53 +02:00
|
|
|
ssh $REMOTE_PORT_OPTION "root@${REMOTE_HOST}" "$2" > "$pipe_location" 2>&1
|
2013-11-02 03:37:44 +01:00
|
|
|
else
|
2014-07-10 22:57:34 +02:00
|
|
|
$2 > "$pipe_location" 2>&1
|
2013-11-02 03:37:44 +01:00
|
|
|
fi
|
2013-11-13 03:10:23 +01:00
|
|
|
|
|
|
|
return $?
|
2013-11-13 02:24:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# run a command
|
|
|
|
#
|
2014-07-10 23:02:19 +02:00
|
|
|
# $1: 0 ($LOCAL) to run command locally,
|
|
|
|
# 1 ($REMOTE) to run remotely if remote host defined
|
2013-11-13 02:24:42 +01:00
|
|
|
# $2: command
|
2013-11-13 03:10:23 +01:00
|
|
|
# $3: filename to direct output of command into
|
2013-11-13 02:24:42 +01:00
|
|
|
cmd()
|
|
|
|
{
|
2013-11-13 03:10:23 +01:00
|
|
|
_cmd $1 "$2" "$3"
|
2013-11-02 03:37:44 +01:00
|
|
|
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
return
|
|
|
|
fi
|
2013-11-07 11:03:05 +01:00
|
|
|
|
2013-11-13 03:10:23 +01:00
|
|
|
echo "Failed to run \"$2\", aborting"
|
|
|
|
rm -f "$3" # don't leave an empty file
|
2013-11-02 03:37:44 +01:00
|
|
|
exit $EXIT_FAILURE
|
|
|
|
}
|
|
|
|
|
2013-11-13 02:24:42 +01:00
|
|
|
# run a command where failure is considered to be non-fatal
|
|
|
|
#
|
2014-07-10 23:02:19 +02:00
|
|
|
# $1: 0 ($LOCAL) to run command locally,
|
|
|
|
# 1 ($REMOTE) to run remotely if remote host defined
|
2013-11-13 02:24:42 +01:00
|
|
|
# $2: command
|
2013-11-13 03:10:23 +01:00
|
|
|
# $3: filename to direct output of command into
|
2013-11-13 02:24:42 +01:00
|
|
|
cmd_nonfatal()
|
|
|
|
{
|
2013-11-13 03:10:23 +01:00
|
|
|
_cmd $1 "$2" "$3"
|
2013-11-13 02:24:42 +01:00
|
|
|
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2013-11-13 03:10:23 +01:00
|
|
|
echo "Failed to run \"$2\", ignoring"
|
|
|
|
rm -f "$3" # don't leave an empty file
|
2013-11-13 02:24:42 +01:00
|
|
|
}
|
|
|
|
|
2014-07-10 23:00:35 +02:00
|
|
|
# read from a serial port device
|
|
|
|
#
|
|
|
|
# $1: serial device to read from
|
|
|
|
# $2: serial port speed
|
|
|
|
# $3: filename to direct output of command into
|
|
|
|
get_serial_bootlog () {
|
|
|
|
|
2015-12-17 20:02:45 +01:00
|
|
|
local TTY=$1
|
|
|
|
local SPEED=$2
|
|
|
|
local FILENAME=$3
|
|
|
|
|
|
|
|
if [ ! -c "$TTY" ]; then
|
|
|
|
echo "$TTY is not a valid serial device"
|
2014-07-10 23:00:35 +02:00
|
|
|
exit $EXIT_FAILURE
|
|
|
|
fi
|
|
|
|
|
|
|
|
# make the text more noticible
|
|
|
|
test_cmd $LOCAL "tput" $NONFATAL
|
|
|
|
tput_not_available=$?
|
|
|
|
if [ $tput_not_available -eq 0 ]; then
|
|
|
|
tput bold
|
|
|
|
tput setaf 10 # set bright green
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
2015-12-17 20:02:45 +01:00
|
|
|
echo "Waiting to receive boot log from $TTY"
|
2017-09-17 03:43:08 +02:00
|
|
|
echo "Press [Enter] when the boot is complete."
|
2015-12-17 20:02:45 +01:00
|
|
|
echo
|
2014-07-10 23:00:35 +02:00
|
|
|
|
|
|
|
if [ $tput_not_available -eq 0 ]; then
|
|
|
|
tput sgr0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# set up the serial port
|
2015-12-17 20:02:45 +01:00
|
|
|
stty -F $TTY $SPEED cs8 -cstopb -parenb clocal
|
2014-07-10 23:00:35 +02:00
|
|
|
|
|
|
|
# read from the serial port - user must press enter when complete
|
|
|
|
test_cmd $LOCAL "tee"
|
2015-12-17 20:02:45 +01:00
|
|
|
while read LINE; do
|
|
|
|
echo "$LINE" | tee -a "$FILENAME"
|
|
|
|
done < "$SERIAL_DEVICE" &
|
2014-07-10 23:00:35 +02:00
|
|
|
PID=$!
|
|
|
|
|
2015-12-17 20:02:45 +01:00
|
|
|
read foo
|
|
|
|
kill "$PID" 2>/dev/null
|
2014-07-10 23:00:35 +02:00
|
|
|
|
2015-12-17 20:02:45 +01:00
|
|
|
echo "Finished reading boot log."
|
2014-07-10 23:00:35 +02:00
|
|
|
}
|
|
|
|
|
2013-11-13 01:49:45 +01:00
|
|
|
show_help() {
|
|
|
|
echo "Usage:
|
|
|
|
${0} <option>
|
|
|
|
|
|
|
|
Options
|
2017-09-16 21:59:23 +02:00
|
|
|
-c, --cbmem
|
|
|
|
Path to cbmem on device under test (DUT).
|
2016-05-07 20:44:05 +02:00
|
|
|
-C, --clobber
|
2013-11-13 01:49:45 +01:00
|
|
|
Clobber temporary output when finished. Useful for debugging.
|
2016-05-07 20:44:05 +02:00
|
|
|
-h, --help
|
|
|
|
Show this message.
|
|
|
|
-i, --image <image>
|
2015-11-19 22:04:27 +01:00
|
|
|
Path to coreboot image (Default is $COREBOOT_IMAGE).
|
2016-05-07 20:44:05 +02:00
|
|
|
-r, --remote-host <host>
|
2013-11-13 01:49:45 +01:00
|
|
|
Obtain machine information from remote host (using ssh).
|
2016-05-07 20:44:05 +02:00
|
|
|
-s, --serial-device </dev/xxx>
|
2014-07-10 23:00:35 +02:00
|
|
|
Obtain boot log via serial device.
|
2016-05-07 20:44:05 +02:00
|
|
|
-S, --serial-speed <speed>
|
2015-12-17 20:02:45 +01:00
|
|
|
Set the port speed for the serial device (Default is $SERIAL_PORT_SPEED).
|
2016-05-07 20:44:05 +02:00
|
|
|
-u, --upload-results
|
2013-11-13 01:49:45 +01:00
|
|
|
Upload results to coreboot.org.
|
2016-05-07 20:44:05 +02:00
|
|
|
|
|
|
|
Long options:
|
|
|
|
--ssh-port <port>
|
|
|
|
Use a specific SSH port.
|
2013-11-13 01:49:45 +01:00
|
|
|
"
|
|
|
|
}
|
|
|
|
|
2016-04-26 23:07:42 +02:00
|
|
|
getopt -T
|
|
|
|
if [ $? -ne 4 ]; then
|
|
|
|
echo "GNU-compatible getopt(1) required."
|
|
|
|
exit $EXIT_FAILURE
|
|
|
|
fi
|
|
|
|
|
2017-09-16 21:59:23 +02:00
|
|
|
LONGOPTS="cbmem:,clobber,help,image:,remote-host:,upload-results"
|
2016-05-07 20:44:05 +02:00
|
|
|
LONGOPTS="${LONGOPTS},serial-device:,serial-speed:"
|
|
|
|
LONGOPTS="${LONGOPTS},ssh-port:"
|
|
|
|
|
2017-09-16 21:59:23 +02:00
|
|
|
ARGS=$(getopt -o c:Chi:r:s:S:u -l "$LONGOPTS" -n "$0" -- "$@");
|
2016-04-26 23:07:42 +02:00
|
|
|
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
|
|
|
eval set -- "$ARGS"
|
|
|
|
while true ; do
|
|
|
|
case "$1" in
|
2016-05-07 20:44:05 +02:00
|
|
|
# generic options
|
2017-09-16 21:59:23 +02:00
|
|
|
-c|--cbmem)
|
|
|
|
shift
|
|
|
|
CBMEM_PATH="$1"
|
|
|
|
;;
|
2016-05-07 20:44:05 +02:00
|
|
|
-C|--clobber)
|
|
|
|
CLOBBER_OUTPUT=1
|
|
|
|
;;
|
|
|
|
-h|--help)
|
2013-11-02 03:37:44 +01:00
|
|
|
show_help
|
|
|
|
exit $EXIT_SUCCESS
|
|
|
|
;;
|
2016-05-07 20:44:05 +02:00
|
|
|
-i|--image)
|
2016-04-26 23:07:42 +02:00
|
|
|
shift
|
|
|
|
COREBOOT_IMAGE="$1"
|
2015-11-19 22:04:27 +01:00
|
|
|
;;
|
2016-05-07 20:44:05 +02:00
|
|
|
-r|--remote-host)
|
2016-04-26 23:07:42 +02:00
|
|
|
shift
|
|
|
|
REMOTE_HOST="$1"
|
2013-11-02 03:37:44 +01:00
|
|
|
;;
|
2016-05-07 20:44:05 +02:00
|
|
|
-u|--upload-results)
|
|
|
|
UPLOAD_RESULTS=1
|
2016-05-10 17:43:53 +02:00
|
|
|
;;
|
2016-05-07 20:44:05 +02:00
|
|
|
|
|
|
|
# serial port options
|
|
|
|
-s|--serial-device)
|
2016-04-26 23:07:42 +02:00
|
|
|
shift
|
|
|
|
SERIAL_DEVICE="$1"
|
2014-07-10 23:00:35 +02:00
|
|
|
;;
|
2016-05-07 20:44:05 +02:00
|
|
|
-S|--serial-speed)
|
2016-04-26 23:07:42 +02:00
|
|
|
shift
|
|
|
|
SERIAL_PORT_SPEED="$1"
|
2014-07-10 23:00:35 +02:00
|
|
|
;;
|
2016-05-07 20:44:05 +02:00
|
|
|
|
|
|
|
# ssh options
|
|
|
|
--ssh-port)
|
|
|
|
shift
|
|
|
|
REMOTE_PORT_OPTION="-p $1"
|
2013-11-02 03:37:44 +01:00
|
|
|
;;
|
2016-05-07 20:44:05 +02:00
|
|
|
|
|
|
|
# error handling
|
2016-04-26 23:07:42 +02:00
|
|
|
--)
|
|
|
|
shift
|
|
|
|
if [ -n "$*" ]; then
|
|
|
|
echo "Non-option parameters detected: '$*'"
|
|
|
|
exit $EXIT_FAILURE
|
|
|
|
fi
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "error processing options at '$1'"
|
|
|
|
exit $EXIT_FAILURE
|
2013-11-02 03:37:44 +01:00
|
|
|
esac
|
2016-04-26 23:07:42 +02:00
|
|
|
shift
|
2013-11-02 03:37:44 +01:00
|
|
|
done
|
|
|
|
|
2013-11-12 03:44:05 +01:00
|
|
|
grep -rH 'coreboot.org' .git/config >/dev/null 2>&1
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Script must be run from root of coreboot directory"
|
2013-11-02 03:37:44 +01:00
|
|
|
exit $EXIT_FAILURE
|
|
|
|
fi
|
|
|
|
|
2016-05-17 17:38:10 +02:00
|
|
|
if [ ! -e "$COREBOOT_IMAGE" ]; then
|
|
|
|
echo "board_status needs $COREBOOT_IMAGE, but it does not exist."
|
|
|
|
echo "Use \"-i IMAGE_FILE\" to select a different image, or \"--help\" for more options."
|
|
|
|
exit $EXIT_FAILURE
|
|
|
|
fi
|
|
|
|
|
2013-11-12 03:44:05 +01:00
|
|
|
# Results will be placed in a temporary location until we're ready to upload.
|
|
|
|
# If the user does not wish to upload, results will remain in /tmp.
|
2015-08-13 07:57:26 +02:00
|
|
|
tmpdir=$(mktemp -d --tmpdir coreboot_board_status.XXXXXXXX)
|
2013-11-12 03:44:05 +01:00
|
|
|
|
2015-11-19 22:08:51 +01:00
|
|
|
# Obtain coreboot config by running cbfstool on the ROM image. cbfstool may
|
|
|
|
# already exist in build/ or util/cbfstool/, but if not then we'll build it
|
|
|
|
# now and clean it when we're done.
|
2014-07-16 22:22:59 +02:00
|
|
|
cbfstool_cmd="build/cbfstool"
|
2015-11-19 22:08:51 +01:00
|
|
|
do_clean_cbfstool=0
|
|
|
|
if [ ! -x $cbfstool_cmd ]; then
|
|
|
|
cbfstool_cmd="util/cbfstool/cbfstool"
|
|
|
|
if [ -e $cbfstool_cmd ]; then
|
|
|
|
if test ! -x $cbfstool_cmd; then
|
|
|
|
echo "Cannot execute $cbfstool_cmd."
|
|
|
|
exit $EXIT_FAILURE
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
make -C util/cbfstool/
|
|
|
|
do_clean_cbfstool=1
|
|
|
|
fi
|
2014-07-16 22:22:59 +02:00
|
|
|
fi
|
2013-11-12 03:44:05 +01:00
|
|
|
test_cmd $LOCAL "$cbfstool_cmd"
|
2015-11-19 22:08:51 +01:00
|
|
|
|
|
|
|
tmpcfg=$(mktemp coreboot_config.XXXXXX)
|
2015-11-19 22:04:27 +01:00
|
|
|
echo "Extracting config.txt from $COREBOOT_IMAGE"
|
|
|
|
$cbfstool_cmd "$COREBOOT_IMAGE" extract -n config -f "${tmpdir}/config.txt" >/dev/null 2>&1
|
2015-12-17 20:49:15 +01:00
|
|
|
mv "${tmpdir}/config.txt" "${tmpdir}/config.short.txt"
|
|
|
|
cp "${tmpdir}/config.short.txt" "${tmpcfg}"
|
|
|
|
yes "" | make "DOTCONFIG=${tmpcfg}" oldconfig 2>/dev/null >/dev/null
|
|
|
|
mv "${tmpcfg}" "${tmpdir}/config.txt"
|
|
|
|
rm -f "${tmpcfg}.old"
|
2015-11-19 22:04:27 +01:00
|
|
|
$cbfstool_cmd "$COREBOOT_IMAGE" print > "${tmpdir}/cbfs.txt"
|
|
|
|
rom_contents=$($cbfstool_cmd "$COREBOOT_IMAGE" print 2>&1)
|
2015-12-17 20:33:39 +01:00
|
|
|
if [ -n "$(echo $rom_contents | grep payload_config)" ]; then
|
2015-11-19 22:04:27 +01:00
|
|
|
echo "Extracting payload_config from $COREBOOT_IMAGE"
|
|
|
|
$cbfstool_cmd "$COREBOOT_IMAGE" extract -n payload_config -f "${tmpdir}/payload_config.txt" >/dev/null 2>&1
|
2015-12-17 20:33:39 +01:00
|
|
|
fi
|
|
|
|
if [ -n "$(echo $rom_contents | grep payload_version)" ]; then
|
2015-11-19 22:04:27 +01:00
|
|
|
echo "Extracting payload_version from $COREBOOT_IMAGE"
|
|
|
|
$cbfstool_cmd "$COREBOOT_IMAGE" extract -n payload_version -f "${tmpdir}/payload_version.txt" >/dev/null 2>&1
|
2015-12-17 20:33:39 +01:00
|
|
|
fi
|
2015-11-19 22:04:27 +01:00
|
|
|
md5sum -b "$COREBOOT_IMAGE" > "${tmpdir}/rom_checksum.txt"
|
2015-02-19 19:35:58 +01:00
|
|
|
|
2015-11-19 22:08:51 +01:00
|
|
|
if test $do_clean_cbfstool -eq 1; then
|
|
|
|
make -C util/cbfstool clean
|
|
|
|
fi
|
|
|
|
|
2015-02-19 19:35:58 +01:00
|
|
|
# Obtain board and revision info to form the directory structure:
|
|
|
|
# <vendor>/<board>/<revision>/<timestamp>
|
2015-12-17 20:49:15 +01:00
|
|
|
mainboard_dir="$(grep CONFIG_MAINBOARD_DIR "${tmpdir}/config.txt" | awk -F '"' '{ print $2 }')"
|
2013-11-12 03:44:05 +01:00
|
|
|
vendor=$(echo "$mainboard_dir" | awk -F '/' '{ print $1 }')
|
|
|
|
mainboard=$(echo "$mainboard_dir" | awk -F '/' '{ print $2 }')
|
2013-11-02 03:37:44 +01:00
|
|
|
|
2013-11-12 03:43:39 +01:00
|
|
|
getrevision="util/board_status/getrevision.sh"
|
2013-11-12 03:44:05 +01:00
|
|
|
test_cmd $LOCAL $getrevision
|
|
|
|
tagged_version=$($getrevision -T)
|
|
|
|
timestamp=$($getrevision -t)
|
|
|
|
|
|
|
|
results="${vendor}/${mainboard}/${tagged_version}/${timestamp}"
|
|
|
|
|
2017-10-15 10:56:36 +02:00
|
|
|
if [ -n "$(echo $tagged_version | grep dirty)" ]; then
|
|
|
|
echo "The repository is in a dirty state. Please see the output of"
|
|
|
|
echo "'git status' below."
|
|
|
|
git status
|
|
|
|
exit $EXIT_FAILURE
|
|
|
|
fi
|
|
|
|
|
2013-11-12 03:44:05 +01:00
|
|
|
echo "Temporarily placing output in ${tmpdir}/${results}"
|
|
|
|
mkdir -p "${tmpdir}/${results}"
|
|
|
|
|
|
|
|
mv "${tmpdir}/config.txt" "${tmpdir}/${results}"
|
2015-12-17 20:33:39 +01:00
|
|
|
test -f "${tmpdir}/payload_config.txt" && mv "${tmpdir}/payload_config.txt" "${tmpdir}/${results}"
|
|
|
|
test -f "${tmpdir}/payload_version.txt" && mv "${tmpdir}/payload_version.txt" "${tmpdir}/${results}"
|
2015-06-12 11:35:10 +02:00
|
|
|
mv "${tmpdir}/config.short.txt" "${tmpdir}/${results}"
|
2014-05-30 09:26:46 +02:00
|
|
|
mv "${tmpdir}/cbfs.txt" "${tmpdir}/${results}"
|
2015-12-17 20:44:35 +01:00
|
|
|
mv "${tmpdir}/rom_checksum.txt" "${tmpdir}/${results}"
|
2013-11-12 03:44:05 +01:00
|
|
|
|
2015-12-17 20:49:15 +01:00
|
|
|
touch "${tmpdir}/${results}/revision.txt"
|
|
|
|
printf "Local revision: %s\n" "$($getrevision -l)" >> "${tmpdir}/${results}/revision.txt"
|
|
|
|
printf "Tagged revision: %s\n" "${tagged_version}" >> "${tmpdir}/${results}/revision.txt"
|
|
|
|
printf "Upstream revision: %s\n" "$($getrevision -u)" >> "${tmpdir}/${results}/revision.txt"
|
|
|
|
printf "Upstream URL: %s\n" "$($getrevision -U)" >> "${tmpdir}/${results}/revision.txt"
|
|
|
|
printf "Timestamp: %s\n" "$timestamp" >> "${tmpdir}/${results}/revision.txt"
|
2013-11-12 03:44:05 +01:00
|
|
|
|
2017-09-16 21:59:23 +02:00
|
|
|
if [ -n "$CBMEM_PATH" ]; then
|
|
|
|
cbmem_cmd="$CBMEM_PATH"
|
|
|
|
else
|
|
|
|
cbmem_cmd="cbmem"
|
|
|
|
fi
|
|
|
|
|
2017-09-16 22:01:13 +02:00
|
|
|
if [ -n "$SERIAL_DEVICE" ]; then
|
|
|
|
get_serial_bootlog "$SERIAL_DEVICE" "$SERIAL_PORT_SPEED" "${tmpdir}/${results}/coreboot_console.txt"
|
|
|
|
elif [ -n "$REMOTE_HOST" ]; then
|
2015-12-17 20:38:45 +01:00
|
|
|
echo "Verifying that CBMEM is available on remote device"
|
2017-09-16 21:59:23 +02:00
|
|
|
test_cmd $REMOTE "$cbmem_cmd"
|
2015-12-17 20:38:45 +01:00
|
|
|
echo "Getting coreboot boot log"
|
2018-09-06 17:32:58 +02:00
|
|
|
cmd $REMOTE "$cbmem_cmd -1" "${tmpdir}/${results}/coreboot_console.txt"
|
2015-12-17 20:38:45 +01:00
|
|
|
echo "Getting timestamp data"
|
2017-09-16 21:59:23 +02:00
|
|
|
cmd_nonfatal $REMOTE "$cbmem_cmd -t" "${tmpdir}/${results}/coreboot_timestamps.txt"
|
2017-09-17 03:43:08 +02:00
|
|
|
|
|
|
|
echo "Getting remote dmesg"
|
2018-11-17 16:50:48 +01:00
|
|
|
cmd $REMOTE sudo dmesg "${tmpdir}/${results}/kernel_log.txt"
|
2014-07-10 23:00:35 +02:00
|
|
|
else
|
2017-09-16 22:01:13 +02:00
|
|
|
echo "Verifying that CBMEM is available"
|
|
|
|
if [ $(id -u) -ne 0 ]; then
|
2018-05-02 15:43:27 +02:00
|
|
|
command -v "$cbmem_cmd" >/dev/null
|
2017-09-16 22:01:13 +02:00
|
|
|
if [ $? -ne 0 ]; then
|
2018-05-02 15:43:27 +02:00
|
|
|
echo "Failed to run $cbmem_cmd. Check \$PATH or" \
|
|
|
|
"use -c to specify path to cbmem binary."
|
2017-09-16 22:01:13 +02:00
|
|
|
exit $EXIT_FAILURE
|
|
|
|
else
|
|
|
|
cbmem_cmd="sudo $cbmem_cmd"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
test_cmd $LOCAL "$cbmem_cmd"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Getting coreboot boot log"
|
2018-09-06 17:32:58 +02:00
|
|
|
cmd $LOCAL "$cbmem_cmd -1" "${tmpdir}/${results}/coreboot_console.txt"
|
2017-09-16 22:01:13 +02:00
|
|
|
echo "Getting timestamp data"
|
|
|
|
cmd_nonfatal $LOCAL "$cbmem_cmd -t" "${tmpdir}/${results}/coreboot_timestamps.txt"
|
|
|
|
|
|
|
|
echo "Getting local dmesg"
|
|
|
|
cmd $LOCAL dmesg "${tmpdir}/${results}/kernel_log.txt"
|
2014-07-10 23:00:35 +02:00
|
|
|
fi
|
2013-11-12 03:44:05 +01:00
|
|
|
|
2013-11-13 03:17:19 +01:00
|
|
|
#
|
|
|
|
# Finish up.
|
|
|
|
#
|
2014-07-10 23:02:19 +02:00
|
|
|
coreboot_dir=$(pwd)
|
2013-11-12 03:44:05 +01:00
|
|
|
if [ $UPLOAD_RESULTS -eq 1 ]; then
|
|
|
|
# extract username from ssh://<username>@review.coreboot.org/blah
|
2014-08-10 15:18:22 +02:00
|
|
|
bsrepo=$(git config --get remote.origin.url | sed "s,\(.*\)/coreboot,\1/board-status,")
|
2013-11-12 03:44:05 +01:00
|
|
|
|
|
|
|
cd "util/board_status/"
|
|
|
|
if [ ! -e "board-status" ]; then
|
2013-11-13 03:17:19 +01:00
|
|
|
# FIXME: the board-status directory might get big over time.
|
|
|
|
# Is there a way we can push the results without fetching the
|
|
|
|
# whole repo?
|
2015-12-17 20:49:15 +01:00
|
|
|
git clone "$bsrepo"
|
2013-11-12 03:44:05 +01:00
|
|
|
if [ $? -ne 0 ]; then
|
2015-05-20 22:32:15 +02:00
|
|
|
echo "Error cloning board-status repo, aborting."
|
2013-11-12 03:44:05 +01:00
|
|
|
exit $EXIT_FAILURE
|
|
|
|
fi
|
|
|
|
fi
|
2013-11-02 03:37:44 +01:00
|
|
|
|
2013-11-12 03:44:05 +01:00
|
|
|
cd "board-status"
|
2016-03-30 09:54:16 +02:00
|
|
|
|
|
|
|
echo "Checking for duplicate results"
|
|
|
|
# get any updates to board-status
|
|
|
|
git pull
|
|
|
|
|
|
|
|
echo "${tagged_version}" | grep dirty >/dev/null 2>&1
|
|
|
|
clean_version=$?
|
|
|
|
existing_results=$(git ls-files "${mainboard_dir}/${tagged_version}")
|
|
|
|
|
|
|
|
# reject duplicate results of non-dirty versions
|
|
|
|
if [ "${clean_version}" -eq 1 ] && [ -n "${existing_results}" ] ; then
|
|
|
|
echo "Result is a duplicate, aborting"
|
|
|
|
exit $EXIT_FAILURE
|
|
|
|
fi
|
|
|
|
|
2013-11-12 03:44:05 +01:00
|
|
|
echo "Copying results to $(pwd)/${results}"
|
2013-11-02 03:37:44 +01:00
|
|
|
|
2013-11-12 03:44:05 +01:00
|
|
|
# Note: Result directory should be unique due to the timestamp.
|
|
|
|
cp -R "${tmpdir}/${vendor}" .
|
2013-11-02 03:37:44 +01:00
|
|
|
|
2013-11-12 03:44:05 +01:00
|
|
|
echo "Uploading results"
|
|
|
|
git add "${vendor}"
|
2014-02-09 10:24:22 +01:00
|
|
|
git commit -a -m "${mainboard_dir}/${tagged_version}/${timestamp}"
|
2015-05-20 07:35:56 +02:00
|
|
|
count=0
|
2016-05-10 17:43:53 +02:00
|
|
|
until git push origin master || test $count -eq 3; do
|
2015-05-20 07:35:56 +02:00
|
|
|
git pull --rebase
|
|
|
|
count=$((count + 1))
|
|
|
|
done
|
2013-11-02 03:37:44 +01:00
|
|
|
|
2013-11-12 03:44:05 +01:00
|
|
|
# Results have been uploaded so it's pointless to keep the
|
|
|
|
# temporary files around.
|
|
|
|
rm -rf "${tmpdir}"
|
2015-05-20 07:35:56 +02:00
|
|
|
if test $count -eq 3; then
|
|
|
|
echo "Error uploading to board-status repo, aborting."
|
|
|
|
exit $EXIT_FAILURE
|
|
|
|
fi
|
2013-11-12 03:44:05 +01:00
|
|
|
fi
|
|
|
|
cd "$coreboot_dir"
|
2013-11-02 03:37:44 +01:00
|
|
|
|
|
|
|
if [ $CLOBBER_OUTPUT -eq 1 ]; then
|
2015-12-17 20:49:15 +01:00
|
|
|
rm -rf "${tmpdir}"
|
2014-07-10 22:59:11 +02:00
|
|
|
else
|
2017-09-06 08:38:03 +02:00
|
|
|
if [ $UPLOAD_RESULTS -eq 1 ]; then
|
|
|
|
echo
|
|
|
|
echo "output files are in $(dirname $0)/board-status/${mainboard_dir}/${tagged_version}/${timestamp}"
|
|
|
|
else
|
|
|
|
echo
|
|
|
|
echo "output files are in ${tmpdir}/${results}"
|
|
|
|
fi
|
2013-11-02 03:37:44 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
exit $EXIT_SUCCESS
|