Skip to contentSkip to conversation

utils/test-pkg: fix long option parsing

PATCH New Thomas De Schampheleire 4 participants 7 messages Feb 5, 2019 – Jun 25, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 utils/test-pkg: fix long option parsing

From: Thomas De Schampheleire <[email protected]>

The long option parsing of test-pkg is broken because:
- some long options are not declared
- there should be a comma between long options, the colon does not replace it.

This change also revealed that the declaration of 'toolchains-dir' should have been 'toolchains-csv', originally introduced in commit ed59f81a3cb4ddb.

---
 utils/test-pkg | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

v3: unchanged
v2: new patch

utils/test-pkg +2 -2
index 1995fa8578..087f9ddca9 100755
@@ -5,12 +5,12 @@ TOOLCHAINS_CSV='support/config-fragments/autobuild/toolchain-configs.csv'
 
 main() {
     local o O opts
-    local cfg dir pkg random toolchains_dir toolchain all number mode
+    local cfg dir pkg random toolchains_csv toolchain all number mode
     local ret nb nb_skip nb_fail nb_legal nb_tc build_dir
     local -a toolchains
 
     o='hac:d:n:p:r:t:'
-    O='help,config-snippet:build-dir:package:,random:,toolchains-dir:'
+    O='help,all,config-snippet:,build-dir:,number:,package:,random:,toolchains-csv:'
     opts="$(getopt -n "${my_name}" -o "${o}" -l "${O}" -- "${@}")"
     eval set -- "${opts}"
 
Signature · 1 line
2.19.2
#1 lore raw

PATCH v3 2/2 utils/test-pkg: clean output dir for successful builds

From: Thomas De Schampheleire <[email protected]>

test-pkg will use gigabytes of space when testing all toolchains. Nevertheless, you are normally only interested in the actual build / host tree when there is a build failure.

Do a 'make clean' for successful builds to save disk space, unless the new option '-k/--keep' is set.
Note that the logfile and configuration is always retained for inspection.

---
 utils/test-pkg | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

v3: add missing help entry for --keep
v2: make the feature optional via '--keep' (feedback Arnout and Peter)

utils/test-pkg +18 -3
index 087f9ddca9..c2aec0784d 100755
@@ -6,16 +6,17 @@ TOOLCHAINS_CSV='support/config-fragments/autobuild/toolchain-configs.csv'
 main() {
     local o O opts
     local cfg dir pkg random toolchains_csv toolchain all number mode
-    local ret nb nb_skip nb_fail nb_legal nb_tc build_dir
+    local ret nb nb_skip nb_fail nb_legal nb_tc build_dir keep
     local -a toolchains
 
-    o='hac:d:n:p:r:t:'
-    O='help,all,config-snippet:,build-dir:,number:,package:,random:,toolchains-csv:'
+    o='hakc:d:n:p:r:t:'
+    O='help,all,keep,config-snippet:,build-dir:,number:,package:,random:,toolchains-csv:'
     opts="$(getopt -n "${my_name}" -o "${o}" -l "${O}" -- "${@}")"
     eval set -- "${opts}"
 
     random=0
     all=0
+    keep=0
     number=0
     mode=0
     toolchains_csv="${TOOLCHAINS_CSV}"
@@ -27,6 +28,9 @@ main() {
         (-a|--all)
             all=1; shift 1
             ;;
+        (-k|--keep)
+            keep=1; shift 1
+            ;;
         (-c|--config-snippet)
             cfg="${2}"; shift 2
             ;;
@@ -161,6 +165,12 @@ build_one() {
     if ! make O="${dir}" legal-info >> "${dir}/logfile" 2>&1; then
         return 3
     fi
+
+    # If we get here, the build was successful. Clean up the build/host
+    # directories to save disk space, unless 'keep' was set.
+    if [ ${keep} -ne 1 ]; then
+        make O="${dir}" clean >> "${dir}/logfile" 2>&1
+    fi
 }
 
 help() {
@@ -221,6 +231,11 @@ Options:
         try. If not specified, the toolchains in ${TOOLCHAINS_CSV} will be
         used.
 
+    -k, --keep
+        Keep the build directories even if the build succeeds.
+        Note: the logfile and configuration is always retained, even without
+        this option.
+
 Example:
 
     Testing libcec would require a config snippet that contains:
Signature · 1 line
2.19.2
#2 lore raw

PATCH v3 2/2 utils/test-pkg: clean output dir for successful builds

Thomas, All,

On 2019-02-05 22:21 +0100, Thomas De Schampheleire spake thusly:

Quoted 11 lines

From: Thomas De Schampheleire <[email protected]>

test-pkg will use gigabytes of space when testing all toolchains. Nevertheless, you are normally only interested in the actual build / host tree when there is a build failure.

Do a 'make clean' for successful builds to save disk space, unless the new option '-k/--keep' is set.
Note that the logfile and configuration is always retained for inspection.

Regards,
Yann E. MORIN.

Quoted 74 lines
---
 utils/test-pkg | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

v3: add missing help entry for --keep
v2: make the feature optional via '--keep' (feedback Arnout and Peter)

utils/test-pkg +18 -3
index 087f9ddca9..c2aec0784d 100755
@@ -6,16 +6,17 @@ TOOLCHAINS_CSV='support/config-fragments/autobuild/toolchain-configs.csv'
 main() {
     local o O opts
     local cfg dir pkg random toolchains_csv toolchain all number mode
-    local ret nb nb_skip nb_fail nb_legal nb_tc build_dir
+    local ret nb nb_skip nb_fail nb_legal nb_tc build_dir keep
     local -a toolchains
 
-    o='hac:d:n:p:r:t:'
-    O='help,all,config-snippet:,build-dir:,number:,package:,random:,toolchains-csv:'
+    o='hakc:d:n:p:r:t:'
+    O='help,all,keep,config-snippet:,build-dir:,number:,package:,random:,toolchains-csv:'
     opts="$(getopt -n "${my_name}" -o "${o}" -l "${O}" -- "${@}")"
     eval set -- "${opts}"
 
     random=0
     all=0
+    keep=0
     number=0
     mode=0
     toolchains_csv="${TOOLCHAINS_CSV}"
@@ -27,6 +28,9 @@ main() {
         (-a|--all)
             all=1; shift 1
             ;;
+        (-k|--keep)
+            keep=1; shift 1
+            ;;
         (-c|--config-snippet)
             cfg="${2}"; shift 2
             ;;
@@ -161,6 +165,12 @@ build_one() {
     if ! make O="${dir}" legal-info >> "${dir}/logfile" 2>&1; then
         return 3
     fi
+
+    # If we get here, the build was successful. Clean up the build/host
+    # directories to save disk space, unless 'keep' was set.
+    if [ ${keep} -ne 1 ]; then
+        make O="${dir}" clean >> "${dir}/logfile" 2>&1
+    fi
 }
 
 help() {
@@ -221,6 +231,11 @@ Options:
         try. If not specified, the toolchains in ${TOOLCHAINS_CSV} will be
         used.
 
+    -k, --keep
+        Keep the build directories even if the build succeeds.
+        Note: the logfile and configuration is always retained, even without
+        this option.
+
 Example:
 
     Testing libcec would require a config snippet that contains:
Signature · 6 lines
2.19.2

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH v3 2/2 utils/test-pkg: clean output dir for successful builds

Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Thomas, All,
On 2019-02-05 22:21 +0100, Thomas De Schampheleire spake thusly:

Quoted 6 lines

From: Thomas De Schampheleire <[email protected]>

test-pkg will use gigabytes of space when testing all toolchains. Nevertheless, you are normally only interested in the actual build / host tree when there is a build failure.

Quoted 7 lines
Quoted 5 lines

Do a 'make clean' for successful builds to save disk space, unless the new option '-k/--keep' is set.
Note that the logfile and configuration is always retained for inspection.

While not strictly a bugfix, the risk seems quite low and it is nicer to keep the tooling the same in the supported branches, so:

Committed to 2019.02.x and 2019.05.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#4 lore raw

PATCH v3 1/2 utils/test-pkg: fix long option parsing

In reply to Thomas De Schampheleire

Thomas, All,

On 2019-02-05 22:21 +0100, Thomas De Schampheleire spake thusly:

Quoted 11 lines

From: Thomas De Schampheleire <[email protected]>

The long option parsing of test-pkg is broken because:
- some long options are not declared
- there should be a comma between long options, the colon does not replace it.

This change also revealed that the declaration of 'toolchains-dir' should have been 'toolchains-csv', originally introduced in commit ed59f81a3cb4ddb.

Regards,
Yann E. MORIN.

Quoted 33 lines
---
 utils/test-pkg | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

v3: unchanged
v2: new patch

utils/test-pkg +2 -2
index 1995fa8578..087f9ddca9 100755
@@ -5,12 +5,12 @@ TOOLCHAINS_CSV='support/config-fragments/autobuild/toolchain-configs.csv'
 
 main() {
     local o O opts
-    local cfg dir pkg random toolchains_dir toolchain all number mode
+    local cfg dir pkg random toolchains_csv toolchain all number mode
     local ret nb nb_skip nb_fail nb_legal nb_tc build_dir
     local -a toolchains
 
     o='hac:d:n:p:r:t:'
-    O='help,config-snippet:build-dir:package:,random:,toolchains-dir:'
+    O='help,all,config-snippet:,build-dir:,number:,package:,random:,toolchains-csv:'
     opts="$(getopt -n "${my_name}" -o "${o}" -l "${O}" -- "${@}")"
     eval set -- "${opts}"
 
Signature · 6 lines
2.19.2

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#5 lore raw

PATCH v3 1/2 utils/test-pkg: fix long option parsing

Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Thomas, All,
On 2019-02-05 22:21 +0100, Thomas De Schampheleire spake thusly:

Quoted 7 lines

From: Thomas De Schampheleire <[email protected]>

The long option parsing of test-pkg is broken because:
- some long options are not declared
- there should be a comma between long options, the colon does not replace it.

Quoted 6 lines
Quoted 4 lines

This change also revealed that the declaration of 'toolchains-dir' should have been 'toolchains-csv', originally introduced in commit ed59f81a3cb4ddb.

Committed to 2019.02.x and 2019.05.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#6 lore raw

PATCH v3 1/2 utils/test-pkg: fix long option parsing

In reply to Thomas De Schampheleire
Quoted 7 lines · On Tue, 5 Feb 2019 22:21:41 +0100 Thomas De Schampheleire…

From: Thomas De Schampheleire <[email protected]>

The long option parsing of test-pkg is broken because:
- some long options are not declared
- there should be a comma between long options, the colon does not replace it.

Quoted 7 lines

This change also revealed that the declaration of 'toolchains-dir' should have been 'toolchains-csv', originally introduced in commit ed59f81a3cb4ddb.

---
 utils/test-pkg | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Both patches applied. Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com