Skip to contentSkip to conversation

support: script to build-test packages

PATCH New Yann E. MORIN 5 participants 29 messages Feb 8, 2017 – Feb 12, 2017

lore
Share & tools
lore
#0 lore raw

v3 cover support: script to build-test packages

Hello All!

As Thomas Petazzoni initially wrote (and slightly edited to match the new script):

This has been often asked, and yesterday I needed it, so I did a quick and dirty hack. The following script takes as argument a defconfig fragment that defines a bunch of Buildroot configuration options, and will built this fragment against all the toolchain configurations tested in the autobuilders.

Example:

    $ cat test-jack2.snippet
    BR2_PACKAGE_JACK2=y
    BR2_PACKAGE_JACK2_LEGACY=y
    BR2_PACKAGE_JACK2_DBUS=y
    $ ./support/scripts/test-pkg -c test-jack2.snippet -d ~/br-test-jack2 -p jack2
             armv5-ctng-linux-gnueabi : download config, olddefconfig, dirclean, build: OK
           armv7-ctng-linux-gnueabihf : download config, olddefconfig, dirclean, build: OK
                     br-aarch64-glibc : download config, olddefconfig, dirclean, build: OK
                        br-arcle-hs38 : download config, olddefconfig, dirclean, build: OK
                         br-arm-basic : download config, olddefconfig, SKIPPED
               br-arm-cortex-a9-glibc : download config, olddefconfig, dirclean, build: OK
                br-arm-cortex-a9-musl : download config, olddefconfig, dirclean, build: OK
                br-arm-cortex-m4-full : download config, olddefconfig, SKIPPED
                          br-arm-full : download config, olddefconfig, dirclean, build: OK
                 br-arm-full-nothread : download config, olddefconfig, SKIPPED
                   br-arm-full-static : download config, olddefconfig, SKIPPED
                         br-bfin-full : download config, olddefconfig, SKIPPED
                br-i386-pentium4-full : download config, olddefconfig, dirclean, build: OK
             br-i386-pentium-mmx-musl : download config, olddefconfig, dirclean, build: OK
                    br-m68k-5208-full : download config, olddefconfig, SKIPPED
                   br-m68k-68040-full : download config, olddefconfig, dirclean, build: OK
                 br-microblazeel-full : download config, olddefconfig, dirclean, build: OK
                   br-mips64-n64-full : download config, olddefconfig, dirclean, build: OK
              br-mips32r6-el-hf-glibc : download config, olddefconfig, dirclean, build: OK
              br-mips64r6-el-hf-glibc : download config, olddefconfig, dirclean, build: OK
                   br-mipsel-o32-full : download config, olddefconfig, dirclean, build: OK
                       br-nios2-glibc : download config, olddefconfig, dirclean, build: OK
            br-powerpc-603e-basic-cpp : download config, olddefconfig, SKIPPED
          br-powerpc64le-power8-glibc : download config, olddefconfig, dirclean, build: OK
            br-powerpc64-power7-glibc : download config, olddefconfig, dirclean, build: OK
               br-powerpc-e500mc-full : download config, olddefconfig, dirclean, build: OK
                          br-sh4-full : download config, olddefconfig, dirclean, build: OK
                      br-sparc-uclibc : download config, olddefconfig, SKIPPED
                     br-sparc64-glibc : download config, olddefconfig, dirclean, build: OK
                 br-x86-64-core2-full : download config, olddefconfig, dirclean, build: OK
                       br-x86-64-musl : download config, olddefconfig, dirclean, build: OK
                       br-xtensa-full : download config, olddefconfig, dirclean, build: OK
                  i686-ctng-linux-gnu : download config, olddefconfig, dirclean, build: OK
                       linaro-aarch64 : download config, olddefconfig, dirclean, build: FAILED
                           linaro-arm : download config, olddefconfig, dirclean, build: FAILED
          mips64el-ctng_n32-linux-gnu : download config, olddefconfig, dirclean, build: OK
          mips64el-ctng_n64-linux-gnu : download config, olddefconfig, dirclean, build: FAILED
     powerpc-ctng_e500v2-linux-gnuspe : download config, olddefconfig, dirclean, build: OK
                  sourcery-arm-armv4t : download config, olddefconfig, dirclean, build: OK
                         sourcery-arm : download config, olddefconfig, dirclean, build: OK
                  sourcery-arm-thumb2 : download config, olddefconfig, dirclean, build: OK
                      sourcery-mips64 : download config, olddefconfig, dirclean, build: OK
                        sourcery-mips : download config, olddefconfig, dirclean, build: OK
                       sourcery-nios2 : download config, olddefconfig, dirclean, build: OK
                          sourcery-sh : download config, olddefconfig, dirclean, build: FAILED
                      sourcery-x86-64 : download config, olddefconfig, dirclean, build: OK
                         sourcery-x86 : download config, olddefconfig, dirclean, build: OK
        x86_64-ctng_locales-linux-gnu : download config, olddefconfig, dirclean, build: OK
    8 configurations were skipped
    4 configurations would not build

So, the jack2 package, with both its "legacy" and "dbus" backends has been built in all those configurations.

It says "OK" when the build was successful, "FAILED" when it failed and "SKIPPED" when for some reason the options could not be enabled for the current toolchain configuration (for example if this package is disabled on this architecture, or if a toolchain feature is missing, etc.).

Note that the script excludes the "internal toolchain" configurations, because they take too long to build.

One nice trick is that you can re-run the script, and it will simply restart the build. So after fixing your package, if you want to test it again, you don't have to clean everything and restart from scratch: the build directory for your package is removed in each output directory, and the build resumed.

Changes v2 -> v3:
- simplify the code to store missing config lines (Luca)
- properly run when -r is not provided
- add 5th path to use an alternate list
- add 6th patch to print the progress [n/N] for each toolchain

Regards,
Yann E. MORIN.

The following changes since commit 5d065ef1da3c213ad6fc0d039f92dbbb68dca921

wget: add upstream patch to fix build failure (2017-02-08 15:41:53 +0100)

are available in the git repository at:

git://git.buildroot.org/~ymorin/git/buildroot.git

for you to fetch changes up to aeb2ab98194fac3ad0a73727707023552624d52e

support/test-pkg: print number of toolchain and progress (2017-02-08 21:05:35 +0100)

----------------------------------------------------------------
Yann E. MORIN (6):
support/scripts: add script to test a package support/test-pkg: store lines missing from resulting configuraiton support/test-pkg: report number and types of failures supprt/test-pkg: add option to limit the number of tests support/test-pkg: add option to use an alternate list of toolchains support/test-pkg: print number of toolchain and progress

 support/scripts/test-pkg | 257 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 257 insertions(+)
 create mode 100755 support/scripts/test-pkg
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.  |
'------------------------------^-------^------------------^--------------------'
#1 lore raw

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

This script helps in testing that a package 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
]

---
Changes v2 -> v3:
- grammar (Luca)

---
 support/scripts/test-pkg | 168 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 168 insertions(+)
 create mode 100755 support/scripts/test-pkg
