Skip to content

Commit

Permalink
Merge pull request containers#3812 from flouthoc/test-rootless-unshared
Browse files Browse the repository at this point in the history
buildah: increase rootless test coverage with `rootless + unshare`
  • Loading branch information
openshift-merge-robot committed Mar 9, 2022
2 parents 2605775 + 0b8c6ca commit cf6d58b
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 67 deletions.
6 changes: 0 additions & 6 deletions tests/add.bats
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ load helpers
}

@test "add-local-plain" {
skip_if_rootless_environment
createrandom ${TESTDIR}/randomfile
createrandom ${TESTDIR}/other-randomfile

Expand Down Expand Up @@ -60,7 +59,6 @@ load helpers
}

@test "add-local-archive" {
skip_if_rootless_environment
createrandom ${TESTDIR}/randomfile
createrandom ${TESTDIR}/other-randomfile

Expand Down Expand Up @@ -203,7 +201,6 @@ load helpers
}

@test "add --ignorefile" {
skip_if_rootless_environment
mytest=${TESTDIR}/mytest
mkdir -p ${mytest}
touch ${mytest}/mystuff
Expand Down Expand Up @@ -237,7 +234,6 @@ stuff/mystuff"
}

@test "add quietly" {
skip_if_rootless_environment
_prefetch busybox
createrandom ${TESTDIR}/randomfile
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json busybox
Expand All @@ -250,7 +246,6 @@ stuff/mystuff"
}

@test "add from container" {
skip_if_rootless_environment
_prefetch busybox
createrandom ${TESTDIR}/randomfile
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json busybox
Expand All @@ -270,7 +265,6 @@ stuff/mystuff"
}

@test "add from image" {
skip_if_rootless_environment
_prefetch busybox
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json busybox
cid=$output
Expand Down
3 changes: 0 additions & 3 deletions tests/basic.bats
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ load helpers
}

@test "mount" {
skip_if_rootless_environment
run_buildah from --signature-policy ${TESTSDIR}/policy.json scratch
cid=$output
run_buildah mount $cid
Expand All @@ -50,7 +49,6 @@ load helpers
}

@test "by-name" {
skip_if_rootless_environment
run_buildah from --signature-policy ${TESTSDIR}/policy.json --name scratch-working-image-for-test scratch
cid=$output
run_buildah mount scratch-working-image-for-test
Expand All @@ -60,7 +58,6 @@ load helpers
}

@test "commit" {
skip_if_rootless_environment
createrandom ${TESTDIR}/randomfile
createrandom ${TESTDIR}/other-randomfile

Expand Down
26 changes: 0 additions & 26 deletions tests/bud.bats
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ load helpers
}

@test "bud with .dockerignore - unmatched" {
skip_if_rootless_environment
# Here .dockerignore contains 'unmatched', which will not match anything.
# Therefore everything in the subdirectory should be copied into the image.
#
Expand Down Expand Up @@ -261,7 +260,6 @@ _EOF
}

@test "bud with --layers, multistage, and COPY with --from" {
skip_if_rootless_environment
_prefetch alpine
cp -a ${TESTSDIR}/bud/use-layers ${TESTDIR}/use-layers

Expand Down Expand Up @@ -351,7 +349,6 @@ _EOF
}

@test "bud-multistage-cache" {
skip_if_rootless_environment
_prefetch alpine busybox
target=foo
run_buildah build --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.extended ${TESTSDIR}/bud/multi-stage-builds
Expand Down Expand Up @@ -636,7 +633,6 @@ _EOF
}

@test "bud-from-multiple-files-one-from" {
skip_if_rootless_environment
target=scratch-image
run_buildah build --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/from-multiple-files/Dockerfile1.scratch -f ${TESTSDIR}/bud/from-multiple-files/Dockerfile2.nofrom ${TESTSDIR}/bud/from-multiple-files
run_buildah from --quiet ${target}
Expand All @@ -662,7 +658,6 @@ _EOF
}

@test "bud-from-multiple-files-two-froms" {
skip_if_rootless_environment
_prefetch alpine
target=scratch-image
run_buildah build --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile1.scratch -f Dockerfile2.withfrom ${TESTSDIR}/bud/from-multiple-files
Expand All @@ -689,7 +684,6 @@ _EOF
}

@test "bud-multi-stage-builds" {
skip_if_rootless_environment
_prefetch alpine
target=multi-stage-index
run_buildah build --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/multi-stage-builds/Dockerfile.index ${TESTSDIR}/bud/multi-stage-builds
Expand Down Expand Up @@ -726,7 +720,6 @@ _EOF
}

@test "bud-multi-stage-builds-small-as" {
skip_if_rootless_environment
_prefetch alpine
target=multi-stage-index
run_buildah build --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/multi-stage-builds-small-as/Dockerfile.index ${TESTSDIR}/bud/multi-stage-builds-small-as
Expand Down Expand Up @@ -763,7 +756,6 @@ _EOF
}

