Skip to contentSkip to conversation

utils/test-pkg: Generate package config if it is not specified

PATCH New Vadim Kochan 4 participants 4 messages Mar 1, 2019 – Mar 27, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 utils/test-pkg: Generate package config if it is not specified

From: Vadim Kochan <[email protected]>

It is possible to generate one-line config for the package just by normalize it to the form:

    BR2_PACKAGE_${pkg_replaced-to_and_uppercase}

it simplifes a bit of testing package where no additional config options are needed.

---
 utils/test-pkg | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
utils/test-pkg +16 -1
index 1995fa8..cce4679 100755
@@ -2,12 +2,20 @@
 set -e
 
 TOOLCHAINS_CSV='support/config-fragments/autobuild/toolchain-configs.csv'
+TEMP_CONF=""
+
+do_clean() {
+    if [ ! -z "${TEMP_CONF}" ]; then
+        rm -f "${TEMP_CONF}"
+    fi
+}
 
 main() {
     local o O opts
     local cfg dir pkg random toolchains_dir toolchain all number mode
     local ret nb nb_skip nb_fail nb_legal nb_tc build_dir
     local -a toolchains
+    local pkg_br_name
 
     o='hac:d:n:p:r:t:'
     O='help,config-snippet:build-dir:package:,random:,toolchains-dir:'
@@ -50,8 +58,15 @@ main() {
             ;;
         esac
     done
+
+    trap do_clean INT TERM HUP EXIT
+
     if [ -z "${cfg}" ]; then
-        printf "error: no config snippet specified\n" >&2; exit 1
+        pkg_br_name="${pkg//-/_}"
+        pkg_br_name="BR2_PACKAGE_${pkg_br_name^^}"
+        TEMP_CONF=$(mktemp /tmp/test-${pkg}-config.XXXXXX)
+        echo "${pkg_br_name}=y" > ${TEMP_CONF}
+        cfg="${TEMP_CONF}"
     fi
     if [ ! -e "${cfg}" ]; then
         printf "error: %s: no such file\n" "${cfg}" >&2; exit 1
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 utils/test-pkg: Generate package config if it is not specified

Quoted 11 lines · Vadim Kochan

From: Vadim Kochan <[email protected]>

It is possible to generate one-line config for the package just by normalize it to the form:

    BR2_PACKAGE_${pkg_replaced-to_and_uppercase}

it simplifes a bit of testing package where no additional config options are needed.

Quoted 9 lines
---
 utils/test-pkg | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
utils/test-pkg +0 -0
index 1995fa8..cce4679 100755

utils/test-pkg line 9

Quoted 8 lines
utils/test-pkg +5 -0
@@ -2,12 +2,20 @@
 set -e
 
 TOOLCHAINS_CSV='support/config-fragments/autobuild/toolchain-configs.csv'
+TEMP_CONF=""
+
+do_clean() {
+    if [ ! -z "${TEMP_CONF}" ]; then
+        rm -f "${TEMP_CONF}"

A race-free way of cleaning up! Excellent!

Quoted 13 lines
utils/test-pkg +3 -0
+    fi
+}
 
 main() {
     local o O opts
     local cfg dir pkg random toolchains_dir toolchain all number mode
     local ret nb nb_skip nb_fail nb_legal nb_tc build_dir
     local -a toolchains
+    local pkg_br_name
 
     o='hac:d:n:p:r:t:'
     O='help,config-snippet:build-dir:package:,random:,toolchains-dir:'

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

Quoted 9 lines
utils/test-pkg +4 -1
@@ -50,8 +58,15 @@ main() {
             ;;
         esac
     done
+
+    trap do_clean INT TERM HUP EXIT
+
     if [ -z "${cfg}" ]; then
-        printf "error: no config snippet specified\n" >&2; exit 1
+        pkg_br_name="${pkg//-/_}"

The script is already using bash, so this is OK.

However, the UPPERCASE macro also converts . to _. Still, since we don't have
any package with . in it, it should be fine.

Regards,
Arnout

Quoted 8 lines
utils/test-pkg +4 -0
+        pkg_br_name="BR2_PACKAGE_${pkg_br_name^^}"
+        TEMP_CONF=$(mktemp /tmp/test-${pkg}-config.XXXXXX)
+        echo "${pkg_br_name}=y" > ${TEMP_CONF}
+        cfg="${TEMP_CONF}"
     fi
     if [ ! -e "${cfg}" ]; then
         printf "error: %s: no such file\n" "${cfg}" >&2; exit 1
#2 lore raw

PATCH 1/1 utils/test-pkg: Generate package config if it is not specified

In reply to Vadim Kochan

Hello Vadim,

Quoted 7 lines · On Fri, 1 Mar 2019 14:33:42 +0200 Vadim Kochan <[email protected]> wrote:

From: Vadim Kochan <[email protected]>

It is possible to generate one-line config for the package just by normalize it to the form:

    BR2_PACKAGE_${pkg_replaced-to_and_uppercase}
Quoted 7 lines

it simplifes a bit of testing package where no additional config options are needed.

---
 utils/test-pkg | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

Applied to master, thanks. I was initially a bit skeptical because if the package has a dependency, your solution does not work very well, and users could believe that the package is going to be tested while it won't. But in fact in that case all tests are going to be "SKIPPED" because the BR2_PACKAGE_FOO=y line is not in the final .config. This will clearly tell the user that much not testing has happened. So I'm fine with this, and therefore I applied.

Thanks!

Thomas

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

PATCH 1/1 utils/test-pkg: Generate package config if it is not specified

Quoted 21 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Hello Vadim,

Quoted 7 lines · On Fri, 1 Mar 2019 14:33:42 +0200 Vadim Kochan <[email protected]> wrote:

From: Vadim Kochan <[email protected]>

It is possible to generate one-line config for the package just by normalize it to the form:

BR2_PACKAGE_${pkg_replaced-to_and_uppercase}

Quoted 7 lines

it simplifes a bit of testing package where no additional config options are needed.

---
utils/test-pkg | 17 ++++++++++++++++-

1 file changed, 16 insertions(+), 1 deletion(-)
Quoted 7 lines

Applied to master, thanks. I was initially a bit skeptical because if the package has a dependency, your solution does not work very well, and users could believe that the package is going to be tested while it won't. But in fact in that case all tests are going to be "SKIPPED" because the BR2_PACKAGE_FOO=y line is not in the final .config. This will clearly tell the user that much not testing has happened. So I'm fine with this, and therefore I applied.

While this isn't a bugfix, it seems quite safe and can be useful for users - So I've committed it to 2019.02.x as well, thanks.

Signature · 1 line
Bye, Peter Korsgaard