MAKEALL: Fix return value
PATCH 1/1 MAKEALL: Fix return value
Previously MAKEALL would always return a value of 0, even if 1 or more boards did not compile.
This change causes MAKEALL to return the number of board's which did not compile. 0 indicates success, 2 indicates 2 board did not compile, etc. Boards with compile warnings do not affect the return value, only boards which failed to compile.
Note that this change also requires changing the script interpreter from sh to bash to support bash's PIPESTATUS variable.
--- MAKEALL | 29 +++++++++++------------------ 1 files changed, 11 insertions(+), 18 deletions(-)
MAKEALL +10 -1
@@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Print statistics when we exit trap exit 1 2 3 15
@@ -39,6 +39,7 @@ LIST="" ERR_CNT=0 ERR_LIST="" TOTAL_CNT=0 +RC=0 ######################################################################### ## MPC5xx Systems
@@ -936,6 +921,10 @@ build_target() { ${MAKE} ${JOBS} all 2>&1 >${LOG_DIR}/$target.MAKELOG \ | tee ${LOG_DIR}/$target.ERR + + # Keep a running total of all 'make' return values + RC=$((RC + ${PIPESTATUS[0]})) + if [ -s ${LOG_DIR}/$target.ERR ] ; then ERR_CNT=$((ERR_CNT + 1)) ERR_LIST="${ERR_LIST} $target"
@@ -959,6 +948,10 @@ print_stats() { echo "Boards with warnings or errors: ${ERR_CNT} (${ERR_LIST} )" fi echo "----------------------------------------------------------" + + # Return how many board compiles failed, assuming 'make' returns 2 + # for builds which failed + exit $(((RC + 1) / 2)) } #-----------------------------------------------------------------------
Signature · 1 line
1.6.2.1
PATCH 1/1 MAKEALL: Fix return value
MAKEALL build_target() { · line 923
Quoted 2 lines · On Sunday 06 December 2009 02:09:34 Peter Tyser wrote:
MAKEALL +0
-0${MAKE} ${JOBS} all 2>&1 >${LOG_DIR}/$target.MAKELOG \ | tee ${LOG_DIR}/$target.ERR
you could rewrite this to keep POSIX compliance:
# need to maintain exit value ourselves as pipes eat it
fail=${LOG_DIR}/$target.failed
rm -f ${fail}
(${MAKE} ${JOBS} all 2>&1 >${LOG_DIR}/$target.MAKELOG \
|| touch ${fail}) | tee ${LOG_DIR}/$target.ERR
[ -e ${fail} ] && : $(( RC += 1 ))
rm -f ${fail}MAKEALL build_target() { · line 926
Quoted 2 lines
MAKEALL +2
-0+ # Keep a running total of all 'make' return values + RC=$((RC + ${PIPESTATUS[0]}))
this might be more natural:
: $(( RC += ${PIPESTATUS[0]} ))MAKEALL print_stats() { · line 954
Quoted 3 lines
MAKEALL +3
-0+ # Return how many board compiles failed, assuming 'make' returns 2 + # for builds which failed + exit $(((RC + 1) / 2))
the problem here is that exit statuses have a range of 256 values. so as soon as more than 255 boards fail, this wont work. maybe i'm being overly paranoid though ?
$ (exit 256); echo $? 0 -mike -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: This is a digitally signed message part. Url : http://lists.denx.de/pipermail/u-boot/attachments/20091206/42d33a07/attachment.pgp
PATCH 1/1 MAKEALL: Fix return value
Thanks for looking the change over Mike.
Quoted 4 lines · Mike Frysinger
MAKEALL build_target() { · line 923
Quoted 2 lines · On Sunday 06 December 2009 02:09:34 Peter Tyser wrote:
MAKEALL +0
-0${MAKE} ${JOBS} all 2>&1 >${LOG_DIR}/$target.MAKELOG \ | tee ${LOG_DIR}/$target.ERR
Quoted 8 lines
you could rewrite this to keep POSIX compliance:
# need to maintain exit value ourselves as pipes eat it fail=${LOG_DIR}/$target.failed rm -f ${fail} (${MAKE} ${JOBS} all 2>&1 >${LOG_DIR}/$target.MAKELOG \ || touch ${fail}) | tee ${LOG_DIR}/$target.ERR [ -e ${fail} ] && : $(( RC += 1 )) rm -f ${fail}
Ahh, clever. It doesn't really matter which way to me. PIPESTATUS seems more straightforward, but maintaining POSIX compliance would be nice too.
Quoted 5 lines
MAKEALL build_target() { · line 926
Quoted 2 lines
MAKEALL +2
-0+ # Keep a running total of all 'make' return values + RC=$((RC + ${PIPESTATUS[0]}))this might be more natural:
: $(( RC += ${PIPESTATUS[0]} ))
K.
Quoted 7 lines
MAKEALL print_stats() { · line 954
Quoted 3 lines
MAKEALL +3
-0+ # Return how many board compiles failed, assuming 'make' returns 2 + # for builds which failed + exit $(((RC + 1) / 2))the problem here is that exit statuses have a range of 256 values. so as soon as more than 255 boards fail, this wont work. maybe i'm being overly paranoid though ?
Good point. I can change RC into a bitwise OR of the 'make' return values instead of a sum. I think 98% of the time people just want to know if any board compile failed, not specifically how many boards failed.
Peter
PATCH 1/1 MAKEALL: Fix return value
Quoted 12 lines · On Sunday 06 December 2009 03:44:06 Peter Tyser wrote:
Quoted 11 lines · Mike Frysinger
MAKEALL build_target() { · line 923
Quoted 3 lines · On Sunday 06 December 2009 02:09:34 Peter Tyser wrote:
MAKEALL +0
-0${MAKE} ${JOBS} all 2>&1 >${LOG_DIR}/$target.MAKELOG \ | tee ${LOG_DIR}/$target.ERRyou could rewrite this to keep POSIX compliance:
# need to maintain exit value ourselves as pipes eat it fail=${LOG_DIR}/$target.failed rm -f ${fail} (${MAKE} ${JOBS} all 2>&1 >${LOG_DIR}/$target.MAKELOG \
Quoted 8 lines
Quoted 4 lines
|| touch ${fail}) | tee ${LOG_DIR}/$target.ERR [ -e ${fail} ] && : $(( RC += 1 )) rm -f ${fail}Ahh, clever. It doesn't really matter which way to me. PIPESTATUS seems more straightforward, but maintaining POSIX compliance would be nice too.
i agree with both points
Quoted 8 lines
Quoted 7 lines
MAKEALL print_stats() { · line 954
Quoted 3 lines
MAKEALL +3
-0+ # Return how many board compiles failed, assuming 'make' returns 2 + # for builds which failed + exit $(((RC + 1) / 2))the problem here is that exit statuses have a range of 256 values. so as soon as more than 255 boards fail, this wont work. maybe i'm being overly paranoid though ?
Quoted 4 lines
Good point. I can change RC into a bitwise OR of the 'make' return values instead of a sum. I think 98% of the time people just want to know if any board compile failed, not specifically how many boards failed.
right, so maybe something like:
: $(( RC = (RC + 1) / 2 )) # exit values top out at 255 exit $(( RC > 255 ? 255 : RC ))
not that ive ever looked at the exit status as anything meaningful ... i always review the ERR files to make sure they're all 0 bytes.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20091206/fd0076f7/attachment.pgp
PATCH 1/1 MAKEALL: Fix return value
In reply to Peter TyserDear Peter Tyser,
Quoted 5 lines · In message <[email protected]> you wrote:
Previously MAKEALL would always return a value of 0, even if 1 or more boards did not compile.
This change causes MAKEALL to return the number of board's which did not compile. 0 indicates success, 2 indicates 2 board did not compile, etc.
NAK. This is non-standard behaviour. Commands usually return 0 for OK or 1 in case of errors. Any higher numbers (especially when exceeding the magical limit of 127) may cause confusion to callers.
And as Mike pointed out, above 255 it simply breaks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Alles Gescheite ist schon gedacht worden, man mu? nur versuchen, es noch einmal zu denken. -- Goethe, Maximen und Reflexionen