blob: 13c58e1740a3d3b593fa677500fe372351f38326 [file] [log] [blame]
David Hendricks6583a812013-11-01 19:37:44 -07001#!/bin/sh
2#
3# This file is part of the coreboot project.
4#
5# Copyright (C) 2013 Google Inc.
Martin Roth8e0071b2014-07-10 15:00:35 -06006# Copyright (C) 2014 Sage Electronic Engineering, LLC.
Zheng Bao86655cf2013-11-07 18:03:05 +08007#
David Hendricks6583a812013-11-01 19:37:44 -07008
9EXIT_SUCCESS=0
10EXIT_FAILURE=1
David Hendricks6583a812013-11-01 19:37:44 -070011
12# Stuff from command-line switches
David Hendricks1173bf32015-11-19 13:04:27 -080013COREBOOT_IMAGE="build/coreboot.rom"
David Hendricks6583a812013-11-01 19:37:44 -070014REMOTE_HOST=""
Jonathan Neuschäfer4aef6822016-05-10 17:43:53 +020015REMOTE_PORT_OPTION=""
David Hendricks6583a812013-11-01 19:37:44 -070016CLOBBER_OUTPUT=0
17UPLOAD_RESULTS=0
Martin Roth8e0071b2014-07-10 15:00:35 -060018SERIAL_PORT_SPEED=115200
David Hendricks6583a812013-11-01 19:37:44 -070019
David Hendricks1b6e7a62013-11-11 18:44:05 -080020# Used to specify whether a command should always be run locally or
21# if command should be run remoteley when a remote host is specified.
22LOCAL=0
23REMOTE=1
Martin Rothbe5340b2014-06-22 21:46:24 -060024FATAL=0
25NONFATAL=1
David Hendricks1b6e7a62013-11-11 18:44:05 -080026
David Hendricksc863be72017-09-16 12:59:23 -070027# Used if cbmem is not in default $PATH, e.g. not installed or when using `sudo`
28CBMEM_PATH=""
29
David Hendricks6583a812013-11-01 19:37:44 -070030# test a command
31#
Martin Rothbcd09932014-07-10 15:02:19 -060032# $1: 0 ($LOCAL) to run command locally,
33# 1 ($REMOTE) to run remotely if remote host defined
David Hendricks6583a812013-11-01 19:37:44 -070034# $2: command to test
Martin Rothbe5340b2014-06-22 21:46:24 -060035# $3: 0 ($FATAL) Exit with an error if the command fails
36# 1 ($NONFATAL) Don't exit on command test failure
David Hendricks6583a812013-11-01 19:37:44 -070037test_cmd()
38{
39 local rc
40
41 if [ -e "$2" ]; then
42 return
43 fi
44
Vladimir Serbinenko77005b42014-01-21 02:39:46 +010045 if [ "$1" -eq "$REMOTE" ] && [ -n "$REMOTE_HOST" ]; then
Jonathan Neuschäfer4aef6822016-05-10 17:43:53 +020046 ssh $REMOTE_PORT_OPTION root@${REMOTE_HOST} command -v "$2" > /dev/null
David Hendricks6583a812013-11-01 19:37:44 -070047 rc=$?
48 else
Patrick Georgi1cbef1c2015-08-10 10:21:14 +020049 command -v "$2" >/dev/null
David Hendricks6583a812013-11-01 19:37:44 -070050 rc=$?
51 fi
52
53 if [ $rc -eq 0 ]; then
Martin Rothbe5340b2014-06-22 21:46:24 -060054 return 0
55 fi
56
Patrick Georgi4ef309e2014-08-10 15:44:04 +020057 if [ "$3" = "1" ]; then
Martin Rothbe5340b2014-06-22 21:46:24 -060058 return 1
David Hendricks6583a812013-11-01 19:37:44 -070059 fi
60
61 echo "$2 not found"
62 exit $EXIT_FAILURE
63}
64
David Hendricksf8b90e42013-11-12 17:24:42 -080065_cmd()
David Hendricks6583a812013-11-01 19:37:44 -070066{
67 if [ -e "$2" ]; then
David Hendricksf8b90e42013-11-12 17:24:42 -080068 return $EXIT_FAILURE
David Hendricks6583a812013-11-01 19:37:44 -070069 fi
70
Martin Roth22461772014-07-10 14:57:34 -060071 if [ -n "$3" ]; then
72 pipe_location="${3}"
David Hendricks6583a812013-11-01 19:37:44 -070073 else
Martin Roth22461772014-07-10 14:57:34 -060074 pipe_location="/dev/null"
75 fi
76
77 if [ "$1" -eq "$REMOTE" ] && [ -n "$REMOTE_HOST" ]; then
Jonathan Neuschäfer4aef6822016-05-10 17:43:53 +020078 ssh $REMOTE_PORT_OPTION "root@${REMOTE_HOST}" "$2" > "$pipe_location" 2>&1
Martin Roth22461772014-07-10 14:57:34 -060079 else
80 $2 > "$pipe_location" 2>&1
David Hendricks6583a812013-11-01 19:37:44 -070081 fi
David Hendricks406ce8a2013-11-12 18:10:23 -080082
83 return $?
David Hendricksf8b90e42013-11-12 17:24:42 -080084}
85
86# run a command
87#
Martin Rothbcd09932014-07-10 15:02:19 -060088# $1: 0 ($LOCAL) to run command locally,
89# 1 ($REMOTE) to run remotely if remote host defined
David Hendricksf8b90e42013-11-12 17:24:42 -080090# $2: command
David Hendricks406ce8a2013-11-12 18:10:23 -080091# $3: filename to direct output of command into
David Hendricksf8b90e42013-11-12 17:24:42 -080092cmd()
93{
David Hendricks406ce8a2013-11-12 18:10:23 -080094 _cmd $1 "$2" "$3"
David Hendricks6583a812013-11-01 19:37:44 -070095
96 if [ $? -eq 0 ]; then
97 return
98 fi
Zheng Bao86655cf2013-11-07 18:03:05 +080099
David Hendricks406ce8a2013-11-12 18:10:23 -0800100 echo "Failed to run \"$2\", aborting"
101 rm -f "$3" # don't leave an empty file
David Hendricks6583a812013-11-01 19:37:44 -0700102 exit $EXIT_FAILURE
103}
104
David Hendricksf8b90e42013-11-12 17:24:42 -0800105# run a command where failure is considered to be non-fatal
106#
Martin Rothbcd09932014-07-10 15:02:19 -0600107# $1: 0 ($LOCAL) to run command locally,
108# 1 ($REMOTE) to run remotely if remote host defined
David Hendricksf8b90e42013-11-12 17:24:42 -0800109# $2: command
David Hendricks406ce8a2013-11-12 18:10:23 -0800110# $3: filename to direct output of command into
David Hendricksf8b90e42013-11-12 17:24:42 -0800111cmd_nonfatal()
112{
David Hendricks406ce8a2013-11-12 18:10:23 -0800113 _cmd $1 "$2" "$3"
David Hendricksf8b90e42013-11-12 17:24:42 -0800114
115 if [ $? -eq 0 ]; then
116 return
117 fi
118
David Hendricks406ce8a2013-11-12 18:10:23 -0800119 echo "Failed to run \"$2\", ignoring"
120 rm -f "$3" # don't leave an empty file
David Hendricksf8b90e42013-11-12 17:24:42 -0800121}
122
Martin Roth8e0071b2014-07-10 15:00:35 -0600123# read from a serial port device
124#
125# $1: serial device to read from
126# $2: serial port speed
127# $3: filename to direct output of command into
128get_serial_bootlog () {
129
Martin Rothd0128df2015-12-17 12:02:45 -0700130 local TTY=$1
131 local SPEED=$2
132 local FILENAME=$3
133
134 if [ ! -c "$TTY" ]; then
135 echo "$TTY is not a valid serial device"
Martin Roth8e0071b2014-07-10 15:00:35 -0600136 exit $EXIT_FAILURE
137 fi
138
139 # make the text more noticible
140 test_cmd $LOCAL "tput" $NONFATAL
141 tput_not_available=$?
142 if [ $tput_not_available -eq 0 ]; then
143 tput bold
144 tput setaf 10 # set bright green
145 fi
146
147 echo
Martin Rothd0128df2015-12-17 12:02:45 -0700148 echo "Waiting to receive boot log from $TTY"
David Hendricks0dcfb592017-09-16 18:43:08 -0700149 echo "Press [Enter] when the boot is complete."
Martin Rothd0128df2015-12-17 12:02:45 -0700150 echo
Martin Roth8e0071b2014-07-10 15:00:35 -0600151
152 if [ $tput_not_available -eq 0 ]; then
153 tput sgr0
154 fi
155
156 # set up the serial port
Martin Rothd0128df2015-12-17 12:02:45 -0700157 stty -F $TTY $SPEED cs8 -cstopb -parenb clocal
Martin Roth8e0071b2014-07-10 15:00:35 -0600158
159 # read from the serial port - user must press enter when complete
160 test_cmd $LOCAL "tee"
Martin Rothd0128df2015-12-17 12:02:45 -0700161 while read LINE; do
162 echo "$LINE" | tee -a "$FILENAME"
163 done < "$SERIAL_DEVICE" &
Martin Roth8e0071b2014-07-10 15:00:35 -0600164 PID=$!
165
Martin Rothd0128df2015-12-17 12:02:45 -0700166 read foo
167 kill "$PID" 2>/dev/null
Martin Roth8e0071b2014-07-10 15:00:35 -0600168
Martin Rothd0128df2015-12-17 12:02:45 -0700169 echo "Finished reading boot log."
Martin Roth8e0071b2014-07-10 15:00:35 -0600170}
171
David Hendricks1fc65f72013-11-12 16:49:45 -0800172show_help() {
173 echo "Usage:
174 ${0} <option>
175
176Options
David Hendricksc863be72017-09-16 12:59:23 -0700177 -c, --cbmem
178 Path to cbmem on device under test (DUT).
David Hendricksb2aa5282016-05-07 11:44:05 -0700179 -C, --clobber
David Hendricks1fc65f72013-11-12 16:49:45 -0800180 Clobber temporary output when finished. Useful for debugging.
David Hendricksb2aa5282016-05-07 11:44:05 -0700181 -h, --help
182 Show this message.
183 -i, --image <image>
David Hendricks1173bf32015-11-19 13:04:27 -0800184 Path to coreboot image (Default is $COREBOOT_IMAGE).
David Hendricksb2aa5282016-05-07 11:44:05 -0700185 -r, --remote-host <host>
David Hendricks1fc65f72013-11-12 16:49:45 -0800186 Obtain machine information from remote host (using ssh).
David Hendricksb2aa5282016-05-07 11:44:05 -0700187 -s, --serial-device </dev/xxx>
188 Obtain boot log via serial device.
189 -S, --serial-speed <speed>
190 Set the port speed for the serial device (Default is $SERIAL_PORT_SPEED).
191 -u, --upload-results
192 Upload results to coreboot.org.
193
194Long options:
Jonathan Neuschäfer4aef6822016-05-10 17:43:53 +0200195 --ssh-port <port>
196 Use a specific SSH port.
David Hendricks1fc65f72013-11-12 16:49:45 -0800197"
198}
199
David Hendricks292be872016-04-26 14:07:42 -0700200getopt -T
201if [ $? -ne 4 ]; then
202 echo "GNU-compatible getopt(1) required."
203 exit $EXIT_FAILURE
204fi
205
David Hendricksc863be72017-09-16 12:59:23 -0700206LONGOPTS="cbmem:,clobber,help,image:,remote-host:,upload-results"
David Hendricksb2aa5282016-05-07 11:44:05 -0700207LONGOPTS="${LONGOPTS},serial-device:,serial-speed:"
208LONGOPTS="${LONGOPTS},ssh-port:"
209
David Hendricksc863be72017-09-16 12:59:23 -0700210ARGS=$(getopt -o c:Chi:r:s:S:u -l "$LONGOPTS" -n "$0" -- "$@");
David Hendricks292be872016-04-26 14:07:42 -0700211if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
212eval set -- "$ARGS"
213while true ; do
214 case "$1" in
David Hendricksb2aa5282016-05-07 11:44:05 -0700215 # generic options
David Hendricksc863be72017-09-16 12:59:23 -0700216 -c|--cbmem)
217 shift
218 CBMEM_PATH="$1"
219 ;;
David Hendricksb2aa5282016-05-07 11:44:05 -0700220 -C|--clobber)
221 CLOBBER_OUTPUT=1
222 ;;
223 -h|--help)
David Hendricks6583a812013-11-01 19:37:44 -0700224 show_help
225 exit $EXIT_SUCCESS
226 ;;
David Hendricksb2aa5282016-05-07 11:44:05 -0700227 -i|--image)
David Hendricks292be872016-04-26 14:07:42 -0700228 shift
229 COREBOOT_IMAGE="$1"
David Hendricks1173bf32015-11-19 13:04:27 -0800230 ;;
David Hendricksb2aa5282016-05-07 11:44:05 -0700231 -r|--remote-host)
David Hendricks292be872016-04-26 14:07:42 -0700232 shift
233 REMOTE_HOST="$1"
David Hendricks6583a812013-11-01 19:37:44 -0700234 ;;
David Hendricksb2aa5282016-05-07 11:44:05 -0700235 -u|--upload-results)
236 UPLOAD_RESULTS=1
237 ;;
238
239 # serial port options
240 -s|--serial-device)
241 shift
242 SERIAL_DEVICE="$1"
243 ;;
244 -S|--serial-speed)
245 shift
246 SERIAL_PORT_SPEED="$1"
247 ;;
248
249 # ssh options
Jonathan Neuschäfer4aef6822016-05-10 17:43:53 +0200250 --ssh-port)
251 shift
252 REMOTE_PORT_OPTION="-p $1"
253 ;;
David Hendricksb2aa5282016-05-07 11:44:05 -0700254
255 # error handling
David Hendricks292be872016-04-26 14:07:42 -0700256 --)
257 shift
258 if [ -n "$*" ]; then
259 echo "Non-option parameters detected: '$*'"
260 exit $EXIT_FAILURE
261 fi
262 break
263 ;;
264 *)
265 echo "error processing options at '$1'"
266 exit $EXIT_FAILURE
David Hendricks6583a812013-11-01 19:37:44 -0700267 esac
David Hendricks292be872016-04-26 14:07:42 -0700268 shift
David Hendricks6583a812013-11-01 19:37:44 -0700269done
270
David Hendricks1b6e7a62013-11-11 18:44:05 -0800271grep -rH 'coreboot.org' .git/config >/dev/null 2>&1
272if [ $? -ne 0 ]; then
273 echo "Script must be run from root of coreboot directory"
David Hendricks6583a812013-11-01 19:37:44 -0700274 exit $EXIT_FAILURE
275fi
276
Jonathan Neuschäfer0e962ee2016-05-17 17:38:10 +0200277if [ ! -e "$COREBOOT_IMAGE" ]; then
278 echo "board_status needs $COREBOOT_IMAGE, but it does not exist."
279 echo "Use \"-i IMAGE_FILE\" to select a different image, or \"--help\" for more options."
280 exit $EXIT_FAILURE
281fi
282
David Hendricks1b6e7a62013-11-11 18:44:05 -0800283# Results will be placed in a temporary location until we're ready to upload.
284# If the user does not wish to upload, results will remain in /tmp.
Patrick Georgiaa7dcef2015-08-13 07:57:26 +0200285tmpdir=$(mktemp -d --tmpdir coreboot_board_status.XXXXXXXX)
David Hendricks1b6e7a62013-11-11 18:44:05 -0800286
David Hendricks9f542972015-11-19 13:08:51 -0800287# Obtain coreboot config by running cbfstool on the ROM image. cbfstool may
288# already exist in build/ or util/cbfstool/, but if not then we'll build it
289# now and clean it when we're done.
Idwer Volleringb37ee1e2014-07-16 22:22:59 +0200290cbfstool_cmd="build/cbfstool"
David Hendricks9f542972015-11-19 13:08:51 -0800291do_clean_cbfstool=0
292if [ ! -x $cbfstool_cmd ]; then
293 cbfstool_cmd="util/cbfstool/cbfstool"
294 if [ -e $cbfstool_cmd ]; then
295 if test ! -x $cbfstool_cmd; then
296 echo "Cannot execute $cbfstool_cmd."
297 exit $EXIT_FAILURE
298 fi
299 else
300 make -C util/cbfstool/
301 do_clean_cbfstool=1
302 fi
Idwer Volleringb37ee1e2014-07-16 22:22:59 +0200303fi
David Hendricks1b6e7a62013-11-11 18:44:05 -0800304test_cmd $LOCAL "$cbfstool_cmd"
David Hendricks9f542972015-11-19 13:08:51 -0800305
306tmpcfg=$(mktemp coreboot_config.XXXXXX)
David Hendricks1173bf32015-11-19 13:04:27 -0800307echo "Extracting config.txt from $COREBOOT_IMAGE"
308$cbfstool_cmd "$COREBOOT_IMAGE" extract -n config -f "${tmpdir}/config.txt" >/dev/null 2>&1
Martin Roth9f25da12015-12-17 12:49:15 -0700309mv "${tmpdir}/config.txt" "${tmpdir}/config.short.txt"
310cp "${tmpdir}/config.short.txt" "${tmpcfg}"
311yes "" | make "DOTCONFIG=${tmpcfg}" oldconfig 2>/dev/null >/dev/null
312mv "${tmpcfg}" "${tmpdir}/config.txt"
313rm -f "${tmpcfg}.old"
David Hendricks1173bf32015-11-19 13:04:27 -0800314$cbfstool_cmd "$COREBOOT_IMAGE" print > "${tmpdir}/cbfs.txt"
315rom_contents=$($cbfstool_cmd "$COREBOOT_IMAGE" print 2>&1)
Martin Roth2e44ea22015-12-17 12:33:39 -0700316if [ -n "$(echo $rom_contents | grep payload_config)" ]; then
David Hendricks1173bf32015-11-19 13:04:27 -0800317 echo "Extracting payload_config from $COREBOOT_IMAGE"
318 $cbfstool_cmd "$COREBOOT_IMAGE" extract -n payload_config -f "${tmpdir}/payload_config.txt" >/dev/null 2>&1
Martin Roth2e44ea22015-12-17 12:33:39 -0700319fi
320if [ -n "$(echo $rom_contents | grep payload_version)" ]; then
David Hendricks1173bf32015-11-19 13:04:27 -0800321 echo "Extracting payload_version from $COREBOOT_IMAGE"
322 $cbfstool_cmd "$COREBOOT_IMAGE" extract -n payload_version -f "${tmpdir}/payload_version.txt" >/dev/null 2>&1
Martin Roth2e44ea22015-12-17 12:33:39 -0700323fi
David Hendricks1173bf32015-11-19 13:04:27 -0800324md5sum -b "$COREBOOT_IMAGE" > "${tmpdir}/rom_checksum.txt"
Paul Menzel1cc77e02015-02-19 19:35:58 +0100325
David Hendricks9f542972015-11-19 13:08:51 -0800326if test $do_clean_cbfstool -eq 1; then
327 make -C util/cbfstool clean
328fi
329
Paul Menzel1cc77e02015-02-19 19:35:58 +0100330# Obtain board and revision info to form the directory structure:
331# <vendor>/<board>/<revision>/<timestamp>
Martin Roth9f25da12015-12-17 12:49:15 -0700332mainboard_dir="$(grep CONFIG_MAINBOARD_DIR "${tmpdir}/config.txt" | awk -F '"' '{ print $2 }')"
David Hendricks1b6e7a62013-11-11 18:44:05 -0800333vendor=$(echo "$mainboard_dir" | awk -F '/' '{ print $1 }')
334mainboard=$(echo "$mainboard_dir" | awk -F '/' '{ print $2 }')
David Hendricks6583a812013-11-01 19:37:44 -0700335
David Hendricksc5e947ef2013-11-11 18:43:39 -0800336getrevision="util/board_status/getrevision.sh"
David Hendricks1b6e7a62013-11-11 18:44:05 -0800337test_cmd $LOCAL $getrevision
338tagged_version=$($getrevision -T)
339timestamp=$($getrevision -t)
David Hendricks6583a812013-11-01 19:37:44 -0700340
David Hendricks1b6e7a62013-11-11 18:44:05 -0800341results="${vendor}/${mainboard}/${tagged_version}/${timestamp}"
David Hendricks6583a812013-11-01 19:37:44 -0700342
Paul Menzelc724ac12017-10-15 10:56:36 +0200343if [ -n "$(echo $tagged_version | grep dirty)" ]; then
344 echo "The repository is in a dirty state. Please see the output of"
345 echo "'git status' below."
346 git status
347 exit $EXIT_FAILURE
348fi
349
David Hendricks1b6e7a62013-11-11 18:44:05 -0800350echo "Temporarily placing output in ${tmpdir}/${results}"
351mkdir -p "${tmpdir}/${results}"
David Hendricks6583a812013-11-01 19:37:44 -0700352
David Hendricks1b6e7a62013-11-11 18:44:05 -0800353mv "${tmpdir}/config.txt" "${tmpdir}/${results}"
Martin Roth2e44ea22015-12-17 12:33:39 -0700354test -f "${tmpdir}/payload_config.txt" && mv "${tmpdir}/payload_config.txt" "${tmpdir}/${results}"
355test -f "${tmpdir}/payload_version.txt" && mv "${tmpdir}/payload_version.txt" "${tmpdir}/${results}"
Patrick Georgi368488a2015-06-12 11:35:10 +0200356mv "${tmpdir}/config.short.txt" "${tmpdir}/${results}"
Paul Menzel4b10bb72014-05-30 09:26:46 +0200357mv "${tmpdir}/cbfs.txt" "${tmpdir}/${results}"
Martin Roth072b5aa2015-12-17 12:44:35 -0700358mv "${tmpdir}/rom_checksum.txt" "${tmpdir}/${results}"
David Hendricks6583a812013-11-01 19:37:44 -0700359
Martin Roth9f25da12015-12-17 12:49:15 -0700360touch "${tmpdir}/${results}/revision.txt"
361printf "Local revision: %s\n" "$($getrevision -l)" >> "${tmpdir}/${results}/revision.txt"
362printf "Tagged revision: %s\n" "${tagged_version}" >> "${tmpdir}/${results}/revision.txt"
363printf "Upstream revision: %s\n" "$($getrevision -u)" >> "${tmpdir}/${results}/revision.txt"
364printf "Upstream URL: %s\n" "$($getrevision -U)" >> "${tmpdir}/${results}/revision.txt"
365printf "Timestamp: %s\n" "$timestamp" >> "${tmpdir}/${results}/revision.txt"
David Hendricks1b6e7a62013-11-11 18:44:05 -0800366
David Hendricksc863be72017-09-16 12:59:23 -0700367if [ -n "$CBMEM_PATH" ]; then
368 cbmem_cmd="$CBMEM_PATH"
369else
370 cbmem_cmd="cbmem"
371fi
372
David Hendricksbb90fb52017-09-16 13:01:13 -0700373if [ -n "$SERIAL_DEVICE" ]; then
374 get_serial_bootlog "$SERIAL_DEVICE" "$SERIAL_PORT_SPEED" "${tmpdir}/${results}/coreboot_console.txt"
375elif [ -n "$REMOTE_HOST" ]; then
Martin Roth574d1652015-12-17 12:38:45 -0700376 echo "Verifying that CBMEM is available on remote device"
David Hendricksc863be72017-09-16 12:59:23 -0700377 test_cmd $REMOTE "$cbmem_cmd"
Martin Roth574d1652015-12-17 12:38:45 -0700378 echo "Getting coreboot boot log"
David Hendricksc863be72017-09-16 12:59:23 -0700379 cmd $REMOTE "$cbmem_cmd -c" "${tmpdir}/${results}/coreboot_console.txt"
Martin Roth574d1652015-12-17 12:38:45 -0700380 echo "Getting timestamp data"
David Hendricksc863be72017-09-16 12:59:23 -0700381 cmd_nonfatal $REMOTE "$cbmem_cmd -t" "${tmpdir}/${results}/coreboot_timestamps.txt"
David Hendricks0dcfb592017-09-16 18:43:08 -0700382
383 echo "Getting remote dmesg"
384 cmd $REMOTE dmesg "${tmpdir}/${results}/kernel_log.txt"
Martin Roth8e0071b2014-07-10 15:00:35 -0600385else
David Hendricksbb90fb52017-09-16 13:01:13 -0700386 echo "Verifying that CBMEM is available"
387 if [ $(id -u) -ne 0 ]; then
Matthias Gazzari25c7e322018-05-02 15:43:27 +0200388 command -v "$cbmem_cmd" >/dev/null
David Hendricksbb90fb52017-09-16 13:01:13 -0700389 if [ $? -ne 0 ]; then
Matthias Gazzari25c7e322018-05-02 15:43:27 +0200390 echo "Failed to run $cbmem_cmd. Check \$PATH or" \
391 "use -c to specify path to cbmem binary."
David Hendricksbb90fb52017-09-16 13:01:13 -0700392 exit $EXIT_FAILURE
393 else
394 cbmem_cmd="sudo $cbmem_cmd"
395 fi
396 else
397 test_cmd $LOCAL "$cbmem_cmd"
398 fi
399
400 echo "Getting coreboot boot log"
401 cmd $LOCAL "$cbmem_cmd -c" "${tmpdir}/${results}/coreboot_console.txt"
402 echo "Getting timestamp data"
403 cmd_nonfatal $LOCAL "$cbmem_cmd -t" "${tmpdir}/${results}/coreboot_timestamps.txt"
404
405 echo "Getting local dmesg"
406 cmd $LOCAL dmesg "${tmpdir}/${results}/kernel_log.txt"
Martin Roth8e0071b2014-07-10 15:00:35 -0600407fi
David Hendricks1b6e7a62013-11-11 18:44:05 -0800408
David Hendricksa4affe12013-11-12 18:17:19 -0800409#
410# Finish up.
411#
Martin Rothbcd09932014-07-10 15:02:19 -0600412coreboot_dir=$(pwd)
David Hendricks1b6e7a62013-11-11 18:44:05 -0800413if [ $UPLOAD_RESULTS -eq 1 ]; then
414 # extract username from ssh://<username>@review.coreboot.org/blah
Patrick Georgi77b182a2014-08-10 15:18:22 +0200415 bsrepo=$(git config --get remote.origin.url | sed "s,\(.*\)/coreboot,\1/board-status,")
David Hendricks1b6e7a62013-11-11 18:44:05 -0800416
417 cd "util/board_status/"
418 if [ ! -e "board-status" ]; then
David Hendricksa4affe12013-11-12 18:17:19 -0800419 # FIXME: the board-status directory might get big over time.
420 # Is there a way we can push the results without fetching the
421 # whole repo?
Martin Roth9f25da12015-12-17 12:49:15 -0700422 git clone "$bsrepo"
David Hendricks1b6e7a62013-11-11 18:44:05 -0800423 if [ $? -ne 0 ]; then
Paul Menzel749e0752015-05-20 22:32:15 +0200424 echo "Error cloning board-status repo, aborting."
David Hendricks1b6e7a62013-11-11 18:44:05 -0800425 exit $EXIT_FAILURE
426 fi
427 fi
428
429 cd "board-status"
Huimin Zhang2fb24832016-03-30 00:54:16 -0700430
431 echo "Checking for duplicate results"
432 # get any updates to board-status
433 git pull
434
435 echo "${tagged_version}" | grep dirty >/dev/null 2>&1
436 clean_version=$?
437 existing_results=$(git ls-files "${mainboard_dir}/${tagged_version}")
438
439 # reject duplicate results of non-dirty versions
440 if [ "${clean_version}" -eq 1 ] && [ -n "${existing_results}" ] ; then
441 echo "Result is a duplicate, aborting"
442 exit $EXIT_FAILURE
443 fi
444
David Hendricks1b6e7a62013-11-11 18:44:05 -0800445 echo "Copying results to $(pwd)/${results}"
446
447 # Note: Result directory should be unique due to the timestamp.
448 cp -R "${tmpdir}/${vendor}" .
449
450 echo "Uploading results"
451 git add "${vendor}"
Paul Menzel04eb2e82014-02-09 10:24:22 +0100452 git commit -a -m "${mainboard_dir}/${tagged_version}/${timestamp}"
Paul Menzel54e6aa72015-05-20 07:35:56 +0200453 count=0
Jonathan Neuschäfer478c8892016-05-10 17:43:53 +0200454 until git push origin master || test $count -eq 3; do
Paul Menzel54e6aa72015-05-20 07:35:56 +0200455 git pull --rebase
456 count=$((count + 1))
457 done
David Hendricks1b6e7a62013-11-11 18:44:05 -0800458
459 # Results have been uploaded so it's pointless to keep the
460 # temporary files around.
461 rm -rf "${tmpdir}"
Paul Menzel54e6aa72015-05-20 07:35:56 +0200462 if test $count -eq 3; then
463 echo "Error uploading to board-status repo, aborting."
464 exit $EXIT_FAILURE
465 fi
David Hendricks1b6e7a62013-11-11 18:44:05 -0800466fi
467cd "$coreboot_dir"
David Hendricks6583a812013-11-01 19:37:44 -0700468
469if [ $CLOBBER_OUTPUT -eq 1 ]; then
Martin Roth9f25da12015-12-17 12:49:15 -0700470 rm -rf "${tmpdir}"
Martin Roth13c7db82014-07-10 14:59:11 -0600471else
David Hendricks588a7222017-09-05 23:38:03 -0700472 if [ $UPLOAD_RESULTS -eq 1 ]; then
473 echo
474 echo "output files are in $(dirname $0)/board-status/${mainboard_dir}/${tagged_version}/${timestamp}"
475 else
476 echo
477 echo "output files are in ${tmpdir}/${results}"
478 fi
David Hendricks6583a812013-11-01 19:37:44 -0700479fi
480
481exit $EXIT_SUCCESS