Skip to contentSkip to conversation

utils/test-pkg: set the return code for fail

PATCH New heiko.thiery at gmail.com 2 participants 3 messages Oct 10, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 utils/test-pkg: set the return code for fail

From: Heiko Thiery <[email protected]>

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

---
 utils/test-pkg | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
utils/test-pkg +8 -1
index f3b34d5d0d..5e440b12f6 100755
@@ -138,6 +138,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() {
@@ -264,4 +268,7 @@ _EOF_
 }
 
 my_name="${0##*/}"
-main "${@}"
+main "${@}" && ret=0 || ret=${?}
+if [ ${ret} -ne 0 ]; then
+    exit 1
+fi
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 utils/test-pkg: set the return code for fail

Quoted 33 lines

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

---
 utils/test-pkg | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
utils/test-pkg +8 -2
index f3b34d5d0d..5e440b12f6 100755
@@ -138,6 +138,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() {
@@ -264,4 +268,7 @@ _EOF_
 }
 
 my_name="${0##*/}"
-main "${@}"
+main "${@}" && ret=0 || ret=${?}
+if [ ${ret} -ne 0 ]; then
+    exit 1
+fi
--
Quoted 2 lines

2.20.1

forgot the v2 prefix

#2 lore raw

PATCH 1/1 utils/test-pkg: set the return code for fail

In reply to heiko.thiery at gmail.com

Heiko, All,

On 2019-10-10 10:51 +0200, heiko.thiery at gmail.com spake thusly:

Quoted 4 lines

From: Heiko Thiery <[email protected]>

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

This commit log should be updated now that the option has been removed.

Quoted 10 lines
---
 utils/test-pkg | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
utils/test-pkg +0 -0
index f3b34d5d0d..5e440b12f6 100755

utils/test-pkg main() { · line 144

Quoted 7 lines
utils/test-pkg +4 -0
@@ -138,6 +138,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

It might be simpler to just return the number of failures:

    return $((nb_fail+nb_legal))

utils/test-pkg _EOF_ · line 274

Quoted 12 lines
utils/test-pkg +4 -1
 }
 
 build_one() {
@@ -264,4 +268,7 @@ _EOF_
 }
 
 my_name="${0##*/}"
-main "${@}"
+main "${@}" && ret=0 || ret=${?}
+if [ ${ret} -ne 0 ]; then
+    exit 1
+fi

No need for this gymnastics: the script will return with the same return code as the last command in the script, which in this case happen to be the return code of main(), which will be 1 in case of error. So, you really only need to change the return code of main().

Regards,
Yann E. MORIN.

Quoted 7 lines
Signature · 6 lines
2.20.1

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 21 lines
                                        ____________
.-----------------.--------------------:       _    :------------------.
|  Yann E. MORIN  | Real-Time Embedded |    __/ )   | /"\ ASCII RIBBON |
| +33 534.541.179 | Software  Designer |  _/ - /'   | \ / CAMPAIGN     |
| +33 638.411.245 '--------------------: (_    `--, |  X  AGAINST      |
|      yann.morin (at) orange.com      |_="    ,--' | / \ HTML MAIL    |
'--------------------------------------:______/_____:------------------'


_________________________________________________________________________________________________________________________

Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.

This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.