aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAKASHI Takahiro <takahiro.akashi@linaro.org>2015-10-28 09:42:48 +0900
committerAKASHI Takahiro <takahiro.akashi@linaro.org>2015-10-28 17:40:56 +0900
commit1a11f87ca832a18ce6b2843b156abb223dbb6147 (patch)
treeeec2c135a60782a47bd706706ec5f0b14fde3000
parentafa6773301cb4c4b8276efd44836269dd094b622 (diff)
downloadkbuildtest-1a11f87ca832a18ce6b2843b156abb223dbb6147.tar.gz
second workable version
-rwxr-xr-xkbuildtest.sh183
1 files changed, 122 insertions, 61 deletions
diff --git a/kbuildtest.sh b/kbuildtest.sh
index 5b127d6..15e01b9 100755
--- a/kbuildtest.sh
+++ b/kbuildtest.sh
@@ -1,14 +1,18 @@
#!/bin/sh
+#
+# copyright 2015, AKASHI Takahiro
+# GPL v2
-GETOPTARGS="a:A:b:C:e:hi:Il:no:P:v"
+SELF=$0
+GETOPTARGS="a:A:b:C:e:hi:Il:no:p:Sv"
ARGS=$(getopt ${GETOPTARGS} $*)
function print_usage() {
- echo "Usage: $(basename ${SELF}) [options] <commit>"
+ echo "Usage: $(basename ${SELF}) [options] [<commit>]"
echo "options:"
echo " -a <config>...: forcedly add these configs"
echo " -A <ARCH>: overide ARCH"
- echo " -b <build dir>: passed to 'make' as -o"
+ echo " -b <build dir>: passed to 'make' as O="
echo " -C <CROSS_COMPILE>: overide CROSS_COMPILE"
echo " -e <config>...: exclude these configs"
echo " -h : help messages"
@@ -17,7 +21,8 @@ function print_usage() {
echo " -l <log root dir>"
echo " -n : not executing, but creating environment"
echo " -o <flag>...: passed to 'make' as flags"
-# echo " -P <param file>: parameter file, only used with -I"
+ echo " -p <param file>: re-use parameter file"
+# echo " -S : skip creating environment"
echo " -v : verbose messages"
echo "<commit>: commit object name to start from"
}
@@ -65,9 +70,12 @@ function parse_args() {
OFLAGS="$2"
OFLAGS=${OFLAGS//,/ }
shift 2;;
- -P)
+ -p)
PARAMFILE="$2"
shift 2;;
+ -S)
+ sflag="-S";
+ shift;;
-v)
vflag="-v";
ECHO=echo
@@ -79,11 +87,11 @@ function parse_args() {
done
# Infenior loop check
- if [ ! -z ${iflag} ]
+ if [ -n "${iflag}" ]
then
- if [ -z ${PARAMFILE} ]
+ if [ -z "${PARAMFILE}" ]
then
- echo "Inferior loop, but no -P specified"
+ echo "Inferior loop, but no -p specified"
exit 2
else
return
@@ -91,6 +99,17 @@ function parse_args() {
fi
# top level check
+ if [ -n "${PARAMFILE}" ]
+ then
+ if [ ! -f "${PARAMFILE}" ]
+ then
+ echo "${PARAMFILE} not found"
+ exit 2
+ fi
+ sflag="-S"
+ return
+ fi
+
if [ $# -eq 0 ]
then
print_usage
@@ -113,7 +132,7 @@ function parse_args() {
exit 2
fi
- if [ -z ${LOGROOTDIR} ]
+ if [ -z "${LOGROOTDIR}" ]
then
LOGROOTDIR="/tmp"
elif [ ! -d ${LOGROOTDIR} ]
@@ -122,7 +141,7 @@ function parse_args() {
exit 2
fi
- if [ -z ${BUILDTMPDIR} ]
+ if [ -z "${BUILDTMPDIR}" ]
then
BUILDTMPDIR="/tmp"
elif [ ! -d ${BUILDTMPDIR} ]
@@ -131,7 +150,7 @@ function parse_args() {
exit 2
fi
- if [ -z ${OFLAGS} ]
+ if [ -z "${OFLAGS}" ]
then
case "${ARCH}" in
x86)
@@ -144,8 +163,19 @@ function parse_args() {
OFLAGS=${OFLAGS//,/ }
fi
- ${ECHO} ARCH is ${ARCH}
- ${ECHO} CC is ${CROSS_COMPILE}gcc
+ ${ECHO} "ARCH:" ${ARCH}
+ ${ECHO} "CC: " ${CROSS_COMPILE}gcc
+}
+
+function check_patches {
+# echo doing git log --format=%h ${COMMIT}..HEAD
+ PATCHLIST=$(git log --format=%h ${COMMIT}..HEAD 2> /dev/null)
+ if [ $? -ne 0 ] || [ -z "${PATCHLIST}" ]
+ then
+ echo doubious commit: ${COMMIT}
+ exit 2
+ fi
+ ${ECHO} "Commits: " ${PATCHLIST}
}
function setup_env {
@@ -157,16 +187,17 @@ function setup_env {
mkdir ${LOGDIR}
mkdir ${BUILDDIR}
- ${ECHO} "Log directory is ${LOGDIR}"
- ${ECHO} "Build directory is ${BUILDDIR}"
+ ${ECHO} "Log dir: " ${LOGDIR}
+ ${ECHO} "Build dir:" ${BUILDDIR}
+ ${ECHO} ======
}
function save_env {
echo ADD_CONFIGS=\"${ADD_CONFIGS}\" >> ${PARAMFILE}
- if [ ! -z ${ARCH} ] ; then
+ if [ -n "${ARCH}" ] ; then
echo ARCH=${ARCH} >> ${PARAMFILE}
fi
- if [ ! -z ${CROSS_COMPILE} ] ; then
+ if [ -n "${CROSS_COMPILE}" ] ; then
echo CROSS_COMPILE=${CROSS_COMPILE} >> ${PARAMFILE}
fi
echo EXCL_CONFIGS=\"${EXCL_CONFIGS}\" >> ${PARAMFILE}
@@ -174,26 +205,16 @@ function save_env {
echo LOGDIR=${LOGDIR} >> ${PARAMFILE}
echo BUILDDIR=${BUILDDIR} >> ${PARAMFILE}
echo OFLAGS=\"${OFLAGS}\" >> ${PARAMFILE}
-# echo PATCHLIST="${PATCHLIST}" >> ${PARAMFILE}
-}
-
-function create_patchlist {
-# echo doing git log --format=%h ${COMMIT}..HEAD
- PATCHLIST=$(git log --format=%h ${COMMIT}..HEAD 2> /dev/null)
- if [ $? -ne 0 ] || [ -z "${PATCHLIST}" ]
- then
- echo doubious commit: ${COMMIT}
- exit 2
- fi
- ${ECHO} Patches are ${PATCHLIST}
+ echo COMMIT=${COMMIT} >> ${PARAMFILE}
}
function do_combo {
+# echo do_combo $1 - $2
if [ -z "$2" ]
then
- ${ECHO} Creating config $p/$i
mkdir ${LOGDIR}/$p/$i
- echo $1 | tr " " "\n" | sed 's/^\(CONFIG_[A-Za-z0-9_]*\)$/\1=y/' > ${LOGDIR}/$p/$i/kernel_config
+ ${ECHO} "$i:" $1
+ echo $1 | tr " " "\n" > ${LOGDIR}/$p/$i/kernel_config
i=$(expr $i + 1)
return
@@ -201,37 +222,46 @@ function do_combo {
local head=$(echo $2 | awk '{print $1}')
local tail=$(echo $2 | awk '{$1=""; print}')
-# echo 1111 - $1 2222 - $1
-# echo head - $head tail - $tail
+ local head_0=$(echo ${head} | sed 's/\(CONFIG_[A-Za-z0-9_]*\)=.*/\1/')
+ if [ "${head}" = "${head_0}" ]
+ then
+ local head_y="${head_0}=y"
+ else
+ local head_y=${head}
+ fi
+ local head_n="${head_0}=n"
if [ -z "${tail}" ]
then
- ${ECHO} Creating config $p/$i
mkdir ${LOGDIR}/$p/$i
- echo $1 $tail | tr " " "\n" | sed 's/^\(CONFIG_[A-Za-z0-9_]*\)$/\1=y/' > ${LOGDIR}/$p/$i/kernel_config
+ ${ECHO} "$i:" $1 $head_n
+ echo $1 $head_n | tr " " "\n" > ${LOGDIR}/$p/$i/kernel_config
i=$(expr $i + 1)
- ${ECHO} Creating config $p/$i
+
mkdir ${LOGDIR}/$p/$i
- echo $1 $head $tail | tr " " "\n" | sed 's/^\(CONFIG_[A-Za-z0-9_]*\)$/\1=y/' > ${LOGDIR}/$p/$i/kernel_config
+ ${ECHO} "$i:" $1 $head_y
+ echo $1 $head_y | tr " " "\n" > ${LOGDIR}/$p/$i/kernel_config
i=$(expr $i + 1)
return
fi
-# echo do_combo2 "$1" - "$tail"
- do_combo "$1" "$tail"
-# echo do_combo1 "$1 $head" - "$tail"
- do_combo "$1 $head" "$tail"
+ do_combo "$1 $head_n" "$tail"
+ do_combo "$1 $head_y" "$tail"
}
function create_configs {
+ ${ECHO} Creating configs for $p
+
ALLCONFIGS=${LOGDIR}/allconfigs
- if [ ! -z "${ADD_CONFIGS}" ]
+ if [ -n "${ADD_CONFIGS}" ]
then
ADD_CONFIGS=$(echo ${ADD_CONFIGS} | tr " " "\n" | \
- awk '{print "CONFIG_"$1}' | xargs echo)
+ awk '{print "CONFIG_"$1}' | \
+ sed -n -e '/\([^=]*\)=./p' -e 's/^\([^=]*\)$/&=y/p' | \
+ xargs echo)
fi
- if [ ! -z "${INCL_CONFIGS}" ]
+ if [ -n "${INCL_CONFIGS}" ]
then
INCL_CONFIGS=$(echo ${INCL_CONFIGS} | tr " " "\n" | \
awk '{print "CONFIG_"$1}' | xargs echo)
@@ -246,53 +276,71 @@ function create_configs {
s/config_/CONFIG_/gp
' - | (cat - ; echo ${INCL_CONFIGS}) | \
tr -s " " "\n" | sort | uniq | comm -23 - ${ALLCONFIGS} >> ${ALLCONFIGS}
+ l=$(tempfile -d /tmp)
+ sort ${ALLCONFIGS} | sed '/^$/d' > $l
+ mv -f $l ${ALLCONFIGS}
for e in ${EXCL_CONFIGS}
do
sed -i -e "/CONFIG_$e/d" ${ALLCONFIGS}
done
+ COMBO_CONFIGS=$(cat ${ALLCONFIGS} | \
+ sed -n -e '/\([^=]*\)=./p' -e 's/^\([^=]*\)$/&=y/p' | \
+ xargs echo)
i=1
- do_combo "${ADD_CONFIGS}" "$(cat ${ALLCONFIGS})"
+ do_combo "${ADD_CONFIGS}" "${COMBO_CONFIGS}"
}
function run_build_test {
-# make O=${BUILDDIR} defconfig > ${LOGDIR}/$p/$c/config.log 2>&1
+ make O=${BUILDDIR} defconfig > ${LOGDIR}/$p/$c/config.log 2>&1
cat ${LOGDIR}/$p/$c/kernel_config >> ${BUILDDIR}/.config
make O=${BUILDDIR} olddefconfig > ${LOGDIR}/$p/$c/config.log 2>&1
if [ $? -ne 0 ]
then
- echo $p/$c FAIL config >> ${LOGDIR}/results.log
+ echo $p/$c FAIL config >> ${LOGDIR}/results
return
fi
cp ${BUILDDIR}/.config ${LOGDIR}/$p/$c/kernel_config_build
- if [ ! -z ${nflag} ]
+ if [ -n "${nflag}" ]
then
return
fi
- ${ECHO} Do make O=${BUILDDIR} ${OFLAGS}
+ ${ECHO} $c: make O=${BUILDDIR} ${OFLAGS}
make O=${BUILDDIR} ${OFLAGS} > ${LOGDIR}/$p/$c/build.log 2>&1
if [ $? -eq 0 ]
then
echo $p/$c PASS
else
echo $p/$c FAIL
- fi >> ${LOGDIR}/results.log
+ fi >> ${LOGDIR}/results
+# test run
# ./baa
make O=${BUILDDIR} clean > ${LOGDIR}/$p/$c/clean.log 2>&1
}
function run_build_test_configs {
p=$(git log --format=%h -1)
- ${ECHO} Processing patch $p
mkdir ${LOGDIR}/$p
- create_configs
+ if [ -z "${sflag}" ]
+ then
+ create_configs
+ TESTS=$(seq 1 $(expr $i - 1))
+ else
+ TESTS=$(cd ${LOGDIR}/$p ; ls -v)
+ fi
+# echo TESTS are ${TESTS}
+
+ if [ -z ${nflag} ]
+ then
+ ${ECHO} Processing patch $p "($(echo ${TESTS} | xargs echo))"
+ fi
error=0
- for c in $(seq 1 $(expr $i - 1))
+ for c in ${TESTS}
do
run_build_test
if [ ${error} -ne 0 ]
@@ -303,24 +351,31 @@ function run_build_test_configs {
}
function run_build_test_loop {
+ make mrproper > /dev/null 2>&1
+
# for later git,
-# git rebase -x "${SELF}" -i ${COMMIT}
+# git rebase -x "${SELF} ..." -i ${COMMIT}
# or
-# export GIT_EDITOR="../inscmd.sh \"exec ${SELF} ${nflag} ${vflag} -I -P ${PARAMFILE} \""
- SED_CMD="/^pick /a exec ${SELF} ${nflag} ${vflag} -I -P ${PARAMFILE}"
+ SED_CMD="/^pick /a exec ${SELF} ${nflag} ${sflag} ${vflag} -I -p ${PARAMFILE}"
export GIT_EDITOR="sed -i -e '${SED_CMD}'"
# echo GIT_EIDTOR is ${GIT_EDITOR}
git rebase -i ${COMMIT} 2> /dev/null
+
+ if [ -n "${vflag}" ] && [ -z "${nflag}" ]
+ then
+ echo ======
+ echo results:
+ cat ${LOGDIR}/results
+ fi
}
#
# main
#
-SELF=$0
parse_args
# for inferior loop
-if [ ! -z ${iflag} ]
+if [ -n "${iflag}" ]
then
trap "git rebase --abort" SIGINT SIGTERM
@@ -336,11 +391,17 @@ then
fi
# top level
-setup_env
+if [ -z "${sflag}" ]
+then
+ check_patches
-create_patchlist
+ setup_env
-save_env
+ save_env
+else
+ . ${PARAMFILE}
+ mv ${LOGDIR}/results ${LOGDIR}/results.old > /dev/null 2>&1
+fi
run_build_test_loop