BATS major cleanup, part 1: log-level

PR #1935 removed the default --debug logging; so all run_buildah
calls now use the default (error). It is safe to remove unnecessary
instances of --log-level=error .

For ease of review, this commit was entirely machine-generated via:

    $ perl -pi -e 's/ --log-level=error / /' *.bats

Signed-off-by: Ed Santiago <santiago@redhat.com>

Closes: #2029
Approved by: rhatdan
This commit is contained in:
Ed Santiago 2019-12-11 11:28:27 -07:00 committed by Atomic Bot
parent acc7c35b61
commit dee4b68ef0
22 changed files with 467 additions and 467 deletions

View File

@ -102,9 +102,9 @@ load helpers
run_buildah rmi remove-container-image run_buildah rmi remove-container-image
run_buildah rmi containers-storage:other-new-image run_buildah rmi containers-storage:other-new-image
run_buildah rmi another-new-image run_buildah rmi another-new-image
run_buildah --log-level=error images -q run_buildah images -q
[ "$output" != "" ] [ "$output" != "" ]
run_buildah rmi -a run_buildah rmi -a
run_buildah --log-level=error images -q run_buildah images -q
expect_output "" expect_output ""
} }

View File

@ -30,7 +30,7 @@ load helpers
blobcachedir=${TESTDIR}/cache blobcachedir=${TESTDIR}/cache
mkdir -p ${blobcachedir} mkdir -p ${blobcachedir}
# Pull an image using a fresh directory for the blob cache. # Pull an image using a fresh directory for the blob cache.
run_buildah --log-level=error from --quiet --blob-cache=${blobcachedir} --signature-policy ${TESTSDIR}/policy.json k8s.gcr.io/pause run_buildah from --quiet --blob-cache=${blobcachedir} --signature-policy ${TESTSDIR}/policy.json k8s.gcr.io/pause
ctr="$output" ctr="$output"
run_buildah add ${ctr} ${TESTSDIR}/bud/add-file/file / run_buildah add ${ctr} ${TESTSDIR}/bud/add-file/file /
# Commit the image without using the blob cache, using compression so that uncompressed blobs # Commit the image without using the blob cache, using compression so that uncompressed blobs
@ -97,7 +97,7 @@ load helpers
blobcachedir=${TESTDIR}/cache blobcachedir=${TESTDIR}/cache
mkdir -p ${blobcachedir} mkdir -p ${blobcachedir}
# Pull an image using a fresh directory for the blob cache. # Pull an image using a fresh directory for the blob cache.
run_buildah --log-level=error from --quiet --blob-cache=${blobcachedir} --signature-policy ${TESTSDIR}/policy.json k8s.gcr.io/pause run_buildah from --quiet --blob-cache=${blobcachedir} --signature-policy ${TESTSDIR}/policy.json k8s.gcr.io/pause
ctr="$output" ctr="$output"
run_buildah add ${ctr} ${TESTSDIR}/bud/add-file/file / run_buildah add ${ctr} ${TESTSDIR}/bud/add-file/file /
# Commit the image using the blob cache. # Commit the image using the blob cache.

File diff suppressed because it is too large Load Diff

View File

@ -6,24 +6,24 @@ load helpers
image=busybox image=busybox
# Pull down the image, if we have to. # Pull down the image, if we have to.
cid=$(buildah --log-level=error from --pull=false --signature-policy ${TESTSDIR}/policy.json $image) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json $image)
[ $? -eq 0 ] [ $? -eq 0 ]
[ $(wc -l <<< "$cid") -eq 1 ] [ $(wc -l <<< "$cid") -eq 1 ]
buildah rm $cid buildah rm $cid
# Get the image's ID. # Get the image's ID.
run_buildah --log-level=error images -q $image run_buildah images -q $image
expect_line_count 1 expect_line_count 1
iid="$output" iid="$output"
# Use the image's ID to create a container. # Use the image's ID to create a container.
run_buildah --log-level=error from --pull=false --signature-policy ${TESTSDIR}/policy.json ${iid} run_buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json ${iid}
expect_line_count 1 expect_line_count 1
cid="$output" cid="$output"
buildah rm $cid buildah rm $cid
# Use a truncated form of the image's ID to create a container. # Use a truncated form of the image's ID to create a container.
run_buildah --log-level=error from --pull=false --signature-policy ${TESTSDIR}/policy.json ${iid:0:6} run_buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json ${iid:0:6}
expect_line_count 1 expect_line_count 1
cid="$output" cid="$output"
buildah rm $cid buildah rm $cid
@ -35,21 +35,21 @@ load helpers
image=busybox image=busybox
# Pull down the image, if we have to. # Pull down the image, if we have to.
cid=$(buildah --log-level=error from --pull=false --signature-policy ${TESTSDIR}/policy.json $image) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json $image)
[ $? -eq 0 ] [ $? -eq 0 ]
[ $(wc -l <<< "$cid") -eq 1 ] [ $(wc -l <<< "$cid") -eq 1 ]
buildah rm $cid buildah rm $cid
# Get the image's ID. # Get the image's ID.
run_buildah --log-level=error images -q $image run_buildah images -q $image
expect_line_count 1 expect_line_count 1
iid="$output" iid="$output"
# Use the image's ID to inspect it. # Use the image's ID to inspect it.
run_buildah --log-level=error inspect --type=image ${iid} run_buildah inspect --type=image ${iid}
# Use a truncated copy of the image's ID to inspect it. # Use a truncated copy of the image's ID to inspect it.
run_buildah --log-level=error inspect --type=image ${iid:0:6} run_buildah inspect --type=image ${iid:0:6}
buildah rmi $iid buildah rmi $iid
} }
@ -62,13 +62,13 @@ load helpers
mkdir -p $TARGET $TARGET-truncated mkdir -p $TARGET $TARGET-truncated
# Pull down the image, if we have to. # Pull down the image, if we have to.
cid=$(buildah --log-level=error from --pull=false --signature-policy ${TESTSDIR}/policy.json $image) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json $image)
[ $? -eq 0 ] [ $? -eq 0 ]
[ $(wc -l <<< "$cid") -eq 1 ] [ $(wc -l <<< "$cid") -eq 1 ]
buildah rm $cid buildah rm $cid
# Get the image's ID. # Get the image's ID.
run_buildah --log-level=error images -q $IMAGE run_buildah images -q $IMAGE
expect_line_count 1 expect_line_count 1
iid="$output" iid="$output"
@ -87,16 +87,16 @@ load helpers
image=busybox image=busybox
# Pull down the image, if we have to. # Pull down the image, if we have to.
cid=$(buildah --log-level=error from --pull=false --signature-policy ${TESTSDIR}/policy.json $image) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json $image)
[ $? -eq 0 ] [ $? -eq 0 ]
[ $(wc -l <<< "$cid") -eq 1 ] [ $(wc -l <<< "$cid") -eq 1 ]
buildah rm $cid buildah rm $cid
# Get the image's ID. # Get the image's ID.
run_buildah --log-level=error images -q $image run_buildah images -q $image
expect_line_count 1 expect_line_count 1
iid="$output" iid="$output"
# Use a truncated copy of the image's ID to remove it. # Use a truncated copy of the image's ID to remove it.
run_buildah --log-level=error rmi ${iid:0:6} run_buildah rmi ${iid:0:6}
} }

View File

