[coreboot-gerrit] New patch to review for coreboot: f5e172f board_status.sh: pass filename as an arg to command wrappers
David Hendricks (dhendrix@chromium.org)
gerrit at coreboot.org
Wed Nov 13 03:26:26 CET 2013
David Hendricks (dhendrix at chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4050
-gerrit
commit f5e172f387e70022acc63e5c5d5aefde638c00a9
Author: David Hendricks <dhendrix at chromium.org>
Date: Tue Nov 12 18:10:23 2013 -0800
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 at chromium.org>
---
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 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?
More information about the coreboot-gerrit
mailing list