All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] MAKEALL: Fix return value
@ 2009-12-06  7:09 Peter Tyser
  2009-12-06  7:45 ` Mike Frysinger
  2009-12-06 16:43 ` Wolfgang Denk
  0 siblings, 2 replies; 5+ messages in thread
From: Peter Tyser @ 2009-12-06  7:09 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
---
 MAKEALL |   29 +++++++++++------------------
 1 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/MAKEALL b/MAKEALL
index d63c5c2..1227abd 100755
--- a/MAKEALL
+++ b/MAKEALL
@@ -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))
 }
 
 #-----------------------------------------------------------------------
-- 
1.6.2.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH] MAKEALL: Fix return value
  2009-12-06  7:09 [U-Boot] [PATCH] MAKEALL: Fix return value Peter Tyser
@ 2009-12-06  7:45 ` Mike Frysinger
  2009-12-06  8:44   ` Peter Tyser
  2009-12-06 16:43 ` Wolfgang Denk
  1 sibling, 1 reply; 5+ messages in thread
From: Mike Frysinger @ 2009-12-06  7:45 UTC (permalink / raw)
  To: u-boot

On Sunday 06 December 2009 02:09:34 Peter Tyser wrote:
>  	${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}

> +	# Keep a running total of all 'make' return values
> +	RC=$((RC + ${PIPESTATUS[0]}))

this might be more natural:
	: $(( RC += ${PIPESTATUS[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 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH] MAKEALL: Fix return value
  2009-12-06  7:45 ` Mike Frysinger
@ 2009-12-06  8:44   ` Peter Tyser
  2009-12-06 23:20     ` Mike Frysinger
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Tyser @ 2009-12-06  8:44 UTC (permalink / raw)
  To: u-boot

Thanks for looking the change over Mike.

On Sun, 2009-12-06 at 02:45 -0500, Mike Frysinger wrote:
> On Sunday 06 December 2009 02:09:34 Peter Tyser wrote:
> >  	${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}

Ahh, clever.  It doesn't really matter which way to me.  PIPESTATUS
seems more straightforward, but maintaining POSIX compliance would be
nice too.

> > +	# Keep a running total of all 'make' return values
> > +	RC=$((RC + ${PIPESTATUS[0]}))
> 
> this might be more natural:
> 	: $(( RC += ${PIPESTATUS[0]} ))

K.

> > +	# 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH] MAKEALL: Fix return value
  2009-12-06  7:09 [U-Boot] [PATCH] MAKEALL: Fix return value Peter Tyser
  2009-12-06  7:45 ` Mike Frysinger
@ 2009-12-06 16:43 ` Wolfgang Denk
  1 sibling, 0 replies; 5+ messages in thread
From: Wolfgang Denk @ 2009-12-06 16:43 UTC (permalink / raw)
  To: u-boot

Dear Peter Tyser,

In message <1260083374-11002-1-git-send-email-ptyser@xes-inc.com> 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

-- 
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH] MAKEALL: Fix return value
  2009-12-06  8:44   ` Peter Tyser
@ 2009-12-06 23:20     ` Mike Frysinger
  0 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2009-12-06 23:20 UTC (permalink / raw)
  To: u-boot

On Sunday 06 December 2009 03:44:06 Peter Tyser wrote:
> On Sun, 2009-12-06 at 02:45 -0500, Mike Frysinger wrote:
> > On Sunday 06 December 2009 02:09:34 Peter Tyser wrote:
> > >  	${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}
> 
> 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

> > > +	# 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.

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 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-12-06 23:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-06  7:09 [U-Boot] [PATCH] MAKEALL: Fix return value Peter Tyser
2009-12-06  7:45 ` Mike Frysinger
2009-12-06  8:44   ` Peter Tyser
2009-12-06 23:20     ` Mike Frysinger
2009-12-06 16:43 ` Wolfgang Denk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.