From 406ce8a06e82dc17c7153c02585aa3e8f885561f Mon Sep 17 00:00:00 2001 From: David Hendricks Date: Tue, 12 Nov 2013 18:10:23 -0800 Subject: 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 Reviewed-on: http://review.coreboot.org/4050 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich --- util/board_status/board_status.sh | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/util/board_status/board_status.sh b/util/board_status/board_status.sh index f7300bdcdd..2fb3555d64 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? -- cgit v1.2.3