diff --git a/tests/installed/itest-bare-unit.sh b/tests/installed/itest-bare-unit.sh index 28ea4651..fe07f24f 100755 --- a/tests/installed/itest-bare-unit.sh +++ b/tests/installed/itest-bare-unit.sh @@ -15,14 +15,7 @@ dn=$(dirname $0) export G_TEST_SRCDIR=$(realpath $dn/../..) # Use /var/tmp to hopefully use XFS + O_TMPFILE etc. -tempdir=$(mktemp -d /var/tmp/tap-test.XXXXXX) -touch ${tempdir}/.testtmp -function cleanup () { - if test -f ${tempdir}/.testtmp; then - rm "${tempdir}" -rf - fi -} -trap cleanup EXIT -cd ${tempdir} +prepare_tmpdir /var/tmp +trap _tmpdir_cleanup EXIT /usr/libexec/installed-tests/libostree/test-basic.sh /usr/libexec/installed-tests/libostree/test-basic-c diff --git a/tests/installed/itest-bareuser-nouserxattrs.sh b/tests/installed/itest-bareuser-nouserxattrs.sh index 06d3e109..c8c07948 100755 --- a/tests/installed/itest-bareuser-nouserxattrs.sh +++ b/tests/installed/itest-bareuser-nouserxattrs.sh @@ -10,9 +10,8 @@ set -xeuo pipefail dn=$(dirname $0) . ${dn}/libinsttest.sh -test_tmpdir=$(prepare_tmpdir) +prepare_tmpdir trap _tmpdir_cleanup EXIT -cd ${test_tmpdir} mkdir mnt mount -t tmpfs tmpfs mnt diff --git a/tests/installed/itest-payload-link.sh b/tests/installed/itest-payload-link.sh index 807d497d..7469f43e 100755 --- a/tests/installed/itest-payload-link.sh +++ b/tests/installed/itest-payload-link.sh @@ -26,8 +26,9 @@ dn=$(dirname $0) echo "1..1" -cd /var/srv -mkdir repo +# Use /var/tmp so we have O_TMPFILE etc. +prepare_tmpdir /var/tmp +trap _tmpdir_cleanup EXIT ostree --repo=repo init --mode=archive echo -e '[archive]\nzlib-level=1\n' >> repo/config host_nonremoteref=$(echo ${host_refspec} | sed 's,[^:]*:,,') @@ -39,12 +40,10 @@ run_tmp_webserver $(pwd)/repo origin=$(cat ${test_tmpdir}/httpd-address) cleanup() { - cd ${oldpwd} + cd ${test_tmpdir} umount mnt || true - test -n "${blkdev}" && losetup -d ${blkdev} || true - rm -rf mnt testblk.img + test -n "${blkdev:-}" && losetup -d ${blkdev} || true } -oldpwd=`pwd` trap cleanup EXIT mkdir mnt @@ -57,29 +56,25 @@ fi mkfs.xfs -m reflink=1 ${blkdev} mount ${blkdev} mnt +cd mnt -test_tmpdir=$(pwd)/mnt -cd ${test_tmpdir} - +# Test that coreutils will do reflink touch a -if cp --reflink a b; then - mkdir repo - ostree --repo=repo init - ostree config --repo=repo set core.payload-link-threshold 0 - ostree --repo=repo remote add origin --set=gpg-verify=false ${origin} - ostree --repo=repo pull --disable-static-deltas origin ${host_nonremoteref} - find repo -type l -name '*.payload-link' >payload-links.txt - assert_not_streq "$(wc -l < payload-links.txt)" "0" +cp --reflink a b +mkdir repo +ostree --repo=repo init +ostree config --repo=repo set core.payload-link-threshold 0 +ostree --repo=repo remote add origin --set=gpg-verify=false ${origin} +ostree --repo=repo pull --disable-static-deltas origin ${host_nonremoteref} +find repo -type l -name '*.payload-link' >payload-links.txt +assert_not_streq "$(wc -l < payload-links.txt)" "0" - # Disable logging for inner loop, otherwise it'd be enormous - set +x - cat payload-links.txt | while read i; do - payload_checksum=$(basename $(dirname $i))$(basename $i .payload-link) - payload_checksum_calculated=$(sha256sum $(readlink -f $i) | cut -d ' ' -f 1) - assert_streq "${payload_checksum}" "${payload_checksum_calculated}" - done - set -x - echo "ok pull creates .payload-link" -else - echo "ok # SKIP no reflink support in the file system" -fi +# Disable logging for inner loop, otherwise it'd be enormous +set +x +cat payload-links.txt | while read i; do + payload_checksum=$(basename $(dirname $i))$(basename $i .payload-link) + payload_checksum_calculated=$(sha256sum $(readlink -f $i) | cut -d ' ' -f 1) + assert_streq "${payload_checksum}" "${payload_checksum_calculated}" +done +set -x +echo "ok pull creates .payload-link" diff --git a/tests/installed/itest-pull-space.sh b/tests/installed/itest-pull-space.sh index 36703a40..8d218b15 100755 --- a/tests/installed/itest-pull-space.sh +++ b/tests/installed/itest-pull-space.sh @@ -6,7 +6,7 @@ set -xeuo pipefail dn=$(dirname $0) . ${dn}/libinsttest.sh -test_tmpdir=$(prepare_tmpdir) +prepare_tmpdir trap _tmpdir_cleanup EXIT cd ${test_tmpdir} diff --git a/tests/installed/itest-pull.sh b/tests/installed/itest-pull.sh index 65cb9449..b80acdbc 100755 --- a/tests/installed/itest-pull.sh +++ b/tests/installed/itest-pull.sh @@ -7,12 +7,10 @@ set -xeuo pipefail dn=$(dirname $0) . ${dn}/libinsttest.sh -test_tmpdir=$(prepare_tmpdir) +prepare_tmpdir /var/tmp trap _tmpdir_cleanup EXIT # Take the host's ostree, and make it archive -cd /var/srv -rm repo bare-repo -rf mkdir repo ostree --repo=repo init --mode=archive echo -e '[archive]\nzlib-level=1\n' >> repo/config diff --git a/tests/installed/itest-remotes.sh b/tests/installed/itest-remotes.sh index 9b48b68f..8a79015f 100755 --- a/tests/installed/itest-remotes.sh +++ b/tests/installed/itest-remotes.sh @@ -7,7 +7,7 @@ set -xeuo pipefail dn=$(dirname $0) . ${dn}/libinsttest.sh -test_tmpdir=$(prepare_tmpdir) +prepare_tmpdir trap _tmpdir_cleanup EXIT ostree remote list > remotes.txt diff --git a/tests/installed/libinsttest.sh b/tests/installed/libinsttest.sh index d0ee8c6c..6d6ba50c 100644 --- a/tests/installed/libinsttest.sh +++ b/tests/installed/libinsttest.sh @@ -30,10 +30,10 @@ function _tmpdir_cleanup () { fi } prepare_tmpdir() { - test_tmpdir=$(mktemp -d) + local tmpdir=${1:-/tmp} + test_tmpdir=$(mktemp -p ${tmpdir} -d ostree-insttest.XXXXXXXX) touch ${test_tmpdir}/.testtmp cd ${test_tmpdir} - echo ${test_tmpdir} } # This is copied from flatpak/flatpak/tests/test-webserver.sh