test-dependencies.sh: Return non-zero return code when there was some failure detected
* this is useful when using from jenkins job where you don't want to read output just to dectect how bad it was * add .log suffix to all files, so they can be easily downloaded from http servers without default mimetype set to something useful * add recipes failed in step 1 to steps 2 and 3 to generate standalone logs for them (From OE-Core rev: cef1d6deb5437edae56740436d8e77b8d941945a) Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
4e2656dc10
commit
dbb4c73233
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
# Author: Martin Jansa <martin.jansa@gmail.com>
|
# Author: Martin Jansa <martin.jansa@gmail.com>
|
||||||
#
|
#
|
||||||
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
# Used to detect missing dependencies or automagically
|
# Used to detect missing dependencies or automagically
|
||||||
# enabled dependencies which aren't explicitly enabled
|
# enabled dependencies which aren't explicitly enabled
|
||||||
# or disabled.
|
# or disabled. Using bash to have PIPESTATUS variable.
|
||||||
|
|
||||||
# It does 3 builds of <target>
|
# It does 3 builds of <target>
|
||||||
# 1st to populate sstate-cache directory and sysroot
|
# 1st to populate sstate-cache directory and sysroot
|
||||||
|
@ -131,6 +131,7 @@ done
|
||||||
echo "$buildtype" | grep -v '^[1234c ]*$' && echo_error "Invalid buildtype \"$buildtype\", only some combination of 1, 2, 3, 4, c separated by space is allowed"
|
echo "$buildtype" | grep -v '^[1234c ]*$' && echo_error "Invalid buildtype \"$buildtype\", only some combination of 1, 2, 3, 4, c separated by space is allowed"
|
||||||
|
|
||||||
OUTPUT_BASE=test-dependencies/`date "+%s"`
|
OUTPUT_BASE=test-dependencies/`date "+%s"`
|
||||||
|
declare -i RESULT=0
|
||||||
|
|
||||||
build_all() {
|
build_all() {
|
||||||
echo "===== 1st build to populate sstate-cache directory and sysroot ====="
|
echo "===== 1st build to populate sstate-cache directory and sysroot ====="
|
||||||
|
@ -138,6 +139,9 @@ build_all() {
|
||||||
mkdir -p ${OUTPUT1}
|
mkdir -p ${OUTPUT1}
|
||||||
echo "Logs will be stored in ${OUTPUT1} directory"
|
echo "Logs will be stored in ${OUTPUT1} directory"
|
||||||
bitbake -k $targets 2>&1 | tee -a ${OUTPUT1}/complete.log
|
bitbake -k $targets 2>&1 | tee -a ${OUTPUT1}/complete.log
|
||||||
|
RESULT+=${PIPESTATUS[0]}
|
||||||
|
grep "ERROR: Task.*failed" ${OUTPUT1}/complete.log > ${OUTPUT1}/failed-tasks.log
|
||||||
|
cat ${OUTPUT1}/failed-tasks.log | sed 's@.*/@@g; s@_.*@@g; s@\..*@@g' | sort -u > ${OUTPUT1}/failed-recipes.log
|
||||||
}
|
}
|
||||||
|
|
||||||
build_every_recipe() {
|
build_every_recipe() {
|
||||||
|
@ -162,12 +166,24 @@ build_every_recipe() {
|
||||||
rm -rf $tmpdir/deploy $tmpdir/pkgdata $tmpdir/sstate-control $tmpdir/stamps $tmpdir/sysroots $tmpdir/work $tmpdir/work-shared 2>/dev/null
|
rm -rf $tmpdir/deploy $tmpdir/pkgdata $tmpdir/sstate-control $tmpdir/stamps $tmpdir/sysroots $tmpdir/work $tmpdir/work-shared 2>/dev/null
|
||||||
fi
|
fi
|
||||||
i=1
|
i=1
|
||||||
count=`cat $recipes | wc -l`
|
count=`cat $recipes ${OUTPUT1}/failed-recipes.log | sort -u | wc -l`
|
||||||
for recipe in `cat $recipes`; do
|
for recipe in `cat $recipes ${OUTPUT1}/failed-recipes.log | sort -u`; do
|
||||||
echo "Building recipe: ${recipe} ($i/$count)"
|
echo "Building recipe: ${recipe} ($i/$count)"
|
||||||
bitbake -c cleansstate ${recipe} > ${OUTPUTB}/log.${recipe} 2>&1;
|
declare -i RECIPE_RESULT=0
|
||||||
bitbake ${recipe} >> ${OUTPUTB}/log.${recipe} 2>&1;
|
bitbake -c cleansstate ${recipe} > ${OUTPUTB}/${recipe}.log 2>&1;
|
||||||
grep "ERROR: Task.*failed" ${OUTPUTB}/log.${recipe} && mv ${OUTPUTB}/log.${recipe} ${OUTPUTB}/failed/${recipe} || mv ${OUTPUTB}/log.${recipe} ${OUTPUTB}/ok/${recipe}
|
RECIPE_RESULT+=$?
|
||||||
|
bitbake ${recipe} >> ${OUTPUTB}/${recipe}.log 2>&1;
|
||||||
|
RECIPE_RESULT+=$?
|
||||||
|
if [ "${RECIPE_RESULT}" != "0" ] ; then
|
||||||
|
RESULT+=${RECIPE_RESULT}
|
||||||
|
mv ${OUTPUTB}/${recipe}.log ${OUTPUTB}/failed/
|
||||||
|
grep "ERROR: Task.*failed" ${OUTPUTB}/failed/${recipe}.log | tee -a ${OUTPUTB}/failed-tasks.log
|
||||||
|
grep "ERROR: Task.*failed" ${OUTPUTB}/failed/${recipe}.log | sed 's@.*/@@g; s@_.*@@g; s@\..*@@g' >> ${OUTPUTB}/failed-recipes.log
|
||||||
|
# and append also ${recipe} in case the failed task was from some dependency
|
||||||
|
echo ${recipe} >> ${OUTPUTB}/failed-recipes.log
|
||||||
|
else
|
||||||
|
mv ${OUTPUTB}/${recipe}.log ${OUTPUTB}/ok/
|
||||||
|
fi
|
||||||
if [ "${TYPE}" != "2" ] ; then
|
if [ "${TYPE}" != "2" ] ; then
|
||||||
rm -rf $tmpdir/deploy $tmpdir/pkgdata $tmpdir/sstate-control $tmpdir/stamps $tmpdir/sysroots $tmpdir/work $tmpdir/work-shared 2>/dev/null
|
rm -rf $tmpdir/deploy $tmpdir/pkgdata $tmpdir/sstate-control $tmpdir/stamps $tmpdir/sysroots $tmpdir/work $tmpdir/work-shared 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
@ -184,8 +200,6 @@ build_every_recipe() {
|
||||||
dest=`echo $f | sed "s#$tmpdir/work/##g; s#/#_#g"`
|
dest=`echo $f | sed "s#$tmpdir/work/##g; s#/#_#g"`
|
||||||
cp $f ${OUTPUTB}/do_package/$dest
|
cp $f ${OUTPUTB}/do_package/$dest
|
||||||
done
|
done
|
||||||
grep "ERROR: Task.*failed" ${OUTPUTB}/failed/* 2>/dev/null
|
|
||||||
ls -1 ${OUTPUTB}/failed/* >> ${OUTPUT_BASE}/failed.recipes 2>/dev/null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compare_deps() {
|
compare_deps() {
|
||||||
|
@ -209,8 +223,10 @@ compare_deps() {
|
||||||
find ${OUTPUT_MAX}/packages/ -name latest | sed "s#${OUTPUT_MAX}/##g" | while read pkg; do
|
find ${OUTPUT_MAX}/packages/ -name latest | sed "s#${OUTPUT_MAX}/##g" | while read pkg; do
|
||||||
max_pkg=${OUTPUT_MAX}/${pkg}
|
max_pkg=${OUTPUT_MAX}/${pkg}
|
||||||
min_pkg=${OUTPUT_MIN}/${pkg}
|
min_pkg=${OUTPUT_MIN}/${pkg}
|
||||||
|
recipe=`echo "${pkg}" | sed 's#/.*##g'`
|
||||||
if [ ! -f "${min_pkg}" ] ; then
|
if [ ! -f "${min_pkg}" ] ; then
|
||||||
echo "ERROR: ${min_pkg} doesn't exist" | tee -a ${OUTPUT_FILE}
|
echo "ERROR: ${min_pkg} doesn't exist" | tee -a ${OUTPUT_FILE}
|
||||||
|
echo ${recipe} >> ${OUTPUTC}/failed-recipes.log
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
# strip version information in parenthesis
|
# strip version information in parenthesis
|
||||||
|
@ -231,17 +247,18 @@ compare_deps() {
|
||||||
if [ -n "${missing_deps}" ] ; then
|
if [ -n "${missing_deps}" ] ; then
|
||||||
echo # to get rid of dots on last line
|
echo # to get rid of dots on last line
|
||||||
echo "WARN: ${pkg} lost dependency on ${missing_deps}" | tee -a ${OUTPUT_FILE}
|
echo "WARN: ${pkg} lost dependency on ${missing_deps}" | tee -a ${OUTPUT_FILE}
|
||||||
|
echo ${recipe} >> ${OUTPUTC}/failed-recipes.log
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
i=`expr $i + 1`
|
i=`expr $i + 1`
|
||||||
done
|
done
|
||||||
echo # to get rid of dots on last line
|
echo # to get rid of dots on last line
|
||||||
echo "Found differences: "
|
echo "Found differences: "
|
||||||
grep "^WARN: " ${OUTPUT_FILE} | tee ${OUTPUT_FILE}.warn
|
grep "^WARN: " ${OUTPUT_FILE} | tee ${OUTPUT_FILE}.warn.log
|
||||||
echo "Found errors: "
|
echo "Found errors: "
|
||||||
grep "^ERROR: " ${OUTPUT_FILE} | tee ${OUTPUT_FILE}.error
|
grep "^ERROR: " ${OUTPUT_FILE} | tee ${OUTPUT_FILE}.error.log
|
||||||
# useful for reexecuting this script with only small subset of recipes with known issues
|
RESULT+=`cat ${OUTPUT_FILE}.warn.log | wc -l`
|
||||||
sed 's#.*[ /]packages/\([^/]*\)/\([^/]*\)/.*#\2#g' ${OUTPUT_FILE}.warn ${OUTPUT_FILE}.error | sort -u >> ${OUTPUT_BASE}/failed.recipes
|
RESULT+=`cat ${OUTPUT_FILE}.error.log | wc -l`
|
||||||
}
|
}
|
||||||
|
|
||||||
for TYPE in $buildtype; do
|
for TYPE in $buildtype; do
|
||||||
|
@ -254,3 +271,12 @@ for TYPE in $buildtype; do
|
||||||
*) echo_error "Invalid buildtype \"$TYPE\""
|
*) echo_error "Invalid buildtype \"$TYPE\""
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
cat ${OUTPUT_BASE}/*/failed-recipes.log | sort -u > ${OUTPUT_BASE}/failed-recipes.log
|
||||||
|
|
||||||
|
if [ "${RESULT}" != "0" ] ; then
|
||||||
|
echo "ERROR: ${RESULT} issues were found in these recipes: `cat ${OUTPUT_BASE}/failed-recipes.log | xargs`"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "INFO: Output written in: ${OUTPUT_BASE}"
|
||||||
|
exit ${RESULT}
|
||||||
|
|
Loading…
Reference in New Issue