4 TOOLCHAINS_CSV='support/config-fragments/autobuild/toolchain-configs.csv'
8 local cfg dir pkg random toolchains_dir toolchain all number mode
9 local ret nb nb_skip nb_fail nb_legal nb_tc build_dir
13 O='help,config-snippet:build-dir:package:,random:,toolchains-dir:'
14 opts="$(getopt -n "${my_name}" -o "${o}" -l "${O}" -- "${@}")"
21 toolchains_csv="${TOOLCHAINS_CSV}"
22 while [ ${#} -gt 0 ]; do
37 number="${2}"; shift 2
43 random="${2}"; shift 2
46 toolchains_csv="${2}"; shift 2
53 if [ -z "${cfg}" ]; then
54 printf "error: no config snippet specified\n" >&2; exit 1
56 if [ ! -e "${cfg}" ]; then
57 printf "error: %s: no such file\n" "${cfg}" >&2; exit 1
59 if [ -z "${dir}" ]; then
60 dir="${HOME}/br-test-pkg"
63 if [ ${random} -gt 0 ]; then
67 if [ ${number} -gt 0 ]; then
71 if [ ${all} -eq 1 ]; then
75 # Default mode is to test the N first toolchains, which have been
76 # chosen to be a good selection of toolchains.
77 if [ ${mode} -eq 0 ] ; then
79 elif [ ${mode} -gt 1 ] ; then
80 printf "error: --all, --number and --random are mutually exclusive\n" >&2; exit 1
83 # Extract the URLs of the toolchains; drop internal toolchains
84 # E.g.: http://server/path/to/name.config,arch,libc
85 # --> http://server/path/to/name.config
86 toolchains=($(sed -r -e 's/,.*//; /internal/d; /^#/d; /^$/d;' "${toolchains_csv}" \
87 |if [ ${random} -gt 0 ]; then \
88 sort -R |head -n ${random}
89 elif [ ${number} -gt 0 ]; then \
97 nb_tc="${#toolchains[@]}"
98 if [ ${nb_tc} -eq 0 ]; then
99 printf "error: no toolchain found (networking issue?)\n" >&2; exit 1
106 for toolchainconfig in "${toolchains[@]}"; do
108 toolchain="$(basename "${toolchainconfig}" .config)"
109 build_dir="${dir}/${toolchain}"
110 printf "%40s [%*d/%d]: " "${toolchain}" ${#nb_tc} ${nb} ${nb_tc}
111 build_one "${build_dir}" "${toolchainconfig}" "${cfg}" "${pkg}" && ret=0 || ret=${?}
114 (1) : $((nb_skip++)); printf "SKIPPED\n";;
115 (2) : $((nb_fail++)); printf "FAILED\n";;
116 (3) : $((nb_legal++)); printf "FAILED\n";;
120 printf "%d builds, %d skipped, %d build failed, %d legal-info failed\n" \
121 ${nb} ${nb_skip} ${nb_fail} ${nb_legal}
126 local toolchainconfig="${2}"
132 support/kconfig/merge_config.sh -O "${dir}" \
133 "${toolchainconfig}" "support/config-fragments/minimal.config" "${cfg}" \
135 # We want all the options from the snippet to be present as-is (set
136 # or not set) in the actual .config; if one of them is not, it means
137 # some dependency from the toolchain or arch is not available, in
138 # which case this config is untestable and we skip it.
139 # We don't care about the locale to sort in, as long as both sort are
140 # done in the same locale.
141 comm -23 <(sort "${cfg}") <(sort "${dir}/.config") >"${dir}/missing.config"
142 if [ -s "${dir}/missing.config" ]; then
145 # Remove file, it's empty anyway.
146 rm -f "${dir}/missing.config"
148 if [ -n "${pkg}" ]; then
149 if ! make O="${dir}" "${pkg}-dirclean" >> "${dir}/logfile" 2>&1; then
154 # shellcheck disable=SC2086
155 if ! make O="${dir}" ${pkg} >> "${dir}/logfile" 2>&1; then
159 # legal-info done systematically, because some packages have different
160 # sources depending on the configuration (e.g. lua-5.2 vs. lua-5.3)
161 if ! make O="${dir}" legal-info >> "${dir}/logfile" 2>&1; then
168 test-pkg: test-build a package against various toolchains and architectures
170 The supplied config snippet is appended to each toolchain config, the
171 resulting configuration is checked to ensure it still contains all options
172 specified in the snippet; if any is missing, the build is skipped, on the
173 assumption that the package under test requires a toolchain or architecture
174 feature that is missing.
176 In case failures are noticed, you can fix the package and just re-run the
177 same command again; it will re-run the test where it failed. If you did
178 specify a package (with -p), the package build dir will be removed first.
180 The list of toolchains is retrieved from ${TOOLCHAINS_CSV}.
181 Only the external toolchains are tried, because building a Buildroot toolchain
182 would take too long. An alternative toolchains CSV file can be specified with
183 the -t option. This file should have lines consisting of the path to the
184 toolchain config fragment and the required host architecture, separated by a
185 comma. The config fragments should contain only the toolchain and architecture
188 By default, a useful subset of toolchains is tested. If needed, all
189 toolchains can be tested (-a), an arbitrary number of toolchains (-n
190 in order, -r for random).
197 -c CFG, --config-snippet CFG
198 Use the CFG file as the source for the config snippet. This file
199 should contain all the config options required to build a package.
201 -d DIR, --build-dir DIR
202 Do the builds in directory DIR, one sub-dir per toolchain.
204 -p PKG, --package PKG
205 Test-build the package PKG, by running 'make PKG'; if not specified,
209 Test all toolchains, instead of the default subset defined by
210 Buildroot developers.
213 Test N toolchains, in the order defined in the toolchain CSV
217 Limit the tests to the N randomly selected toolchains.
219 -t CSVFILE, --toolchains-csv CSVFILE
220 CSV file containing the paths to config fragments of toolchains to
221 try. If not specified, the toolchains in ${TOOLCHAINS_CSV} will be
226 Testing libcec would require a config snippet that contains:
229 Testing libcurl with openSSL support would require a snippet such as:
230 BR2_PACKAGE_OPENSSL=y
231 BR2_PACKAGE_LIBCURL=y