2016-12-03 02:07:08 +03:00
#!/bin/bash
2016-12-09 01:31:20 +03:00
set -euo pipefail
2016-12-03 02:07:08 +03:00
dn=$(cd $(dirname $0) && pwd)
2016-12-22 20:39:28 +03:00
export topsrcdir=$(cd $dn/.. && pwd)
2017-09-29 17:01:18 +03:00
. ${dn}/common/libcomposetest.sh
2016-12-22 20:39:28 +03:00
2017-01-06 17:52:57 +03:00
# avoid refetching yum metadata everytime
export RPMOSTREE_USE_CACHED_METADATA=1
2016-12-09 01:31:20 +03:00
LOG=${LOG:-compose.log}
date > ${LOG}
colour_print() {
colour=$1; shift
[ ! -t 1 ] || echo -en "\e[${colour}m"
echo -n "$@"
[ ! -t 1 ] || echo -en "\e[0m"
echo
}
pass_print() {
colour_print 32 "$@" # green
}
fail_print() {
colour_print 31 "$@" # red
}
skip_print() {
colour_print 34 "$@" # blue
}
2016-12-03 02:07:08 +03:00
uid=$(id -u)
test_compose_datadir=/var/tmp/rpmostree-compose-cache-${uid}
export test_compose_datadir
mkdir -p ${test_compose_datadir}
datadir_owner=$(stat -c '%u' ${test_compose_datadir})
test ${uid} = ${datadir_owner}
# Pre-cache RPMs for each test, and share ostree repos between them for efficiency
repo=${test_compose_datadir}/repo
export repo
ostree --repo=${repo} init --mode=archive
repobuild=${test_compose_datadir}/repo-build
export repobuild
ostree --repo=${repobuild} init --mode=bare-user
mkdir -p ${test_compose_datadir}/cache
2016-12-09 01:31:20 +03:00
echo "Preparing compose tests..." | tee -a ${LOG}
2017-09-29 17:01:18 +03:00
setup_rpmmd_repos ${dn}/composedata
2017-05-26 23:21:02 +03:00
2016-12-03 02:07:08 +03:00
# Delete the default ref, since we want to use subrefs of it
2017-08-30 16:32:58 +03:00
compose_prepargs=
if test -n "${RPMOSTREE_COMPOSE_CACHEONLY:-}"; then
compose_prepargs="--cache-only"
fi
2017-08-18 23:45:44 +03:00
(set -x
rm ${repobuild}/refs/heads/* -rf
2017-08-30 16:32:58 +03:00
rpm-ostree compose --repo=${repobuild} tree --dry-run ${compose_prepargs} --cachedir=${test_compose_datadir}/cache ${dn}/composedata/fedora-base.json
2016-12-09 01:31:20 +03:00
rm ${repobuild}/refs/heads/* -rf) &>> ${LOG}
total=0
pass=0
fail=0
skip=0
for tf in $(find ${dn}/compose-tests -name 'test-*.sh' | sort); do
if [ -n "${TESTS+ }" ]; then
tfbn=$(basename "$tf" .sh)
tfbn=" ${tfbn#test-} "
if [[ " $TESTS " != *$tfbn* ]]; then
continue
fi
fi
let "total += 1"
bn=$(basename ${tf})
printf "Running $bn...\n"
printf "\n\n===== ${bn} =====\n\n" >> ${LOG}
2016-12-03 02:07:08 +03:00
2016-12-09 01:31:20 +03:00
# do some dirty piping to get some instant feedback and help debugging
if ${tf} |& tee -a ${LOG} \
| grep -e '^ok ' --line-buffered \
| xargs -d '\n' -n 1 echo " "; then
pass_print "PASS: $bn"
echo "PASS" >> ${LOG}
let "pass += 1"
else
if test $? = 77; then
skip_print "SKIP: $bn"
echo "SKIP" >> ${LOG}
let "skip += 1"
else
fail_print "FAIL: $bn"
echo "FAIL" >> ${LOG}
let "fail += 1"
2017-08-30 16:32:58 +03:00
if test -n "${RPMOSTREE_COMPOSE_FASTFAIL:-}"; then
break;
fi
2016-12-09 01:31:20 +03:00
fi
fi
2016-12-03 02:07:08 +03:00
done
2016-12-09 01:31:20 +03:00
[ ${fail} -eq 0 ] && printer=pass || printer=fail
${printer}_print "TOTAL: $total PASS: $pass SKIP: $skip FAIL: $fail"
echo "See ${LOG} for more information."
[ ${fail} -eq 0 ]