Skip to contentSkip to conversation

support/scripts: add script to test a package

PATCH New Yann E. MORIN 6 participants 10 messages Feb 6, 2017 – Feb 7, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 support/scripts: add script to test a package

This script helps in testing that a pacakge builds fine on a wide range of architectures and toolchains: BE/LE, 32/64-bit, musl/glibc/uclibc...

[yann.morin.1998 at free.fr:
- completely rewrite the script from Thomas, with help from Luca
]

---
 support/scripts/test-pkg | 158 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 158 insertions(+)
 create mode 100755 support/scripts/test-pkg
support/scripts/test-pkg new file +158 -0
new file mode 100755
index 0000000..40b373e
@@ -0,0 +1,158 @@
+#!/bin/bash
+set -e
+
+TOOLCHAINS_BASE_URL='http://autobuild.buildroot.org/toolchains/configs'
+
+main() {
+    local o O opts
+    local cfg dir pkg toolchain out
+    local -a toolchains
+
+    o='hc:d:p:'
+    O='help,config-snippet:build-dir:package:'
+    opts="$( getopt -n "${my_name}" -o "${o}" -l "${O}" -- "${@}"  )"
+    eval set -- "${opts}"
+
+    while [ ${#} -gt 0 ]; do
+        case "${1}" in
+        (-h|--help)
+            help; exit 0
+            ;;
+        (-c|--config-snippet)
+            cfg="${2}"; shift 2
+            ;;
+        (-d|--build-dir)
+            dir="${2}"; shift 2
+            ;;
+        (-p|--package)
+            pkg="${2}"; shift 2
+            ;;
+        (--)
+            shift; break
+            ;;
+        esac
+    done
+    if [ -z "${cfg}" ]; then
+        printf "error: no config snippet specified\n" 2>&1; exit 1
+    fi
+    if [ -z "${dir}" ]; then
+        dir="${HOME}/br-test-pkg"
+    fi
+
+    # Extract the toolchains names
+    toolchains=( $( curl -s "${TOOLCHAINS_BASE_URL}/toolchain-configs.csv" \
+                    |sed -r -e 's/,.*//; s:.*/(.*)\.config:\1:; /internal/d;'
+                  )
+               )
+
+    if [ ${#toolchains[@]} -eq 0 ]; then
+        printf "error: no toolchain found (networking issue?)\n" 2>&1; exit 1
+    fi
+
+    for toolchain in "${toolchains[@]}"; do
+        build_one "${dir}" "${toolchain}" "${cfg}" "${pkg}"
+    done
+}
+
+build_one() {
+    local dir="${1}"
+    local tc="${2}"
+    local cfg="${3}"
+    local pkg="${4}"
+    local line
+
+    printf "%40s: " "${tc}"
+
+    dir="${dir}/${tc}"
+    mkdir -p "${dir}"
+
+    printf "download config"
+    if ! curl -s "${TOOLCHAINS_BASE_URL}/${toolchain}.config" >"${dir}/.config"; then
+        printf ": FAILED\n"
+        return
+    fi
+
+    cat >>"${dir}/.config" <<-_EOF_
+	BR2_INIT_NONE=y
+	BR2_SYSTEM_BIN_SH_NONE=y
+	# BR2_PACKAGE_BUSYBOX is not set
+	# BR2_TARGET_ROOTFS_TAR is not set
+	_EOF_
+    cat "${cfg}" >>"${dir}/.config"
+
+    printf ", olddefconfig"
+    if ! make O="${dir}" olddefconfig >/dev/null 2>&1; then
+        printf ": FAILED\n"
+        return
+    fi
+    while read line; do
+        if ! grep "^${line}\$" "${dir}/.config" >/dev/null 2>&1; then
+            printf ", SKIPPED\n"
+            return
+        fi
+    done <"${cfg}"
+
+    printf ", source"
+    if ! make O=${dir} source >> ${dir}/logfile 2>&1; then
+        printf ": FAILED\n"
+        return
+    fi
+
+    if [ -n "${pkg}" ]; then
+        printf ", dirclean"
+        if ! make O=${dir} "${pkg}-dirclean" >> ${dir}/logfile 2>&1; then
+            printf ": FAILED\n"
+            return
+        fi
+    fi
+
+    printf ", build"
+    if ! make O=${dir} ${pkg} >> ${dir}/logfile 2>&1; then
+        printf ": FAILED\n"
+        return
+    fi
+
+    printf ": OK\n"
+}
+
+help() {
+    cat <<_EOF_
+${my_name}: test that a package builds with various toolchains and archs
+
+${my_name} will test-build a package (as specified in a .config snippet)
+against various toolchains on different architectures.
+
+The list of toolchains is retrieved from Buidlroot autobuilders.
+
+In case failures are noticed, you have the opportunity to fix the issue
+and relaunch the test.
+
+Options
+
+    -h, --help
+        Print this help.
+
+    -c CFG, --config-snippet CFG
+        Use the CFG file as the source for the config snippet. This file
+        should contain all the config options required to build a package.
+
+    -d DIR, --build-dir DIR
+        Do the builds in directory DIR, one sub-dir per toolchain.
+
+    -p PKG, --package PKG
+        Test-build the package PKG.
+
+Example:
+
+    Testing libcec would require a config snippet that contains:
+        BR2_PACKAGE_LIBCEC=y
+
+    Testing libcurl with openSSL support would require a snippet such as:
+        BR2_PACKAGE_OPENSSL=y
+        BR2_PACKAGE_LIBCURL=y
+
+_EOF_
+}
+
+my_name="${0##*/}"
+main "${@}"
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 support/scripts: add script to test a package

Hi,

Quoted 9 lines · Yann E. MORIN

This script helps in testing that a pacakge builds fine on a wide range of architectures and toolchains: BE/LE, 32/64-bit, musl/glibc/uclibc...

[yann.morin.1998 at free.fr:
- completely rewrite the script from Thomas, with help from Luca
]

I like very much this script and it already works very well. I have several remarks below, but only one or two are really relevant. But I'd definitely prefer to see it on master ASAP (i.e. before 2017.02-rc1) and improve it later.

Quoted 6 lines
support/scripts/test-pkg new file +0 -0
new file mode 100755
index 0000000..40b373e
@@ -0,0 +1,158 @@

[...]

Quoted 1 line

+ # Extract the toolchains names

I think the correct wording is "toolchain names".

support/scripts/test-pkg line 46

Quoted 4 lines
support/scripts/test-pkg new file +4 -0
+    toolchains=( $( curl -s "${TOOLCHAINS_BASE_URL}/toolchain-configs.csv" \
+                    |sed -r -e 's/,.*//; s:.*/(.*)\.config:\1:; /internal/d;'
+                  )
+               )

Detecting internal toolchains from the filename alone seems a bit fragile. The check would be more robust if we at least fetched the toolchain config and grepped for "BR2_TOOLCHAIN_EXTERNAL=y" there. Of course it would make the script more complex, and I'm OK if this is done in a later step.

support/scripts/test-pkg line 66

Quoted 10 lines
support/scripts/test-pkg new file +10 -0
+build_one() {
+    local dir="${1}"
+    local tc="${2}"
+    local cfg="${3}"
+    local pkg="${4}"
+    local line
+
+    printf "%40s: " "${tc}"
+
+    dir="${dir}/${tc}"

Minor nit: why not simply doing in the preamble:

    local tc="${2}"
    local dir="${1}/${tc}"

support/scripts/test-pkg line 89

Quoted 7 lines
support/scripts/test-pkg new file +7 -0
+    printf ", olddefconfig"
+    if ! make O="${dir}" olddefconfig >/dev/null 2>&1; then
+        printf ": FAILED\n"
+        return
+    fi
+    while read line; do
+        if ! grep "^${line}\$" "${dir}/.config" >/dev/null 2>&1; then

I suggest removing the redirects and using 'grep -q' here.

support/scripts/test-pkg line 99

Quoted 5 lines
support/scripts/test-pkg new file +5 -0
+    printf ", source"
+    if ! make O=${dir} source >> ${dir}/logfile 2>&1; then
+        printf ": FAILED\n"
+        return
+    fi

Splitting the source step from the build step is nice since it clearly separated download-related issues (wrong URL, network down...) from build errors.

But as discussed IRL it also means we download the ACTUAL_SOURCE files, which means hundreds of megabytes with external toolchains. Possible solutions:

* remove the "make source" step and let "make ${pkg}" download only the sources that are really needed for building
* remove the "make source" step as above, but only if ${pkg} is empty
* add a "source-only-filed-needed-for-build" :) target and use that

support/scripts/test-pkg line 125

Quoted 8 lines
support/scripts/test-pkg new file +8 -0
+help() {
+    cat <<_EOF_
+${my_name}: test that a package builds with various toolchains and archs
+
+${my_name} will test-build a package (as specified in a .config snippet)
+against various toolchains on different architectures.
+
+The list of toolchains is retrieved from Buidlroot autobuilders.

Buidlroot -> Buildroot

Also why not appending "available at ${TOOLCHAINS_BASE_URL}"?

Quoted 7 lines
support/scripts/test-pkg new file +7 -0
+In case failures are noticed, you have the opportunity to fix the issue
+and relaunch the test.
+
+Options
+
+    -h, --help
+        Print this help.

support/scripts/test-pkg line 143

Quoted 10 lines
support/scripts/test-pkg new file +10 -0
+
+    -c CFG, --config-snippet CFG
+        Use the CFG file as the source for the config snippet. This file
+        should contain all the config options required to build a package.
+
+    -d DIR, --build-dir DIR
+        Do the builds in directory DIR, one sub-dir per toolchain.
+
+    -p PKG, --package PKG
+        Test-build the package PKG.

Add: 'if not specified, runs "make" without a target'

Signature · 1 line
Luca
#2 lore raw

PATCH 1/1 support/scripts: add script to test a package

Hello,

Quoted 4 lines · Luca Ceresoli

Splitting the source step from the build step is nice since it clearly separated download-related issues (wrong URL, network down...) from build errors.

Quoted 8 lines

But as discussed IRL it also means we download the ACTUAL_SOURCE files, which means hundreds of megabytes with external toolchains. Possible solutions:

* remove the "make source" step and let "make ${pkg}" download only the sources that are really needed for building
* remove the "make source" step as above, but only if ${pkg} is empty
* add a "source-only-filed-needed-for-build" :) target and use that

I don't really see the need for separating the build step from the source step in this script. Why not just do the build, and that's it?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#3 lore raw

PATCH 1/1 support/scripts: add script to test a package

Hi,

Quoted 12 lines · Thomas Petazzoni

Hello,

Quoted 8 lines · Luca Ceresoli

Splitting the source step from the build step is nice since it clearly separated download-related issues (wrong URL, network down...) from build errors.

But as discussed IRL it also means we download the ACTUAL_SOURCE files, which means hundreds of megabytes with external toolchains. Possible solutions:

Quoted 7 lines
Quoted 4 lines

* remove the "make source" step and let "make ${pkg}" download only the sources that are really needed for building
* remove the "make source" step as above, but only if ${pkg} is empty
* add a "source-only-filed-needed-for-build" :) target and use that

I don't really see the need for separating the build step from the source step in this script. Why not just do the build, and that's it?

For two reasons:

1. catch wrong URLs early, before building all dependencies
2. make URL errors stand out clearly, thus being more informative

I agree these are not crucial to the goal of the script. They are "nice to have", so I won't complain if we get rid of this step.

Signature · 1 line
Luca
#4 lore raw

PATCH 1/1 support/scripts: add script to test a package

In reply to Luca Ceresoli

Luca, All,

On 2017-02-06 21:40 +0100, Luca Ceresoli spake thusly:

Quoted 1 line · Yann E. MORIN

[--SNIP--]

Quoted 9 lines

support/scripts/test-pkg line 89

Quoted 7 lines
support/scripts/test-pkg new file +7 -0
+    printf ", olddefconfig"
+    if ! make O="${dir}" olddefconfig >/dev/null 2>&1; then
+        printf ": FAILED\n"
+        return
+    fi
+    while read line; do
+        if ! grep "^${line}\$" "${dir}/.config" >/dev/null 2>&1; then

I suggest removing the redirects and using 'grep -q' here.

grep -q is not POSIX. ;-)

Quoted 10 lines

support/scripts/test-pkg line 99

Quoted 5 lines
support/scripts/test-pkg new file +5 -0
+    printf ", source"
+    if ! make O=${dir} source >> ${dir}/logfile 2>&1; then
+        printf ": FAILED\n"
+        return
+    fi

Splitting the source step from the build step is nice since it clearly separated download-related issues (wrong URL, network down...) from build errors.

Quoted 8 lines

But as discussed IRL it also means we download the ACTUAL_SOURCE files, which means hundreds of megabytes with external toolchains. Possible solutions:

* remove the "make source" step and let "make ${pkg}" download only the sources that are really needed for building
* remove the "make source" step as above, but only if ${pkg} is empty
* add a "source-only-filed-needed-for-build" :) target and use that

I'll remove the separate source action, it makes it simpler.

Quoted 10 lines

support/scripts/test-pkg line 125

Quoted 8 lines
support/scripts/test-pkg new file +8 -0
+help() {
+    cat <<_EOF_
+${my_name}: test that a package builds with various toolchains and archs
+
+${my_name} will test-build a package (as specified in a .config snippet)
+against various toolchains on different architectures.
+
+The list of toolchains is retrieved from Buidlroot autobuilders.

Buidlroot -> Buildroot

Buidlroot sounds more like Beetlejuice. ;-)

Quoted 1 line

Also why not appending "available at ${TOOLCHAINS_BASE_URL}"?

Can do.

Quoted 4 lines

support/scripts/test-pkg line 143

Quoted 2 lines
support/scripts/test-pkg new file +2 -0
+    -p PKG, --package PKG
+        Test-build the package PKG.

Add: 'if not specified, runs "make" without a target'

Can do.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#5 lore raw

PATCH 1/1 support/scripts: add script to test a package

Hi Yann, Thomas,

Quoted 13 lines · Yann E. MORIN

Luca, All,

On 2017-02-06 21:40 +0100, Luca Ceresoli spake thusly:

Quoted 1 line · Yann E. MORIN

[--SNIP--]

Quoted 8 lines
Quoted 7 lines
support/scripts/test-pkg new file +7 -0
+    printf ", olddefconfig"
+    if ! make O="${dir}" olddefconfig >/dev/null 2>&1; then
+        printf ": FAILED\n"
+        return
+    fi
+    while read line; do
+        if ! grep "^${line}\$" "${dir}/.config" >/dev/null 2>&1; then
Quoted 3 lines
Quoted 1 line

I suggest removing the redirects and using 'grep -q' here.

grep -q is not POSIX. ;-)

