4 TOOLCHAINS_CSV='support/config-fragments/autobuild/toolchain-configs.csv'
8 local cfg dir pkg random toolchains_dir toolchain
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}" -- "${@}")"
18 toolchains_csv="${TOOLCHAINS_CSV}"
19 while [ ${#} -gt 0 ]; do
34 random="${2}"; shift 2
37 toolchains_csv="${2}"; shift 2
44 if [ -z "${cfg}" ]; then
45 printf "error: no config snippet specified\n" >&2; exit 1
47 if [ ! -e "${cfg}" ]; then
48 printf "error: %s: no such file\n" "${cfg}" >&2; exit 1
50 if [ -z "${dir}" ]; then
51 dir="${HOME}/br-test-pkg"
54 # Extract the URLs of the toolchains; drop internal toolchains
55 # E.g.: http://server/path/to/name.config,arch,libc
56 # --> http://server/path/to/name.config
57 toolchains=($(sed -r -e 's/,.*//; /internal/d; /^#/d; /^$/d;' "${toolchains_csv}" \
58 |if [ ${random} -gt 0 ]; then \
59 sort -R |head -n ${random}
66 nb_tc="${#toolchains[@]}"
67 if [ ${nb_tc} -eq 0 ]; then
68 printf "error: no toolchain found (networking issue?)\n" >&2; exit 1
75 for toolchainconfig in "${toolchains[@]}"; do
77 toolchain="$(basename "${toolchainconfig}" .config)"
78 build_dir="${dir}/${toolchain}"
79 printf "%40s [%*d/%d]: " "${toolchain}" ${#nb_tc} ${nb} ${nb_tc}
80 build_one "${build_dir}" "${toolchainconfig}" "${cfg}" "${pkg}" && ret=0 || ret=${?}
83 (1) : $((nb_skip++)); printf "SKIPPED\n";;
84 (2) : $((nb_fail++)); printf "FAILED\n";;
85 (3) : $((nb_legal++)); printf "FAILED\n";;
89 printf "%d builds, %d skipped, %d build failed, %d legal-info failed\n" \
90 ${nb} ${nb_skip} ${nb_fail} ${nb_legal}
95 local toolchainconfig="${2}"
101 support/kconfig/merge_config.sh -O "${dir}" \
102 "${toolchainconfig}" "support/config-fragments/minimal.config" "${cfg}" \
104 # We want all the options from the snippet to be present as-is (set
105 # or not set) in the actual .config; if one of them is not, it means
106 # some dependency from the toolchain or arch is not available, in
107 # which case this config is untestable and we skip it.
108 # We don't care about the locale to sort in, as long as both sort are
109 # done in the same locale.
110 comm -23 <(sort "${cfg}") <(sort "${dir}/.config") >"${dir}/missing.config"
111 if [ -s "${dir}/missing.config" ]; then
114 # Remove file, it's empty anyway.
115 rm -f "${dir}/missing.config"
117 if [ -n "${pkg}" ]; then
118 if ! make O="${dir}" "${pkg}-dirclean" >> "${dir}/logfile" 2>&1; then
123 # shellcheck disable=SC2086
124 if ! make O="${dir}" ${pkg} >> "${dir}/logfile" 2>&1; then
128 # legal-info done systematically, because some packages have different
129 # sources depending on the configuration (e.g. lua-5.2 vs. lua-5.3)
130 if ! make O="${dir}" legal-info >> "${dir}/logfile" 2>&1; then
137 test-pkg: test-build a package against various toolchains and architectures
139 The supplied config snippet is appended to each toolchain config, the
140 resulting configuration is checked to ensure it still contains all options
141 specified in the snippet; if any is missing, the build is skipped, on the
142 assumption that the package under test requires a toolchain or architecture
143 feature that is missing.
145 In case failures are noticed, you can fix the package and just re-run the
146 same command again; it will re-run the test where it failed. If you did
147 specify a package (with -p), the package build dir will be removed first.
149 The list of toolchains is retrieved from ${TOOLCHAINS_CSV}.
150 Only the external toolchains are tried, because building a Buildroot toolchain
151 would take too long. An alternative toolchains CSV file can be specified with
152 the -t option. This file should have lines consisting of the path to the
153 toolchain config fragment and the required host architecture, separated by a
154 comma. The config fragments should contain only the toolchain and architecture
162 -c CFG, --config-snippet CFG
163 Use the CFG file as the source for the config snippet. This file
164 should contain all the config options required to build a package.
166 -d DIR, --build-dir DIR
167 Do the builds in directory DIR, one sub-dir per toolchain.
169 -p PKG, --package PKG
170 Test-build the package PKG, by running 'make PKG'; if not specified,
174 Limit the tests to the N randomly selected toolchains, instead of
175 building with all toolchains.
177 -t CSVFILE, --toolchains-csv CSVFILE
178 CSV file containing the paths to config fragments of toolchains to
179 try. If not specified, the toolchains in ${TOOLCHAINS_CSV} will be
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