David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # This file is part of the coreboot project. |
| 4 | # |
| 5 | # Copyright (C) 2013 Google Inc. |
Martin Roth | 8e0071b | 2014-07-10 15:00:35 -0600 | [diff] [blame] | 6 | # Copyright (C) 2014 Sage Electronic Engineering, LLC. |
Zheng Bao | 86655cf | 2013-11-07 18:03:05 +0800 | [diff] [blame] | 7 | # |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 8 | |
| 9 | EXIT_SUCCESS=0 |
| 10 | EXIT_FAILURE=1 |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 11 | |
| 12 | # Stuff from command-line switches |
| 13 | REMOTE_HOST="" |
| 14 | CLOBBER_OUTPUT=0 |
| 15 | UPLOAD_RESULTS=0 |
Martin Roth | 8e0071b | 2014-07-10 15:00:35 -0600 | [diff] [blame] | 16 | SERIAL_PORT_SPEED=115200 |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 17 | |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 18 | # Used to specify whether a command should always be run locally or |
| 19 | # if command should be run remoteley when a remote host is specified. |
| 20 | LOCAL=0 |
| 21 | REMOTE=1 |
Martin Roth | be5340b | 2014-06-22 21:46:24 -0600 | [diff] [blame] | 22 | FATAL=0 |
| 23 | NONFATAL=1 |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 24 | |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 25 | # test a command |
| 26 | # |
Martin Roth | bcd0993 | 2014-07-10 15:02:19 -0600 | [diff] [blame] | 27 | # $1: 0 ($LOCAL) to run command locally, |
| 28 | # 1 ($REMOTE) to run remotely if remote host defined |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 29 | # $2: command to test |
Martin Roth | be5340b | 2014-06-22 21:46:24 -0600 | [diff] [blame] | 30 | # $3: 0 ($FATAL) Exit with an error if the command fails |
| 31 | # 1 ($NONFATAL) Don't exit on command test failure |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 32 | test_cmd() |
| 33 | { |
| 34 | local rc |
| 35 | |
| 36 | if [ -e "$2" ]; then |
| 37 | return |
| 38 | fi |
| 39 | |
Vladimir Serbinenko | 77005b4 | 2014-01-21 02:39:46 +0100 | [diff] [blame] | 40 | if [ "$1" -eq "$REMOTE" ] && [ -n "$REMOTE_HOST" ]; then |
Patrick Georgi | 1cbef1c | 2015-08-10 10:21:14 +0200 | [diff] [blame] | 41 | ssh root@${REMOTE_HOST} command -v "$2" > /dev/null |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 42 | rc=$? |
| 43 | else |
Patrick Georgi | 1cbef1c | 2015-08-10 10:21:14 +0200 | [diff] [blame] | 44 | command -v "$2" >/dev/null |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 45 | rc=$? |
| 46 | fi |
| 47 | |
| 48 | if [ $rc -eq 0 ]; then |
Martin Roth | be5340b | 2014-06-22 21:46:24 -0600 | [diff] [blame] | 49 | return 0 |
| 50 | fi |
| 51 | |
Patrick Georgi | 4ef309e | 2014-08-10 15:44:04 +0200 | [diff] [blame] | 52 | if [ "$3" = "1" ]; then |
Martin Roth | be5340b | 2014-06-22 21:46:24 -0600 | [diff] [blame] | 53 | return 1 |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 54 | fi |
| 55 | |
| 56 | echo "$2 not found" |
| 57 | exit $EXIT_FAILURE |
| 58 | } |
| 59 | |
David Hendricks | f8b90e4 | 2013-11-12 17:24:42 -0800 | [diff] [blame] | 60 | _cmd() |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 61 | { |
| 62 | if [ -e "$2" ]; then |
David Hendricks | f8b90e4 | 2013-11-12 17:24:42 -0800 | [diff] [blame] | 63 | return $EXIT_FAILURE |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 64 | fi |
| 65 | |
Martin Roth | 2246177 | 2014-07-10 14:57:34 -0600 | [diff] [blame] | 66 | if [ -n "$3" ]; then |
| 67 | pipe_location="${3}" |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 68 | else |
Martin Roth | 2246177 | 2014-07-10 14:57:34 -0600 | [diff] [blame] | 69 | pipe_location="/dev/null" |
| 70 | fi |
| 71 | |
| 72 | if [ "$1" -eq "$REMOTE" ] && [ -n "$REMOTE_HOST" ]; then |
Martin Roth | 9f25da1 | 2015-12-17 12:49:15 -0700 | [diff] [blame] | 73 | ssh "root@${REMOTE_HOST}" "$2" > "$pipe_location" 2>&1 |
Martin Roth | 2246177 | 2014-07-10 14:57:34 -0600 | [diff] [blame] | 74 | else |
| 75 | $2 > "$pipe_location" 2>&1 |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 76 | fi |
David Hendricks | 406ce8a | 2013-11-12 18:10:23 -0800 | [diff] [blame] | 77 | |
| 78 | return $? |
David Hendricks | f8b90e4 | 2013-11-12 17:24:42 -0800 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | # run a command |
| 82 | # |
Martin Roth | bcd0993 | 2014-07-10 15:02:19 -0600 | [diff] [blame] | 83 | # $1: 0 ($LOCAL) to run command locally, |
| 84 | # 1 ($REMOTE) to run remotely if remote host defined |
David Hendricks | f8b90e4 | 2013-11-12 17:24:42 -0800 | [diff] [blame] | 85 | # $2: command |
David Hendricks | 406ce8a | 2013-11-12 18:10:23 -0800 | [diff] [blame] | 86 | # $3: filename to direct output of command into |
David Hendricks | f8b90e4 | 2013-11-12 17:24:42 -0800 | [diff] [blame] | 87 | cmd() |
| 88 | { |
David Hendricks | 406ce8a | 2013-11-12 18:10:23 -0800 | [diff] [blame] | 89 | _cmd $1 "$2" "$3" |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 90 | |
| 91 | if [ $? -eq 0 ]; then |
| 92 | return |
| 93 | fi |
Zheng Bao | 86655cf | 2013-11-07 18:03:05 +0800 | [diff] [blame] | 94 | |
David Hendricks | 406ce8a | 2013-11-12 18:10:23 -0800 | [diff] [blame] | 95 | echo "Failed to run \"$2\", aborting" |
| 96 | rm -f "$3" # don't leave an empty file |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 97 | exit $EXIT_FAILURE |
| 98 | } |
| 99 | |
David Hendricks | f8b90e4 | 2013-11-12 17:24:42 -0800 | [diff] [blame] | 100 | # run a command where failure is considered to be non-fatal |
| 101 | # |
Martin Roth | bcd0993 | 2014-07-10 15:02:19 -0600 | [diff] [blame] | 102 | # $1: 0 ($LOCAL) to run command locally, |
| 103 | # 1 ($REMOTE) to run remotely if remote host defined |
David Hendricks | f8b90e4 | 2013-11-12 17:24:42 -0800 | [diff] [blame] | 104 | # $2: command |
David Hendricks | 406ce8a | 2013-11-12 18:10:23 -0800 | [diff] [blame] | 105 | # $3: filename to direct output of command into |
David Hendricks | f8b90e4 | 2013-11-12 17:24:42 -0800 | [diff] [blame] | 106 | cmd_nonfatal() |
| 107 | { |
David Hendricks | 406ce8a | 2013-11-12 18:10:23 -0800 | [diff] [blame] | 108 | _cmd $1 "$2" "$3" |
David Hendricks | f8b90e4 | 2013-11-12 17:24:42 -0800 | [diff] [blame] | 109 | |
| 110 | if [ $? -eq 0 ]; then |
| 111 | return |
| 112 | fi |
| 113 | |
David Hendricks | 406ce8a | 2013-11-12 18:10:23 -0800 | [diff] [blame] | 114 | echo "Failed to run \"$2\", ignoring" |
| 115 | rm -f "$3" # don't leave an empty file |
David Hendricks | f8b90e4 | 2013-11-12 17:24:42 -0800 | [diff] [blame] | 116 | } |
| 117 | |
Martin Roth | 8e0071b | 2014-07-10 15:00:35 -0600 | [diff] [blame] | 118 | # read from a serial port device |
| 119 | # |
| 120 | # $1: serial device to read from |
| 121 | # $2: serial port speed |
| 122 | # $3: filename to direct output of command into |
| 123 | get_serial_bootlog () { |
| 124 | |
Martin Roth | d0128df | 2015-12-17 12:02:45 -0700 | [diff] [blame] | 125 | local TTY=$1 |
| 126 | local SPEED=$2 |
| 127 | local FILENAME=$3 |
| 128 | |
| 129 | if [ ! -c "$TTY" ]; then |
| 130 | echo "$TTY is not a valid serial device" |
Martin Roth | 8e0071b | 2014-07-10 15:00:35 -0600 | [diff] [blame] | 131 | exit $EXIT_FAILURE |
| 132 | fi |
| 133 | |
| 134 | # make the text more noticible |
| 135 | test_cmd $LOCAL "tput" $NONFATAL |
| 136 | tput_not_available=$? |
| 137 | if [ $tput_not_available -eq 0 ]; then |
| 138 | tput bold |
| 139 | tput setaf 10 # set bright green |
| 140 | fi |
| 141 | |
| 142 | echo |
Martin Roth | d0128df | 2015-12-17 12:02:45 -0700 | [diff] [blame] | 143 | echo "Waiting to receive boot log from $TTY" |
Martin Roth | 8e0071b | 2014-07-10 15:00:35 -0600 | [diff] [blame] | 144 | echo "Press [Enter] when the boot is complete and the" |
| 145 | echo "system is ready for ssh to get the dmesg log." |
Martin Roth | d0128df | 2015-12-17 12:02:45 -0700 | [diff] [blame] | 146 | echo |
Martin Roth | 8e0071b | 2014-07-10 15:00:35 -0600 | [diff] [blame] | 147 | |
| 148 | if [ $tput_not_available -eq 0 ]; then |
| 149 | tput sgr0 |
| 150 | fi |
| 151 | |
| 152 | # set up the serial port |
Martin Roth | d0128df | 2015-12-17 12:02:45 -0700 | [diff] [blame] | 153 | stty -F $TTY $SPEED cs8 -cstopb -parenb clocal |
Martin Roth | 8e0071b | 2014-07-10 15:00:35 -0600 | [diff] [blame] | 154 | |
| 155 | # read from the serial port - user must press enter when complete |
| 156 | test_cmd $LOCAL "tee" |
Martin Roth | d0128df | 2015-12-17 12:02:45 -0700 | [diff] [blame] | 157 | while read LINE; do |
| 158 | echo "$LINE" | tee -a "$FILENAME" |
| 159 | done < "$SERIAL_DEVICE" & |
Martin Roth | 8e0071b | 2014-07-10 15:00:35 -0600 | [diff] [blame] | 160 | PID=$! |
| 161 | |
Martin Roth | d0128df | 2015-12-17 12:02:45 -0700 | [diff] [blame] | 162 | read foo |
| 163 | kill "$PID" 2>/dev/null |
Martin Roth | 8e0071b | 2014-07-10 15:00:35 -0600 | [diff] [blame] | 164 | |
Martin Roth | d0128df | 2015-12-17 12:02:45 -0700 | [diff] [blame] | 165 | echo "Finished reading boot log." |
Martin Roth | 8e0071b | 2014-07-10 15:00:35 -0600 | [diff] [blame] | 166 | } |
| 167 | |
David Hendricks | 1fc65f7 | 2013-11-12 16:49:45 -0800 | [diff] [blame] | 168 | show_help() { |
| 169 | echo "Usage: |
| 170 | ${0} <option> |
| 171 | |
| 172 | Options |
| 173 | -h |
| 174 | Show this message. |
| 175 | -C |
| 176 | Clobber temporary output when finished. Useful for debugging. |
| 177 | -r <host> |
| 178 | Obtain machine information from remote host (using ssh). |
Martin Roth | 8e0071b | 2014-07-10 15:00:35 -0600 | [diff] [blame] | 179 | -s </dev/xxx> |
| 180 | Obtain boot log via serial device. |
| 181 | -S <speed> |
Martin Roth | d0128df | 2015-12-17 12:02:45 -0700 | [diff] [blame] | 182 | Set the port speed for the serial device (Default is $SERIAL_PORT_SPEED). |
David Hendricks | 1fc65f7 | 2013-11-12 16:49:45 -0800 | [diff] [blame] | 183 | -u |
| 184 | Upload results to coreboot.org. |
| 185 | " |
| 186 | } |
| 187 | |
Martin Roth | 8e0071b | 2014-07-10 15:00:35 -0600 | [diff] [blame] | 188 | while getopts "Chr:s:S:u" opt; do |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 189 | case "$opt" in |
| 190 | h) |
| 191 | show_help |
| 192 | exit $EXIT_SUCCESS |
| 193 | ;; |
David Hendricks | 16955fd | 2013-11-12 16:45:37 -0800 | [diff] [blame] | 194 | C) |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 195 | CLOBBER_OUTPUT=1 |
| 196 | ;; |
| 197 | r) |
| 198 | REMOTE_HOST="$OPTARG" |
| 199 | ;; |
Martin Roth | 8e0071b | 2014-07-10 15:00:35 -0600 | [diff] [blame] | 200 | s) |
| 201 | SERIAL_DEVICE="$OPTARG" |
| 202 | ;; |
| 203 | S) |
| 204 | SERIAL_PORT_SPEED="$OPTARG" |
| 205 | ;; |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 206 | u) |
| 207 | UPLOAD_RESULTS=1 |
| 208 | ;; |
| 209 | esac |
| 210 | done |
| 211 | |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 212 | grep -rH 'coreboot.org' .git/config >/dev/null 2>&1 |
| 213 | if [ $? -ne 0 ]; then |
| 214 | echo "Script must be run from root of coreboot directory" |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 215 | exit $EXIT_FAILURE |
| 216 | fi |
| 217 | |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 218 | # Results will be placed in a temporary location until we're ready to upload. |
| 219 | # If the user does not wish to upload, results will remain in /tmp. |
Patrick Georgi | aa7dcef | 2015-08-13 07:57:26 +0200 | [diff] [blame] | 220 | tmpdir=$(mktemp -d --tmpdir coreboot_board_status.XXXXXXXX) |
| 221 | tmpcfg=$(mktemp coreboot_config.XXXXXX) |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 222 | |
Idwer Vollering | b37ee1e | 2014-07-16 22:22:59 +0200 | [diff] [blame] | 223 | cbfstool_cmd="build/cbfstool" |
| 224 | if test ! -x build/cbfstool; then |
| 225 | make -C util/cbfstool/ && cp util/cbfstool/cbfstool build/cbfstool |
| 226 | fi |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 227 | test_cmd $LOCAL "$cbfstool_cmd" |
Martin Roth | 574d165 | 2015-12-17 12:38:45 -0700 | [diff] [blame] | 228 | echo "Extracting config.txt from build/coreboot.rom" |
| 229 | $cbfstool_cmd build/coreboot.rom extract -n config -f "${tmpdir}/config.txt" >/dev/null 2>&1 |
Martin Roth | 9f25da1 | 2015-12-17 12:49:15 -0700 | [diff] [blame] | 230 | mv "${tmpdir}/config.txt" "${tmpdir}/config.short.txt" |
| 231 | cp "${tmpdir}/config.short.txt" "${tmpcfg}" |
| 232 | yes "" | make "DOTCONFIG=${tmpcfg}" oldconfig 2>/dev/null >/dev/null |
| 233 | mv "${tmpcfg}" "${tmpdir}/config.txt" |
| 234 | rm -f "${tmpcfg}.old" |
| 235 | $cbfstool_cmd build/coreboot.rom print > "${tmpdir}/cbfs.txt" |
Martin Roth | 2e44ea2 | 2015-12-17 12:33:39 -0700 | [diff] [blame] | 236 | rom_contents=$($cbfstool_cmd build/coreboot.rom print 2>&1) |
| 237 | if [ -n "$(echo $rom_contents | grep payload_config)" ]; then |
| 238 | echo "Extracting payload_config from build/coreboot.rom" |
| 239 | $cbfstool_cmd build/coreboot.rom extract -n payload_config -f "${tmpdir}/payload_config.txt" >/dev/null 2>&1 |
| 240 | fi |
| 241 | if [ -n "$(echo $rom_contents | grep payload_version)" ]; then |
| 242 | echo "Extracting payload_version from build/coreboot.rom" |
| 243 | $cbfstool_cmd build/coreboot.rom extract -n payload_version -f "${tmpdir}/payload_version.txt" >/dev/null 2>&1 |
| 244 | fi |
Martin Roth | 072b5aa | 2015-12-17 12:44:35 -0700 | [diff] [blame] | 245 | md5sum -b build/coreboot.rom > "${tmpdir}/rom_checksum.txt" |
Paul Menzel | 1cc77e0 | 2015-02-19 19:35:58 +0100 | [diff] [blame] | 246 | |
| 247 | # Obtain board and revision info to form the directory structure: |
| 248 | # <vendor>/<board>/<revision>/<timestamp> |
Martin Roth | 9f25da1 | 2015-12-17 12:49:15 -0700 | [diff] [blame] | 249 | mainboard_dir="$(grep CONFIG_MAINBOARD_DIR "${tmpdir}/config.txt" | awk -F '"' '{ print $2 }')" |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 250 | vendor=$(echo "$mainboard_dir" | awk -F '/' '{ print $1 }') |
| 251 | mainboard=$(echo "$mainboard_dir" | awk -F '/' '{ print $2 }') |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 252 | |
David Hendricks | c5e947ef | 2013-11-11 18:43:39 -0800 | [diff] [blame] | 253 | getrevision="util/board_status/getrevision.sh" |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 254 | test_cmd $LOCAL $getrevision |
| 255 | tagged_version=$($getrevision -T) |
| 256 | timestamp=$($getrevision -t) |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 257 | |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 258 | results="${vendor}/${mainboard}/${tagged_version}/${timestamp}" |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 259 | |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 260 | echo "Temporarily placing output in ${tmpdir}/${results}" |
| 261 | mkdir -p "${tmpdir}/${results}" |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 262 | |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 263 | mv "${tmpdir}/config.txt" "${tmpdir}/${results}" |
Martin Roth | 2e44ea2 | 2015-12-17 12:33:39 -0700 | [diff] [blame] | 264 | test -f "${tmpdir}/payload_config.txt" && mv "${tmpdir}/payload_config.txt" "${tmpdir}/${results}" |
| 265 | test -f "${tmpdir}/payload_version.txt" && mv "${tmpdir}/payload_version.txt" "${tmpdir}/${results}" |
Patrick Georgi | 368488a | 2015-06-12 11:35:10 +0200 | [diff] [blame] | 266 | mv "${tmpdir}/config.short.txt" "${tmpdir}/${results}" |
Paul Menzel | 4b10bb7 | 2014-05-30 09:26:46 +0200 | [diff] [blame] | 267 | mv "${tmpdir}/cbfs.txt" "${tmpdir}/${results}" |
Martin Roth | 072b5aa | 2015-12-17 12:44:35 -0700 | [diff] [blame] | 268 | mv "${tmpdir}/rom_checksum.txt" "${tmpdir}/${results}" |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 269 | |
Martin Roth | 9f25da1 | 2015-12-17 12:49:15 -0700 | [diff] [blame] | 270 | touch "${tmpdir}/${results}/revision.txt" |
| 271 | printf "Local revision: %s\n" "$($getrevision -l)" >> "${tmpdir}/${results}/revision.txt" |
| 272 | printf "Tagged revision: %s\n" "${tagged_version}" >> "${tmpdir}/${results}/revision.txt" |
| 273 | printf "Upstream revision: %s\n" "$($getrevision -u)" >> "${tmpdir}/${results}/revision.txt" |
| 274 | printf "Upstream URL: %s\n" "$($getrevision -U)" >> "${tmpdir}/${results}/revision.txt" |
| 275 | printf "Timestamp: %s\n" "$timestamp" >> "${tmpdir}/${results}/revision.txt" |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 276 | |
Martin Roth | 8e0071b | 2014-07-10 15:00:35 -0600 | [diff] [blame] | 277 | if [ -z "$SERIAL_DEVICE" ]; then |
Martin Roth | 574d165 | 2015-12-17 12:38:45 -0700 | [diff] [blame] | 278 | echo "Verifying that CBMEM is available on remote device" |
Martin Roth | 8e0071b | 2014-07-10 15:00:35 -0600 | [diff] [blame] | 279 | test_cmd $REMOTE "cbmem" |
Martin Roth | 574d165 | 2015-12-17 12:38:45 -0700 | [diff] [blame] | 280 | echo "Getting coreboot boot log" |
Martin Roth | 8e0071b | 2014-07-10 15:00:35 -0600 | [diff] [blame] | 281 | cmd $REMOTE "cbmem -c" "${tmpdir}/${results}/coreboot_console.txt" |
Martin Roth | 574d165 | 2015-12-17 12:38:45 -0700 | [diff] [blame] | 282 | echo "Getting timestamp data" |
Martin Roth | 8e0071b | 2014-07-10 15:00:35 -0600 | [diff] [blame] | 283 | cmd_nonfatal $REMOTE "cbmem -t" "${tmpdir}/${results}/coreboot_timestamps.txt" |
| 284 | else |
| 285 | get_serial_bootlog "$SERIAL_DEVICE" "$SERIAL_PORT_SPEED" "${tmpdir}/${results}/coreboot_console.txt" |
| 286 | fi |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 287 | |
Martin Roth | 574d165 | 2015-12-17 12:38:45 -0700 | [diff] [blame] | 288 | echo "Getting remote dmesg" |
David Hendricks | 406ce8a | 2013-11-12 18:10:23 -0800 | [diff] [blame] | 289 | cmd $REMOTE dmesg "${tmpdir}/${results}/kernel_log.txt" |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 290 | |
David Hendricks | a4affe1 | 2013-11-12 18:17:19 -0800 | [diff] [blame] | 291 | # |
| 292 | # Finish up. |
| 293 | # |
Martin Roth | bcd0993 | 2014-07-10 15:02:19 -0600 | [diff] [blame] | 294 | coreboot_dir=$(pwd) |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 295 | if [ $UPLOAD_RESULTS -eq 1 ]; then |
| 296 | # extract username from ssh://<username>@review.coreboot.org/blah |
Patrick Georgi | 77b182a | 2014-08-10 15:18:22 +0200 | [diff] [blame] | 297 | bsrepo=$(git config --get remote.origin.url | sed "s,\(.*\)/coreboot,\1/board-status,") |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 298 | |
| 299 | cd "util/board_status/" |
| 300 | if [ ! -e "board-status" ]; then |
David Hendricks | a4affe1 | 2013-11-12 18:17:19 -0800 | [diff] [blame] | 301 | # FIXME: the board-status directory might get big over time. |
| 302 | # Is there a way we can push the results without fetching the |
| 303 | # whole repo? |
Martin Roth | 9f25da1 | 2015-12-17 12:49:15 -0700 | [diff] [blame] | 304 | git clone "$bsrepo" |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 305 | if [ $? -ne 0 ]; then |
Paul Menzel | 749e075 | 2015-05-20 22:32:15 +0200 | [diff] [blame] | 306 | echo "Error cloning board-status repo, aborting." |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 307 | exit $EXIT_FAILURE |
| 308 | fi |
| 309 | fi |
| 310 | |
| 311 | cd "board-status" |
| 312 | echo "Copying results to $(pwd)/${results}" |
| 313 | |
| 314 | # Note: Result directory should be unique due to the timestamp. |
| 315 | cp -R "${tmpdir}/${vendor}" . |
| 316 | |
| 317 | echo "Uploading results" |
| 318 | git add "${vendor}" |
Paul Menzel | 04eb2e8 | 2014-02-09 10:24:22 +0100 | [diff] [blame] | 319 | git commit -a -m "${mainboard_dir}/${tagged_version}/${timestamp}" |
Paul Menzel | 54e6aa7 | 2015-05-20 07:35:56 +0200 | [diff] [blame] | 320 | count=0 |
| 321 | until git push origin || test $count -eq 3; do |
| 322 | git pull --rebase |
| 323 | count=$((count + 1)) |
| 324 | done |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 325 | |
| 326 | # Results have been uploaded so it's pointless to keep the |
| 327 | # temporary files around. |
| 328 | rm -rf "${tmpdir}" |
Paul Menzel | 54e6aa7 | 2015-05-20 07:35:56 +0200 | [diff] [blame] | 329 | if test $count -eq 3; then |
| 330 | echo "Error uploading to board-status repo, aborting." |
| 331 | exit $EXIT_FAILURE |
| 332 | fi |
David Hendricks | 1b6e7a6 | 2013-11-11 18:44:05 -0800 | [diff] [blame] | 333 | fi |
| 334 | cd "$coreboot_dir" |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 335 | |
| 336 | if [ $CLOBBER_OUTPUT -eq 1 ]; then |
Martin Roth | 9f25da1 | 2015-12-17 12:49:15 -0700 | [diff] [blame] | 337 | rm -rf "${tmpdir}" |
Martin Roth | 13c7db8 | 2014-07-10 14:59:11 -0600 | [diff] [blame] | 338 | else |
| 339 | echo |
| 340 | echo "output files are in ${tmpdir}/${results}" |
David Hendricks | 6583a81 | 2013-11-01 19:37:44 -0700 | [diff] [blame] | 341 | fi |
| 342 | |
| 343 | exit $EXIT_SUCCESS |