:-(

In the meantime I finished building one package (exim) with all toolchains, with and without '-p exim'. I also introduced various
errors: wrong URL, wrong build/configure commands, wrong config snippet, network disconnection.

It all work as expected. So, with the discussed fixed, I expect to add my Acked and Tested tags.

Thanks.

Signature · 1 line
Luca
#6 lore raw

PATCH 1/1 support/scripts: add script to test a package

In reply to Yann E. MORIN
Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

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

Luca, All,
On 2017-02-06 21:40 +0100, Luca Ceresoli spake thusly:

Quoted 1 line · Yann E. MORIN

[--SNIP--]

Quoted 8 lines
Quoted 7 lines
support/scripts/test-pkg new file +7 -0
+    printf ", olddefconfig"
+    if ! make O="${dir}" olddefconfig >/dev/null 2>&1; then
+        printf ": FAILED\n"
+        return
+    fi
+    while read line; do
+        if ! grep "^${line}\$" "${dir}/.config" >/dev/null 2>&1; then
Quoted 3 lines
Quoted 1 line

I suggest removing the redirects and using 'grep -q' here.

grep -q is not POSIX. ;-)

But is that a real concern? We do use grep -q quite a bit already (including in dependencies.sh):

git grep 'grep -q' | wc -l
46

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

