diff options
Diffstat (limited to 'tests/libtest.sh')
-rwxr-xr-x | tests/libtest.sh | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/tests/libtest.sh b/tests/libtest.sh index 686f08dc..5830f210 100755 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -148,6 +148,20 @@ if ! have_selinux_relabel; then fi echo done +# whiteout char 0:0 devices can be created as regular users, but +# cannot be created inside containers mounted via overlayfs +can_create_whiteout_devices() { + mknod -m 000 ${test_tmpdir}/.test-whiteout c 0 0 || return 1 + rm -f ${test_tmpdir}/.test-whiteout + return 0 +} + +echo -n checking for overlayfs whiteouts... +if ! can_create_whiteout_devices; then + export OSTREE_NO_WHITEOUTS=1 +fi +echo done + if test -n "${OT_TESTS_DEBUG:-}"; then set -x fi @@ -245,6 +259,15 @@ setup_test_repository () { ln -s nonexistent baz/alink mkdir baz/another/ echo x > baz/another/y + + # if we are running inside a container we cannot test + # the overlayfs whiteout marker passthrough + if ! test -n "${OSTREE_NO_WHITEOUTS:-}"; then + mkdir whiteouts + touch whiteouts/.ostree-wh.whiteout + touch whiteouts/.ostree-wh.whiteout2 + chmod 755 whiteouts/.ostree-wh.whiteout2 + fi umask "${oldumask}" cd ${test_tmpdir}/files @@ -406,7 +429,7 @@ setup_os_repository () { mkdir osdata cd osdata kver=3.6.0 - mkdir -p usr/bin ${bootdir} usr/lib/modules/${kver} usr/share usr/etc + mkdir -p usr/bin ${bootdir} usr/lib/modules/${kver} usr/share usr/etc usr/container/layers/abcd kernel_path=${bootdir}/vmlinuz initramfs_path=${bootdir}/initramfs.img # the HMAC file is only in /usr/lib/modules @@ -449,6 +472,17 @@ EOF mkdir -p usr/etc/testdirectory echo "a default daemon file" > usr/etc/testdirectory/test + # if we are running inside a container we cannot test + # the overlayfs whiteout marker passthrough + if ! test -n "${OSTREE_NO_WHITEOUTS:-}"; then + # overlayfs whiteout passhthrough marker files + touch usr/container/layers/abcd/.ostree-wh.whiteout + chmod 400 usr/container/layers/abcd/.ostree-wh.whiteout + + touch usr/container/layers/abcd/.ostree-wh.whiteout2 + chmod 777 usr/container/layers/abcd/.ostree-wh.whiteout2 + fi + ${CMD_PREFIX} ostree --repo=${test_tmpdir}/testos-repo commit ${bootable_flag} --add-metadata-string version=1.0.9 -b testos/buildmain/x86_64-runtime -s "Build" # Ensure these commits have distinct second timestamps @@ -588,6 +622,22 @@ skip_without_user_xattrs () { fi } +# Usage: if ! skip_one_without_whiteouts_devices; then ... more tests ...; fi +skip_one_without_whiteouts_devices() { + if ! can_create_whiteout_devices; then + echo "ok # SKIP - this test requires whiteout device support (test outside containers)" + return 0 + else + return 1 + fi +} + +skip_without_whiteouts_devices () { + if ! can_create_whiteout_devices; then + skip "this test requires whiteout device support (test outside containers)" + fi +} + _have_systemd_and_libmount='' have_systemd_and_libmount() { if test "${_have_systemd_and_libmount}" = ''; then |