@test "bud-preserve-subvolumes" {
skip_if_rootless_environment
# This Dockerfile needs us to be able to handle a working RUN instruction.
skip_if_no_runtime

Expand Down Expand Up @@ -906,7 +898,6 @@ function _test_http() {
}

@test "bud-volume-perms" {
skip_if_rootless_environment
# This Dockerfile needs us to be able to handle a working RUN instruction.
skip_if_no_runtime

Expand Down Expand Up @@ -957,7 +948,6 @@ function _test_http() {
}

@test "bud-from-glob" {
skip_if_rootless_environment
_prefetch alpine
target=alpine-image
run_buildah build --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile2.glob ${TESTSDIR}/bud/from-multiple-files
Expand Down Expand Up @@ -1028,7 +1018,6 @@ function _test_http() {
}

@test "bud with symlinks" {
skip_if_rootless_environment
_prefetch alpine
target=alpine-image
run_buildah build --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/symlink
Expand All @@ -1048,7 +1037,6 @@ function _test_http() {
}

@test "bud with symlinks to relative path" {
skip_if_rootless_environment
_prefetch alpine
target=alpine-image
run_buildah build --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.relative-symlink ${TESTSDIR}/bud/symlink
Expand All @@ -1067,7 +1055,6 @@ function _test_http() {
}

@test "bud with multiple symlinks in a path" {
skip_if_rootless_environment
_prefetch alpine
target=alpine-image
run_buildah build --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/symlink/Dockerfile.multiple-symlinks ${TESTSDIR}/bud/symlink
Expand Down Expand Up @@ -1100,7 +1087,6 @@ function _test_http() {
}

@test "bud multi-stage with symlink to absolute path" {
skip_if_rootless_environment
_prefetch ubuntu
target=ubuntu-image
run_buildah build --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.absolute-symlink ${TESTSDIR}/bud/symlink
Expand All @@ -1118,7 +1104,6 @@ function _test_http() {
}

@test "bud multi-stage with dir symlink to absolute path" {
skip_if_rootless_environment
_prefetch ubuntu
target=ubuntu-image
run_buildah build --signature-policy ${TESTSDIR}/policy.json -t ${target} -f Dockerfile.absolute-dir-symlink ${TESTSDIR}/bud/symlink
Expand Down Expand Up @@ -1276,7 +1261,6 @@ function _test_http() {
}

@test "bud-onbuild" {
skip_if_rootless_environment
_prefetch alpine
target=onbuild
run_buildah build --format docker --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/onbuild
Expand Down Expand Up @@ -1359,7 +1343,6 @@ function _test_http() {
}

@test "bud-from-stdin" {
skip_if_rootless_environment
target=scratch-image
cat ${TESTSDIR}/bud/from-multiple-files/Dockerfile1.scratch | run_buildah build --signature-policy ${TESTSDIR}/policy.json -t ${target} -f - ${TESTSDIR}/bud/from-multiple-files
run_buildah from --quiet ${target}
Expand Down Expand Up @@ -1630,7 +1613,6 @@ function _test_http() {
}

@test "bud with FROM AS skip FROM construct" {
skip_if_rootless_environment
_prefetch alpine
run_buildah build --signature-policy ${TESTSDIR}/policy.json -t test1 -f ${TESTSDIR}/bud/from-as/Dockerfile.skip ${TESTSDIR}/bud/from-as
expect_output --substring "LOCAL=/1"
Expand Down Expand Up @@ -1719,7 +1701,6 @@ function _test_http() {
}

@test "bud with copy-from in Dockerfile no prior FROM" {
skip_if_rootless_environment
_prefetch busybox quay.io/libpod/testimage:20210610
target=no-prior-from
run_buildah build --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/copy-from ${TESTSDIR}/bud/copy-from
Expand All @@ -1742,7 +1723,6 @@ function _test_http() {
}

@test "bud with copy-from referencing the base image" {
skip_if_rootless_environment
_prefetch busybox
target=busybox-derived
target_mt=busybox-mt-derived
Expand Down Expand Up @@ -1774,7 +1754,6 @@ function _test_http() {
}

@test "bud-target" {
skip_if_rootless_environment
_prefetch alpine ubuntu
target=target
run_buildah build --signature-policy ${TESTSDIR}/policy.json -t ${target} --target mytarget ${TESTSDIR}/bud/target
Expand Down Expand Up @@ -2029,7 +2008,6 @@ _EOF
}

@test "bud-copy-workdir" {
skip_if_rootless_environment
target=testimage
run_buildah build --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/copy-workdir
run_buildah from ${target}
Expand All @@ -2043,7 +2021,6 @@ _EOF

# regression test for https://github.com/containers/podman/issues/10671
@test "bud-copy-workdir --layers" {
skip_if_rootless_environment
_prefetch alpine

target=testimage
Expand Down Expand Up @@ -2125,7 +2102,6 @@ _EOF
}

@test "bud-copy-dockerignore-hardlinks" {
skip_if_rootless_environment
target=image
mkdir -p ${TESTDIR}/hardlinks/subdir
cp ${TESTSDIR}/bud/recurse/Dockerfile ${TESTDIR}/hardlinks
Expand Down Expand Up @@ -2303,7 +2279,6 @@ _EOF
}

@test "bud with Dockerfile from stdin" {
skip_if_rootless_environment
_prefetch alpine
target=df-stdin
run_buildah build --signature-policy ${TESTSDIR}/policy.json -t ${target} - < ${TESTSDIR}/bud/context-from-stdin/Dockerfile
Expand All @@ -2321,7 +2296,6 @@ _EOF
}

@test "bud with Dockerfile from stdin tar" {
skip_if_rootless_environment
_prefetch alpine
target=df-stdin
# 'cmd1 < <(cmd2)' == 'cmd2 | cmd1' but runs cmd1 in this shell, not sub.
Expand Down
13 changes: 0 additions & 13 deletions tests/copy.bats
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ load helpers
}

@test "copy-local-multiple" {
skip_if_rootless_environment
createrandom ${TESTDIR}/randomfile
createrandom ${TESTDIR}/other-randomfile
createrandom ${TESTDIR}/third-randomfile
Expand Down Expand Up @@ -54,7 +53,6 @@ load helpers
}

@test "copy-local-plain" {
skip_if_rootless_environment
createrandom ${TESTDIR}/randomfile
createrandom ${TESTDIR}/other-randomfile
createrandom ${TESTDIR}/third-randomfile
Expand All @@ -81,7 +79,6 @@ load helpers
}

@test "copy-local-subdirectory" {
skip_if_rootless_environment
mkdir -p ${TESTDIR}/subdir
createrandom ${TESTDIR}/subdir/randomfile
createrandom ${TESTDIR}/subdir/other-randomfile
Expand All @@ -104,7 +101,6 @@ load helpers
}

@test "copy-local-force-directory" {
skip_if_rootless_environment
createrandom ${TESTDIR}/randomfile

run_buildah from --signature-policy ${TESTSDIR}/policy.json scratch
Expand All @@ -128,7 +124,6 @@ load helpers
}

@test "copy-url-mtime" {
skip_if_rootless_environment
# Create a file with random content and a non-now timestamp (so we can
# can trust that buildah correctly set mtime on copy)
createrandom ${TESTDIR}/randomfile
Expand Down Expand Up @@ -242,7 +237,6 @@ load helpers
}

@test "copy-symlink" {
skip_if_rootless_environment
createrandom ${TESTDIR}/randomfile
ln -s ${TESTDIR}/randomfile ${TESTDIR}/link-randomfile

Expand All @@ -266,7 +260,6 @@ load helpers
}

@test "ignore-socket" {
skip_if_rootless_environment
createrandom ${TESTDIR}/randomfile
# This seems to be the least-worst way to create a socket: run and kill nc
nc -lkU ${TESTDIR}/test.socket &
Expand Down Expand Up @@ -300,7 +293,6 @@ load helpers
}

@test "copy-symlink-archive-suffix" {
skip_if_rootless_environment
createrandom ${TESTDIR}/randomfile.tar.gz
ln -s ${TESTDIR}/randomfile.tar.gz ${TESTDIR}/link-randomfile.tar.gz

Expand Down Expand Up @@ -335,7 +327,6 @@ load helpers
}

@test "copy --ignorefile" {
skip_if_rootless_environment
mytest=${TESTDIR}/mytest
mkdir -p ${mytest}
touch ${mytest}/mystuff
Expand Down Expand Up @@ -369,7 +360,6 @@ stuff/mystuff"
}

@test "copy-quiet" {
skip_if_rootless_environment
createrandom ${TESTDIR}/randomfile
_prefetch alpine
run_buildah from --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json alpine
Expand All @@ -384,7 +374,6 @@ stuff/mystuff"
}

@test "copy-from-container" {
skip_if_rootless_environment
_prefetch busybox
createrandom ${TESTDIR}/randomfile
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json busybox
Expand All @@ -404,7 +393,6 @@ stuff/mystuff"
}

@test "copy-container-root" {
skip_if_rootless_environment
_prefetch busybox
createrandom ${TESTDIR}/randomfile
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json busybox
Expand All @@ -422,7 +410,6 @@ stuff/mystuff"
}

@test "add-from-image" {
skip_if_rootless_environment
_prefetch busybox
run_buildah from --quiet --signature-policy ${TESTSDIR}/policy.json busybox
cid=$output
Expand Down
Loading

0 comments on commit cf6d58b

Please sign in to comment.