@ -29,15 +29,15 @@ load helpers
buildah commit --signature-policy ${TESTSDIR}/policy.json $cid alpine-image-oci buildah commit --signature-policy ${TESTSDIR}/policy.json $cid alpine-image-oci
buildah commit --format docker --disable-compression=false --signature-policy ${TESTSDIR}/policy.json $cid alpine-image-docker buildah commit --format docker --disable-compression=false --signature-policy ${TESTSDIR}/policy.json $cid alpine-image-docker
buildah --log-level=error inspect --type=image --format '{{.Manifest}}' alpine-image-oci | grep "application/vnd.oci.image.layer.v1.tar" buildah inspect --type=image --format '{{.Manifest}}' alpine-image-oci | grep "application/vnd.oci.image.layer.v1.tar"
buildah --log-level=error inspect --type=image --format '{{.Manifest}}' alpine-image-docker | grep "application/vnd.docker.image.rootfs.diff.tar.gzip" buildah inspect --type=image --format '{{.Manifest}}' alpine-image-docker | grep "application/vnd.docker.image.rootfs.diff.tar.gzip"
buildah rm $cid buildah rm $cid
buildah rmi -a buildah rmi -a
} }
@test "commit quiet test" { @test "commit quiet test" {
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah --log-level=error commit --iidfile /dev/null --signature-policy ${TESTSDIR}/policy.json -q $cid alpine-image run_buildah commit --iidfile /dev/null --signature-policy ${TESTSDIR}/policy.json -q $cid alpine-image
expect_output "" expect_output ""
buildah rm $cid buildah rm $cid
buildah rmi -a buildah rmi -a
@ -46,7 +46,7 @@ load helpers
@test "commit rm test" { @test "commit rm test" {
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
buildah commit --signature-policy ${TESTSDIR}/policy.json --rm $cid alpine-image buildah commit --signature-policy ${TESTSDIR}/policy.json --rm $cid alpine-image
run_buildah 1 --log-level=error rm $cid run_buildah 1 rm $cid
expect_output --substring "error removing container \"alpine-working-container\": error reading build container: container not known" expect_output --substring "error removing container \"alpine-working-container\": error reading build container: container not known"
buildah rmi -a buildah rmi -a
} }
@ -62,7 +62,7 @@ load helpers
@test "commit-rejected-name" { @test "commit-rejected-name" {
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah 1 --log-level=error commit --signature-policy ${TESTSDIR}/policy.json $cid ThisNameShouldBeRejected run_buildah 1 commit --signature-policy ${TESTSDIR}/policy.json $cid ThisNameShouldBeRejected
expect_output --substring "must be lower" expect_output --substring "must be lower"
} }
@ -73,18 +73,18 @@ load helpers
target=new-image target=new-image
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah --log-level=error config --created-by "untracked actions" $cid run_buildah config --created-by "untracked actions" $cid
run_buildah --log-level=error commit --signature-policy ${TESTSDIR}/policy.json $cid ${target} run_buildah commit --signature-policy ${TESTSDIR}/policy.json $cid ${target}
run_buildah --log-level=error inspect --format '{{.Config}}' ${target} run_buildah inspect --format '{{.Config}}' ${target}
config="$output" config="$output"
run python3 -c 'import json, sys; config = json.load(sys.stdin); print(config["history"][len(config["history"])-1]["created_by"])' <<< "$config" run python3 -c 'import json, sys; config = json.load(sys.stdin); print(config["history"][len(config["history"])-1]["created_by"])' <<< "$config"
echo "$output" echo "$output"
[ "${status}" -eq 0 ] [ "${status}" -eq 0 ]
[ "$output" == "untracked actions" ] [ "$output" == "untracked actions" ]
run_buildah --log-level=error config --created-by "" $cid run_buildah config --created-by "" $cid
run_buildah --log-level=error commit --signature-policy ${TESTSDIR}/policy.json $cid ${target} run_buildah commit --signature-policy ${TESTSDIR}/policy.json $cid ${target}
run_buildah --log-level=error inspect --format '{{.Config}}' ${target} run_buildah inspect --format '{{.Config}}' ${target}
config="$output" config="$output"
run python3 -c 'import json, sys; config = json.load(sys.stdin); print(config["history"][len(config["history"])-1]["created_by"])' <<< "$config" run python3 -c 'import json, sys; config = json.load(sys.stdin); print(config["history"][len(config["history"])-1]["created_by"])' <<< "$config"
echo "$output" echo "$output"

View File

@ -23,7 +23,7 @@ function check_matrix() {
# matrix test: all permutations of .Docker.* and .OCIv1.* in all image types # matrix test: all permutations of .Docker.* and .OCIv1.* in all image types
for image in docker oci; do for image in docker oci; do
for which in Docker OCIv1; do for which in Docker OCIv1; do
run_buildah --log-level=error inspect --type=image --format "{{.$which.$setting}}" scratch-image-$image run_buildah inspect --type=image --format "{{.$which.$setting}}" scratch-image-$image
expect_output "$expect" expect_output "$expect"
done done
done done
@ -143,7 +143,7 @@ function check_matrix() {
check_matrix 'Architecture' 'amd64' check_matrix 'Architecture' 'amd64'
check_matrix 'OS' 'linux' check_matrix 'OS' 'linux'
buildah --log-level=error inspect --format '{{.ImageCreatedBy}}' $cid | grep COINCIDENCE buildah inspect --format '{{.ImageCreatedBy}}' $cid | grep COINCIDENCE
check_matrix 'Config.Cmd' '[COMMAND-OR-ARGS]' check_matrix 'Config.Cmd' '[COMMAND-OR-ARGS]'
check_matrix 'Config.Entrypoint' '[/bin/sh -c /ENTRYPOINT]' check_matrix 'Config.Entrypoint' '[/bin/sh -c /ENTRYPOINT]'
@ -156,23 +156,23 @@ function check_matrix() {
check_matrix 'Config.Volumes' "map[/VOLUME:{}]" check_matrix 'Config.Volumes' "map[/VOLUME:{}]"
check_matrix 'Config.WorkingDir' '/tmp' check_matrix 'Config.WorkingDir' '/tmp'
buildah --log-level=error inspect --type=image --format '{{(index .Docker.History 0).Comment}}' scratch-image-docker | grep PROBABLY-EMPTY buildah inspect --type=image --format '{{(index .Docker.History 0).Comment}}' scratch-image-docker | grep PROBABLY-EMPTY
buildah --log-level=error inspect --type=image --format '{{(index .OCIv1.History 0).Comment}}' scratch-image-docker | grep PROBABLY-EMPTY buildah inspect --type=image --format '{{(index .OCIv1.History 0).Comment}}' scratch-image-docker | grep PROBABLY-EMPTY
buildah --log-level=error inspect --type=image --format '{{(index .Docker.History 0).Comment}}' scratch-image-oci | grep PROBABLY-EMPTY buildah inspect --type=image --format '{{(index .Docker.History 0).Comment}}' scratch-image-oci | grep PROBABLY-EMPTY
buildah --log-level=error inspect --type=image --format '{{(index .OCIv1.History 0).Comment}}' scratch-image-oci | grep PROBABLY-EMPTY buildah inspect --type=image --format '{{(index .OCIv1.History 0).Comment}}' scratch-image-oci | grep PROBABLY-EMPTY
# The following aren't part of the Docker v2 spec, so they're discarded when we save to Docker format. # The following aren't part of the Docker v2 spec, so they're discarded when we save to Docker format.
buildah --log-level=error inspect --type=image --format '{{.ImageAnnotations}}' scratch-image-oci | grep ANNOTATION:VALUE1,VALUE2 buildah inspect --type=image --format '{{.ImageAnnotations}}' scratch-image-oci | grep ANNOTATION:VALUE1,VALUE2
buildah --log-level=error inspect --format '{{.ImageAnnotations}}' $cid | grep ANNOTATION:VALUE1,VALUE2 buildah inspect --format '{{.ImageAnnotations}}' $cid | grep ANNOTATION:VALUE1,VALUE2
buildah --log-level=error inspect --type=image --format '{{.Docker.Comment}}' scratch-image-docker | grep INFORMATIVE buildah inspect --type=image --format '{{.Docker.Comment}}' scratch-image-docker | grep INFORMATIVE
buildah --log-level=error inspect --type=image --format '{{.Docker.Config.Domainname}}' scratch-image-docker | grep mydomain.local buildah inspect --type=image --format '{{.Docker.Config.Domainname}}' scratch-image-docker | grep mydomain.local
buildah --log-level=error inspect --type=image --format '{{.Docker.Config.Hostname}}' scratch-image-docker | grep cleverhostname buildah inspect --type=image --format '{{.Docker.Config.Hostname}}' scratch-image-docker | grep cleverhostname
buildah --log-level=error inspect --type=image --format '{{.Docker.Config.Shell}}' scratch-image-docker | grep /bin/arbitrarysh buildah inspect --type=image --format '{{.Docker.Config.Shell}}' scratch-image-docker | grep /bin/arbitrarysh
buildah --log-level=error inspect -f '{{.Docker.Config.Healthcheck.Test}}' scratch-image-docker | grep true buildah inspect -f '{{.Docker.Config.Healthcheck.Test}}' scratch-image-docker | grep true
buildah --log-level=error inspect -f '{{.Docker.Config.Healthcheck.StartPeriod}}' scratch-image-docker | grep 5 buildah inspect -f '{{.Docker.Config.Healthcheck.StartPeriod}}' scratch-image-docker | grep 5
buildah --log-level=error inspect -f '{{.Docker.Config.Healthcheck.Interval}}' scratch-image-docker | grep 6 buildah inspect -f '{{.Docker.Config.Healthcheck.Interval}}' scratch-image-docker | grep 6
buildah --log-level=error inspect -f '{{.Docker.Config.Healthcheck.Timeout}}' scratch-image-docker | grep 7 buildah inspect -f '{{.Docker.Config.Healthcheck.Timeout}}' scratch-image-docker | grep 7
buildah --log-level=error inspect -f '{{.Docker.Config.Healthcheck.Retries}}' scratch-image-docker | grep 8 buildah inspect -f '{{.Docker.Config.Healthcheck.Retries}}' scratch-image-docker | grep 8
rm -rf /VOLUME rm -rf /VOLUME
} }
@ -183,10 +183,10 @@ function check_matrix() {
buildah commit --format docker --signature-policy ${TESTSDIR}/policy.json $cid env-image-docker buildah commit --format docker --signature-policy ${TESTSDIR}/policy.json $cid env-image-docker
buildah commit --format oci --signature-policy ${TESTSDIR}/policy.json $cid env-image-oci buildah commit --format oci --signature-policy ${TESTSDIR}/policy.json $cid env-image-oci
run_buildah --log-level=error inspect --type=image --format '{{.Docker.Config.Env}}' env-image-docker run_buildah inspect --type=image --format '{{.Docker.Config.Env}}' env-image-docker
expect_output --substring "combined=bar/bar1" expect_output --substring "combined=bar/bar1"
run_buildah --log-level=error inspect --type=image --format '{{.OCIv1.Config.Env}}' env-image-docker run_buildah inspect --type=image --format '{{.OCIv1.Config.Env}}' env-image-docker
expect_output --substring "combined=bar/bar1" expect_output --substring "combined=bar/bar1"
buildah rm $cid buildah rm $cid
@ -195,15 +195,15 @@ function check_matrix() {
@test "user" { @test "user" {
cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull --signature-policy ${TESTSDIR}/policy.json alpine)
bndoutput=$(buildah --log-level=error run $cid grep CapBnd /proc/self/status) bndoutput=$(buildah run $cid grep CapBnd /proc/self/status)
buildah config --user 1000 $cid buildah config --user 1000 $cid
run_buildah --log-level=error run $cid id -u run_buildah run $cid id -u
expect_output "1000" expect_output "1000"
run_buildah --log-level=error run $cid sh -c "grep CapEff /proc/self/status | cut -f2" run_buildah run $cid sh -c "grep CapEff /proc/self/status | cut -f2"
expect_output "0000000000000000" expect_output "0000000000000000"
run_buildah --log-level=error run $cid grep CapBnd /proc/self/status run_buildah run $cid grep CapBnd /proc/self/status
expect_output "$bndoutput" expect_output "$bndoutput"
buildah rm $cid buildah rm $cid
@ -221,13 +221,13 @@ function check_matrix() {
buildah commit --format docker --signature-policy ${TESTSDIR}/policy.json $cid scratch-image-docker buildah commit --format docker --signature-policy ${TESTSDIR}/policy.json $cid scratch-image-docker
buildah commit --format oci --signature-policy ${TESTSDIR}/policy.json $cid scratch-image-oci buildah commit --format oci --signature-policy ${TESTSDIR}/policy.json $cid scratch-image-oci
buildah --log-level=error inspect --format '{{.ImageCreatedBy}}' $cid | grep COINCIDENCE buildah inspect --format '{{.ImageCreatedBy}}' $cid | grep COINCIDENCE
check_matrix 'Config.Volumes' "map[/VOLUME:{}]" check_matrix 'Config.Volumes' "map[/VOLUME:{}]"
check_matrix 'Config.Env' '[VARIABLE=VALUE1,VALUE2]' check_matrix 'Config.Env' '[VARIABLE=VALUE1,VALUE2]'
check_matrix 'Config.Labels.LABEL' 'VALUE' check_matrix 'Config.Labels.LABEL' 'VALUE'
buildah --log-level=error inspect --type=image --format '{{.ImageAnnotations}}' scratch-image-oci | grep ANNOTATION:VALUE1,VALUE2 buildah inspect --type=image --format '{{.ImageAnnotations}}' scratch-image-oci | grep ANNOTATION:VALUE1,VALUE2
buildah --log-level=error inspect --format '{{.ImageAnnotations}}' $cid | grep ANNOTATION:VALUE1,VALUE2 buildah inspect --format '{{.ImageAnnotations}}' $cid | grep ANNOTATION:VALUE1,VALUE2
buildah config \ buildah config \
--created-by COINCIDENCE \ --created-by COINCIDENCE \
@ -239,12 +239,12 @@ function check_matrix() {
buildah commit --format docker --signature-policy ${TESTSDIR}/policy.json $cid scratch-image-docker buildah commit --format docker --signature-policy ${TESTSDIR}/policy.json $cid scratch-image-docker
buildah commit --format oci --signature-policy ${TESTSDIR}/policy.json $cid scratch-image-oci buildah commit --format oci --signature-policy ${TESTSDIR}/policy.json $cid scratch-image-oci
buildah --log-level=error inspect --format '{{.ImageCreatedBy}}' $cid | grep COINCIDENCE buildah inspect --format '{{.ImageCreatedBy}}' $cid | grep COINCIDENCE
check_matrix 'Config.Volumes' 'map[]' check_matrix 'Config.Volumes' 'map[]'
check_matrix 'Config.Env' '[]' check_matrix 'Config.Env' '[]'
check_matrix 'Config.Labels.LABEL' '<no value>' check_matrix 'Config.Labels.LABEL' '<no value>'
buildah --log-level=error inspect --type=image --format '{{.ImageAnnotations}}' scratch-image-oci | grep "map\[\]" buildah inspect --type=image --format '{{.ImageAnnotations}}' scratch-image-oci | grep "map\[\]"
buildah --log-level=error inspect --format '{{.ImageAnnotations}}' $cid | grep "map\[\]" buildah inspect --format '{{.ImageAnnotations}}' $cid | grep "map\[\]"
@ -258,7 +258,7 @@ function check_matrix() {
buildah commit --format docker --signature-policy ${TESTSDIR}/policy.json $cid scratch-image-docker buildah commit --format docker --signature-policy ${TESTSDIR}/policy.json $cid scratch-image-docker
buildah commit --format oci --signature-policy ${TESTSDIR}/policy.json $cid scratch-image-oci buildah commit --format oci --signature-policy ${TESTSDIR}/policy.json $cid scratch-image-oci
buildah --log-level=error inspect --format '{{.ImageCreatedBy}}' $cid | grep COINCIDENCE buildah inspect --format '{{.ImageCreatedBy}}' $cid | grep COINCIDENCE
check_matrix 'Config.Volumes' "map[/VOLUME-:{}]" check_matrix 'Config.Volumes' "map[/VOLUME-:{}]"

View File

@ -5,7 +5,7 @@ load helpers
@test "containers" { @test "containers" {
cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox) cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah --log-level=error containers run_buildah containers
expect_line_count 3 expect_line_count 3
buildah rm -a buildah rm -a
@ -15,7 +15,7 @@ load helpers
@test "containers filter test" { @test "containers filter test" {
cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox) cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah --log-level=error containers --filter name=$cid1 run_buildah containers --filter name=$cid1
expect_line_count 2 expect_line_count 2
buildah rm -a buildah rm -a
@ -25,7 +25,7 @@ load helpers
@test "containers format test" { @test "containers format test" {
cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox) cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah --log-level=error containers --format "{{.ContainerName}}" run_buildah containers --format "{{.ContainerName}}"
expect_line_count 2 expect_line_count 2
expect_output --from="${lines[0]}" "alpine-working-container" expect_output --from="${lines[0]}" "alpine-working-container"
expect_output --from="${lines[1]}" "busybox-working-container" expect_output --from="${lines[1]}" "busybox-working-container"
@ -36,7 +36,7 @@ load helpers
@test "containers json test" { @test "containers json test" {
cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
out=$(buildah --log-level=error containers --json | grep "{" | wc -l) out=$(buildah containers --json | grep "{" | wc -l)
[ "$out" -ne "0" ] [ "$out" -ne "0" ]
buildah rm -a buildah rm -a
buildah rmi -a -f buildah rmi -a -f
@ -45,7 +45,7 @@ load helpers
@test "containers noheading test" { @test "containers noheading test" {
cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox) cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah --log-level=error containers --noheading run_buildah containers --noheading
expect_line_count 2 expect_line_count 2
if [[ $output =~ "NAME" ]]; then if [[ $output =~ "NAME" ]]; then
expect_output "[no instance of 'NAME']" "'NAME' header should be absent" expect_output "[no instance of 'NAME']" "'NAME' header should be absent"
@ -58,7 +58,7 @@ load helpers
@test "containers quiet test" { @test "containers quiet test" {
cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox) cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah --log-level=error containers --quiet run_buildah containers --quiet
expect_line_count 2 expect_line_count 2
# Both lines should be CIDs and nothing else. # Both lines should be CIDs and nothing else.

View File

@ -66,7 +66,7 @@ load helpers
# ctrid=$(buildah from localhost:5000/my-alpine --cert-dir ${TESTDIR}/auth) # ctrid=$(buildah from localhost:5000/my-alpine --cert-dir ${TESTDIR}/auth)
# buildah rm $ctrid # buildah rm $ctrid
# buildah rmi -f $(buildah --log-level=error images -q) # buildah rmi -f $(buildah images -q)
# This should work # This should work
# ctrid=$(buildah from localhost:5000/my-alpine --cert-dir ${TESTDIR}/auth --tls-verify true) # ctrid=$(buildah from localhost:5000/my-alpine --cert-dir ${TESTDIR}/auth --tls-verify true)
@ -82,7 +82,7 @@ load helpers
# docker rmi -f localhost:5000/my-alpine # docker rmi -f localhost:5000/my-alpine
# docker rmi -f $(docker images -q) # docker rmi -f $(docker images -q)
# buildah rm $ctrid # buildah rm $ctrid
# buildah rmi -f $(buildah --log-level=error images -q) # buildah rmi -f $(buildah images -q)
} }
@test "from-authenticate-cert-and-creds" { @test "from-authenticate-cert-and-creds" {
@ -105,7 +105,7 @@ load helpers
# ctrid=$(buildah from localhost:5000/my-alpine --cert-dir ${TESTDIR}/auth) # ctrid=$(buildah from localhost:5000/my-alpine --cert-dir ${TESTDIR}/auth)
# buildah rm $ctrid # buildah rm $ctrid
# buildah rmi -f $(buildah --log-level=error images -q) # buildah rmi -f $(buildah images -q)
# docker logout localhost:5000 # docker logout localhost:5000
@ -122,7 +122,7 @@ load helpers
# docker rmi -f localhost:5000/my-alpine # docker rmi -f localhost:5000/my-alpine
# docker rmi -f $(docker images -q) # docker rmi -f $(docker images -q)
# buildah rm $ctrid # buildah rm $ctrid
# buildah rmi -f $(buildah --log-level=error images -q) # buildah rmi -f $(buildah images -q)
} }
@test "from-tagged-image" { @test "from-tagged-image" {
@ -216,7 +216,7 @@ load helpers
skip_if_cgroupsv2 skip_if_cgroupsv2
cid=$(buildah from --cpu-period=5000 --pull --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --cpu-period=5000 --pull --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah --log-level=error run $cid cat /sys/fs/cgroup/cpu/cpu.cfs_period_us run_buildah run $cid cat /sys/fs/cgroup/cpu/cpu.cfs_period_us
expect_output "5000" expect_output "5000"
buildah rm $cid buildah rm $cid
} }
@ -228,7 +228,7 @@ load helpers
skip_if_cgroupsv2 skip_if_cgroupsv2
cid=$(buildah from --cpu-quota=5000 --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --cpu-quota=5000 --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah --log-level=error run $cid cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us run_buildah run $cid cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us
expect_output "5000" expect_output "5000"
buildah rm $cid buildah rm $cid
} }
@ -240,7 +240,7 @@ load helpers
skip_if_cgroupsv2 skip_if_cgroupsv2
cid=$(buildah from --cpu-shares=2 --pull --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --cpu-shares=2 --pull --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah --log-level=error run $cid cat /sys/fs/cgroup/cpu/cpu.shares run_buildah run $cid cat /sys/fs/cgroup/cpu/cpu.shares
expect_output "2" expect_output "2"
buildah rm $cid buildah rm $cid
} }
@ -252,7 +252,7 @@ load helpers
skip_if_cgroupsv2 "cgroupsv2: fails with EPERM on writing cpuset.cpus" skip_if_cgroupsv2 "cgroupsv2: fails with EPERM on writing cpuset.cpus"
cid=$(buildah from --cpuset-cpus=0 --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --cpuset-cpus=0 --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah --log-level=error run $cid cat /sys/fs/cgroup/cpuset/cpuset.cpus run_buildah run $cid cat /sys/fs/cgroup/cpuset/cpuset.cpus
expect_output "0" expect_output "0"
buildah rm $cid buildah rm $cid
} }
@ -264,7 +264,7 @@ load helpers
skip_if_cgroupsv2 "cgroupsv2: fails with EPERM on writing cpuset.mems" skip_if_cgroupsv2 "cgroupsv2: fails with EPERM on writing cpuset.mems"
cid=$(buildah from --cpuset-mems=0 --pull --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --cpuset-mems=0 --pull --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah --log-level=error run $cid cat /sys/fs/cgroup/cpuset/cpuset.mems run_buildah run $cid cat /sys/fs/cgroup/cpuset/cpuset.mems
expect_output "0" expect_output "0"
buildah rm $cid buildah rm $cid
} }
@ -280,7 +280,7 @@ load helpers
if is_cgroupsv2; then if is_cgroupsv2; then
mpath="/sys/fs/cgroup\$(awk -F: '{print \$3}' /proc/self/cgroup)/memory.max" mpath="/sys/fs/cgroup\$(awk -F: '{print \$3}' /proc/self/cgroup)/memory.max"
fi fi
run_buildah --log-level=error run $cid sh -c "cat $mpath" run_buildah run $cid sh -c "cat $mpath"
expect_output "41943040" "$mpath" expect_output "41943040" "$mpath"
buildah rm $cid buildah rm $cid
} }
@ -289,7 +289,7 @@ load helpers
skip_if_no_runtime skip_if_no_runtime
cid=$(buildah from --volume=${TESTDIR}:/myvol --pull --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --volume=${TESTDIR}:/myvol --pull --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah --log-level=error run $cid -- cat /proc/mounts run_buildah run $cid -- cat /proc/mounts
expect_output --substring " /myvol " expect_output --substring " /myvol "
buildah rm $cid buildah rm $cid
} }
@ -299,7 +299,7 @@ load helpers
skip_if_no_runtime skip_if_no_runtime
cid=$(buildah from --volume=${TESTDIR}:/myvol:ro --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --volume=${TESTDIR}:/myvol:ro --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah --log-level=error run $cid -- cat /proc/mounts run_buildah run $cid -- cat /proc/mounts
expect_output --substring " /myvol " expect_output --substring " /myvol "
buildah rm $cid buildah rm $cid
} }
@ -309,7 +309,7 @@ load helpers
skip_if_no_runtime skip_if_no_runtime
cid=$(buildah from --shm-size=80m --pull --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --shm-size=80m --pull --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah --log-level=error run $cid -- df -h /dev/shm run_buildah run $cid -- df -h /dev/shm
expect_output --substring " 80.0M " expect_output --substring " 80.0M "
buildah rm $cid buildah rm $cid
} }
@ -326,14 +326,14 @@ load helpers
@test "from name test" { @test "from name test" {
container_name=mycontainer container_name=mycontainer
cid=$(buildah from --name=${container_name} --pull --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --name=${container_name} --pull --signature-policy ${TESTSDIR}/policy.json alpine)
buildah --log-level=error inspect --format '{{.Container}}' ${container_name} buildah inspect --format '{{.Container}}' ${container_name}
buildah rm $cid buildah rm $cid
} }
@test "from cidfile test" { @test "from cidfile test" {
buildah from --cidfile output.cid --pull=false --signature-policy ${TESTSDIR}/policy.json alpine buildah from --cidfile output.cid --pull=false --signature-policy ${TESTSDIR}/policy.json alpine
cid=$(cat output.cid) cid=$(cat output.cid)
run_buildah --log-level=error containers -f id=${cid} run_buildah containers -f id=${cid}
buildah rm ${cid} buildah rm ${cid}
} }

View File

@ -86,7 +86,7 @@ function testconfighistory() {
@test "history-copy" { @test "history-copy" {
createrandom ${TESTDIR}/randomfile createrandom ${TESTDIR}/randomfile
buildah from --name copyctr --format docker scratch buildah from --name copyctr --format docker scratch
run_buildah --log-level=error copy --add-history copyctr ${TESTDIR}/randomfile run_buildah copy --add-history copyctr ${TESTDIR}/randomfile
digest="$output" digest="$output"
buildah commit --signature-policy ${TESTSDIR}/policy.json copyctr copyimg buildah commit --signature-policy ${TESTSDIR}/policy.json copyctr copyimg
buildah inspect --format '{{range .Docker.History}}{{println .CreatedBy}}{{end}}' copyimg buildah inspect --format '{{range .Docker.History}}{{println .CreatedBy}}{{end}}' copyimg

View File

@ -18,7 +18,7 @@ load helpers
@test "images" { @test "images" {
cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox) cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah --log-level=error images run_buildah images
expect_line_count 3 expect_line_count 3
buildah rm -a buildah rm -a
buildah rmi -a -f buildah rmi -a -f
@ -26,15 +26,15 @@ load helpers
@test "images all test" { @test "images all test" {
buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test ${TESTSDIR}/bud/use-layers buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test ${TESTSDIR}/bud/use-layers
run_buildah --log-level=error images run_buildah images
expect_line_count 3 expect_line_count 3
run_buildah --log-level=error images -a run_buildah images -a
expect_line_count 8 expect_line_count 8
# create a no name image which should show up when doing buildah images without the --all flag # create a no name image which should show up when doing buildah images without the --all flag
buildah bud --signature-policy ${TESTSDIR}/policy.json ${TESTSDIR}/bud/use-layers buildah bud --signature-policy ${TESTSDIR}/policy.json ${TESTSDIR}/bud/use-layers
run_buildah --log-level=error images run_buildah images
expect_line_count 4 expect_line_count 4
buildah rmi -a -f buildah rmi -a -f
@ -43,7 +43,7 @@ load helpers
@test "images filter test" { @test "images filter test" {
cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json k8s.gcr.io/pause) cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json k8s.gcr.io/pause)
cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox) cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah --log-level=error images --noheading --filter since=k8s.gcr.io/pause run_buildah images --noheading --filter since=k8s.gcr.io/pause
expect_line_count 1 expect_line_count 1
buildah rm -a buildah rm -a
buildah rmi -a -f buildah rmi -a -f
@ -52,7 +52,7 @@ load helpers
@test "images format test" { @test "images format test" {
cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox) cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah --log-level=error images --format "{{.Name}}" run_buildah images --format "{{.Name}}"
expect_line_count 2 expect_line_count 2
buildah rm -a buildah rm -a
buildah rmi -a -f buildah rmi -a -f
@ -61,7 +61,7 @@ load helpers
@test "images noheading test" { @test "images noheading test" {
cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox) cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah --log-level=error images --noheading run_buildah images --noheading
expect_line_count 2 expect_line_count 2
buildah rm -a buildah rm -a
buildah rmi -a -f buildah rmi -a -f
@ -70,7 +70,7 @@ load helpers
@test "images quiet test" { @test "images quiet test" {
cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox) cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah --log-level=error images --quiet run_buildah images --quiet
expect_line_count 2 expect_line_count 2
buildah rm -a buildah rm -a
buildah rmi -a -f buildah rmi -a -f
@ -79,7 +79,7 @@ load helpers
@test "images no-trunc test" { @test "images no-trunc test" {
cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox) cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah --log-level=error images -q --no-trunc run_buildah images -q --no-trunc
expect_line_count 2 expect_line_count 2
expect_output --substring --from="${lines[0]}" "sha256" expect_output --substring --from="${lines[0]}" "sha256"
buildah rm -a buildah rm -a
@ -89,10 +89,10 @@ load helpers
@test "images json test" { @test "images json test" {
cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox) cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah --log-level=error images --json run_buildah images --json
expect_line_count 30 expect_line_count 30
run_buildah --log-level=error images --json alpine run_buildah images --json alpine
expect_line_count 16 expect_line_count 16
buildah rm -a buildah rm -a
buildah rmi -a -f buildah rmi -a -f
@ -103,7 +103,7 @@ load helpers
buildah commit --signature-policy ${TESTSDIR}/policy.json $cid test buildah commit --signature-policy ${TESTSDIR}/policy.json $cid test
buildah tag test new-name buildah tag test new-name
run_buildah --log-level=error images --json run_buildah images --json
[ $(grep '"id": "' <<< "$output" | wc -l) -eq 1 ] [ $(grep '"id": "' <<< "$output" | wc -l) -eq 1 ]
buildah rm -a buildah rm -a
@ -116,7 +116,7 @@ load helpers
buildah commit --signature-policy ${TESTSDIR}/policy.json $cid1 test buildah commit --signature-policy ${TESTSDIR}/policy.json $cid1 test
buildah commit --signature-policy ${TESTSDIR}/policy.json $cid2 test2 buildah commit --signature-policy ${TESTSDIR}/policy.json $cid2 test2
run_buildah --log-level=error images --json run_buildah images --json
run python3 -m json.tool <<< "$output" run python3 -m json.tool <<< "$output"
[ "${status}" -eq 0 ] [ "${status}" -eq 0 ]
@ -127,14 +127,14 @@ load helpers
@test "specify an existing image" { @test "specify an existing image" {
cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox) cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah --log-level=error images alpine run_buildah images alpine
expect_line_count 2 expect_line_count 2
buildah rm -a buildah rm -a
buildah rmi -a -f buildah rmi -a -f
} }
@test "specify a nonexistent image" { @test "specify a nonexistent image" {
run_buildah 1 --log-level=error images alpine run_buildah 1 images alpine
expect_output --from="${lines[0]}" "No such image alpine" expect_output --from="${lines[0]}" "No such image alpine"
expect_line_count 1 expect_line_count 1
} }
@ -143,14 +143,14 @@ load helpers
cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json scratch) cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json scratch)
buildah commit --signature-policy ${TESTSDIR}/policy.json $cid test buildah commit --signature-policy ${TESTSDIR}/policy.json $cid test
buildah commit --signature-policy ${TESTSDIR}/policy.json $cid test buildah commit --signature-policy ${TESTSDIR}/policy.json $cid test
run_buildah --log-level=error images run_buildah images
expect_line_count 3 expect_line_count 3
run_buildah --log-level=error images --filter dangling=true run_buildah images --filter dangling=true
expect_output --substring " <none> " expect_output --substring " <none> "
expect_line_count 2 expect_line_count 2
run_buildah --log-level=error images --filter dangling=false run_buildah images --filter dangling=false
expect_output --substring " latest " expect_output --substring " latest "
expect_line_count 2 expect_line_count 2

View File

@ -3,26 +3,26 @@
load helpers load helpers
@test "log-level set to debug" { @test "log-level set to debug" {
run_buildah --log-level=error --log-level=debug images -q run_buildah --log-level=debug images -q
expect_output --substring "level=debug " expect_output --substring "level=debug "
} }
@test "log-level set to info" { @test "log-level set to info" {
run_buildah --log-level=error --log-level=info images -q run_buildah --log-level=info images -q
expect_output "" expect_output ""
} }
@test "log-level set to warn" { @test "log-level set to warn" {
run_buildah --log-level=error --log-level=warn images -q run_buildah --log-level=warn images -q
expect_output "" expect_output ""
} }
@test "log-level set to error" { @test "log-level set to error" {
run_buildah --log-level=error --log-level=error images -q run_buildah --log-level=error images -q
expect_output "" expect_output ""
} }
@test "log-level set to invalid" { @test "log-level set to invalid" {
run_buildah 1 --log-level=error --log-level=invalid images -q run_buildah 1 --log-level=invalid images -q
expect_output --substring "unable to parse log level" expect_output --substring "unable to parse log level"
} }

View File

@ -15,13 +15,13 @@ load helpers
@test "mount one container" { @test "mount one container" {
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah --log-level=error mount "$cid" run_buildah mount "$cid"
buildah rm $cid buildah rm $cid
buildah rmi -f alpine buildah rmi -f alpine
} }
@test "mount bad container" { @test "mount bad container" {
run_buildah 1 --log-level=error mount badcontainer run_buildah 1 mount badcontainer
} }
@test "mount multi images" { @test "mount multi images" {
@ -49,7 +49,7 @@ load helpers
buildah mount "$cid2" buildah mount "$cid2"
cid3=$(buildah from --pull-never --signature-policy ${TESTSDIR}/policy.json alpine) cid3=$(buildah from --pull-never --signature-policy ${TESTSDIR}/policy.json alpine)
buildah mount "$cid3" buildah mount "$cid3"
run_buildah --log-level=error mount run_buildah mount
expect_output --from="${lines[0]}" --substring "/tmp" "mount line 1 of 3" expect_output --from="${lines[0]}" --substring "/tmp" "mount line 1 of 3"
expect_output --from="${lines[1]}" --substring "/tmp" "mount line 2 of 3" expect_output --from="${lines[1]}" --substring "/tmp" "mount line 2 of 3"
expect_output --from="${lines[2]}" --substring "/tmp" "mount line 3 of 3" expect_output --from="${lines[2]}" --substring "/tmp" "mount line 3 of 3"

View File

@ -7,7 +7,7 @@ load helpers
skip "BUILDAH_ISOLATION = $BUILDAH_ISOLATION" skip "BUILDAH_ISOLATION = $BUILDAH_ISOLATION"
fi fi
run_buildah --log-level=error from --signature-policy ${TESTSDIR}/policy.json --quiet alpine run_buildah from --signature-policy ${TESTSDIR}/policy.json --quiet alpine
[ "$output" != "" ] [ "$output" != "" ]
ctr="$output" ctr="$output"
@ -38,36 +38,36 @@ load helpers
gidsize=$((${RANDOM}+1024)) gidsize=$((${RANDOM}+1024))
# Create a container that uses that mapping. # Create a container that uses that mapping.
run_buildah --log-level=error from --signature-policy ${TESTSDIR}/policy.json --quiet --userns-uid-map 0:$uidbase:$uidsize --userns-gid-map 0:$gidbase:$gidsize alpine run_buildah from --signature-policy ${TESTSDIR}/policy.json --quiet --userns-uid-map 0:$uidbase:$uidsize --userns-gid-map 0:$gidbase:$gidsize alpine
[ "$output" != "" ] [ "$output" != "" ]
ctr="$output" ctr="$output"
# Check that with settings that require a user namespace, we also get a new network namespace by default. # Check that with settings that require a user namespace, we also get a new network namespace by default.
buildah run $RUNOPTS "$ctr" readlink /proc/self/ns/net buildah run $RUNOPTS "$ctr" readlink /proc/self/ns/net
run_buildah --log-level=error run $RUNOPTS "$ctr" readlink /proc/self/ns/net run_buildah run $RUNOPTS "$ctr" readlink /proc/self/ns/net
[ "$output" != "" ] [ "$output" != "" ]
[ "$output" != "$mynetns" ] [ "$output" != "$mynetns" ]
# Check that with settings that require a user namespace, we can still try to use the host's network namespace. # Check that with settings that require a user namespace, we can still try to use the host's network namespace.
buildah run $RUNOPTS --net=host "$ctr" readlink /proc/self/ns/net buildah run $RUNOPTS --net=host "$ctr" readlink /proc/self/ns/net
run_buildah --log-level=error run $RUNOPTS --net=host "$ctr" readlink /proc/self/ns/net run_buildah run $RUNOPTS --net=host "$ctr" readlink /proc/self/ns/net
[ "$output" != "" ] [ "$output" != "" ]
[ "$output" == "$mynetns" ] [ "$output" == "$mynetns" ]
# Create a container that doesn't use that mapping. # Create a container that doesn't use that mapping.
run_buildah --log-level=error from --signature-policy ${TESTSDIR}/policy.json --quiet alpine run_buildah from --signature-policy ${TESTSDIR}/policy.json --quiet alpine
[ "$output" != "" ] [ "$output" != "" ]
ctr="$output" ctr="$output"
# Check that with settings that don't require a user namespace, we don't get a new network namespace by default. # Check that with settings that don't require a user namespace, we don't get a new network namespace by default.
buildah run $RUNOPTS "$ctr" readlink /proc/self/ns/net buildah run $RUNOPTS "$ctr" readlink /proc/self/ns/net
run_buildah --log-level=error run $RUNOPTS "$ctr" readlink /proc/self/ns/net run_buildah run $RUNOPTS "$ctr" readlink /proc/self/ns/net
[ "$output" != "" ] [ "$output" != "" ]
[ "$output" == "$mynetns" ] [ "$output" == "$mynetns" ]
# Check that with settings that don't require a user namespace, we can request to use a per-container network namespace. # Check that with settings that don't require a user namespace, we can request to use a per-container network namespace.
buildah run $RUNOPTS --net=container "$ctr" readlink /proc/self/ns/net buildah run $RUNOPTS --net=container "$ctr" readlink /proc/self/ns/net
run_buildah --log-level=error run $RUNOPTS --net=container "$ctr" readlink /proc/self/ns/net run_buildah run $RUNOPTS --net=container "$ctr" readlink /proc/self/ns/net
[ "$output" != "" ] [ "$output" != "" ]
[ "$output" != "$mynetns" ] [ "$output" != "$mynetns" ]
} }
@ -165,13 +165,13 @@ load helpers
for i in $(seq 0 "$((${#maps[*]}-1))") ; do for i in $(seq 0 "$((${#maps[*]}-1))") ; do
# Create a container using these mappings. # Create a container using these mappings.
echo "Building container with --signature-policy ${TESTSDIR}/policy.json --quiet ${uidmapargs[$i]} ${gidmapargs[$i]} alpine" echo "Building container with --signature-policy ${TESTSDIR}/policy.json --quiet ${uidmapargs[$i]} ${gidmapargs[$i]} alpine"
run_buildah --log-level=error from --signature-policy ${TESTSDIR}/policy.json --quiet ${uidmapargs[$i]} ${gidmapargs[$i]} alpine run_buildah from --signature-policy ${TESTSDIR}/policy.json --quiet ${uidmapargs[$i]} ${gidmapargs[$i]} alpine
[ "$output" != "" ] [ "$output" != "" ]
ctr="$output" ctr="$output"
# If we specified mappings, expect to be in a different namespace by default. # If we specified mappings, expect to be in a different namespace by default.
buildah run $RUNOPTS "$ctr" readlink /proc/self/ns/user buildah run $RUNOPTS "$ctr" readlink /proc/self/ns/user
run_buildah --log-level=error run $RUNOPTS "$ctr" readlink /proc/self/ns/user run_buildah run $RUNOPTS "$ctr" readlink /proc/self/ns/user
[ "$output" != "" ] [ "$output" != "" ]
case x"$map" in case x"$map" in
x) x)
@ -185,11 +185,11 @@ load helpers
esac esac
# Check that we got the mappings that we expected. # Check that we got the mappings that we expected.
buildah run $RUNOPTS "$ctr" cat /proc/self/uid_map buildah run $RUNOPTS "$ctr" cat /proc/self/uid_map
run_buildah --log-level=error run $RUNOPTS "$ctr" cat /proc/self/uid_map run_buildah run $RUNOPTS "$ctr" cat /proc/self/uid_map
[ "$output" != "" ] [ "$output" != "" ]
uidmap=$(sed -E -e 's, +, ,g' -e 's,^ +,,g' <<< "$output") uidmap=$(sed -E -e 's, +, ,g' -e 's,^ +,,g' <<< "$output")
buildah run $RUNOPTS "$ctr" cat /proc/self/gid_map buildah run $RUNOPTS "$ctr" cat /proc/self/gid_map
run_buildah --log-level=error run $RUNOPTS "$ctr" cat /proc/self/gid_map run_buildah run $RUNOPTS "$ctr" cat /proc/self/gid_map
[ "$output" != "" ] [ "$output" != "" ]
gidmap=$(sed -E -e 's, +, ,g' -e 's,^ +,,g' <<< "$output") gidmap=$(sed -E -e 's, +, ,g' -e 's,^ +,,g' <<< "$output")
echo With settings "$map", expected UID map "${uidmaps[$i]}", got UID map "${uidmap}", expected GID map "${gidmaps[$i]}", got GID map "${gidmap}". echo With settings "$map", expected UID map "${uidmaps[$i]}", got UID map "${uidmap}", expected GID map "${gidmaps[$i]}", got GID map "${gidmap}".
@ -201,21 +201,21 @@ load helpers
# Check that if we copy a file into the container, it gets the right permissions. # Check that if we copy a file into the container, it gets the right permissions.
run_buildah copy --chown 1:1 "$ctr" ${TESTDIR}/somefile / run_buildah copy --chown 1:1 "$ctr" ${TESTDIR}/somefile /
buildah run $RUNOPTS "$ctr" stat -c '%u:%g' /somefile buildah run $RUNOPTS "$ctr" stat -c '%u:%g' /somefile
run_buildah --log-level=error run $RUNOPTS "$ctr" stat -c '%u:%g' /somefile run_buildah run $RUNOPTS "$ctr" stat -c '%u:%g' /somefile
expect_output "1:1" expect_output "1:1"
# Check that if we copy a directory into the container, its contents get the right permissions. # Check that if we copy a directory into the container, its contents get the right permissions.
run_buildah copy "$ctr" ${TESTDIR}/somedir /somedir run_buildah copy "$ctr" ${TESTDIR}/somedir /somedir
buildah run $RUNOPTS "$ctr" stat -c '%u:%g' /somedir buildah run $RUNOPTS "$ctr" stat -c '%u:%g' /somedir
run_buildah --log-level=error run $RUNOPTS "$ctr" stat -c '%u:%g' /somedir run_buildah run $RUNOPTS "$ctr" stat -c '%u:%g' /somedir
expect_output "0:0" expect_output "0:0"
run_buildah --log-level=error mount "$ctr" run_buildah mount "$ctr"
mnt="$output" mnt="$output"
run stat -c '%u:%g %a' "$mnt"/somedir/someotherfile run stat -c '%u:%g %a' "$mnt"/somedir/someotherfile
[ $status -eq 0 ] [ $status -eq 0 ]
expect_output "$rootuid:$rootgid 4700" expect_output "$rootuid:$rootgid 4700"
buildah run $RUNOPTS "$ctr" stat -c '%u:%g %a' /somedir/someotherfile buildah run $RUNOPTS "$ctr" stat -c '%u:%g %a' /somedir/someotherfile
run_buildah --log-level=error run $RUNOPTS "$ctr" stat -c '%u:%g %a' /somedir/someotherfile run_buildah run $RUNOPTS "$ctr" stat -c '%u:%g %a' /somedir/someotherfile
expect_output "0:0 4700" expect_output "0:0 4700"
done done
} }
@ -243,12 +243,12 @@ general_namespace() {
for namespace in "${types[@]}" ; do for namespace in "${types[@]}" ; do
# Specify the setting for this namespace for this container. # Specify the setting for this namespace for this container.
run_buildah --log-level=error from --signature-policy ${TESTSDIR}/policy.json --quiet --"$nsflag"=$namespace alpine run_buildah from --signature-policy ${TESTSDIR}/policy.json --quiet --"$nsflag"=$namespace alpine
[ "$output" != "" ] [ "$output" != "" ]
ctr="$output" ctr="$output"
# Check that, unless we override it, we get that setting in "run". # Check that, unless we override it, we get that setting in "run".
run_buildah --log-level=error run $RUNOPTS "$ctr" readlink /proc/self/ns/"$nstype" run_buildah run $RUNOPTS "$ctr" readlink /proc/self/ns/"$nstype"
[ "$output" != "" ] [ "$output" != "" ]
case "$namespace" in case "$namespace" in
""|container) ""|container)
@ -264,7 +264,7 @@ general_namespace() {
for different in $types ; do for different in $types ; do
# Check that, if we override it, we get what we specify for "run". # Check that, if we override it, we get what we specify for "run".
run_buildah --log-level=error run $RUNOPTS --"$nsflag"=$different "$ctr" readlink /proc/self/ns/"$nstype" run_buildah run $RUNOPTS --"$nsflag"=$different "$ctr" readlink /proc/self/ns/"$nstype"
[ "$output" != "" ] [ "$output" != "" ]
case "$different" in case "$different" in
""|container) ""|container)
@ -341,17 +341,17 @@ general_namespace() {
fi fi
echo "buildah from --signature-policy ${TESTSDIR}/policy.json --ipc=$ipc --net=$net --pid=$pid --userns=$userns --uts=$uts alpine" echo "buildah from --signature-policy ${TESTSDIR}/policy.json --ipc=$ipc --net=$net --pid=$pid --userns=$userns --uts=$uts alpine"
run_buildah --log-level=error from --signature-policy ${TESTSDIR}/policy.json --quiet --ipc=$ipc --net=$net --pid=$pid --userns=$userns --uts=$uts alpine run_buildah from --signature-policy ${TESTSDIR}/policy.json --quiet --ipc=$ipc --net=$net --pid=$pid --userns=$userns --uts=$uts alpine
[ "$output" != "" ] [ "$output" != "" ]
ctr="$output" ctr="$output"
buildah run $ctr pwd buildah run $ctr pwd
run_buildah --log-level=error run $ctr pwd run_buildah run $ctr pwd
[ "$output" != "" ] [ "$output" != "" ]
buildah run --tty=true $ctr pwd buildah run --tty=true $ctr pwd
run_buildah --log-level=error run --tty=true $ctr pwd run_buildah run --tty=true $ctr pwd
[ "$output" != "" ] [ "$output" != "" ]
buildah run --tty=false $ctr pwd buildah run --tty=false $ctr pwd
run_buildah --log-level=error run --tty=false $ctr pwd run_buildah run --tty=false $ctr pwd
[ "$output" != "" ] [ "$output" != "" ]
done done
done done

View File

@ -10,17 +10,17 @@ load helpers
mkdir ${TESTDIR}/lower mkdir ${TESTDIR}/lower
touch ${TESTDIR}/lower/foo touch ${TESTDIR}/lower/foo
cid=$(buildah --log-level=error from -v ${TESTDIR}/lower:/lower:O --quiet --signature-policy ${TESTSDIR}/policy.json $image) cid=$(buildah from -v ${TESTDIR}/lower:/lower:O --quiet --signature-policy ${TESTSDIR}/policy.json $image)
# This should succeed # This should succeed
run_buildah --log-level=error run $cid ls /lower/foo run_buildah run $cid ls /lower/foo
# Create and remove content in the overlay directory, should succeed # Create and remove content in the overlay directory, should succeed
run_buildah --log-level=error run $cid touch /lower/bar run_buildah run $cid touch /lower/bar
run_buildah --log-level=error run $cid rm /lower/foo run_buildah run $cid rm /lower/foo
# This should fail, second runs of containers go back to original # This should fail, second runs of containers go back to original
run_buildah 1 --log-level=error run $cid ls /lower/bar run_buildah 1 run $cid ls /lower/bar
# This should fail # This should fail
run ls ${TESTDIR}/lower/bar run ls ${TESTDIR}/lower/bar

View File

@ -8,10 +8,10 @@ load helpers
imagename=$2 imagename=$2
# Clean up. # Clean up.
for id in $(buildah --log-level=error containers -q) ; do for id in $(buildah containers -q) ; do
buildah rm ${id} buildah rm ${id}
done done
for id in $(buildah --log-level=error images -q) ; do for id in $(buildah images -q) ; do
buildah rmi ${id} buildah rmi ${id}
done done
@ -23,8 +23,8 @@ load helpers
# Get their image IDs. They should be the same one. # Get their image IDs. They should be the same one.
lastid= lastid=
for cid in $(buildah --log-level=error containers -q) ; do for cid in $(buildah containers -q) ; do
run_buildah --log-level=error inspect -f "{{.FromImageID}}" $cid run_buildah inspect -f "{{.FromImageID}}" $cid
expect_line_count 1 expect_line_count 1
if [ "$lastid" != "" ] ; then if [ "$lastid" != "" ] ; then
expect_output "$lastid" expect_output "$lastid"
@ -36,10 +36,10 @@ load helpers
run_buildah images run_buildah images
# Clean up. # Clean up.
for id in $(buildah --log-level=error containers -q) ; do for id in $(buildah containers -q) ; do
buildah rm ${id} buildah rm ${id}
done done
for id in $(buildah --log-level=error images -q) ; do for id in $(buildah images -q) ; do
buildah rmi ${id} buildah rmi ${id}
done done
} }

View File

@ -11,7 +11,7 @@ load helpers
run_buildah containers --format "{{.ContainerName}}" run_buildah containers --format "{{.ContainerName}}"
expect_output --substring "test-container" expect_output --substring "test-container"
run_buildah --log-level=error containers --quiet -f name=${old_name} run_buildah containers --quiet -f name=${old_name}
expect_output "" expect_output ""
buildah rm ${new_name} buildah rm ${new_name}
@ -20,7 +20,7 @@ load helpers
@test "rename same name as current name" { @test "rename same name as current name" {
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah 1 --log-level=error rename ${cid} ${cid} run_buildah 1 rename ${cid} ${cid}
expect_output 'renaming a container with the same name as its current name' expect_output 'renaming a container with the same name as its current name'
buildah rm $cid buildah rm $cid
@ -30,7 +30,7 @@ load helpers
@test "rename same name as other container name" { @test "rename same name as other container name" {
cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid1=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox) cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah 1 --log-level=error rename ${cid1} ${cid2} run_buildah 1 rename ${cid1} ${cid2}
expect_output --substring " already in use by " expect_output --substring " already in use by "
buildah rm $cid1 $cid2 buildah rm $cid1 $cid2

View File

@ -11,7 +11,7 @@ load helpers
} }
@test "remove multiple containers errors" { @test "remove multiple containers errors" {
run_buildah 1 --log-level=error rm mycontainer1 mycontainer2 mycontainer3 run_buildah 1 rm mycontainer1 mycontainer2 mycontainer3
expect_output --from="${lines[0]}" "error removing container \"mycontainer1\": error reading build container: container not known" "output line 1" expect_output --from="${lines[0]}" "error removing container \"mycontainer1\": error reading build container: container not known" "output line 1"
expect_output --from="${lines[1]}" "error removing container \"mycontainer2\": error reading build container: container not known" "output line 2" expect_output --from="${lines[1]}" "error removing container \"mycontainer2\": error reading build container: container not known" "output line 2"
expect_output --from="${lines[2]}" "error removing container \"mycontainer3\": error reading build container: container not known" "output line 3" expect_output --from="${lines[2]}" "error removing container \"mycontainer3\": error reading build container: container not known" "output line 3"
@ -20,14 +20,14 @@ load helpers
@test "remove one container" { @test "remove one container" {
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah --log-level=error rm "$cid" run_buildah rm "$cid"
run_buildah rmi alpine run_buildah rmi alpine
} }
@test "remove multiple containers" { @test "remove multiple containers" {
cid2=$(buildah from --signature-policy ${TESTSDIR}/policy.json alpine) cid2=$(buildah from --signature-policy ${TESTSDIR}/policy.json alpine)
cid3=$(buildah from --signature-policy ${TESTSDIR}/policy.json busybox) cid3=$(buildah from --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah --log-level=error rm "$cid2" "$cid3" run_buildah rm "$cid2" "$cid3"
run_buildah rmi alpine busybox run_buildah rmi alpine busybox
} }
@ -35,13 +35,13 @@ load helpers
cid1=$(buildah from --signature-policy ${TESTSDIR}/policy.json scratch) cid1=$(buildah from --signature-policy ${TESTSDIR}/policy.json scratch)
cid2=$(buildah from --signature-policy ${TESTSDIR}/policy.json alpine) cid2=$(buildah from --signature-policy ${TESTSDIR}/policy.json alpine)
cid3=$(buildah from --signature-policy ${TESTSDIR}/policy.json busybox) cid3=$(buildah from --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah --log-level=error rm -a run_buildah rm -a
run_buildah rmi --all run_buildah rmi --all
} }
@test "use conflicting commands to remove containers" { @test "use conflicting commands to remove containers" {
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah 1 --log-level=error rm -a "$cid" run_buildah 1 rm -a "$cid"
expect_output --substring "when using the --all switch, you may not pass any containers names or IDs" expect_output --substring "when using the --all switch, you may not pass any containers names or IDs"
run_buildah rm "$cid" run_buildah rm "$cid"
run_buildah rmi alpine run_buildah rmi alpine

View File

@ -17,7 +17,7 @@ load helpers
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
buildah rm "$cid" buildah rm "$cid"
buildah rmi alpine buildah rmi alpine
run_buildah --log-level=error images -q run_buildah images -q
expect_output "" expect_output ""
} }
@ -25,16 +25,16 @@ load helpers
cid2=$(buildah from --signature-policy ${TESTSDIR}/policy.json alpine) cid2=$(buildah from --signature-policy ${TESTSDIR}/policy.json alpine)
cid3=$(buildah from --signature-policy ${TESTSDIR}/policy.json busybox) cid3=$(buildah from --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah 1 rmi alpine busybox run_buildah 1 rmi alpine busybox
run_buildah --log-level=error images -q run_buildah images -q
[ "$output" != "" ] [ "$output" != "" ]
buildah rmi -f alpine busybox buildah rmi -f alpine busybox
run_buildah --log-level=error images -q run_buildah images -q
expect_output "" expect_output ""
} }
@test "remove multiple non-existent images errors" { @test "remove multiple non-existent images errors" {
run_buildah 1 --log-level=error rmi image1 image2 image3 run_buildah 1 rmi image1 image2 image3
expect_output --from="${lines[0]}" "could not get image \"image1\": identifier is not an image" "output line 1" expect_output --from="${lines[0]}" "could not get image \"image1\": identifier is not an image" "output line 1"
expect_output --from="${lines[1]}" "could not get image \"image2\": identifier is not an image" "output line 2" expect_output --from="${lines[1]}" "could not get image \"image2\": identifier is not an image" "output line 2"
expect_output --from="${lines[2]}" "could not get image \"image3\": identifier is not an image" "output line 3" expect_output --from="${lines[2]}" "could not get image \"image3\": identifier is not an image" "output line 3"
@ -46,18 +46,18 @@ load helpers
cid2=$(buildah from --signature-policy ${TESTSDIR}/policy.json alpine) cid2=$(buildah from --signature-policy ${TESTSDIR}/policy.json alpine)
cid3=$(buildah from --signature-policy ${TESTSDIR}/policy.json busybox) cid3=$(buildah from --signature-policy ${TESTSDIR}/policy.json busybox)
buildah rmi -a -f buildah rmi -a -f
run_buildah --log-level=error images -q run_buildah images -q
expect_output "" expect_output ""
cid1=$(buildah from --signature-policy ${TESTSDIR}/policy.json scratch) cid1=$(buildah from --signature-policy ${TESTSDIR}/policy.json scratch)
cid2=$(buildah from --signature-policy ${TESTSDIR}/policy.json alpine) cid2=$(buildah from --signature-policy ${TESTSDIR}/policy.json alpine)
cid3=$(buildah from --signature-policy ${TESTSDIR}/policy.json busybox) cid3=$(buildah from --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah 1 rmi --all run_buildah 1 rmi --all
run_buildah --log-level=error images -q run_buildah images -q
[ "$output" != "" ] [ "$output" != "" ]
buildah rmi --all --force buildah rmi --all --force
run_buildah --log-level=error images -q run_buildah images -q
expect_output "" expect_output ""
} }
@ -67,7 +67,7 @@ load helpers
cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json busybox) cid=$(buildah from --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah --log-level=error images -q run_buildah images -q
expect_line_count 1 expect_line_count 1
root=$(buildah mount $cid) root=$(buildah mount $cid)
@ -75,7 +75,7 @@ load helpers
buildah unmount $cid buildah unmount $cid
buildah commit --signature-policy ${TESTSDIR}/policy.json $cid containers-storage:new-image buildah commit --signature-policy ${TESTSDIR}/policy.json $cid containers-storage:new-image
run_buildah --log-level=error images -q run_buildah images -q
expect_line_count 2 expect_line_count 2
root=$(buildah mount $cid) root=$(buildah mount $cid)
@ -83,33 +83,33 @@ load helpers
buildah unmount $cid buildah unmount $cid
buildah commit --signature-policy ${TESTSDIR}/policy.json $cid containers-storage:new-image buildah commit --signature-policy ${TESTSDIR}/policy.json $cid containers-storage:new-image
run_buildah --log-level=error images -q run_buildah images -q
expect_line_count 3 expect_line_count 3
buildah rmi --prune buildah rmi --prune
run_buildah --log-level=error images -q run_buildah images -q
expect_line_count 2 expect_line_count 2
buildah rmi --all --force buildah rmi --all --force
run_buildah --log-level=error images -q run_buildah images -q
expect_output "" expect_output ""
} }
@test "use conflicting commands to remove images" { @test "use conflicting commands to remove images" {
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
buildah rm "$cid" buildah rm "$cid"
run_buildah 1 --log-level=error rmi -a alpine run_buildah 1 rmi -a alpine
expect_output --substring "when using the --all switch, you may not pass any images names or IDs" expect_output --substring "when using the --all switch, you may not pass any images names or IDs"
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
buildah rm "$cid" buildah rm "$cid"
run_buildah 1 --log-level=error rmi -p alpine run_buildah 1 rmi -p alpine
expect_output --substring "when using the --prune switch, you may not pass any images names or IDs" expect_output --substring "when using the --prune switch, you may not pass any images names or IDs"
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
buildah rm "$cid" buildah rm "$cid"
run_buildah 1 --log-level=error rmi -a -p run_buildah 1 rmi -a -p
expect_output --substring "when using the --all switch, you may not use --prune switch" expect_output --substring "when using the --all switch, you may not use --prune switch"
buildah rmi --all buildah rmi --all
} }
@ -120,36 +120,36 @@ load helpers
buildah config --entrypoint '[ "/ENTRYPOINT" ]' $cid buildah config --entrypoint '[ "/ENTRYPOINT" ]' $cid
buildah commit --signature-policy ${TESTSDIR}/policy.json $cid new-image buildah commit --signature-policy ${TESTSDIR}/policy.json $cid new-image
buildah rm -a buildah rm -a
run_buildah 1 --log-level=error rmi alpine run_buildah 1 rmi alpine
expect_line_count 2 expect_line_count 2
run_buildah --log-level=error images -q run_buildah images -q
expect_line_count 1 expect_line_count 1
run_buildah --log-level=error images -q -a run_buildah images -q -a
expect_line_count 2 expect_line_count 2
my_images=( $(buildah --log-level=error images -a -q) ) my_images=( $(buildah images -a -q) )
run_buildah 1 --log-level=error rmi ${my_images[2]} run_buildah 1 rmi ${my_images[2]}
buildah rmi new-image buildah rmi new-image
} }
@test "rmi with cached images" { @test "rmi with cached images" {
buildah rmi -a -f buildah rmi -a -f
buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test1 ${TESTSDIR}/bud/use-layers buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test1 ${TESTSDIR}/bud/use-layers
run_buildah --log-level=error images -a -q run_buildah images -a -q
expect_line_count 7 expect_line_count 7
buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test2 -f Dockerfile.2 ${TESTSDIR}/bud/use-layers buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test2 -f Dockerfile.2 ${TESTSDIR}/bud/use-layers
run_buildah --log-level=error images -a -q run_buildah images -a -q
expect_line_count 9 expect_line_count 9
run_buildah --log-level=error rmi test2 run_buildah rmi test2
run_buildah --log-level=error images -a -q run_buildah images -a -q
expect_line_count 7 expect_line_count 7
run_buildah --log-level=error rmi test1 run_buildah rmi test1
run_buildah --log-level=error images -a -q run_buildah images -a -q
expect_line_count 1 expect_line_count 1
run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test3 -f Dockerfile.2 ${TESTSDIR}/bud/use-layers run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test3 -f Dockerfile.2 ${TESTSDIR}/bud/use-layers
run_buildah 1 --log-level=error rmi alpine run_buildah 1 rmi alpine
expect_line_count 2 expect_line_count 2
run_buildah --log-level=error rmi test3 run_buildah rmi test3
run_buildah --log-level=error images -a -q run_buildah images -a -q
expect_output "" expect_output ""
} }
@ -162,7 +162,7 @@ load helpers
buildah config --env 'foo=bar' $cid buildah config --env 'foo=bar' $cid
buildah commit --signature-policy ${TESTSDIR}/policy.json $cid new-image-2 buildah commit --signature-policy ${TESTSDIR}/policy.json $cid new-image-2
buildah rm -a buildah rm -a
run_buildah --log-level=error rmi new-image-2 run_buildah rmi new-image-2
run_buildah --log-level=error images -q run_buildah images -q
expect_line_count 2 expect_line_count 2
} }

View File

@ -10,10 +10,10 @@ load helpers
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
root=$(buildah mount $cid) root=$(buildah mount $cid)
buildah config --workingdir /tmp $cid buildah config --workingdir /tmp $cid
run_buildah --log-level=error run $cid pwd run_buildah run $cid pwd
expect_output "/tmp" expect_output "/tmp"
buildah config --workingdir /root $cid buildah config --workingdir /root $cid
run_buildah --log-level=error run $cid pwd run_buildah run $cid pwd
expect_output "/root" expect_output "/root"
cp ${TESTDIR}/randomfile $root/tmp/ cp ${TESTDIR}/randomfile $root/tmp/
buildah run $cid cp /tmp/randomfile /tmp/other-randomfile buildah run $cid cp /tmp/randomfile /tmp/other-randomfile
@ -32,22 +32,22 @@ load helpers
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
# This should fail, because buildah run doesn't have a -n flag. # This should fail, because buildah run doesn't have a -n flag.
run_buildah 1 --log-level=error run -n $cid echo test run_buildah 1 run -n $cid echo test
# This should succeed, because buildah run stops caring at the --, which is preserved as part of the command. # This should succeed, because buildah run stops caring at the --, which is preserved as part of the command.
run_buildah --log-level=error run $cid echo -- -n test run_buildah run $cid echo -- -n test
expect_output -- "-- -n test" expect_output -- "-- -n test"
# This should succeed, because buildah run stops caring at the --, which is not part of the command. # This should succeed, because buildah run stops caring at the --, which is not part of the command.
run_buildah --log-level=error run $cid -- echo -n -- test run_buildah run $cid -- echo -n -- test
expect_output -- "-- test" expect_output -- "-- test"
# This should succeed, because buildah run stops caring at the --. # This should succeed, because buildah run stops caring at the --.
run_buildah --log-level=error run $cid -- echo -- -n test -- run_buildah run $cid -- echo -- -n test --
expect_output -- "-- -n test --" expect_output -- "-- -n test --"
# This should succeed, because buildah run stops caring at the --. # This should succeed, because buildah run stops caring at the --.
run_buildah --log-level=error run $cid -- echo -n "test" run_buildah run $cid -- echo -n "test"
expect_output "test" expect_output "test"
buildah rm $cid buildah rm $cid
@ -65,57 +65,57 @@ load helpers
# empty entrypoint, configured cmd, empty run arguments # empty entrypoint, configured cmd, empty run arguments
buildah config --entrypoint "" $cid buildah config --entrypoint "" $cid
buildah config --cmd pwd $cid buildah config --cmd pwd $cid
run_buildah 1 --log-level=error run $cid run_buildah 1 run $cid
expect_output --substring "command must be specified" "empty entrypoint, cmd, no args" expect_output --substring "command must be specified" "empty entrypoint, cmd, no args"
# empty entrypoint, configured cmd, empty run arguments, end parsing option # empty entrypoint, configured cmd, empty run arguments, end parsing option
buildah config --entrypoint "" $cid buildah config --entrypoint "" $cid
buildah config --cmd pwd $cid buildah config --cmd pwd $cid
run_buildah 1 --log-level=error run $cid -- run_buildah 1 run $cid --
expect_output --substring "command must be specified" "empty entrypoint, cmd, no args, --" expect_output --substring "command must be specified" "empty entrypoint, cmd, no args, --"
# configured entrypoint, empty cmd, empty run arguments # configured entrypoint, empty cmd, empty run arguments
buildah config --entrypoint pwd $cid buildah config --entrypoint pwd $cid
buildah config --cmd "" $cid buildah config --cmd "" $cid
run_buildah 1 --log-level=error run $cid run_buildah 1 run $cid
expect_output --substring "command must be specified" "entrypoint, empty cmd, no args" expect_output --substring "command must be specified" "entrypoint, empty cmd, no args"
# configured entrypoint, empty cmd, empty run arguments, end parsing option # configured entrypoint, empty cmd, empty run arguments, end parsing option
buildah config --entrypoint pwd $cid buildah config --entrypoint pwd $cid
buildah config --cmd "" $cid buildah config --cmd "" $cid
run_buildah 1 --log-level=error run $cid -- run_buildah 1 run $cid --
expect_output --substring "command must be specified" "entrypoint, empty cmd, no args, --" expect_output --substring "command must be specified" "entrypoint, empty cmd, no args, --"
# configured entrypoint only, empty run arguments # configured entrypoint only, empty run arguments
buildah config --entrypoint pwd $cid buildah config --entrypoint pwd $cid
run_buildah 1 --log-level=error run $cid run_buildah 1 run $cid
expect_output --substring "command must be specified" "entrypoint, no args" expect_output --substring "command must be specified" "entrypoint, no args"
# configured entrypoint only, empty run arguments, end parsing option # configured entrypoint only, empty run arguments, end parsing option
buildah config --entrypoint pwd $cid buildah config --entrypoint pwd $cid
run_buildah 1 --log-level=error run $cid -- run_buildah 1 run $cid --
expect_output --substring "command must be specified" "entrypoint, no args, --" expect_output --substring "command must be specified" "entrypoint, no args, --"
# configured cmd only, empty run arguments # configured cmd only, empty run arguments
buildah config --cmd pwd $cid buildah config --cmd pwd $cid
run_buildah 1 --log-level=error run $cid run_buildah 1 run $cid
expect_output --substring "command must be specified" "cmd, no args" expect_output --substring "command must be specified" "cmd, no args"
# configured cmd only, empty run arguments, end parsing option # configured cmd only, empty run arguments, end parsing option
buildah config --cmd pwd $cid buildah config --cmd pwd $cid
run_buildah 1 --log-level=error run $cid -- run_buildah 1 run $cid --
expect_output --substring "command must be specified" "cmd, no args, --" expect_output --substring "command must be specified" "cmd, no args, --"
# configured entrypoint, configured cmd, empty run arguments # configured entrypoint, configured cmd, empty run arguments
buildah config --entrypoint "pwd" $cid buildah config --entrypoint "pwd" $cid
buildah config --cmd "whoami" $cid buildah config --cmd "whoami" $cid
run_buildah 1 --log-level=error run $cid run_buildah 1 run $cid
expect_output --substring "command must be specified" "entrypoint, cmd, no args" expect_output --substring "command must be specified" "entrypoint, cmd, no args"
# configured entrypoint, configured cmd, empty run arguments, end parsing option # configured entrypoint, configured cmd, empty run arguments, end parsing option
buildah config --entrypoint "pwd" $cid buildah config --entrypoint "pwd" $cid
buildah config --cmd "whoami" $cid buildah config --cmd "whoami" $cid
run_buildah 1 --log-level=error run $cid -- run_buildah 1 run $cid --
expect_output --substring "command must be specified" "entrypoint, cmd, no args" expect_output --substring "command must be specified" "entrypoint, cmd, no args"
@ -125,29 +125,29 @@ load helpers
# empty entrypoint, configured cmd, configured run arguments # empty entrypoint, configured cmd, configured run arguments
buildah config --entrypoint "" $cid buildah config --entrypoint "" $cid
buildah config --cmd "/invalid/cmd" $cid buildah config --cmd "/invalid/cmd" $cid
run_buildah --log-level=error run $cid -- pwd run_buildah run $cid -- pwd
expect_output "/tmp" "empty entrypoint, invalid cmd, pwd" expect_output "/tmp" "empty entrypoint, invalid cmd, pwd"
# configured entrypoint, empty cmd, configured run arguments # configured entrypoint, empty cmd, configured run arguments
buildah config --entrypoint "/invalid/entrypoint" $cid buildah config --entrypoint "/invalid/entrypoint" $cid
buildah config --cmd "" $cid buildah config --cmd "" $cid
run_buildah --log-level=error run $cid -- pwd run_buildah run $cid -- pwd
expect_output "/tmp" "invalid entrypoint, empty cmd, pwd" expect_output "/tmp" "invalid entrypoint, empty cmd, pwd"
# configured entrypoint only, configured run arguments # configured entrypoint only, configured run arguments
buildah config --entrypoint "/invalid/entrypoint" $cid buildah config --entrypoint "/invalid/entrypoint" $cid
run_buildah --log-level=error run $cid -- pwd run_buildah run $cid -- pwd
expect_output "/tmp" "invalid entrypoint, no cmd(??), pwd" expect_output "/tmp" "invalid entrypoint, no cmd(??), pwd"
# configured cmd only, configured run arguments # configured cmd only, configured run arguments
buildah config --cmd "/invalid/cmd" $cid buildah config --cmd "/invalid/cmd" $cid
run_buildah --log-level=error run $cid -- pwd run_buildah run $cid -- pwd
expect_output "/tmp" "invalid cmd, no entrypoint(??), pwd" expect_output "/tmp" "invalid cmd, no entrypoint(??), pwd"
# configured entrypoint, configured cmd, configured run arguments # configured entrypoint, configured cmd, configured run arguments
buildah config --entrypoint "/invalid/entrypoint" $cid buildah config --entrypoint "/invalid/entrypoint" $cid
buildah config --cmd "/invalid/cmd" $cid buildah config --cmd "/invalid/cmd" $cid
run_buildah --log-level=error run $cid -- pwd run_buildah run $cid -- pwd
expect_output "/tmp" "invalid cmd & entrypoint, pwd" expect_output "/tmp" "invalid cmd & entrypoint, pwd"
buildah rm $cid buildah rm $cid
@ -159,10 +159,10 @@ function configure_and_check_user() {
local expect_g=$3 local expect_g=$3
run_buildah config -u "$setting" $cid run_buildah config -u "$setting" $cid
run_buildah --log-level=error run -- $cid id -u run_buildah run -- $cid id -u
expect_output "$expect_u" "id -u ($setting)" expect_output "$expect_u" "id -u ($setting)"
run_buildah --log-level=error run -- $cid id -g run_buildah run -- $cid id -g
expect_output "$expect_g" "id -g ($setting)" expect_output "$expect_g" "id -g ($setting)"
} }
@ -198,14 +198,14 @@ function configure_and_check_user() {
configure_and_check_user "${testuid}:${testgroupid}" $testuid $testgroupid configure_and_check_user "${testuid}:${testgroupid}" $testuid $testgroupid
buildah config -u ${testbogususer} $cid buildah config -u ${testbogususer} $cid
run_buildah 1 --log-level=error run -- $cid id -u run_buildah 1 run -- $cid id -u
expect_output --substring "unknown user" "id -u (bogus user)" expect_output --substring "unknown user" "id -u (bogus user)"
run_buildah 1 --log-level=error run -- $cid id -g run_buildah 1 run -- $cid id -g
expect_output --substring "unknown user" "id -g (bogus user)" expect_output --substring "unknown user" "id -g (bogus user)"
ln -vsf /etc/passwd $root/etc/passwd ln -vsf /etc/passwd $root/etc/passwd
buildah config -u ${testuser}:${testgroup} $cid buildah config -u ${testuser}:${testgroup} $cid
run_buildah 1 --log-level=error run -- $cid id -u run_buildah 1 run -- $cid id -u
echo "$output" echo "$output"
expect_output --substring "unknown user" "run as unknown user" expect_output --substring "unknown user" "run as unknown user"
@ -219,9 +219,9 @@ function configure_and_check_user() {
runc --version runc --version
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah --log-level=error run $cid hostname run_buildah run $cid hostname
[ "$output" != "foobar" ] [ "$output" != "foobar" ]
run_buildah --log-level=error run --hostname foobar $cid hostname run_buildah run --hostname foobar $cid hostname
expect_output "foobar" expect_output "foobar"
buildah rm $cid buildah rm $cid
} }
@ -239,15 +239,15 @@ function configure_and_check_user() {
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
mkdir -p ${TESTDIR}/was-empty mkdir -p ${TESTDIR}/was-empty
# As a baseline, this should succeed. # As a baseline, this should succeed.
run_buildah --log-level=error run -v ${TESTDIR}/was-empty:/var/not-empty${zflag:+:${zflag}} $cid touch /var/not-empty/testfile run_buildah run -v ${TESTDIR}/was-empty:/var/not-empty${zflag:+:${zflag}} $cid touch /var/not-empty/testfile
# Parsing options that with comma, this should succeed. # Parsing options that with comma, this should succeed.
run_buildah --log-level=error run -v ${TESTDIR}/was-empty:/var/not-empty:rw,rshared${zflag:+,${zflag}} $cid touch /var/not-empty/testfile run_buildah run -v ${TESTDIR}/was-empty:/var/not-empty:rw,rshared${zflag:+,${zflag}} $cid touch /var/not-empty/testfile
# If we're parsing the options at all, this should be read-only, so it should fail. # If we're parsing the options at all, this should be read-only, so it should fail.
run_buildah 1 --log-level=error run -v ${TESTDIR}/was-empty:/var/not-empty:ro${zflag:+,${zflag}} $cid touch /var/not-empty/testfile run_buildah 1 run -v ${TESTDIR}/was-empty:/var/not-empty:ro${zflag:+,${zflag}} $cid touch /var/not-empty/testfile
# Even if the parent directory doesn't exist yet, this should succeed. # Even if the parent directory doesn't exist yet, this should succeed.
run_buildah --log-level=error run -v ${TESTDIR}/was-empty:/var/multi-level/subdirectory $cid touch /var/multi-level/subdirectory/testfile run_buildah run -v ${TESTDIR}/was-empty:/var/multi-level/subdirectory $cid touch /var/multi-level/subdirectory/testfile
# And check the same for file volumes. # And check the same for file volumes.
run_buildah --log-level=error run -v ${TESTDIR}/was-empty/testfile:/var/different-multi-level/subdirectory/testfile $cid touch /var/different-multi-level/subdirectory/testfile run_buildah run -v ${TESTDIR}/was-empty/testfile:/var/different-multi-level/subdirectory/testfile $cid touch /var/different-multi-level/subdirectory/testfile
} }
@test "run --mount" { @test "run --mount" {
@ -263,14 +263,14 @@ function configure_and_check_user() {
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
mkdir -p ${TESTDIR}/was:empty mkdir -p ${TESTDIR}/was:empty
# As a baseline, this should succeed. # As a baseline, this should succeed.
run_buildah --log-level=error run --mount type=tmpfs,dst=/var/tmpfs-not-empty $cid touch /var/tmpfs-not-empty/testfile run_buildah run --mount type=tmpfs,dst=/var/tmpfs-not-empty $cid touch /var/tmpfs-not-empty/testfile
run_buildah --log-level=error run --mount type=bind,src=${TESTDIR}/was:empty,dst=/var/not-empty${zflag:+,${zflag}} $cid touch /var/not-empty/testfile run_buildah run --mount type=bind,src=${TESTDIR}/was:empty,dst=/var/not-empty${zflag:+,${zflag}} $cid touch /var/not-empty/testfile
# If we're parsing the options at all, this should be read-only, so it should fail. # If we're parsing the options at all, this should be read-only, so it should fail.
run_buildah 1 --log-level=error run --mount type=bind,src=${TESTDIR}/was:empty,dst=/var/not-empty,ro${zflag:+,${zflag}} $cid touch /var/not-empty/testfile run_buildah 1 run --mount type=bind,src=${TESTDIR}/was:empty,dst=/var/not-empty,ro${zflag:+,${zflag}} $cid touch /var/not-empty/testfile
# Even if the parent directory doesn't exist yet, this should succeed. # Even if the parent directory doesn't exist yet, this should succeed.
run_buildah --log-level=error run --mount type=bind,src=${TESTDIR}/was:empty,dst=/var/multi-level/subdirectory $cid touch /var/multi-level/subdirectory/testfile run_buildah run --mount type=bind,src=${TESTDIR}/was:empty,dst=/var/multi-level/subdirectory $cid touch /var/multi-level/subdirectory/testfile
# And check the same for file volumes. # And check the same for file volumes.
run_buildah --log-level=error run --mount type=bind,src=${TESTDIR}/was:empty/testfile,dst=/var/different-multi-level/subdirectory/testfile $cid touch /var/different-multi-level/subdirectory/testfile run_buildah run --mount type=bind,src=${TESTDIR}/was:empty/testfile,dst=/var/different-multi-level/subdirectory/testfile $cid touch /var/different-multi-level/subdirectory/testfile
} }
@test "run symlinks" { @test "run symlinks" {
@ -281,7 +281,7 @@ function configure_and_check_user() {
mkdir -p ${TESTDIR}/tmp mkdir -p ${TESTDIR}/tmp
ln -s tmp ${TESTDIR}/tmp2 ln -s tmp ${TESTDIR}/tmp2
export TMPDIR=${TESTDIR}/tmp2 export TMPDIR=${TESTDIR}/tmp2
run_buildah --log-level=error run $cid id run_buildah run $cid id
} }
@test "run --cap-add/--cap-drop" { @test "run --cap-add/--cap-drop" {
@ -290,13 +290,13 @@ function configure_and_check_user() {
runc --version runc --version
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
# Try with default caps. # Try with default caps.
run_buildah --log-level=error run $cid grep ^CapEff /proc/self/status run_buildah run $cid grep ^CapEff /proc/self/status
defaultcaps="$output" defaultcaps="$output"
# Try adding DAC_OVERRIDE. # Try adding DAC_OVERRIDE.
run_buildah --log-level=error run --cap-add CAP_DAC_OVERRIDE $cid grep ^CapEff /proc/self/status run_buildah run --cap-add CAP_DAC_OVERRIDE $cid grep ^CapEff /proc/self/status
addedcaps="$output" addedcaps="$output"
# Try dropping DAC_OVERRIDE. # Try dropping DAC_OVERRIDE.
run_buildah --log-level=error run --cap-drop CAP_DAC_OVERRIDE $cid grep ^CapEff /proc/self/status run_buildah run --cap-drop CAP_DAC_OVERRIDE $cid grep ^CapEff /proc/self/status
droppedcaps="$output" droppedcaps="$output"
# Okay, now the "dropped" and "added" should be different. # Okay, now the "dropped" and "added" should be different.
test "$addedcaps" != "$droppedcaps" test "$addedcaps" != "$droppedcaps"
@ -313,23 +313,23 @@ function configure_and_check_user() {
skip_if_no_runtime skip_if_no_runtime
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah --log-level=error run $cid awk '/open files/{print $4}' /proc/self/limits run_buildah run $cid awk '/open files/{print $4}' /proc/self/limits
expect_output "1048576" "limits: open files (unlimited)" expect_output "1048576" "limits: open files (unlimited)"
run_buildah --log-level=error run $cid awk '/processes/{print $3}' /proc/self/limits run_buildah run $cid awk '/processes/{print $3}' /proc/self/limits
expect_output "1048576" "limits: processes (unlimited)" expect_output "1048576" "limits: processes (unlimited)"
buildah rm $cid buildah rm $cid
cid=$(buildah from --ulimit nofile=300:400 --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --ulimit nofile=300:400 --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah --log-level=error run $cid awk '/open files/{print $4}' /proc/self/limits run_buildah run $cid awk '/open files/{print $4}' /proc/self/limits
expect_output "300" "limits: open files (w/file limit)" expect_output "300" "limits: open files (w/file limit)"
run_buildah --log-level=error run $cid awk '/processes/{print $3}' /proc/self/limits run_buildah run $cid awk '/processes/{print $3}' /proc/self/limits
expect_output "1048576" "limits: processes (w/file limit)" expect_output "1048576" "limits: processes (w/file limit)"
buildah rm $cid buildah rm $cid
cid=$(buildah from --ulimit nproc=100:200 --ulimit nofile=300:400 --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --ulimit nproc=100:200 --ulimit nofile=300:400 --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
run_buildah --log-level=error run $cid awk '/open files/{print $4}' /proc/self/limits run_buildah run $cid awk '/open files/{print $4}' /proc/self/limits
expect_output "300" "limits: open files (w/file & proc limits)" expect_output "300" "limits: open files (w/file & proc limits)"
run_buildah --log-level=error run $cid awk '/processes/{print $3}' /proc/self/limits run_buildah run $cid awk '/processes/{print $3}' /proc/self/limits
expect_output "100" "limits: processes (w/file & proc limits)" expect_output "100" "limits: processes (w/file & proc limits)"
buildah rm $cid buildah rm $cid
} }
@ -344,7 +344,7 @@ function configure_and_check_user() {
echo "$output" echo "$output"
[ "$status" -ne 0 ] [ "$status" -ne 0 ]
# We'll create the mountpoint for "run". # We'll create the mountpoint for "run".
run_buildah --log-level=error run $cid ls -1 /var/lib run_buildah run $cid ls -1 /var/lib
expect_output --substring "registry" expect_output --substring "registry"
# Double-check that the mountpoint is there. # Double-check that the mountpoint is there.
@ -363,7 +363,7 @@ function configure_and_check_user() {
cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine) cid=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json alpine)
# test a standard mount to /run/.containerenv # test a standard mount to /run/.containerenv
run_buildah --log-level=error run $cid ls -1 /run/.containerenv run_buildah run $cid ls -1 /run/.containerenv
expect_output --substring "/run/.containerenv" expect_output --substring "/run/.containerenv"
} }

View File

@ -55,31 +55,31 @@ function teardown() {
# setup the test container # setup the test container
cid=$(buildah --default-mounts-file "$MOUNTS_PATH" --log-level=error \ cid=$(buildah --default-mounts-file "$MOUNTS_PATH" \
from --pull --signature-policy ${TESTSDIR}/policy.json alpine) from --pull --signature-policy ${TESTSDIR}/policy.json alpine)
# test a standard mount to /run/secrets # test a standard mount to /run/secrets
run_buildah --log-level=error run $cid ls /run/secrets run_buildah run $cid ls /run/secrets
expect_output --substring "test.txt" expect_output --substring "test.txt"
# test a mount without destination # test a mount without destination
run_buildah --log-level=error run $cid ls "$TESTSDIR"/rhel/secrets run_buildah run $cid ls "$TESTSDIR"/rhel/secrets
expect_output --substring "test.txt" expect_output --substring "test.txt"
# test a file-based mount # test a file-based mount
run_buildah --log-level=error run $cid cat /test.txt run_buildah run $cid cat /test.txt
expect_output --substring $TESTFILE_CONTENT expect_output --substring $TESTFILE_CONTENT
# test permissions for a file-based mount # test permissions for a file-based mount
run_buildah --log-level=error run $cid stat -c %a /run/secrets/file.txt run_buildah run $cid stat -c %a /run/secrets/file.txt
expect_output --substring 604 expect_output --substring 604
# test permissions for a directory-based mount # test permissions for a directory-based mount
run_buildah --log-level=error run $cid stat -c %a /run/secrets/test-dir run_buildah run $cid stat -c %a /run/secrets/test-dir
expect_output --substring 704 expect_output --substring 704
# test permissions for a file-based mount within a sub-directory # test permissions for a file-based mount within a sub-directory
run_buildah --log-level=error run $cid stat -c %a /run/secrets/test-dir/file.txt run_buildah run $cid stat -c %a /run/secrets/test-dir/file.txt
expect_output --substring 777 expect_output --substring 777
# test a symlink # test a symlink

View File

@ -12,18 +12,18 @@ load helpers
image=alpine image=alpine
# Create a container and read its context as a baseline. # Create a container and read its context as a baseline.
cid=$(buildah --log-level=error from --quiet --signature-policy ${TESTSDIR}/policy.json $image) cid=$(buildah from --quiet --signature-policy ${TESTSDIR}/policy.json $image)
run_buildah --log-level=error run $cid sh -c 'tr \\0 \\n < /proc/self/attr/current' run_buildah run $cid sh -c 'tr \\0 \\n < /proc/self/attr/current'
[ "$output" != "" ] [ "$output" != "" ]
firstlabel="$output" firstlabel="$output"
# Ensure that we label the same container consistently across multiple "run" instructions. # Ensure that we label the same container consistently across multiple "run" instructions.
run_buildah --log-level=error run $cid sh -c 'tr \\0 \\n < /proc/self/attr/current' run_buildah run $cid sh -c 'tr \\0 \\n < /proc/self/attr/current'
expect_output "$firstlabel" "label of second container == first" expect_output "$firstlabel" "label of second container == first"
# Ensure that different containers get different labels. # Ensure that different containers get different labels.
cid1=$(buildah --log-level=error from --quiet --signature-policy ${TESTSDIR}/policy.json $image) cid1=$(buildah from --quiet --signature-policy ${TESTSDIR}/policy.json $image)
run_buildah --log-level=error run $cid1 sh -c 'tr \\0 \\n < /proc/self/attr/current' run_buildah run $cid1 sh -c 'tr \\0 \\n < /proc/self/attr/current'
if [ "$output" = "$firstlabel" ]; then if [ "$output" = "$firstlabel" ]; then
die "Second container has the same label as first (both '$output')" die "Second container has the same label as first (both '$output')"
fi fi
@ -44,8 +44,8 @@ load helpers
firstlabel="unconfined_u:system_r:spc_t:s0-s0:c0.c1023" firstlabel="unconfined_u:system_r:spc_t:s0-s0:c0.c1023"
fi fi
# Create a container and read its context as a baseline. # Create a container and read its context as a baseline.
cid=$(buildah --log-level=error from --security-opt label=disable --quiet --signature-policy ${TESTSDIR}/policy.json $image) cid=$(buildah from --security-opt label=disable --quiet --signature-policy ${TESTSDIR}/policy.json $image)
run_buildah --log-level=error run $cid sh -c 'tr \\0 \\n < /proc/self/attr/current' run_buildah run $cid sh -c 'tr \\0 \\n < /proc/self/attr/current'
expect_output "$firstlabel" "container context matches our own" expect_output "$firstlabel" "container context matches our own"
} }
@ -60,13 +60,13 @@ load helpers
firstlabel="system_u:system_r:container_t:s0:c1,c2" firstlabel="system_u:system_r:container_t:s0:c1,c2"
# Create a container and read its context as a baseline. # Create a container and read its context as a baseline.
cid=$(buildah --log-level=error from --security-opt label="level:s0:c1,c2" --quiet --signature-policy ${TESTSDIR}/policy.json $image) cid=$(buildah from --security-opt label="level:s0:c1,c2" --quiet --signature-policy ${TESTSDIR}/policy.json $image)
# Inspect image # Inspect image
run_buildah --log-level=error inspect --format '{{.ProcessLabel}}' $cid run_buildah inspect --format '{{.ProcessLabel}}' $cid
expect_output "$firstlabel" expect_output "$firstlabel"
# Check actual running context # Check actual running context
run_buildah --log-level=error run $cid sh -c 'tr \\0 \\n < /proc/self/attr/current' run_buildah run $cid sh -c 'tr \\0 \\n < /proc/self/attr/current'
expect_output "$firstlabel" "running container context" expect_output "$firstlabel" "running container context"
} }

View File

@ -10,7 +10,7 @@ function check_lengths() {
# matrix test: check given .Docker.* and .OCIv1.* fields in image # matrix test: check given .Docker.* and .OCIv1.* fields in image
for which in Docker OCIv1; do for which in Docker OCIv1; do
for field in RootFS.DiffIDs History; do for field in RootFS.DiffIDs History; do
run_buildah --log-level=error inspect -t image -f "{{len .$which.$field}}" $image run_buildah inspect -t image -f "{{len .$which.$field}}" $image
expect_output "$expect" expect_output "$expect"
done done
done done
@ -80,34 +80,34 @@ function check_lengths() {
done done
buildah build-using-dockerfile --signature-policy ${TESTSDIR}/policy.json --squash --layers -t squashed ${TESTDIR}/squashed buildah build-using-dockerfile --signature-policy ${TESTSDIR}/policy.json --squash --layers -t squashed ${TESTDIR}/squashed
run_buildah --log-level=error inspect -t image -f '{{len .Docker.RootFS.DiffIDs}}' squashed run_buildah inspect -t image -f '{{len .Docker.RootFS.DiffIDs}}' squashed
[ "$output" -eq 1 ] [ "$output" -eq 1 ]
echo FROM ${from} > ${TESTDIR}/squashed/Dockerfile echo FROM ${from} > ${TESTDIR}/squashed/Dockerfile
buildah build-using-dockerfile --signature-policy ${TESTSDIR}/policy.json --squash -t squashed ${TESTDIR}/squashed buildah build-using-dockerfile --signature-policy ${TESTSDIR}/policy.json --squash -t squashed ${TESTDIR}/squashed
run_buildah --log-level=error inspect -t image -f '{{len .Docker.RootFS.DiffIDs}}' squashed run_buildah inspect -t image -f '{{len .Docker.RootFS.DiffIDs}}' squashed
[ "$output" -eq 1 ] [ "$output" -eq 1 ]
echo USER root >> ${TESTDIR}/squashed/Dockerfile echo USER root >> ${TESTDIR}/squashed/Dockerfile
buildah build-using-dockerfile --signature-policy ${TESTSDIR}/policy.json --squash -t squashed ${TESTDIR}/squashed buildah build-using-dockerfile --signature-policy ${TESTSDIR}/policy.json --squash -t squashed ${TESTDIR}/squashed
run_buildah --log-level=error inspect -t image -f '{{len .Docker.RootFS.DiffIDs}}' squashed run_buildah inspect -t image -f '{{len .Docker.RootFS.DiffIDs}}' squashed
[ "$output" -eq 1 ] [ "$output" -eq 1 ]
echo COPY file / >> ${TESTDIR}/squashed/Dockerfile echo COPY file / >> ${TESTDIR}/squashed/Dockerfile
echo COPY file / > ${TESTDIR}/squashed/file echo COPY file / > ${TESTDIR}/squashed/file
buildah build-using-dockerfile --signature-policy ${TESTSDIR}/policy.json --squash -t squashed ${TESTDIR}/squashed buildah build-using-dockerfile --signature-policy ${TESTSDIR}/policy.json --squash -t squashed ${TESTDIR}/squashed
run_buildah --log-level=error inspect -t image -f '{{len .Docker.RootFS.DiffIDs}}' squashed run_buildah inspect -t image -f '{{len .Docker.RootFS.DiffIDs}}' squashed
[ "$output" -eq 1 ] [ "$output" -eq 1 ]
echo FROM ${from} > ${TESTDIR}/squashed/Dockerfile echo FROM ${from} > ${TESTDIR}/squashed/Dockerfile
buildah build-using-dockerfile --signature-policy ${TESTSDIR}/policy.json --squash --layers -t squashed ${TESTDIR}/squashed buildah build-using-dockerfile --signature-policy ${TESTSDIR}/policy.json --squash --layers -t squashed ${TESTDIR}/squashed
run_buildah --log-level=error inspect -t image -f '{{len .Docker.RootFS.DiffIDs}}' squashed run_buildah inspect -t image -f '{{len .Docker.RootFS.DiffIDs}}' squashed
[ "$output" -eq 1 ] [ "$output" -eq 1 ]
echo USER root >> ${TESTDIR}/squashed/Dockerfile echo USER root >> ${TESTDIR}/squashed/Dockerfile
buildah build-using-dockerfile --signature-policy ${TESTSDIR}/policy.json --squash -t squashed ${TESTDIR}/squashed buildah build-using-dockerfile --signature-policy ${TESTSDIR}/policy.json --squash -t squashed ${TESTDIR}/squashed
run_buildah --log-level=error inspect -t image -f '{{len .Docker.RootFS.DiffIDs}}' squashed run_buildah inspect -t image -f '{{len .Docker.RootFS.DiffIDs}}' squashed
[ "$output" -eq 1 ] [ "$output" -eq 1 ]
echo COPY file / >> ${TESTDIR}/squashed/Dockerfile echo COPY file / >> ${TESTDIR}/squashed/Dockerfile
echo COPY file / > ${TESTDIR}/squashed/file echo COPY file / > ${TESTDIR}/squashed/file
buildah build-using-dockerfile --signature-policy ${TESTSDIR}/policy.json --squash -t squashed ${TESTDIR}/squashed buildah build-using-dockerfile --signature-policy ${TESTSDIR}/policy.json --squash -t squashed ${TESTDIR}/squashed
run_buildah --log-level=error inspect -t image -f '{{len .Docker.RootFS.DiffIDs}}' squashed run_buildah inspect -t image -f '{{len .Docker.RootFS.DiffIDs}}' squashed
[ "$output" -eq 1 ] [ "$output" -eq 1 ]
} }