From: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v2 3/3] Add test infrastructure
Date: Sun, 4 Mar 2012 14:03:16 +0100 [thread overview]
Message-ID: <1330866196-5360-3-git-send-email-arnout@mind.be> (raw)
In-Reply-To: <1330866196-5360-1-git-send-email-arnout@mind.be>
From: "Arnout Vandecappelle (Essensium/Mind)" <arnout@mind.be>
The test infrastructure is a script and a list of tests to be run.
Additional test configurations can be added later to the test directory.
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
.topdeps | 3 +-
.topmsg | 13 ++++-
test/runtests.sh | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
test/testspecs | 24 +++++++++++
4 files changed, 158 insertions(+), 4 deletions(-)
create mode 100755 test/runtests.sh
create mode 100644 test/testspecs
diff --git a/.topdeps b/.topdeps
index 1f7391f..bbe331b 100644
--- a/.topdeps
+++ b/.topdeps
@@ -1 +1,2 @@
-master
+t/print-version
+t/defconfig
diff --git a/.topmsg b/.topmsg
index b431fc4..3a90662 100644
--- a/.topmsg
+++ b/.topmsg
@@ -1,7 +1,14 @@
From: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
-Subject: [PATCH] Add target to print buildroot version
+Subject: [PATCH] Add test infrastructure
-It's convenient to have a target to print the buildroot version, for use
-in external scripts calling buildroot.
+The test infrastructure is a script and a list of tests to be run.
+Additional test configurations can be added later to the test directory.
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
+---
+Changes v2:
+ - Fixed support for defconfig and *packageconfig
+ - This now depends on the BR2_DEFCONFIG patch
+ - Use printf instead of echo (feedback from Yann)
+ - Use ${...} for all variable references (feedback from Yann)
+ - Put quotes around everything (feedback from Yann)
diff --git a/test/runtests.sh b/test/runtests.sh
new file mode 100755
index 0000000..6a4af2d
--- /dev/null
+++ b/test/runtests.sh
@@ -0,0 +1,122 @@
+#! /bin/sh
+# Run test builds of buildroot
+# runtest.sh <testspec>...
+#
+# testspec: <baseconfig>[=<type>,...]
+# A testspec is a config file name (relative to the buildroot top dir),
+# optionally followed by a comma-separated list of config types.
+# Config types are: def, rand, allyes, allno, randpackage, allyespackage,
+# allnopackage
+# If config types are not given, it is taken from a line containing
+# CONFIGTYPES= in the baseconfig. If that is also not present, def
+# and randpackage are tried.
+#
+# If no arguments are given, the testspecs are taken from the testspecs
+# file in the current directory. If that file doesn't exist, the testspecs
+# file in the test directory is taken.
+#
+# The output goes into the current directory.
+
+testdir="$(dirname ${0})"
+topdir="$(cd ${testdir}/..; pwd)"
+
+configdir="${PWD}/gen-config"
+brversion="$(make -C ${topdir} --no-print-directory print-version)"
+
+printf 'Running tests for %s\n' "${brversion}"
+
+# Run build for config $1 with type $2
+function runbuild() {
+ baseconfig="${1}"
+ configtype="${2}"
+
+ printf 'Building %s %sconfig\n' "${baseconfig}" "${configtype}"
+
+ # Interprete baseconfig relative to topdir
+ if [ "${baseconfig:0:1}" = / ]; then
+ baseconfigfile="${baseconfig}"
+ else
+ baseconfigfile="${topdir}/${baseconfig}"
+ fi
+
+ if [ ! -r "${baseconfigfile}" ]; then
+ printf ' *** %s not found\n' "${baseconfig}"
+ return 1
+ fi
+
+ configname="${brversion}-$(basename ${baseconfig})"
+ hostdir="${PWD}/${configname}.hostdir"
+
+ # Create the configtype from baseconfig.
+ # defconfig is a special case because it needs to be passed in
+ # a different way. *packageconfig are also special, because
+ # they need a complete config (not just defconfig) as input, otherwise
+ # the package hack doesn't work, so we need to run make defconfig first.
+ mkdir -p "${configdir}"
+ cp "${baseconfigfile}" "${configdir}/.config.in"
+ printf 'BR2_HOST_DIR="%s"\n' "${hostdir}" >> "${configdir}/.config.in"
+ if [ "${configtype}" = "def" -o "${configtype%*package}" != "${configtype}" ]; then
+ make -C "${topdir}" O="${configdir}" defconfig BR2_DEFCONFIG="${configdir}/.config.in" > "${configdir}.log" || {
+ printf ' *** make defconfig failed for %s\n' "${baseconfig}"
+ return 1
+ }
+ else
+ mv "${configdir}/.config.in" "${configdir}/.config"
+ fi
+ if [ "${configtype}" != "def" ]; then
+ make -C "${topdir}" O="${configdir}" "${configtype}config" > "${configdir}.log" || {
+ printf ' *** make %sconfig failed for %s\n' "${configtype}" "${baseconfig}"
+ return 1
+ }
+ fi
+
+ # Add the sha of the config file to its name, so we can uniquely
+ # identify it. This allows us to remove duplicates, e.g. defconfig
+ # and allnoconfig.
+ fullconfigname="${configname}-$(sha1sum "${configdir}/.config" | cut -c -40)"
+ if [ -e "${fullconfigname}.success" ]; then
+ printf ' %s already built successfully; skipping\n' "${fullconfigname}"
+ return 0
+ fi
+ printf ' Generated %s\n' "${fullconfigname}"
+
+ # Save the defconfig of this config for future reference.
+ make -C "${topdir}" --no-print-directory O="${configdir}" savedefconfig > /dev/null || {
+ printf ' *** Failed savedefconfig for %s\n' "${fullconfigname}"
+ return 1
+ }
+ cp "${configdir}/defconfig" "${fullconfigname}.defconfig"
+
+ outdir="${PWD}/${fullconfigname}.output"
+ logfile="${fullconfigname}.log"
+ mkdir -p "${outdir}"
+ cp "${configdir}/.config" "${outdir}"
+ make -C "${topdir}" O="${outdir}" > "${logfile}" 2>&1 || {
+ printf ' *** Failed %s - see log file for details\n' "${fullconfigname}"
+ touch "${fullconfigname}.failed"
+ #rm -rf ${outdir}
+ return 1
+ }
+
+ printf ' Successfully built %s %sconfig\n' "${baseconfig}" "${configtype}"
+ touch "${fullconfigname}.success"
+ rm -rf "${outdir}"
+ bzip2 "${logfile}"
+}
+
+
+if [ "${1}" ]; then
+ testspecs="$*"
+elif [ -r testspecs ]; then
+ testspecs="$(cat testspecs)"
+else
+ testspecs="$(cat ${testdir}/testspecs)"
+fi
+
+for testspec in ${testspecs}; do
+ baseconfig="${testspec%=*}"
+ configtypes="${testspec#*=}"
+ for configtype in ${configtypes//,/ }; do
+ runbuild "${baseconfig}" "${configtype}"
+ done
+done
diff --git a/test/testspecs b/test/testspecs
new file mode 100644
index 0000000..2e3be3d
--- /dev/null
+++ b/test/testspecs
@@ -0,0 +1,24 @@
+configs/armadeus_apf9328_defconfig=def,randpackage
+configs/at91rm9200df_defconfig=def,randpackage
+configs/at91sam9260dfc_defconfig=def,randpackage
+configs/at91sam9261ek_defconfig=def,randpackage
+configs/at91sam9263ek_defconfig=def,randpackage
+configs/at91sam9g20dfc_defconfig=def,randpackage
+configs/atngw100_defconfig=def,randpackage
+configs/atstk100x_defconfig=def,randpackage
+configs/ea3250_defconfig=def,randpackage
+configs/fdi3250_defconfig=def,randpackage
+configs/integrator926_defconfig=def,randpackage
+configs/kb9202_defconfig=def,randpackage
+configs/mini2440_defconfig=def,randpackage
+configs/mx53loco_defconfig=def,randpackage
+configs/phy3250_defconfig=def,randpackage
+configs/qemu_arm_versatile_defconfig=def,randpackage
+configs/qemu_mips_malta_defconfig=def,randpackage
+configs/qemu_mipsel_malta_defconfig=def,randpackage
+configs/qemu_ppc_g3beige_defconfig=def,randpackage
+configs/qemu_sh4_r2d_defconfig=def,randpackage
+configs/qemu_sparc_ss10_defconfig=def,randpackage
+configs/qemu_x86_64_defconfig=def,randpackage
+configs/qemu_x86_defconfig=def,randpackage
+configs/sheevaplug_defconfig=def,randpackage
--
1.7.9.1
next prev parent reply other threads:[~2012-03-04 13:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-04 13:03 [Buildroot] [PATCH v2 1/3] Add target to print buildroot version Arnout Vandecappelle
2012-03-04 13:03 ` [Buildroot] [PATCH v2 2/3] config: make it possible to specify which config file to use for 'make defconfig' Arnout Vandecappelle
2012-03-05 9:37 ` Thomas Petazzoni
2012-03-05 9:58 ` Luca Ceresoli
2012-03-05 21:58 ` Felipe Contreras
2012-03-04 13:03 ` Arnout Vandecappelle [this message]
2012-03-04 13:22 ` [Buildroot] [PATCH v2 3/3] Add test infrastructure Arnout Vandecappelle
2012-03-05 9:39 ` Thomas Petazzoni
2012-03-06 7:09 ` Arnout Vandecappelle
2012-03-04 13:05 ` [Buildroot] [PATCH v2 1/3] Add target to print buildroot version Arnout Vandecappelle
2012-03-05 9:29 ` Luca Ceresoli
2012-03-06 7:11 ` Arnout Vandecappelle
2012-03-05 9:34 ` Thomas Petazzoni
2012-03-05 9:33 ` Thomas Petazzoni
2012-03-05 9:57 ` Luca Ceresoli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1330866196-5360-3-git-send-email-arnout@mind.be \
--to=arnout@mind.be \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox