tests/installed: Use temporary directories more consistently
This is prep for splitting off "nondestructive" tests which we can run in parallel from the destructive/invasive ones which e.g. change the host refspec, do deployments. The `cd` invocation in `prepare_tmpdir` wasn't working because we were running it in a subshell. Fix this by dropping the subshell. Closes: #1509 Approved by: jlebon
This commit is contained in:
parent
dca1cfa60f
commit
bb9cd1eb72
|
|
@ -15,14 +15,7 @@ dn=$(dirname $0)
|
||||||
export G_TEST_SRCDIR=$(realpath $dn/../..)
|
export G_TEST_SRCDIR=$(realpath $dn/../..)
|
||||||
|
|
||||||
# Use /var/tmp to hopefully use XFS + O_TMPFILE etc.
|
# Use /var/tmp to hopefully use XFS + O_TMPFILE etc.
|
||||||
tempdir=$(mktemp -d /var/tmp/tap-test.XXXXXX)
|
prepare_tmpdir /var/tmp
|
||||||
touch ${tempdir}/.testtmp
|
trap _tmpdir_cleanup EXIT
|
||||||
function cleanup () {
|
|
||||||
if test -f ${tempdir}/.testtmp; then
|
|
||||||
rm "${tempdir}" -rf
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
trap cleanup EXIT
|
|
||||||
cd ${tempdir}
|
|
||||||
/usr/libexec/installed-tests/libostree/test-basic.sh
|
/usr/libexec/installed-tests/libostree/test-basic.sh
|
||||||
/usr/libexec/installed-tests/libostree/test-basic-c
|
/usr/libexec/installed-tests/libostree/test-basic-c
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,8 @@ set -xeuo pipefail
|
||||||
dn=$(dirname $0)
|
dn=$(dirname $0)
|
||||||
. ${dn}/libinsttest.sh
|
. ${dn}/libinsttest.sh
|
||||||
|
|
||||||
test_tmpdir=$(prepare_tmpdir)
|
prepare_tmpdir
|
||||||
trap _tmpdir_cleanup EXIT
|
trap _tmpdir_cleanup EXIT
|
||||||
cd ${test_tmpdir}
|
|
||||||
|
|
||||||
mkdir mnt
|
mkdir mnt
|
||||||
mount -t tmpfs tmpfs mnt
|
mount -t tmpfs tmpfs mnt
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,9 @@ dn=$(dirname $0)
|
||||||
|
|
||||||
echo "1..1"
|
echo "1..1"
|
||||||
|
|
||||||
cd /var/srv
|
# Use /var/tmp so we have O_TMPFILE etc.
|
||||||
mkdir repo
|
prepare_tmpdir /var/tmp
|
||||||
|
trap _tmpdir_cleanup EXIT
|
||||||
ostree --repo=repo init --mode=archive
|
ostree --repo=repo init --mode=archive
|
||||||
echo -e '[archive]\nzlib-level=1\n' >> repo/config
|
echo -e '[archive]\nzlib-level=1\n' >> repo/config
|
||||||
host_nonremoteref=$(echo ${host_refspec} | sed 's,[^:]*:,,')
|
host_nonremoteref=$(echo ${host_refspec} | sed 's,[^:]*:,,')
|
||||||
|
|
@ -39,12 +40,10 @@ run_tmp_webserver $(pwd)/repo
|
||||||
origin=$(cat ${test_tmpdir}/httpd-address)
|
origin=$(cat ${test_tmpdir}/httpd-address)
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
cd ${oldpwd}
|
cd ${test_tmpdir}
|
||||||
umount mnt || true
|
umount mnt || true
|
||||||
test -n "${blkdev}" && losetup -d ${blkdev} || true
|
test -n "${blkdev:-}" && losetup -d ${blkdev} || true
|
||||||
rm -rf mnt testblk.img
|
|
||||||
}
|
}
|
||||||
oldpwd=`pwd`
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
mkdir mnt
|
mkdir mnt
|
||||||
|
|
@ -57,29 +56,25 @@ fi
|
||||||
mkfs.xfs -m reflink=1 ${blkdev}
|
mkfs.xfs -m reflink=1 ${blkdev}
|
||||||
|
|
||||||
mount ${blkdev} mnt
|
mount ${blkdev} mnt
|
||||||
|
cd mnt
|
||||||
|
|
||||||
test_tmpdir=$(pwd)/mnt
|
# Test that coreutils will do reflink
|
||||||
cd ${test_tmpdir}
|
|
||||||
|
|
||||||
touch a
|
touch a
|
||||||
if cp --reflink a b; then
|
cp --reflink a b
|
||||||
mkdir repo
|
mkdir repo
|
||||||
ostree --repo=repo init
|
ostree --repo=repo init
|
||||||
ostree config --repo=repo set core.payload-link-threshold 0
|
ostree config --repo=repo set core.payload-link-threshold 0
|
||||||
ostree --repo=repo remote add origin --set=gpg-verify=false ${origin}
|
ostree --repo=repo remote add origin --set=gpg-verify=false ${origin}
|
||||||
ostree --repo=repo pull --disable-static-deltas origin ${host_nonremoteref}
|
ostree --repo=repo pull --disable-static-deltas origin ${host_nonremoteref}
|
||||||
find repo -type l -name '*.payload-link' >payload-links.txt
|
find repo -type l -name '*.payload-link' >payload-links.txt
|
||||||
assert_not_streq "$(wc -l < payload-links.txt)" "0"
|
assert_not_streq "$(wc -l < payload-links.txt)" "0"
|
||||||
|
|
||||||
# Disable logging for inner loop, otherwise it'd be enormous
|
# Disable logging for inner loop, otherwise it'd be enormous
|
||||||
set +x
|
set +x
|
||||||
cat payload-links.txt | while read i; do
|
cat payload-links.txt | while read i; do
|
||||||
payload_checksum=$(basename $(dirname $i))$(basename $i .payload-link)
|
payload_checksum=$(basename $(dirname $i))$(basename $i .payload-link)
|
||||||
payload_checksum_calculated=$(sha256sum $(readlink -f $i) | cut -d ' ' -f 1)
|
payload_checksum_calculated=$(sha256sum $(readlink -f $i) | cut -d ' ' -f 1)
|
||||||
assert_streq "${payload_checksum}" "${payload_checksum_calculated}"
|
assert_streq "${payload_checksum}" "${payload_checksum_calculated}"
|
||||||
done
|
done
|
||||||
set -x
|
set -x
|
||||||
echo "ok pull creates .payload-link"
|
echo "ok pull creates .payload-link"
|
||||||
else
|
|
||||||
echo "ok # SKIP no reflink support in the file system"
|
|
||||||
fi
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ set -xeuo pipefail
|
||||||
dn=$(dirname $0)
|
dn=$(dirname $0)
|
||||||
. ${dn}/libinsttest.sh
|
. ${dn}/libinsttest.sh
|
||||||
|
|
||||||
test_tmpdir=$(prepare_tmpdir)
|
prepare_tmpdir
|
||||||
trap _tmpdir_cleanup EXIT
|
trap _tmpdir_cleanup EXIT
|
||||||
|
|
||||||
cd ${test_tmpdir}
|
cd ${test_tmpdir}
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,10 @@ set -xeuo pipefail
|
||||||
dn=$(dirname $0)
|
dn=$(dirname $0)
|
||||||
. ${dn}/libinsttest.sh
|
. ${dn}/libinsttest.sh
|
||||||
|
|
||||||
test_tmpdir=$(prepare_tmpdir)
|
prepare_tmpdir /var/tmp
|
||||||
trap _tmpdir_cleanup EXIT
|
trap _tmpdir_cleanup EXIT
|
||||||
|
|
||||||
# Take the host's ostree, and make it archive
|
# Take the host's ostree, and make it archive
|
||||||
cd /var/srv
|
|
||||||
rm repo bare-repo -rf
|
|
||||||
mkdir repo
|
mkdir repo
|
||||||
ostree --repo=repo init --mode=archive
|
ostree --repo=repo init --mode=archive
|
||||||
echo -e '[archive]\nzlib-level=1\n' >> repo/config
|
echo -e '[archive]\nzlib-level=1\n' >> repo/config
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ set -xeuo pipefail
|
||||||
dn=$(dirname $0)
|
dn=$(dirname $0)
|
||||||
. ${dn}/libinsttest.sh
|
. ${dn}/libinsttest.sh
|
||||||
|
|
||||||
test_tmpdir=$(prepare_tmpdir)
|
prepare_tmpdir
|
||||||
trap _tmpdir_cleanup EXIT
|
trap _tmpdir_cleanup EXIT
|
||||||
|
|
||||||
ostree remote list > remotes.txt
|
ostree remote list > remotes.txt
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,10 @@ function _tmpdir_cleanup () {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
prepare_tmpdir() {
|
prepare_tmpdir() {
|
||||||
test_tmpdir=$(mktemp -d)
|
local tmpdir=${1:-/tmp}
|
||||||
|
test_tmpdir=$(mktemp -p ${tmpdir} -d ostree-insttest.XXXXXXXX)
|
||||||
touch ${test_tmpdir}/.testtmp
|
touch ${test_tmpdir}/.testtmp
|
||||||
cd ${test_tmpdir}
|
cd ${test_tmpdir}
|
||||||
echo ${test_tmpdir}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This is copied from flatpak/flatpak/tests/test-webserver.sh
|
# This is copied from flatpak/flatpak/tests/test-webserver.sh
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue