4 TOOLCHAINS_URL
='http://autobuild.buildroot.org/toolchains/configs/toolchain-configs.csv'
8 local cfg dir pkg random toolchain
9 local ret nb nb_skip nb_fail
13 O
='help,config-snippet:build-dir:package:,random:'
14 opts
="$(getopt -n "${my_name}" -o "${o}" -l "${O}" -- "${@}")"
18 while [ ${#} -gt 0 ]; do
33 random
="${2}"; shift 2
40 if [ -z "${cfg}" ]; then
41 printf "error: no config snippet specified\n" >&2; exit 1
43 if [ ! -e "${cfg}" ]; then
44 printf "error: %s: no such file\n" "${cfg}" >&2; exit 1
46 if [ -z "${dir}" ]; then
47 dir
="${HOME}/br-test-pkg"
50 # Extract the URLs of the toolchains; drop internal toolchains
51 # E.g.: http://server/path/to/name.config,arch,libc
52 # --> http://server/path/to/name.config
53 toolchains
=($
(curl
-s "${TOOLCHAINS_URL}" \
54 |
sed -r -e 's/,.*//; /internal/d;' \
55 |
if [ ${random} -gt 0 ]; then \
56 sort -R |
head -n ${random}
63 if [ ${#toolchains[@]} -eq 0 ]; then
64 printf "error: no toolchain found (networking issue?)\n" >&2; exit 1
70 for toolchain
in "${toolchains[@]}"; do
71 build_one
"${dir}" "${toolchain}" "${cfg}" "${pkg}" && ret=0 || ret=${?}
74 (1) : $((nb_skip++));;
75 (2) : $((nb_fail++));;
80 printf "%d builds
, %d skipped
, %d failed
\n" ${nb} ${nb_skip} ${nb_fail}
90 # Using basename(1) on a URL works nicely
91 toolchain="$
(basename "${url}" .config
)"
93 printf "%40s
: " "${toolchain}"
95 dir="${dir}/${toolchain}"
98 if ! curl -s "${url}" >"${dir}/.config
"; then
103 cat >>"${dir}/.config
" <<-_EOF_
105 BR2_SYSTEM_BIN_SH_NONE=y
106 # BR2_PACKAGE_BUSYBOX is not set
107 # BR2_TARGET_ROOTFS_TAR is not set
109 cat "${cfg}" >>"${dir}/.config
"
111 if ! make O="${dir}" olddefconfig > "${dir}/logfile
" 2>&1; then
115 # We want all the options from the snippet to be present as-is (set
116 # or not set) in the actual .config; if one of them is not, it means
117 # some dependency from the toolchain or arch is not available, in
118 # which case this config is untestable and we skip it.
119 # We don't care about the locale to sort in, as long as both sort are
120 # done in the same locale.
121 comm -23 <(sort "${cfg}") <(sort "${dir}/.config") >"${dir}/missing.config
"
122 if [ -s "${dir}/missing.config
" ]; then
126 # Remove file, it's empty anyway.
127 rm -f "${dir}/missing.config
"
129 if [ -n "${pkg}" ]; then
130 if ! make O="${dir}" "${pkg}-dirclean" >> "${dir}/logfile
" 2>&1; then
136 # shellcheck disable=SC2086
137 if ! make O="${dir}" ${pkg} >> "${dir}/logfile
" 2>&1; then
147 test-pkg: test-build a package against various toolchains and architectures
149 The supplied config snippet is appended to each toolchain config, the
150 resulting configuration is checked to ensure it still contains all options
151 specified in the snippet; if any is missing, the build is skipped, on the
152 assumption that the package under test requires a toolchain or architecture
153 feature that is missing.
155 In case failures are noticed, you can fix the package and just re-run the
156 same command again; it will re-run the test where it failed. If you did
157 specify a package (with -p), the package build dir will be removed first.
159 The list of toolchains is retrieved from the Buildroot autobuilders, available
160 at ${TOOLCHAINS_URL}.
167 -c CFG, --config-snippet CFG
168 Use the CFG file as the source for the config snippet. This file
169 should contain all the config options required to build a package.
171 -d DIR, --build-dir DIR
172 Do the builds in directory DIR, one sub-dir per toolchain.
174 -p PKG, --package PKG
175 Test-build the package PKG, by running 'make PKG'; if not specified,
179 Limit the tests to the N randomly selected toolchains, instead of
180 building with all toolchains.
184 Testing libcec would require a config snippet that contains:
187 Testing libcurl with openSSL support would require a snippet such as:
188 BR2_PACKAGE_OPENSSL=y
189 BR2_PACKAGE_LIBCURL=y