PATCH 1/1 support/scripts: add script to test a package

Peter, All,

On 2017-02-07 15:41 +0100, Peter Korsgaard spake thusly:

Quoted 14 lines
Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

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

Luca, All,
On 2017-02-06 21:40 +0100, Luca Ceresoli spake thusly:

Quoted 1 line · Yann E. MORIN

[--SNIP--]

Quoted 8 lines
Quoted 7 lines
support/scripts/test-pkg new file +7 -0
+    printf ", olddefconfig"
+    if ! make O="${dir}" olddefconfig >/dev/null 2>&1; then
+        printf ": FAILED\n"
+        return
+    fi
+    while read line; do
+        if ! grep "^${line}\$" "${dir}/.config" >/dev/null 2>&1; then
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

I suggest removing the redirects and using 'grep -q' here.

grep -q is not POSIX. ;-)

But is that a real concern?

No, of course it is not. But I prefer not having non-portable stuff when the portable solution is pretty easy and straightforward... Personal preference...

Regards,
Yann E. MORIN.

Quoted 8 lines

We do use grep -q quite a bit already
(including in dependencies.sh):

git grep 'grep -q' | wc -l
46

Signature · 1 line
Bye, Peter Korsgaard
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#8 lore raw

PATCH 1/1 support/scripts: add script to test a package

