All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] utils/test-pkg: set the return code for fail
@ 2019-10-10  6:39 heiko.thiery at gmail.com
  2019-10-10  7:39 ` Thomas Petazzoni
  0 siblings, 1 reply; 3+ messages in thread
From: heiko.thiery at gmail.com @ 2019-10-10  6:39 UTC (permalink / raw)
  To: buildroot

From: Heiko Thiery <heiko.thiery@kontron.com>

Add an option (-e) to exit the script with an error if a build
or the legal-info check fails.

Signed-off-by: Heiko Thiery <heiko.thiery@kontron.com>
---
 utils/test-pkg | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/utils/test-pkg b/utils/test-pkg
index f3b34d5d0d..e54c9f0cd8 100755
--- a/utils/test-pkg
+++ b/utils/test-pkg
@@ -17,8 +17,8 @@ main() {
     local -a toolchains
     local pkg_br_name
 
-    o='hakc:d:n:p:r:t:'
-    O='help,all,keep,config-snippet:,build-dir:,number:,package:,random:,toolchains-csv:'
+    o='hakec:d:n:p:r:t:'
+    O='help,all,keep,error,config-snippet:,build-dir:,number:,package:,random:,toolchains-csv:'
     opts="$(getopt -n "${my_name}" -o "${o}" -l "${O}" -- "${@}")"
     eval set -- "${opts}"
 
@@ -28,6 +28,7 @@ main() {
     number=0
     mode=0
     toolchains_csv="${TOOLCHAINS_CSV}"
+    exitcode=0
     while [ ${#} -gt 0 ]; do
         case "${1}" in
         (-h|--help)
@@ -57,6 +58,9 @@ main() {
         (-t|--toolchains-csv)
             toolchains_csv="${2}"; shift 2
             ;;
+        (-e|--error)
+            exitcode=1;shift 1
+            ;;
         (--)
             shift; break
             ;;
@@ -138,6 +142,10 @@ main() {
 
     printf "%d builds, %d skipped, %d build failed, %d legal-info failed\n" \
         ${nb} ${nb_skip} ${nb_fail} ${nb_legal}
+
+    if [ ${nb_fail} -ne 0 -o ${nb_legal} -ne 0 ]; then
+        return 1
+    fi
 }
 
 build_one() {
@@ -251,6 +259,9 @@ Options:
         Note: the logfile and configuration is always retained, even without
         this option.
 
+    -e, --error
+        Set return code in case of build fail or legal-info error.
+
 Example:
 
     Testing libcec would require a config snippet that contains:
@@ -264,4 +275,7 @@ _EOF_
 }
 
 my_name="${0##*/}"
-main "${@}"
+main "${@}" && ret=0 || ret=${?}
+if [ ${exitcode} -ne 0 -a ${ret} -ne 0 ]; then
+    exit 1
+fi
-- 
2.20.1

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

* [Buildroot] [PATCH] utils/test-pkg: set the return code for fail
  2019-10-10  6:39 [Buildroot] [PATCH] utils/test-pkg: set the return code for fail heiko.thiery at gmail.com
@ 2019-10-10  7:39 ` Thomas Petazzoni
  2019-10-10  8:14   ` Heiko Thiery
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Petazzoni @ 2019-10-10  7:39 UTC (permalink / raw)
  To: buildroot

On Thu, 10 Oct 2019 08:39:33 +0200
heiko.thiery at gmail.com wrote:

> From: Heiko Thiery <heiko.thiery@kontron.com>
> 
> Add an option (-e) to exit the script with an error if a build
> or the legal-info check fails.
> 
> Signed-off-by: Heiko Thiery <heiko.thiery@kontron.com>

Why should this be optional? It seems like test-pkg should always
return a non-zero error code when the build or legal-info fails.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* [Buildroot] [PATCH] utils/test-pkg: set the return code for fail
  2019-10-10  7:39 ` Thomas Petazzoni
@ 2019-10-10  8:14   ` Heiko Thiery
  0 siblings, 0 replies; 3+ messages in thread
From: Heiko Thiery @ 2019-10-10  8:14 UTC (permalink / raw)
  To: buildroot

> Why should this be optional? It seems like test-pkg should always
> return a non-zero error code when the build or legal-info fails.

Just did not want to change the default behaviour. But if it is ok to
change the default I can remove the option.

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

end of thread, other threads:[~2019-10-10  8:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-10  6:39 [Buildroot] [PATCH] utils/test-pkg: set the return code for fail heiko.thiery at gmail.com
2019-10-10  7:39 ` Thomas Petazzoni
2019-10-10  8:14   ` Heiko Thiery

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.