utils/test-pkg: add mode to only prepare .config files

Currently, running test-pkg is only done locally on the developers
machine.

In a follow up commit, we'll add the possibility to run test-pkg in a
gitlab-ci pipeline and, to speed things up, with one job per buildable
configuration.

As such, we will need to make sure that test-pkg only prepares the
configurations, and that it does not build them.

Add such a mode, with a new option, --prepare-only

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Romain Naour <romain.naour@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Signed-off-by: Romain Naour <romain.naour@gmail.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
This commit is contained in:
Yann E. MORIN 2021-08-21 15:46:45 +02:00 committed by Arnout Vandecappelle (Essensium/Mind)
parent 2ff7035394
commit a30204b005

View file

@ -12,13 +12,13 @@ do_clean() {
main() { main() {
local o O opts local o O opts
local cfg dir pkg random toolchains_csv toolchain all number mode local cfg dir pkg random toolchains_csv toolchain all number mode prepare_only
local ret nb nb_skip nb_fail nb_legal nb_tc build_dir keep local ret nb nb_skip nb_fail nb_legal nb_tc build_dir keep
local -a toolchains local -a toolchains
local pkg_br_name local pkg_br_name
o='hakc:d:n:p:r:t:' o='hakc:d:n:p:r:t:'
O='help,all,keep,config-snippet:,build-dir:,number:,package:,random:,toolchains-csv:' O='help,all,keep,prepare-only,config-snippet:,build-dir:,number:,package:,random:,toolchains-csv:'
opts="$(getopt -n "${my_name}" -o "${o}" -l "${O}" -- "${@}")" opts="$(getopt -n "${my_name}" -o "${o}" -l "${O}" -- "${@}")"
eval set -- "${opts}" eval set -- "${opts}"
@ -27,6 +27,7 @@ main() {
keep=0 keep=0
number=0 number=0
mode=0 mode=0
prepare_only=0
toolchains_csv="${TOOLCHAINS_CSV}" toolchains_csv="${TOOLCHAINS_CSV}"
while [ ${#} -gt 0 ]; do while [ ${#} -gt 0 ]; do
case "${1}" in case "${1}" in
@ -39,6 +40,9 @@ main() {
(-k|--keep) (-k|--keep)
keep=1; shift 1 keep=1; shift 1
;; ;;
(--prepare-only)
prepare_only=1; shift 1
;;
(-c|--config-snippet) (-c|--config-snippet)
cfg="${2}"; shift 2 cfg="${2}"; shift 2
;; ;;
@ -127,7 +131,7 @@ main() {
toolchain="$(basename "${toolchainconfig}" .config)" toolchain="$(basename "${toolchainconfig}" .config)"
build_dir="${dir}/${toolchain}" build_dir="${dir}/${toolchain}"
printf "%40s [%*d/%d]: " "${toolchain}" ${#nb_tc} ${nb} ${nb_tc} printf "%40s [%*d/%d]: " "${toolchain}" ${#nb_tc} ${nb} ${nb_tc}
build_one "${build_dir}" "${toolchainconfig}" "${cfg}" "${pkg}" && ret=0 || ret=${?} build_one "${build_dir}" "${toolchainconfig}" "${cfg}" "${pkg}" "${prepare_only}" && ret=0 || ret=${?}
case ${ret} in case ${ret} in
(0) printf "OK\n";; (0) printf "OK\n";;
(1) : $((nb_skip++)); printf "SKIPPED\n";; (1) : $((nb_skip++)); printf "SKIPPED\n";;
@ -147,6 +151,7 @@ build_one() {
local toolchainconfig="${2}" local toolchainconfig="${2}"
local cfg="${3}" local cfg="${3}"
local pkg="${4}" local pkg="${4}"
local prepare_only="${5}"
mkdir -p "${dir}" mkdir -p "${dir}"
@ -170,6 +175,11 @@ build_one() {
# Remove file, it's empty anyway. # Remove file, it's empty anyway.
rm -f "${dir}/missing.config" rm -f "${dir}/missing.config"
# Defer building the job to the caller (e.g. a gitlab pipeline)
if [ ${prepare_only} -eq 1 ]; then
return 0
fi
if [ -n "${pkg}" ]; then if [ -n "${pkg}" ]; then
if ! make O="${dir}" "${pkg}-dirclean" >> "${dir}/logfile" 2>&1; then if ! make O="${dir}" "${pkg}-dirclean" >> "${dir}/logfile" 2>&1; then
return 2 return 2
@ -257,6 +267,10 @@ Options:
Note: the logfile and configuration is always retained, even without Note: the logfile and configuration is always retained, even without
this option. this option.
--prepare-only
Only prepare the .config files, but do not build them. Output the
list of build directories to stdout, and the status on stderr.
Example: Example:
Testing libcec would require a config snippet that contains: Testing libcec would require a config snippet that contains: