diff options
author | David Hendricks <dhendrix@chromium.org> | 2013-11-12 18:10:23 -0800 |
---|---|---|
committer | David Hendricks <dhendrix@chromium.org> | 2013-11-17 10:32:14 +0100 |
commit | 406ce8a06e82dc17c7153c02585aa3e8f885561f (patch) | |
tree | 4a936fea8baa87d55dfc34e3bd8dbe0ac54eee32 /util/board_status/board_status.sh | |
parent | f8b90e4622533947dbc21c55b21ea932eb7420c7 (diff) | |
download | coreboot-staging-406ce8a06e82dc17c7153c02585aa3e8f885561f.zip coreboot-staging-406ce8a06e82dc17c7153c02585aa3e8f885561f.tar.gz |
board_status.sh: pass filename as an arg to command wrappers
This allows the command wrappers to delete files if the command
fails. In particular, it delets empty or otherwise useless files
that are generated if a non-fatal command fails.
Change-Id: If26d7b4d7500f160edd1cc2a8b6218792fefae8b
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: http://review.coreboot.org/4050
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'util/board_status/board_status.sh')
-rw-r--r-- | util/board_status/board_status.sh | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/util/board_status/board_status.sh b/util/board_status/board_status.sh index f7300bd..2fb3555 100644 --- a/util/board_status/board_status.sh +++ b/util/board_status/board_status.sh @@ -53,25 +53,29 @@ _cmd() fi if [[ $1 -eq $REMOTE && -n "$REMOTE_HOST" ]]; then - ssh root@${REMOTE_HOST} "$2" + ssh root@${REMOTE_HOST} "$2" > "${3}" 2>&1 else - $2 + $2 > "${3}" 2>&1 fi + + return $? } # run a command # # $1: 0 to run command locally, 1 to run remotely if remote host defined # $2: command +# $3: filename to direct output of command into cmd() { - _cmd $1 $2 + _cmd $1 "$2" "$3" if [ $? -eq 0 ]; then return fi - echo "Failed to run command: $2" + echo "Failed to run \"$2\", aborting" + rm -f "$3" # don't leave an empty file exit $EXIT_FAILURE } @@ -79,15 +83,17 @@ cmd() # # $1: 0 to run command locally, 1 to run remotely if remote host defined # $2: command +# $3: filename to direct output of command into cmd_nonfatal() { - _cmd $1 $2 + _cmd $1 "$2" "$3" if [ $? -eq 0 ]; then return fi - echo "Failed to run command: $2" + echo "Failed to run \"$2\", ignoring" + rm -f "$3" # don't leave an empty file } show_help() { @@ -163,10 +169,10 @@ printf "Upstream URL: %s\n" $($getrevision -U)>> ${tmpdir}/${results}/revision.t printf "Timestamp: %s\n" "$timestamp" >> ${tmpdir}/${results}/revision.txt test_cmd $REMOTE "cbmem" -cmd $REMOTE "cbmem -c" > ${tmpdir}/${results}/coreboot_console.txt -cmd_nonfatal $REMOTE "cbmem -t" > ${tmpdir}/${results}/coreboot_timestamps.txt +cmd $REMOTE "cbmem -c" "${tmpdir}/${results}/coreboot_console.txt" +cmd_nonfatal $REMOTE "cbmem -t" "${tmpdir}/${results}/coreboot_timestamps.txt" -cmd $REMOTE dmesg > ${tmpdir}/${results}/kernel_log.txt +cmd $REMOTE dmesg "${tmpdir}/${results}/kernel_log.txt" # FIXME: the board-status directory might get big over time. Is there a way we # can push the results without fetching the whole repo? |