support/scripts/test-pkg new file +168 -0
new file mode 100755
index 0000000..008b32c
@@ -0,0 +1,168 @@
+#!/bin/bash
+set -e
+
+TOOLCHAINS_URL='http://autobuild.buildroot.org/toolchains/configs/toolchain-configs.csv'
+
+main() {
+    local o O opts
+    local cfg dir pkg toolchain
+    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; exit 1
+    fi
+    if [ -z "${dir}" ]; then
+        dir="${HOME}/br-test-pkg"
+    fi
+
+    # Extract the URLs of the toolchains; drop internal toolchains
+    # E.g.: http://server/path/to/name.config,arch,libc
+    #  -->  http://server/path/to/name.config
+    toolchains=( $( curl -s "${TOOLCHAINS_URL}" \
+                    |sed -r -e 's/,.*//; /internal/d;'
+                  )
+               )
+
+    if [ ${#toolchains[@]} -eq 0 ]; then
+        printf "error: no toolchain found (networking issue?)\n" >&2; exit 1
+    fi
+
+    for toolchain in "${toolchains[@]}"; do
+        build_one "${dir}" "${toolchain}" "${cfg}" "${pkg}"
+    done
+}
+
+build_one() {
+    local dir="${1}"
+    local url="${2}"
+    local cfg="${3}"
+    local pkg="${4}"
+    local toolchain line
+
+    # Using basename(1) on a URL works nicely
+    toolchain="$( basename "${url}" .config )"
+
+    printf "%40s: " "${toolchain}"
+
+    dir="${dir}/${toolchain}"
+    mkdir -p "${dir}"
+
+    printf "download config"
+    if ! curl -s "${url}" >"${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
+    # We want all the options from the snippet to be present as-is (set
+    # 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.
+    while read line; do
+        if ! grep "^${line}\$" "${dir}/.config" >/dev/null 2>&1; then
+            printf ", SKIPPED\n"
+            return
+        fi
+    done <"${cfg}"
+
+    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"
+    # shellcheck disable=SC2086
+    if ! make O="${dir}" ${pkg} >> "${dir}/logfile" 2>&1; then
+        printf ": FAILED\n"
+        return
+    fi
+
+    printf ": OK\n"
+}
+
+help() {
+    cat <<_EOF_
+test-pkg: test-build a package against various toolchains and architectures
+
+The supplied config snippet is appended to each toolchain config, the
+resulting configuration is checked to ensure it still contains all options
+specified in the snippet; if any is missing, the build is skipped, on the
+assumption that the package under test requires a toolchain or architecture
+feature that is missing.
+
+In case failures are noticed, you can fix the package and just re-run the
+same command again; it will re-run the test where it failed. If you did
+specify a package (with -p), the package build dir will be removed first.
+
+The list of toolchains is retrieved from the Buildroot autobuilders, available
+at ${TOOLCHAINS_URL}.
+
+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, by running 'make PKG'; if not specified,
+        just runs 'make'.
+
+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
#2 lore raw

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

Quoted 68 lines · Yann E. MORIN

This script helps in testing that a package 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 ]

---
Changes v2 -> v3:
- grammar (Luca)
---
support/scripts/test-pkg | 168 +++++++++++++++++++++++++++++++++++++++++++++++

1 file changed, 168 insertions(+)

create mode 100755 support/scripts/test-pkg

support/scripts/test-pkg new file +41 -0
new file mode 100755
index 0000000..008b32c
@@ -0,0 +1,168 @@
+#!/bin/bash
+set -e
+
+TOOLCHAINS_URL='http://autobuild.buildroot.org/toolchains/configs/toolchain-configs.csv'
+
+main() {
+    local o O opts
+    local cfg dir pkg toolchain
+    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; exit 1
+    fi
+    if [ -z "${dir}" ]; then
+        dir="${HOME}/br-test-pkg"
+    fi
+

support/scripts/test-pkg line 51

Quoted 10 lines
support/scripts/test-pkg new file +10 -0
+    # Extract the URLs of the toolchains; drop internal toolchains
+    # E.g.: http://server/path/to/name.config,arch,libc
+    #  -->  http://server/path/to/name.config
+    toolchains=( $( curl -s "${TOOLCHAINS_URL}" \
+                    |sed -r -e 's/,.*//; /internal/d;'
+                  )
+               )
+
+    if [ ${#toolchains[@]} -eq 0 ]; then
+        printf "error: no toolchain found (networking issue?)\n" >&2; exit 1

The format string should be in single quotes as it contains a glob char.

I usually put all printf format strings in single quotes since printf is doing the substitutions, not the shell.

Quoted 37 lines
support/scripts/test-pkg new file +37 -0
+    fi
+
+    for toolchain in "${toolchains[@]}"; do
+        build_one "${dir}" "${toolchain}" "${cfg}" "${pkg}"
+    done
+}
+
+build_one() {
+    local dir="${1}"
+    local url="${2}"
+    local cfg="${3}"
+    local pkg="${4}"
+    local toolchain line
+
+    # Using basename(1) on a URL works nicely
+    toolchain="$( basename "${url}" .config )"
+
+    printf "%40s: " "${toolchain}"
+
+    dir="${dir}/${toolchain}"
+    mkdir -p "${dir}"
+
+    printf "download config"
+    if ! curl -s "${url}" >"${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"

support/scripts/test-pkg line 98

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
+    # We want all the options from the snippet to be present as-is (set
+    # 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.
+    while read line; do
+        if ! grep "^${line}\$" "${dir}/.config" >/dev/null 2>&1; then

You should use grep -Fx here since ${line} might contains regex chars:

        if ! grep -Fx "${line}" "${dir}/.config" >/dev/null 2>&1; then

....

support/scripts/test-pkg line 102

Quoted 4 lines
support/scripts/test-pkg new file +4 -0
+            printf ", SKIPPED\n"
+            return
+        fi
+    done <"${cfg}"

.... but I'd get rid of the loop altogether and use comm(1); something like:

if [ -n "$( comm -23 <(sort "${cfg}") <(sort "${dir/.config}") )" ]; then
printf ", SKIPPED\n"
return
fi

Quoted 73 lines
support/scripts/test-pkg new file +66 -0
+
+    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"
+    # shellcheck disable=SC2086
+    if ! make O="${dir}" ${pkg} >> "${dir}/logfile" 2>&1; then
+        printf ": FAILED\n"
+        return
+    fi
+
+    printf ": OK\n"
+}
+
+help() {
+    cat <<_EOF_
+test-pkg: test-build a package against various toolchains and architectures
+
+The supplied config snippet is appended to each toolchain config, the
+resulting configuration is checked to ensure it still contains all options
+specified in the snippet; if any is missing, the build is skipped, on the
+assumption that the package under test requires a toolchain or architecture
+feature that is missing.
+
+In case failures are noticed, you can fix the package and just re-run the
+same command again; it will re-run the test where it failed. If you did
+specify a package (with -p), the package build dir will be removed first.
+
+The list of toolchains is retrieved from the Buildroot autobuilders, available
+at ${TOOLCHAINS_URL}.
+
+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, by running 'make PKG'; if not specified,
+        just runs 'make'.
+
+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 · 6 lines
2.7.4

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
#3 lore raw

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

Quoted 84 lines · Cam Hutchison
Quoted 13 lines · Yann E. MORIN

This script helps in testing that a package 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 ]

Quoted 5 lines

---
Changes v2 -> v3:
- grammar (Luca)
---
support/scripts/test-pkg | 168 ++++++++++++++++++++++++++++++

+++++++++++++++++

support/scripts/test-pkg line 4

Quoted 13 lines
1 file changed, 168 insertions(+)

create mode 100755 support/scripts/test-pkg

support/scripts/test-pkg new file +4 -0
new file mode 100755
index 0000000..008b32c
@@ -0,0 +1,168 @@
+#!/bin/bash
+set -e
+
+TOOLCHAINS_URL='http://autobuild.buildroot.org/

toolchains/configs/toolchain-configs.csv'

Quoted 37 lines
support/scripts/test-pkg new file +37 -0
+
+main() {
+    local o O opts
+    local cfg dir pkg toolchain
+    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; exit 1
+    fi
+    if [ -z "${dir}" ]; then
+        dir="${HOME}/br-test-pkg"
+    fi
+

support/scripts/test-pkg

Quoted 10 lines
support/scripts/test-pkg new file +10 -0
+    # Extract the URLs of the toolchains; drop internal toolchains
+    # E.g.: http://server/path/to/name.config,arch,libc
+    #  -->  http://server/path/to/name.config
+    toolchains=( $( curl -s "${TOOLCHAINS_URL}" \
+                    |sed -r -e 's/,.*//; /internal/d;'
+                  )
+               )
+
+    if [ ${#toolchains[@]} -eq 0 ]; then
+        printf "error: no toolchain found (networking issue?)\n" >&2;

exit 1

Quoted 2 lines

The format string should be in single quotes as it contains a glob char.

I'm wrong here. Globs don't expand in double-quotes.

Quoted 147 lines

I usually put all printf format strings in single quotes since printf is doing the substitutions, not the shell.

Quoted 37 lines
support/scripts/test-pkg new file +37 -0
+    fi
+
+    for toolchain in "${toolchains[@]}"; do
+        build_one "${dir}" "${toolchain}" "${cfg}" "${pkg}"
+    done
+}
+
+build_one() {
+    local dir="${1}"
+    local url="${2}"
+    local cfg="${3}"
+    local pkg="${4}"
+    local toolchain line
+
+    # Using basename(1) on a URL works nicely
+    toolchain="$( basename "${url}" .config )"
+
+    printf "%40s: " "${toolchain}"
+
+    dir="${dir}/${toolchain}"
+    mkdir -p "${dir}"
+
+    printf "download config"
+    if ! curl -s "${url}" >"${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"

support/scripts/test-pkg line 98

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
+    # We want all the options from the snippet to be present as-is (set
+    # 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.
+    while read line; do
+        if ! grep "^${line}\$" "${dir}/.config" >/dev/null 2>&1; then

You should use grep -Fx here since ${line} might contains regex chars:

        if ! grep -Fx "${line}" "${dir}/.config" >/dev/null 2>&1; then

....

support/scripts/test-pkg line 102

Quoted 4 lines
support/scripts/test-pkg new file +4 -0
+            printf ", SKIPPED\n"
+            return
+        fi
+    done <"${cfg}"

.... but I'd get rid of the loop altogether and use comm(1); something like:

    if [ -n "$( comm -23 <(sort "${cfg}") <(sort "${dir/.config}") )" ];

then
printf ", SKIPPED\n"
return
fi

support/scripts/test-pkg

Quoted 4 lines
support/scripts/test-pkg new file +4 -0
+
+    if [ -n "${pkg}" ]; then
+        printf ", dirclean"
+        if ! make O="${dir}" "${pkg}-dirclean" >> "${dir}/logfile" 2>&1;

then

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

support/scripts/test-pkg

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

architectures

support/scripts/test-pkg

Quoted 3 lines
support/scripts/test-pkg new file +3 -0
+
+The supplied config snippet is appended to each toolchain config, the
+resulting configuration is checked to ensure it still contains all

options

support/scripts/test-pkg

Quoted 2 lines
support/scripts/test-pkg new file +2 -0
+specified in the snippet; if any is missing, the build is skipped, on the
+assumption that the package under test requires a toolchain or

architecture

support/scripts/test-pkg

Quoted 7 lines
support/scripts/test-pkg new file +7 -0
+feature that is missing.
+
+In case failures are noticed, you can fix the package and just re-run the
+same command again; it will re-run the test where it failed. If you did
+specify a package (with -p), the package build dir will be removed first.
+
+The list of toolchains is retrieved from the Buildroot autobuilders,

available

support/scripts/test-pkg

Quoted 10 lines
support/scripts/test-pkg new file +10 -0
+at ${TOOLCHAINS_URL}.
+
+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.

support/scripts/test-pkg

Quoted 6 lines
support/scripts/test-pkg new file +6 -0
+
+    -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, by running 'make PKG'; if not

specified,

Quoted 18 lines
support/scripts/test-pkg new file +16 -1
+        just runs 'make'.
+
+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

Quoted 9 lines
Quoted 4 lines

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

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170209/77a164dd/attachment.html>

#4 lore raw

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

In reply to Cam Hutchison

Cam, All,

Since you did not Cc me on that mail, I only noticed it now...

On 2017-02-08 22:00 -0000, Cam Hutchison spake thusly:

Quoted 3 lines
Quoted 2 lines · Yann E. MORIN

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

[--SNIP--]

Quoted 4 lines

support/scripts/test-pkg line 51

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

The format string should be in single quotes as it contains a glob char.

Nope, wildcards are not expanded in double quotes (as you then noticed).

Quoted 2 lines

I usually put all printf format strings in single quotes since printf is doing the substitutions, not the shell.

I tend to agree on the principle: format strings should be single-quoted. But then we have disparate quoting styles, and I don;t like it. I prefer a single quoting style...

But your point is valid as well.

[--SNIP--]

Quoted 14 lines

support/scripts/test-pkg line 98

Quoted 2 lines
support/scripts/test-pkg new file +2 -0
+    while read line; do
+        if ! grep "^${line}\$" "${dir}/.config" >/dev/null 2>&1; then

You should use grep -Fx here since ${line} might contains regex chars:

        if ! grep -Fx "${line}" "${dir}/.config" >/dev/null 2>&1; then

....

support/scripts/test-pkg line 102

Quoted 4 lines
support/scripts/test-pkg new file +4 -0
+            printf ", SKIPPED\n"
+            return
+        fi
+    done <"${cfg}"
Quoted 6 lines

.... but I'd get rid of the loop altogether and use comm(1); something like:

if [ -n "$( comm -23 <(sort "${cfg}") <(sort "${dir/.config}") )" ]; then
printf ", SKIPPED\n"
return
fi

Yup, I'll take a look at using comm instead. Thanks for the tip! :-)

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/6 support/scripts: add script to test a package

Quoted 40 lines · Yann E. MORIN

Cam, All,

Since you did not Cc me on that mail, I only noticed it now...

On 2017-02-08 22:00 -0000, Cam Hutchison spake thusly:

Quoted 3 lines
Quoted 2 lines · Yann E. MORIN

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

[--SNIP--]

Quoted 4 lines

support/scripts/test-pkg line 51

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

The format string should be in single quotes as it contains a glob char.

Nope, wildcards are not expanded in double quotes (as you then noticed).

Quoted 2 lines

I usually put all printf format strings in single quotes since printf is doing the substitutions, not the shell.

I tend to agree on the principle: format strings should be single-quoted. But then we have disparate quoting styles, and I don;t like it. I prefer a single quoting style...

But your point is valid as well.

[--SNIP--]

Quoted 14 lines

support/scripts/test-pkg line 98

Quoted 2 lines
support/scripts/test-pkg new file +2 -0
+    while read line; do
+        if ! grep "^${line}\$" "${dir}/.config" >/dev/null 2>&1; then

You should use grep -Fx here since ${line} might contains regex chars:

        if ! grep -Fx "${line}" "${dir}/.config" >/dev/null 2>&1; then

....

Quoted 4 lines
support/scripts/test-pkg new file +4 -0
+            printf ", SKIPPED\n"
+            return
+        fi
+    done <"${cfg}"
Quoted 9 lines
Quoted 6 lines

.... but I'd get rid of the loop altogether and use comm(1); something like:

if [ -n "$( comm -23 <(sort "${cfg}") <(sort "${dir/.config}") )" ]; then
printf ", SKIPPED\n"
return
fi

Yup, I'll take a look at using comm instead. Thanks for the tip! :-)

Here is a feature request, but only if it does not add much
complexity: I was expecting the script to accept this:

echo "BR2_PACKAGE_BUSYBOX=y" | support/scripts/test-pkg -p busybox -c -

i.e. let '-' indicate that the config snippet is to be taken from standard input, a principle supported by many unix tools already. The 'echo' could be more complex in someone else's use case, for example a concatenation of several pre-existing snippets.

Best regards,
Thomas

#6 lore raw

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

Thomas DS, All,

On 2017-02-11 22:19 +0100, Thomas De Schampheleire spake thusly:

Quoted 1 line · Yann E. MORIN

[--SNIP--]

Quoted 9 lines

Here is a feature request, but only if it does not add much
complexity: I was expecting the script to accept this:

echo "BR2_PACKAGE_BUSYBOX=y" | support/scripts/test-pkg -p busybox -c -

i.e. let '-' indicate that the config snippet is to be taken from standard input, a principle supported by many unix tools already. The 'echo' could be more complex in someone else's use case, for example a concatenation of several pre-existing snippets.

Which means that we'd have to manage a temporary file internally. Well, we can do without it, at the cost of some complexity in the script.

What would be the use-case that would prevent on to do:

    $ printf "Bla\nBle\n" >foo.cfg
    $ ./support/scripts/test-pkg -p busybox -c foo.cfg
    $ rm foo.cfg

instead?

But yes, that's doable. Lt's just post-pone that "enhancement" for later...

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.  |
'------------------------------^-------^------------------^--------------------'
#7 lore raw

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

In reply to Yann E. MORIN

Hi,

Quoted 13 lines · Yann E. MORIN

This script helps in testing that a package 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
]

Quoted 3 lines

---
Changes v2 -> v3:
- grammar (Luca)

There are more changes in reality, not only grammar fixes. So the Acked and Reviewed-by tags should be removed IMO.

But I'm OK with the new version as well, so:

[tested the exim package with all toolchains, with and without -p, introducing build, URL and defconfig errors]

Signature · 1 line
Luca
#8 lore raw

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

In reply to Yann E. MORIN

Hello,

For some reason only your cover letter had PATCHv3, not the patches themselves. Could you check what happened?

Quoted 4 lines · Yann E. MORIN

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

Quoted 8 lines

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

First of all, thanks for taking over my initial crappy submission and making it something production ready. I've applied your patch, but I nonetheless have a few comments about it. See below.

Quoted 1 line

+ opts="$( getopt -n "${my_name}" -o "${o}" -l "${O}" -- "${@}" )"

I continue to terribly dislike this whole concept of putting a space after an opening parenthesis and before a closing parenthesis.

I know this is your coding style, but it is *not* the Buildroot coding style. So I'd appreciate if the shell scripts could also comply with the Buildroot coding style on this.

Quoted 1 line

+ printf "download config"

I find all these prints to be really useless, and they clutter the output for nothing. My original script had a very lean and readable output:

	<toolchain>:	<status>

and now it's the much more verbose (and useless):

armv5-ctng-linux-gnueabi: download config, olddefconfig, build: OK
armv7-ctng-linux-gnueabihf: download config, olddefconfig, build: OK

(which would get even more verbose if I had passed a -p option, since dirclean would have been added).

I'd really prefer if we got rid of those additional prints, they are not useful, and make the whole thing less readable.

Thanks!

Thomas

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

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

Thomas, All,

On 2017-02-09 22:50 +0100, Thomas Petazzoni spake thusly:

Quoted 2 lines

For some reason only your cover letter had PATCHv3, not the patches themselves. Could you check what happened?

Yup, I'll check...

Quoted 18 lines · Yann E. MORIN
Quoted 4 lines

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

Quoted 8 lines

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

First of all, thanks for taking over my initial crappy submission and making it something production ready. I've applied your patch, but I nonetheless have a few comments about it. See below.

Quoted 8 lines
Quoted 1 line

+ opts="$( getopt -n "${my_name}" -o "${o}" -l "${O}" -- "${@}" )"

I continue to terribly dislike this whole concept of putting a space after an opening parenthesis and before a closing parenthesis.

I know this is your coding style, but it is *not* the Buildroot coding style. So I'd appreciate if the shell scripts could also comply with the Buildroot coding style on this.

Fair enough. I'll post a patch fixing this.

Quoted 10 lines
Quoted 1 line

+ printf "download config"

I find all these prints to be really useless, and they clutter the output for nothing. My original script had a very lean and readable output:

	<toolchain>:	<status>

and now it's the much more verbose (and useless):

Quoted 8 lines

armv5-ctng-linux-gnueabi: download config, olddefconfig, build: OK
armv7-ctng-linux-gnueabihf: download config, olddefconfig, build: OK

(which would get even more verbose if I had passed a -p option, since dirclean would have been added).

I'd really prefer if we got rid of those additional prints, they are not useful, and make the whole thing less readable.

Well, I like that there is so feedback of what's going on under the hood...

But I'll send updates to 'fix' that.

Thanks! :-)

Regards,
Yann E. MORIN.

Quoted 7 lines

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
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.  |
'------------------------------^-------^------------------^--------------------'
#10 lore raw

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

In reply to Yann E. MORIN

Hello,

Quoted 4 lines · Yann E. MORIN

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

Quoted 8 lines

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

Another comment: now that the script itself has been merged, adding a quick note in the manual about it would be nice, so that developers adding new packages (or bumping versions) can quickly test by using this script.

Thanks!

Thomas

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

PATCH v3 2/6 support/test-pkg: store lines missing from resulting configuraiton

In reply to Yann E. MORIN

When a build is skipped, store the lines from the config snippet, that are missing in the resulting configuration, in a file in the build directory, for the user to inspect.

Cc Thomas Petazzoni <[email protected]>
Cc Luca Ceresoli <[email protected]>
Cc Thomas De Schampheleire <[email protected]>

---
Changes v2 -> v3:
- simplify the code a bit (Luca)

---
 support/scripts/test-pkg | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
support/scripts/test-pkg +11 -4
index 008b32c..5eeaf63 100755
@@ -61,7 +61,7 @@ build_one() {
     local url="${2}"
     local cfg="${3}"
     local pkg="${4}"
-    local toolchain line
+    local toolchain line skip
 
     # Using basename(1) on a URL works nicely
     toolchain="$( basename "${url}" .config )"
@@ -94,12 +94,19 @@ build_one() {
     # 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.
+    skip=false
     while read line; do
         if ! grep "^${line}\$" "${dir}/.config" >/dev/null 2>&1; then
-            printf ", SKIPPED\n"
-            return
+            printf "%s\n" "${line}"
+            skip=true
         fi
-    done <"${cfg}"
+    done <"${cfg}" >"${dir}/missing.config"
+    if ${skip}; then
+        printf ", SKIPPED\n"
+        return
+    fi
+    # Remove file, it's empty anyway.
+    rm -f "${dir}/missing.config"
 
     if [ -n "${pkg}" ]; then
         printf ", dirclean"
Signature · 1 line
2.7.4
#12 lore raw

PATCH 2/6 support/test-pkg: store lines missing from resulting configuraiton

Hi,

Quoted 8 lines · Yann E. MORIN

When a build is skipped, store the lines from the config snippet, that are missing in the resulting configuration, in a file in the build directory, for the user to inspect.

Cc Thomas Petazzoni <[email protected]>
Cc Luca Ceresoli <[email protected]>
Cc Thomas De Schampheleire <[email protected]>
Signature · 1 line
Luca
#13 lore raw

PATCH 2/6 support/test-pkg: store lines missing from resulting configuraiton

In reply to Yann E. MORIN

Hello,

Quoted 9 lines · Yann E. MORIN

When a build is skipped, store the lines from the config snippet, that are missing in the resulting configuration, in a file in the build directory, for the user to inspect.

Cc Thomas Petazzoni <[email protected]>
Cc Luca Ceresoli <[email protected]>
Cc Thomas De Schampheleire <[email protected]>
Quoted 6 lines

---
Changes v2 -> v3:
- simplify the code a bit (Luca)

---
 support/scripts/test-pkg | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Applied to master, thanks.

Thomas

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

PATCH v3 3/6 support/test-pkg: report number and types of failures

In reply to Yann E. MORIN
Cc Thomas Petazzoni <[email protected]>
Cc Luca Ceresoli <[email protected]>
Cc Thomas De Schampheleire <[email protected]>
---
 support/scripts/test-pkg | 42 ++++++++++++++++++++++++++++++++++++------
 1 file changed, 36 insertions(+), 6 deletions(-)
support/scripts/test-pkg +36 -6
index 5eeaf63..f40b51d 100755
@@ -6,6 +6,7 @@ TOOLCHAINS_URL='http://autobuild.buildroot.org/toolchains/configs/toolchain-conf
 main() {
     local o O opts
     local cfg dir pkg toolchain
+    local ret nb_dl nb_cfg nb_skip nb_clean nb_build
     local -a toolchains
 
     o='hc:d:p:'
@@ -51,9 +52,38 @@ main() {
         printf "error: no toolchain found (networking issue?)\n" >&2; exit 1
     fi
 
+    nb_dl=0
+    nb_cfg=0
+    nb_skip=0
+    nb_clean=0
+    nb_build=0
     for toolchain in "${toolchains[@]}"; do
-        build_one "${dir}" "${toolchain}" "${cfg}" "${pkg}"
+        build_one "${dir}" "${toolchain}" "${cfg}" "${pkg}" && ret=0 || ret=${?}
+        case ${ret} in
+        (0) ;;
+        (1) : $((nb_dl++));;
+        (2) : $((nb_cfg++));;
+        (3) : $((nb_skip++));;
+        (4) : $((nb_clean++));;
+        (5) : $((nb_build++));;
+        esac
     done
+
+    if [ ${nb_dl} -ne 0 ]; then
+        printf "%d configurations could not be downloaded\n" ${nb_dl}
+    fi
+    if [ ${nb_cfg} -ne 0 ]; then
+        printf "%d configurations could not be applied\n" ${nb_cfg}
+    fi
+    if [ ${nb_skip} -ne 0 ]; then
+        printf "%d configurations were skipped\n" ${nb_skip}
+    fi
+    if [ ${nb_clean} -ne 0 ]; then
+        printf "%d configurations could not be dircleaned\n" ${nb_clean}
+    fi
+    if [ ${nb_build} -ne 0 ]; then
+        printf "%d configurations would not build\n" ${nb_build}
+    fi
 }
 
 build_one() {
@@ -74,7 +104,7 @@ build_one() {
     printf "download config"
     if ! curl -s "${url}" >"${dir}/.config"; then
         printf ": FAILED\n"
-        return
+        return 1
     fi
 
     cat >>"${dir}/.config" <<-_EOF_
@@ -88,7 +118,7 @@ build_one() {
     printf ", olddefconfig"
     if ! make O="${dir}" olddefconfig >/dev/null 2>&1; then
         printf ": FAILED\n"
-        return
+        return 2
     fi
     # We want all the options from the snippet to be present as-is (set
     # or not set) in the actual .config; if one of them is not, it means
@@ -103,7 +133,7 @@ build_one() {
     done <"${cfg}" >"${dir}/missing.config"
     if ${skip}; then
         printf ", SKIPPED\n"
-        return
+        return 3
     fi
     # Remove file, it's empty anyway.
     rm -f "${dir}/missing.config"
@@ -112,7 +142,7 @@ build_one() {
         printf ", dirclean"
         if ! make O="${dir}" "${pkg}-dirclean" >> "${dir}/logfile" 2>&1; then
             printf ": FAILED\n"
-            return
+            return 4
         fi
     fi
 
@@ -120,7 +150,7 @@ build_one() {
     # shellcheck disable=SC2086
     if ! make O="${dir}" ${pkg} >> "${dir}/logfile" 2>&1; then
         printf ": FAILED\n"
-        return
+        return 5
     fi
 
     printf ": OK\n"
Signature · 1 line
2.7.4
#15 lore raw

PATCH 3/6 support/test-pkg: report number and types of failures

Hi,

Quoted 5 lines · Yann E. MORIN
Cc Thomas Petazzoni <[email protected]>
Cc Luca Ceresoli <[email protected]>
Cc Thomas De Schampheleire <[email protected]>

Review confirmed since the patch has not changed since v2.

Additionally:

Signature · 1 line
Luca
#16 lore raw

PATCH 3/6 support/test-pkg: report number and types of failures

In reply to Yann E. MORIN

Hello,

Quoted 5 lines · Yann E. MORIN
support/scripts/test-pkg +5 -0
+    if [ ${nb_dl} -ne 0 ]; then
+        printf "%d configurations could not be downloaded\n" ${nb_dl}
+    fi
+    if [ ${nb_cfg} -ne 0 ]; then
+        printf "%d configurations could not be applied\n" ${nb_cfg}

support/scripts/test-pkg main() { · line 86

Quoted 10 lines
support/scripts/test-pkg +10 -0
+    fi
+    if [ ${nb_skip} -ne 0 ]; then
+        printf "%d configurations were skipped\n" ${nb_skip}
+    fi
+    if [ ${nb_clean} -ne 0 ]; then
+        printf "%d configurations could not be dircleaned\n" ${nb_clean}
+    fi
+    if [ ${nb_build} -ne 0 ]; then
+        printf "%d configurations would not build\n" ${nb_build}
+    fi

This is really verbose and not very useful. Instead what would be much more useful is just:

successes = %d, failures = %d, skipped = %d

(possibly presented in a different way, my point is really that number of successes, number of failures and numbers of skipped configurations is really all what matters)

Thomas

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

PATCH 3/6 support/test-pkg: report number and types of failures

Quoted 20 lines · Thomas Petazzoni

Hello,

Quoted 5 lines · Yann E. MORIN
support/scripts/test-pkg +5 -0
+    if [ ${nb_dl} -ne 0 ]; then
+        printf "%d configurations could not be downloaded\n" ${nb_dl}
+    fi
+    if [ ${nb_cfg} -ne 0 ]; then
+        printf "%d configurations could not be applied\n" ${nb_cfg}

support/scripts/test-pkg main() { · line 86

Quoted 10 lines
support/scripts/test-pkg +10 -0
+    fi
+    if [ ${nb_skip} -ne 0 ]; then
+        printf "%d configurations were skipped\n" ${nb_skip}
+    fi
+    if [ ${nb_clean} -ne 0 ]; then
+        printf "%d configurations could not be dircleaned\n" ${nb_clean}
+    fi
+    if [ ${nb_build} -ne 0 ]; then
+        printf "%d configurations would not build\n" ${nb_build}
+    fi
Quoted 9 lines

This is really verbose and not very useful. Instead what would be much more useful is just:

successes = %d, failures = %d, skipped = %d

(possibly presented in a different way, my point is really that number of successes, number of failures and numbers of skipped configurations is really all what matters)

I agree with Thomas here. Especially because a failure in download, olddefconfig and dirclean steps is exceptional. Most failures will be due to build problems or to a lesser extent invalid cofigurations (either completely invalid == developer error in providing the snippet, or invalid in some toolchains only).
Since the amount of toolchains that will be checked is limited, it is not a lot of work to scroll up to view the actual problems.

/Thomas

#18 lore raw

PATCH v3 3/6 support/test-pkg: report number and types of failures

Thomas DS, All,

On 2017-02-11 20:48 +0100, Thomas De Schampheleire spake thusly:

Quoted 32 lines
Quoted 20 lines · Thomas Petazzoni

Hello,

Quoted 5 lines · Yann E. MORIN
support/scripts/test-pkg +5 -0
+    if [ ${nb_dl} -ne 0 ]; then
+        printf "%d configurations could not be downloaded\n" ${nb_dl}
+    fi
+    if [ ${nb_cfg} -ne 0 ]; then
+        printf "%d configurations could not be applied\n" ${nb_cfg}

support/scripts/test-pkg main() { · line 86

Quoted 10 lines
support/scripts/test-pkg +10 -0
+    fi
+    if [ ${nb_skip} -ne 0 ]; then
+        printf "%d configurations were skipped\n" ${nb_skip}
+    fi
+    if [ ${nb_clean} -ne 0 ]; then
+        printf "%d configurations could not be dircleaned\n" ${nb_clean}
+    fi
+    if [ ${nb_build} -ne 0 ]; then
+        printf "%d configurations would not build\n" ${nb_build}
+    fi
Quoted 9 lines

This is really verbose and not very useful. Instead what would be much more useful is just:

successes = %d, failures = %d, skipped = %d

(possibly presented in a different way, my point is really that number of successes, number of failures and numbers of skipped configurations is really all what matters)

Quoted 7 lines

I agree with Thomas here. Especially because a failure in download, olddefconfig and dirclean steps is exceptional. Most failures will be due to build problems or to a lesser extent invalid cofigurations (either completely invalid == developer error in providing the snippet, or invalid in some toolchains only).
Since the amount of toolchains that will be checked is limited, it is not a lot of work to scroll up to view the actual problems.

I already fixed it as per Thomas P. suggestion. It will be in the next re-spin (tomorrow).

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.  |
'------------------------------^-------^------------------^--------------------'
#19 lore raw

PATCH v3 4/6 supprt/test-pkg: add option to limit the number of tests

In reply to Yann E. MORIN

Sometimes, it interesting to have a global overview of whether the package builds at all or not, rather than test on all toolchains.

Add an option that allows testing on a limited set of randomly choosen toolchains.

Cc Thomas Petazzoni <[email protected]>
Cc Luca Ceresoli <[email protected]>
Cc Thomas De Schampheleire <[email protected]>

---
Changes v1 -> v2;
- fix when option is not provided

---
 support/scripts/test-pkg | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
support/scripts/test-pkg +17 -4
index f40b51d..59c9f23 100755
@@ -5,15 +5,16 @@ TOOLCHAINS_URL='http://autobuild.buildroot.org/toolchains/configs/toolchain-conf
 
 main() {
     local o O opts
-    local cfg dir pkg toolchain
+    local cfg dir pkg random toolchain
     local ret nb_dl nb_cfg nb_skip nb_clean nb_build
     local -a toolchains
 
-    o='hc:d:p:'
-    O='help,config-snippet:build-dir:package:'
+    o='hc:d:p:r:'
+    O='help,config-snippet:build-dir:package:,random:'
     opts="$( getopt -n "${my_name}" -o "${o}" -l "${O}" -- "${@}"  )"
     eval set -- "${opts}"
 
+    random=0
     while [ ${#} -gt 0 ]; do
         case "${1}" in
         (-h|--help)
@@ -28,6 +29,9 @@ main() {
         (-p|--package)
             pkg="${2}"; shift 2
             ;;
+        (-r|--random)
+            random="${2}"; shift 2
+            ;;
         (--)
             shift; break
             ;;
@@ -44,7 +48,12 @@ main() {
     # E.g.: http://server/path/to/name.config,arch,libc
     #  -->  http://server/path/to/name.config
     toolchains=( $( curl -s "${TOOLCHAINS_URL}" \
-                    |sed -r -e 's/,.*//; /internal/d;'
+                    |sed -r -e 's/,.*//; /internal/d;' \
+                    |if [ ${random} -gt 0 ]; then \
+                        sort -R |head -n ${random}
+                     else
+                        cat
+                     fi |sort
                   )
                )
 
@@ -189,6 +198,10 @@ Options:
         Test-build the package PKG, by running 'make PKG'; if not specified,
         just runs 'make'.
 
+    -r N, --random N
+        Limit the tests to the N randomly selected toolchains, instead of
+        building with all toolchains.
+
 Example:
 
     Testing libcec would require a config snippet that contains:
Signature · 1 line
2.7.4
#20 lore raw

PATCH 4/6 supprt/test-pkg: add option to limit the number of tests

Hello,

Quoted 11 lines · Yann E. MORIN

Sometimes, it interesting to have a global overview of whether the package builds at all or not, rather than test on all toolchains.

Add an option that allows testing on a limited set of randomly choosen toolchains.

Cc Thomas Petazzoni <[email protected]>
Cc Luca Ceresoli <[email protected]>
Cc Thomas De Schampheleire <[email protected]>
Quoted 6 lines

---
Changes v1 -> v2;
- fix when option is not provided

---
 support/scripts/test-pkg | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

Applied to master, thanks.

Thomas

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

PATCH v3 5/6 support/test-pkg: add option to use an alternate list of toolchains

In reply to Yann E. MORIN

For now, testing a package requires network access. However, there are situations where everything is already cached locally (especially the toolchains tarballs) and network is not available (e.g. in the train, travelling back from FOSDEM...)

Alternatively, one may also want to test against a subset of the default toolchains (e.g. the ones known to have a specific issue).

Add an option to use an alternate URL, which can be remote or a path to a local file.

---
 support/scripts/test-pkg | 47 +++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 41 insertions(+), 6 deletions(-)
support/scripts/test-pkg +41 -6
index 59c9f23..e77c804 100755
@@ -5,16 +5,17 @@ TOOLCHAINS_URL='http://autobuild.buildroot.org/toolchains/configs/toolchain-conf
 
 main() {
     local o O opts
-    local cfg dir pkg random toolchain
+    local cfg dir pkg random url toolchain
     local ret nb_dl nb_cfg nb_skip nb_clean nb_build
     local -a toolchains
 
-    o='hc:d:p:r:'
-    O='help,config-snippet:build-dir:package:,random:'
+    o='hc:d:p:r:t:'
+    O='help,config-snippet:build-dir:package:,random:,toolchains:'
     opts="$( getopt -n "${my_name}" -o "${o}" -l "${O}" -- "${@}"  )"
     eval set -- "${opts}"
 
     random=0
+    url="${TOOLCHAINS_URL}"
     while [ ${#} -gt 0 ]; do
         case "${1}" in
         (-h|--help)
@@ -32,6 +33,9 @@ main() {
         (-r|--random)
             random="${2}"; shift 2
             ;;
+        (-t|--toolchains)
+            url="${2}"; shift 2
+            ;;
         (--)
             shift; break
             ;;
@@ -44,10 +48,16 @@ main() {
         dir="${HOME}/br-test-pkg"
     fi
 
+    # Transform local paths to URI to make curl happy and simplify
+    # our code path
+    case "${url}" in
+    (/*)    url="file://${url}";;
+    esac
+
     # Extract the URLs of the toolchains; drop internal toolchains
     # E.g.: http://server/path/to/name.config,arch,libc
     #  -->  http://server/path/to/name.config
-    toolchains=( $( curl -s "${TOOLCHAINS_URL}" \
+    toolchains=( $( curl -s "${url}" \
                     |sed -r -e 's/,.*//; /internal/d;' \
                     |if [ ${random} -gt 0 ]; then \
                         sort -R |head -n ${random}
@@ -102,6 +112,12 @@ build_one() {
     local pkg="${4}"
     local toolchain line skip
 
+    # Transform local paths to URI to make curl happy and simplify
+    # our code path
+    case "${url}" in
+    (/*)    url="file://${url}";;
+    esac
+
     # Using basename(1) on a URL works nicely
     toolchain="$( basename "${url}" .config )"
 
@@ -179,8 +195,22 @@ In case failures are noticed, you can fix the package and just re-run the
 same command again; it will re-run the test where it failed. If you did
 specify a package (with -p), the package build dir will be removed first.
 
-The list of toolchains is retrieved from the Buildroot autobuilders, available
-at ${TOOLCHAINS_URL}.
+Unless specified with -t, the list of toolchains is retrieved from the
+Buildroot autobuilders, available at:
+    ${TOOLCHAINS_URL}
+
+The list of toolchains should contain the URLs to all toolchains, one per
+line, along with the architecture and C library used, separated by commas,
+"URL,ARCH,LIBC" (only the first field, URL, is used by this script). For
+example:
+
+    https://server/path/to/toolchain-1.config,arm,glibc
+    /path/to/local-toolchain.config,i386,musl
+
+The URL for each toolchain should point to a .config file that contains
+only the toolchain and architecture settings. URLs that contain the string
+'internal' are skipped, on the assumption that the configuration would
+build an internal toolchain (which takes a lot of time).
 
 Options:
 
@@ -202,6 +232,11 @@ Options:
         Limit the tests to the N randomly selected toolchains, instead of
         building with all toolchains.
 
+    -t URL, --toolchains URL
+        Use the toolchains described at URL instead of the toolchains used
+        by the Buildroot autobuilders (see above). URL can be a path to a
+        local file.
+
 Example:
 
     Testing libcec would require a config snippet that contains:
Signature · 1 line
2.7.4
#22 lore raw

PATCH 5/6 support/test-pkg: add option to use an alternate list of toolchains

Quoted 70 lines · Yann E. MORIN

For now, testing a package requires network access. However, there are situations where everything is already cached locally (especially the toolchains tarballs) and network is not available (e.g. in the train, travelling back from FOSDEM...)

Alternatively, one may also want to test against a subset of the default toolchains (e.g. the ones known to have a specific issue).

Add an option to use an alternate URL, which can be remote or a path to a local file.

---
 support/scripts/test-pkg | 47 +++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 41 insertions(+), 6 deletions(-)
support/scripts/test-pkg +14 -4
index 59c9f23..e77c804 100755
@@ -5,16 +5,17 @@ TOOLCHAINS_URL='http://autobuild.buildroot.org/toolchains/configs/toolchain-conf
 
 main() {
     local o O opts
-    local cfg dir pkg random toolchain
+    local cfg dir pkg random url toolchain
     local ret nb_dl nb_cfg nb_skip nb_clean nb_build
     local -a toolchains
 
-    o='hc:d:p:r:'
-    O='help,config-snippet:build-dir:package:,random:'
+    o='hc:d:p:r:t:'
+    O='help,config-snippet:build-dir:package:,random:,toolchains:'
     opts="$( getopt -n "${my_name}" -o "${o}" -l "${O}" -- "${@}"  )"
     eval set -- "${opts}"
 
     random=0
+    url="${TOOLCHAINS_URL}"
     while [ ${#} -gt 0 ]; do
         case "${1}" in
         (-h|--help)
@@ -32,6 +33,9 @@ main() {
         (-r|--random)
             random="${2}"; shift 2
             ;;
+        (-t|--toolchains)
+            url="${2}"; shift 2
+            ;;
         (--)
             shift; break
             ;;
@@ -44,10 +48,16 @@ main() {
         dir="${HOME}/br-test-pkg"
     fi
 
+    # Transform local paths to URI to make curl happy and simplify
+    # our code path
+    case "${url}" in
+    (/*)    url="file://${url}";;
+    esac
+
     # Extract the URLs of the toolchains; drop internal toolchains
     # E.g.: http://server/path/to/name.config,arch,libc
     #  -->  http://server/path/to/name.config
-    toolchains=( $( curl -s "${TOOLCHAINS_URL}" \
+    toolchains=( $( curl -s "${url}" \
                     |sed -r -e 's/,.*//; /internal/d;' \
                     |if [ ${random} -gt 0 ]; then \
                         sort -R |head -n ${random}

support/scripts/test-pkg build_one() { · line 119

Quoted 8 lines
support/scripts/test-pkg +5 -0
@@ -102,6 +112,12 @@ build_one() {
     local pkg="${4}"
     local toolchain line skip
 
+    # Transform local paths to URI to make curl happy and simplify
+    # our code path
+    case "${url}" in
+    (/*)    url="file://${url}";;
+    esac

Some duplication that could be extracted to a function?

#23 lore raw

PATCH v3 5/6 support/test-pkg: add option to use an alternate list of toolchains

Thomas DS, All,

On 2017-02-11 20:53 +0100, Thomas De Schampheleire spake thusly:

Quoted 11 lines · Yann E. MORIN
Quoted 10 lines

For now, testing a package requires network access. However, there are situations where everything is already cached locally (especially the toolchains tarballs) and network is not available (e.g. in the train, travelling back from FOSDEM...)

Alternatively, one may also want to test against a subset of the default toolchains (e.g. the ones known to have a specific issue).

Add an option to use an alternate URL, which can be remote or a path to a local file.

[--SNIP--]

Quoted 18 lines
Quoted 18 lines
support/scripts/test-pkg +7 -1
+    # Transform local paths to URI to make curl happy and simplify
+    # our code path
+    case "${url}" in
+    (/*)    url="file://${url}";;
+    esac
+
     # Extract the URLs of the toolchains; drop internal toolchains
     # E.g.: http://server/path/to/name.config,arch,libc
     #  -->  http://server/path/to/name.config
-    toolchains=( $( curl -s "${TOOLCHAINS_URL}" \
+    toolchains=( $( curl -s "${url}" \
                     |sed -r -e 's/,.*//; /internal/d;' \
                     |if [ ${random} -gt 0 ]; then \
                         sort -R |head -n ${random}
@@ -102,6 +112,12 @@ build_one() {
     local pkg="${4}"
     local toolchain line skip
 
Quoted 7 lines

support/scripts/test-pkg main() { · line 55

Quoted 5 lines
support/scripts/test-pkg +5 -0
+    # Transform local paths to URI to make curl happy and simplify
+    # our code path
+    case "${url}" in
+    (/*)    url="file://${url}";;
+    esac

Some duplication that could be extracted to a function?

I wondered as much, too, but this is really trivial code. Also, if this gets to be a function, then that would have to be used using shell expansion, like:

    url="$(canonical_url "${url}")"

which does not look very nice either.

So I believe duplication is acceptable in this case.

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.  |
'------------------------------^-------^------------------^--------------------'
#24 lore raw

PATCH v3 6/6 support/test-pkg: print number of toolchain and progress

In reply to Yann E. MORIN
---
 support/scripts/test-pkg | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
support/scripts/test-pkg +13 -9
index e77c804..919200d 100755
@@ -6,7 +6,7 @@ TOOLCHAINS_URL='http://autobuild.buildroot.org/toolchains/configs/toolchain-conf
 main() {
     local o O opts
     local cfg dir pkg random url toolchain
-    local ret nb_dl nb_cfg nb_skip nb_clean nb_build
+    local ret nb nb_dl nb_cfg nb_skip nb_clean nb_build
     local -a toolchains
 
     o='hc:d:p:r:t:'
@@ -71,13 +71,18 @@ main() {
         printf "error: no toolchain found (networking issue?)\n" >&2; exit 1
     fi
 
+    printf "Found %d toolchains\n" ${#toolchains[@]}
+
+    nb=1
     nb_dl=0
     nb_cfg=0
     nb_skip=0
     nb_clean=0
     nb_build=0
     for toolchain in "${toolchains[@]}"; do
+        printf "%40s [%3d/%3d]: " "$( basename "${toolchain}" .config)" ${nb} ${#toolchains[@]}
         build_one "${dir}" "${toolchain}" "${cfg}" "${pkg}" && ret=0 || ret=${?}
+        printf "\n"
         case ${ret} in
         (0) ;;
         (1) : $((nb_dl++));;
@@ -86,6 +91,7 @@ main() {
         (4) : $((nb_clean++));;
         (5) : $((nb_build++));;
         esac
+        : $((nb++))
     done
 
     if [ ${nb_dl} -ne 0 ]; then
@@ -121,14 +127,12 @@ build_one() {
     # Using basename(1) on a URL works nicely
     toolchain="$( basename "${url}" .config )"
 
-    printf "%40s: " "${toolchain}"
-
     dir="${dir}/${toolchain}"
     mkdir -p "${dir}"
 
     printf "download config"
     if ! curl -s "${url}" >"${dir}/.config"; then
-        printf ": FAILED\n"
+        printf ": FAILED"
         return 1
     fi
 
@@ -142,7 +146,7 @@ build_one() {
 
     printf ", olddefconfig"
     if ! make O="${dir}" olddefconfig >/dev/null 2>&1; then
-        printf ": FAILED\n"
+        printf ": FAILED"
         return 2
     fi
     # We want all the options from the snippet to be present as-is (set
@@ -157,7 +161,7 @@ build_one() {
         fi
     done <"${cfg}" >"${dir}/missing.config"
     if ${skip}; then
-        printf ", SKIPPED\n"
+        printf ", SKIPPED"
         return 3
     fi
     # Remove file, it's empty anyway.
@@ -166,7 +170,7 @@ build_one() {
     if [ -n "${pkg}" ]; then
         printf ", dirclean"
         if ! make O="${dir}" "${pkg}-dirclean" >> "${dir}/logfile" 2>&1; then
-            printf ": FAILED\n"
+            printf ": FAILED"
             return 4
         fi
     fi
@@ -174,11 +178,11 @@ build_one() {
     printf ", build"
     # shellcheck disable=SC2086
     if ! make O="${dir}" ${pkg} >> "${dir}/logfile" 2>&1; then
-        printf ": FAILED\n"
+        printf ": FAILED"
         return 5
     fi
 
-    printf ": OK\n"
+    printf ": OK"
 }
 
 help() {
Signature · 1 line
2.7.4
#25 lore raw

PATCH 6/6 support/test-pkg: print number of toolchain and progress

Quoted 22 lines · Yann E. MORIN
---
 support/scripts/test-pkg | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
support/scripts/test-pkg +1 -1
index e77c804..919200d 100755
@@ -6,7 +6,7 @@ TOOLCHAINS_URL='http://autobuild.buildroot.org/toolchains/configs/toolchain-conf
 main() {
     local o O opts
     local cfg dir pkg random url toolchain
-    local ret nb_dl nb_cfg nb_skip nb_clean nb_build
+    local ret nb nb_dl nb_cfg nb_skip nb_clean nb_build
     local -a toolchains
 
     o='hc:d:p:r:t:'
@@ -71,13 +71,18 @@ main() {
         printf "error: no toolchain found (networking issue?)\n" >&2; exit 1
     fi
 

support/scripts/test-pkg main() { · line 83

Quoted 10 lines
support/scripts/test-pkg +4 -0
+    printf "Found %d toolchains\n" ${#toolchains[@]}
+
+    nb=1
     nb_dl=0
     nb_cfg=0
     nb_skip=0
     nb_clean=0
     nb_build=0
     for toolchain in "${toolchains[@]}"; do
+        printf "%40s [%3d/%3d]: " "$( basename "${toolchain}" .config)" ${nb} ${#toolchains[@]}

Do you expect more than 99 toolchains very soon?
I know it's a nit, but the following does not look very nice IMHO: [ 2/ 48] I would either use %2d for the counters, or alternatively:

nbfmt="%d"
if [ ${#toolchains[@]} -gt 9 ]; then

    nbfmt="%2d"
elif [ ${#toolchains[@]} -gt 99 ]; then
    nbfmt="%3d"

fi

Regardless:

#26 lore raw

PATCH v3 6/6 support/test-pkg: print number of toolchain and progress

Thomas DS, All,

On 2017-02-11 21:09 +0100, Thomas De Schampheleire spake thusly:

Quoted 43 lines · Yann E. MORIN
Quoted 22 lines
---
 support/scripts/test-pkg | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
support/scripts/test-pkg +1 -1
index e77c804..919200d 100755
@@ -6,7 +6,7 @@ TOOLCHAINS_URL='http://autobuild.buildroot.org/toolchains/configs/toolchain-conf
 main() {
     local o O opts
     local cfg dir pkg random url toolchain
-    local ret nb_dl nb_cfg nb_skip nb_clean nb_build
+    local ret nb nb_dl nb_cfg nb_skip nb_clean nb_build
     local -a toolchains
 
     o='hc:d:p:r:t:'
@@ -71,13 +71,18 @@ main() {
         printf "error: no toolchain found (networking issue?)\n" >&2; exit 1
     fi
 

support/scripts/test-pkg main() { · line 83

Quoted 10 lines
support/scripts/test-pkg +4 -0
+    printf "Found %d toolchains\n" ${#toolchains[@]}
+
+    nb=1
     nb_dl=0
     nb_cfg=0
     nb_skip=0
     nb_clean=0
     nb_build=0
     for toolchain in "${toolchains[@]}"; do
+        printf "%40s [%3d/%3d]: " "$( basename "${toolchain}" .config)" ${nb} ${#toolchains[@]}

Do you expect more than 99 toolchains very soon?
I know it's a nit, but the following does not look very nice IMHO: [ 2/ 48] I would either use %2d for the counters, or alternatively:

nbfmt="%d"
if [ ${#toolchains[@]} -gt 9 ]; then

    nbfmt="%2d"
elif [ ${#toolchains[@]} -gt 99 ]; then
    nbfmt="%3d"
Quoted 6 lines

fi

Regardless:

Thanks, but I eventually dropped that patch from the series. It does not bring much in the end.

If people argue that it is better to keep it, I can re-instate it.

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.  |
'------------------------------^-------^------------------^--------------------'
#27 lore raw

PATCH 6/6 support/test-pkg: print number of toolchain and progress

On Feb 11, 2017 23:25, "Yann E. MORIN" <[email protected]> wrote:

Thomas DS, All,

On 2017-02-11 21:09 +0100, Thomas De Schampheleire spake thusly:

Quoted 1 line

On Wed, Feb 8, 2017 at 9:15 PM, Yann E. MORIN <[email protected]>

Quoted 10 lines · wrote:

support/scripts/test-pkg TOOLCHAINS_URL='http://autobuild.buildroot.org/

Quoted 10 lines
---
 support/scripts/test-pkg | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
support/scripts/test-pkg +0 -0
index e77c804..919200d 100755
@@ -6,7 +6,7 @@ TOOLCHAINS_URL='http://autobuild.buildroot.org/

toolchains/configs/toolchain-conf

Quoted 10 lines

support/scripts/test-pkg main() { · line 71

Quoted 10 lines
support/scripts/test-pkg +1 -1
 main() {
     local o O opts
     local cfg dir pkg random url toolchain
-    local ret nb_dl nb_cfg nb_skip nb_clean nb_build
+    local ret nb nb_dl nb_cfg nb_skip nb_clean nb_build
     local -a toolchains
 
     o='hc:d:p:r:t:'
@@ -71,13 +71,18 @@ main() {
         printf "error: no toolchain found (networking issue?)\n" >&2;

exit 1

Quoted 12 lines

support/scripts/test-pkg main() {

Quoted 12 lines
support/scripts/test-pkg +4 -0
     fi
 
+    printf "Found %d toolchains\n" ${#toolchains[@]}
+
+    nb=1
     nb_dl=0
     nb_cfg=0
     nb_skip=0
     nb_clean=0
     nb_build=0
     for toolchain in "${toolchains[@]}"; do
+        printf "%40s [%3d/%3d]: " "$( basename "${toolchain}"

.config)" ${nb} ${#toolchains[@]}

Quoted 3 lines

Do you expect more than 99 toolchains very soon?
I know it's a nit, but the following does not look very nice IMHO: [ 2/

48]

Quoted 7 lines

I would either use %2d for the counters, or alternatively:

nbfmt="%d"
if [ ${#toolchains[@]} -gt 9 ]; then

    nbfmt="%2d"
elif [ ${#toolchains[@]} -gt 99 ]; then
    nbfmt="%3d"
Quoted 6 lines

fi

Regardless:

Thanks, but I eventually dropped that patch from the series. It does not bring much in the end.

If people argue that it is better to keep it, I can re-instate it.

For my part, I think there is value in such progress indication...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20170212/9daefa86/attachment.html>

#28 lore raw

PATCH v3 6/6 support/test-pkg: print number of toolchain and progress

Thomas DS, All,

On 2017-02-12 07:40 +0100, Thomas De Schampheleire spake thusly:

Quoted 1 line · Yann E. MORIN

[--SNIP--]

Quoted 6 lines
Quoted 4 lines

Thanks, but I eventually dropped that patch from the series. It does not bring much in the end.

If people argue that it is better to keep it, I can re-instate it.

For my part, I think there is value in such progress indication...

I heard thy complain; I shall then reinstate the progress. ;-)

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.  |
'------------------------------^-------^------------------^--------------------'