rpm-ostree/tests/ex-container
Colin Walters 1acd834104 Add test infra for ex container, and one test for bash
We have some unit-style tests that run `ex container`, but
they aren't "real"; they don't use scripts for example.  Let's
add tests for this similar to `tests/compose`.

We use a 26 base, but the target repos need to be 27
to pick up the fix for: https://bugzilla.redhat.com/show_bug.cgi?id=1478172

Add some bits to share infra between `tests/compose` and `tests/ex-container`;
basically handling the rpmmd repos. I tweaked things to be more streamlined
there between the `.papr.yml` and the test script.

Right now this is just one test for `bash`, but lays some of the infrastructure
for doing more. One thing that we need to do to improve more here is to better
cache RPMs, a bit like the compose tests do.

Closes: #1024
Approved by: jlebon
2017-10-02 18:04:24 +00:00

39 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# Tests for `rpm-ostree ex container`.
set -xeuo pipefail
dn=$(cd $(dirname $0) && pwd)
export topsrcdir=$(cd $dn/.. && pwd)
. ${dn}/common/libtest-core.sh
. ${dn}/common/libcomposetest.sh
if test "$(id -u)" = 0; then
fatal "Don't run $0 as root"
fi
LOGDIR=${LOGDIR:-$(pwd)/ex-compose-logs}
tmpdir=$(mktemp -d /var/tmp/rpm-ostree-container.XXXXXX)
touch ${tmpdir}/.tmpdir
cleanup_tmp() {
# This sanity check ensures we don't delete something else
if test -z "${TEST_SKIP_CLEANUP:-}" && test -f ${tmpdir}/.tmpdir; then
rm -rf ${tmpdir}
fi
}
trap cleanup_tmp EXIT
cd ${tmpdir}
rpm-ostree ex container init
# Need 27 due to http://bugzilla.redhat.com/1478172 only built there
setup_rpmmd_repos ${tmpdir}/rpmmd.repos.d 27
echo "Results in ${LOGDIR}"
rm ${LOGDIR} -rf
mkdir -p ${LOGDIR}
# Ideally pass $(cwd) down into parallel somehow
export test_tmpdir=${tmpdir}
ls ${dn}/ex-container-tests/test-*.sh | sort |
parallel --tag --halt soon,fail=1 --joblog joblog --results ${LOGDIR} --line-buffer {}