In reply to Yann E. MORIN
Quoted 1 line · Yann E. MORIN

This script helps in testing that a pacakge builds fine on a wide range

package

Quoted 55 lines

of architectures and toolchains: BE/LE, 32/64-bit, musl/glibc/uclibc...

[yann.morin.1998 at free.fr:
- completely rewrite the script from Thomas, with help from Luca
]

---
 support/scripts/test-pkg | 158 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 158 insertions(+)
 create mode 100755 support/scripts/test-pkg
support/scripts/test-pkg new file +36 -0
new file mode 100755
index 0000000..40b373e
@@ -0,0 +1,158 @@
+#!/bin/bash
+set -e
+
+TOOLCHAINS_BASE_URL='http://autobuild.buildroot.org/toolchains/configs'
+
+main() {
+    local o O opts
+    local cfg dir pkg toolchain out
+    local -a toolchains
+
+    o='hc:d:p:'
+    O='help,config-snippet:build-dir:package:'
+    opts="$( getopt -n "${my_name}" -o "${o}" -l "${O}" -- "${@}"  )"
+    eval set -- "${opts}"
+
+    while [ ${#} -gt 0 ]; do
+        case "${1}" in
+        (-h|--help)
+            help; exit 0
+            ;;
+        (-c|--config-snippet)
+            cfg="${2}"; shift 2
+            ;;
+        (-d|--build-dir)
+            dir="${2}"; shift 2
+            ;;
+        (-p|--package)
+            pkg="${2}"; shift 2
+            ;;
+        (--)
+            shift; break
+            ;;
+        esac
+    done
+    if [ -z "${cfg}" ]; then
+        printf "error: no config snippet specified\n" 2>&1; exit 1

support/scripts/test-pkg line 46

Quoted 10 lines
support/scripts/test-pkg new file +10 -0
+    fi
+    if [ -z "${dir}" ]; then
+        dir="${HOME}/br-test-pkg"
+    fi
+
+    # Extract the toolchains names
+    toolchains=( $( curl -s "${TOOLCHAINS_BASE_URL}/toolchain-configs.csv" \
+                    |sed -r -e 's/,.*//; s:.*/(.*)\.config:\1:; /internal/d;'
+                  )
+               )

I always find it useful that such text transformation code carries a short comment giving example input and output.

support/scripts/test-pkg line 49

Quoted 3 lines
support/scripts/test-pkg new file +3 -0
+
+    if [ ${#toolchains[@]} -eq 0 ]; then
+        printf "error: no toolchain found (networking issue?)\n" 2>&1; exit 1

What is the purpose of 2>&1 ? Don't you mean >&2 , i.e. send the print command to stderr ?
Same for other error prints in this file.

support/scripts/test-pkg line 59

Quoted 10 lines
support/scripts/test-pkg new file +10 -0
+    fi
+
+    for toolchain in "${toolchains[@]}"; do
+        build_one "${dir}" "${toolchain}" "${cfg}" "${pkg}"
+    done
+}
+
+build_one() {
+    local dir="${1}"
+    local tc="${2}"

Pretty cryptic, 'tc' for 'toolchain, IMO.

support/scripts/test-pkg line 70

Quoted 11 lines
support/scripts/test-pkg new file +11 -0
+    local cfg="${3}"
+    local pkg="${4}"
+    local line
+
+    printf "%40s: " "${tc}"
+
+    dir="${dir}/${tc}"
+    mkdir -p "${dir}"
+
+    printf "download config"
+    if ! curl -s "${TOOLCHAINS_BASE_URL}/${toolchain}.config" >"${dir}/.config"; then

Here you use 'toolchain' iso 'tc', which is the loop variable used before calling this function. This works 'by luck', but is not the intended design.

Quoted 13 lines
support/scripts/test-pkg new file +13 -0
+        printf ": FAILED\n"
+        return
+    fi
+
+    cat >>"${dir}/.config" <<-_EOF_
+       BR2_INIT_NONE=y
+       BR2_SYSTEM_BIN_SH_NONE=y
+       # BR2_PACKAGE_BUSYBOX is not set
+       # BR2_TARGET_ROOTFS_TAR is not set
+       _EOF_
+    cat "${cfg}" >>"${dir}/.config"
+
+    printf ", olddefconfig"

support/scripts/test-pkg line 93

Quoted 10 lines
support/scripts/test-pkg new file +10 -0
+    if ! make O="${dir}" olddefconfig >/dev/null 2>&1; then
+        printf ": FAILED\n"
+        return
+    fi
+    while read line; do
+        if ! grep "^${line}\$" "${dir}/.config" >/dev/null 2>&1; then
+            printf ", SKIPPED\n"
+            return
+        fi
+    done <"${cfg}"

I think a brief comment of what is happening before each block would be useful. What is happening here? You try to set the config provided by the user and then check if it worked? If that understanding is correct, couldn't the 'SKIPPED' message not be more verbose in explaining _why_ it was skipped? A short explanation, and the line/config option that caused this skip.

Quoted 17 lines
support/scripts/test-pkg new file +17 -0
+
+    printf ", source"
+    if ! make O=${dir} source >> ${dir}/logfile 2>&1; then
+        printf ": FAILED\n"
+        return
+    fi
+
+    if [ -n "${pkg}" ]; then
+        printf ", dirclean"
+        if ! make O=${dir} "${pkg}-dirclean" >> ${dir}/logfile 2>&1; then
+            printf ": FAILED\n"
+            return
+        fi
+    fi
+
+    printf ", build"
+    if ! make O=${dir} ${pkg} >> ${dir}/logfile 2>&1; then

support/scripts/test-pkg line 120

Quoted 10 lines
support/scripts/test-pkg new file +10 -0
+        printf ": FAILED\n"
+        return
+    fi
+
+    printf ": OK\n"
+}
+
+help() {
+    cat <<_EOF_
+${my_name}: test that a package builds with various toolchains and archs

I would start discussing about 'archs' vs 'arches' so perhaps we should just use 'architectures'.

support/scripts/test-pkg line 128

Quoted 8 lines
support/scripts/test-pkg new file +8 -0
+
+${my_name} will test-build a package (as specified in a .config snippet)
+against various toolchains on different architectures.
+
+The list of toolchains is retrieved from Buidlroot autobuilders.
+
+In case failures are noticed, you have the opportunity to fix the issue
+and relaunch the test.

I find it a bit odd to 'get the opportunity to fix', isn't this obvious that if it failed you need to fix and retest?

Quoted 37 lines
support/scripts/test-pkg new file +30 -1
+
+Options
+
+    -h, --help
+        Print this help.
+
+    -c CFG, --config-snippet CFG
+        Use the CFG file as the source for the config snippet. This file
+        should contain all the config options required to build a package.
+
+    -d DIR, --build-dir DIR
+        Do the builds in directory DIR, one sub-dir per toolchain.
+
+    -p PKG, --package PKG
+        Test-build the package PKG.
+
+Example:
+
+    Testing libcec would require a config snippet that contains:
+        BR2_PACKAGE_LIBCEC=y
+
+    Testing libcurl with openSSL support would require a snippet such as:
+        BR2_PACKAGE_OPENSSL=y
+        BR2_PACKAGE_LIBCURL=y
+
+_EOF_
+}
+
+my_name="${0##*/}"
+main "${@}"
--

2.7.4

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

#9 lore raw

PATCH 1/1 support/scripts: add script to test a package

Thomas DS, All,

On 2017-02-06 21:44 +0100, Thomas De Schampheleire spake thusly:

Quoted 4 lines · Yann E. MORIN
Quoted 1 line

This script helps in testing that a pacakge builds fine on a wide range

package

Meh... ;-)

Quoted 3 lines
Quoted 1 line

+ printf "error: no toolchain found (networking issue?)\n" 2>&1; exit 1

What is the purpose of 2>&1 ? Don't you mean >&2 , i.e. send the print command to stderr ?

Yup...

Quoted 2 lines
Quoted 1 line

+ local tc="${2}"

Pretty cryptic, 'tc' for 'toolchain, IMO.

[--SNIP--]

Quoted 4 lines
Quoted 1 line

+ if ! curl -s "${TOOLCHAINS_BASE_URL}/${toolchain}.config" >"${dir}/.config"; then

Here you use 'toolchain' iso 'tc', which is the loop variable used before calling this function. This works 'by luck', but is not the intended design.

Fixed.

Quoted 12 lines

support/scripts/test-pkg line 93

Quoted 11 lines
support/scripts/test-pkg new file +11 -0
+    printf ", olddefconfig"
+    if ! make O="${dir}" olddefconfig >/dev/null 2>&1; then
+        printf ": FAILED\n"
+        return
+    fi
+    while read line; do
+        if ! grep "^${line}\$" "${dir}/.config" >/dev/null 2>&1; then
+            printf ", SKIPPED\n"
+            return
+        fi
+    done <"${cfg}"
Quoted 3 lines

I think a brief comment of what is happening before each block would be useful. What is happening here? You try to set the config provided by the user and then check if it worked?

Would the following be OK? ;-)

We want all the options from the snippet to be present as-is (=y or not set) in the actual .config; if one of them is not, it means some dependency from the toolchain or arch is not available, in which case this config is untestable and we skip it.

Quoted 4 lines

If that understanding is correct,
couldn't the 'SKIPPED' message not be more verbose in explaining _why_ it was skipped? A short explanation, and the line/config option that caused this skip.

I'd like to keep the output as simple as possible. The missing stuff can be stored in a file in the output dir.

Quoted 4 lines
Quoted 1 line

+${my_name}: test that a package builds with various toolchains and archs

I would start discussing about 'archs' vs 'arches' so perhaps we should just use 'architectures'.

OK.

Quoted 10 lines

support/scripts/test-pkg line 128

Quoted 7 lines

+${my_name} will test-build a package (as specified in a .config snippet)

support/scripts/test-pkg new file +6 -0
+against various toolchains on different architectures.
+
+The list of toolchains is retrieved from Buidlroot autobuilders.
+
+In case failures are noticed, you have the opportunity to fix the issue
+and relaunch the test.

I find it a bit odd to 'get the opportunity to fix', isn't this obvious that if it failed you need to fix and retest?

I'll try to rephrase that.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'