board_status.sh: add support for non-fatal commands

This adds cmd_nonfatal() for commands which are considered
non-essential and can be expected to fail safely. This can be used,
for example, to gather data that is generated when using non-standard
utilities or coreboot config options.

Change-Id: Ie43944d2eb73f9aae1c30c3a204cfc413e11d286
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: http://review.coreboot.org/4049
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
This commit is contained in:
David Hendricks 2013-11-12 17:24:42 -08:00
parent 1fc65f76f4
commit f8b90e4622
1 changed files with 27 additions and 9 deletions

View File

@ -46,14 +46,10 @@ test_cmd()
exit $EXIT_FAILURE exit $EXIT_FAILURE
} }
# run a command _cmd()
#
# $1: 0 to run command locally, 1 to run remotely if remote host defined
# $2: command
cmd()
{ {
if [ -e "$2" ]; then if [ -e "$2" ]; then
return return $EXIT_FAILURE
fi fi
if [[ $1 -eq $REMOTE && -n "$REMOTE_HOST" ]]; then if [[ $1 -eq $REMOTE && -n "$REMOTE_HOST" ]]; then
@ -61,6 +57,15 @@ cmd()
else else
$2 $2
fi fi
}
# run a command
#
# $1: 0 to run command locally, 1 to run remotely if remote host defined
# $2: command
cmd()
{
_cmd $1 $2
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
return return
@ -70,6 +75,21 @@ cmd()
exit $EXIT_FAILURE exit $EXIT_FAILURE
} }
# run a command where failure is considered to be non-fatal
#
# $1: 0 to run command locally, 1 to run remotely if remote host defined
# $2: command
cmd_nonfatal()
{
_cmd $1 $2
if [ $? -eq 0 ]; then
return
fi
echo "Failed to run command: $2"
}
show_help() { show_help() {
echo "Usage: echo "Usage:
${0} <option> ${0} <option>
@ -144,9 +164,7 @@ printf "Timestamp: %s\n" "$timestamp" >> ${tmpdir}/${results}/revision.txt
test_cmd $REMOTE "cbmem" test_cmd $REMOTE "cbmem"
cmd $REMOTE "cbmem -c" > ${tmpdir}/${results}/coreboot_console.txt cmd $REMOTE "cbmem -c" > ${tmpdir}/${results}/coreboot_console.txt
cmd_nonfatal $REMOTE "cbmem -t" > ${tmpdir}/${results}/coreboot_timestamps.txt
# TODO: Some commands should be optional and be non-fatal in case of error.
#cmd $REMOTE "cbmem -t" > ${outdir}/coreboot_timestamps.txt
cmd $REMOTE dmesg > ${tmpdir}/${results}/kernel_log.txt cmd $REMOTE dmesg > ${tmpdir}/${results}/kernel_log.txt