diff --git a/Makefile b/Makefile index 82bd446270..7030cf90b4 100644 --- a/Makefile +++ b/Makefile @@ -665,7 +665,7 @@ localmachine: localsystem: # Wipe existing config, database, and cache: start with clean slate. $(RM) -rf ${HOME}/.local/share/containers ${HOME}/.config/containers - if timeout -v 1 true; then PODMAN=$(CURDIR)/bin/podman QUADLET=$(CURDIR)/bin/quadlet bats test/system/; else echo "Skipping $@: 'timeout -v' unavailable'"; fi + if timeout -v 1 true; then PODMAN=$(CURDIR)/bin/podman QUADLET=$(CURDIR)/bin/quadlet bats -T test/system/; else echo "Skipping $@: 'timeout -v' unavailable'"; fi .PHONY: remotesystem remotesystem: @@ -690,7 +690,7 @@ remotesystem: echo "Error: ./bin/podman system service did not come up on $$SOCK_FILE" >&2;\ exit 1;\ fi;\ - env PODMAN="$(CURDIR)/bin/podman-remote --url $$PODMAN_SOCKET" bats test/system/ ;\ + env PODMAN="$(CURDIR)/bin/podman-remote --url $$PODMAN_SOCKET" bats -T test/system/ ;\ rc=$$?;\ kill %1;\ rm -f $$SOCK_FILE;\ diff --git a/test/system/001-basic.bats b/test/system/001-basic.bats index 7b4cc58b3e..7c10296290 100644 --- a/test/system/001-basic.bats +++ b/test/system/001-basic.bats @@ -195,10 +195,10 @@ See 'podman version --help'" "podman version --remote" } @test "podman --log-level recognizes log levels" { - run_podman 1 --log-level=telepathic info + run_podman 1 --log-level=telepathic version is "$output" 'Log Level "telepathic" is not supported.*' - run_podman --log-level=trace info + run_podman --log-level=trace version if ! is_remote; then # podman-remote does not do any trace logging assert "$output" =~ " level=trace " "log-level=trace" @@ -207,33 +207,33 @@ See 'podman version --help'" "podman version --remote" assert "$output" =~ " level=info " "log-level=trace includes info" assert "$output" !~ " level=warn" "log-level=trace does not show warn" - run_podman --log-level=debug info + run_podman --log-level=debug version assert "$output" !~ " level=trace " "log-level=debug does not show trace" assert "$output" =~ " level=debug " "log-level=debug" assert "$output" =~ " level=info " "log-level=debug includes info" assert "$output" !~ " level=warn" "log-level=debug does not show warn" - run_podman --log-level=info info + run_podman --log-level=info version assert "$output" !~ " level=trace " "log-level=info does not show trace" assert "$output" !~ " level=debug " "log-level=info does not show debug" assert "$output" =~ " level=info " "log-level=info" - run_podman --log-level=warn info + run_podman --log-level=warn version assert "$output" !~ " level=" "log-level=warn shows no logs at all" - run_podman --log-level=warning info + run_podman --log-level=warning version assert "$output" !~ " level=" "log-level=warning shows no logs at all" - run_podman --log-level=error info + run_podman --log-level=error version assert "$output" !~ " level=" "log-level=error shows no logs at all" # docker compat - run_podman --debug info + run_podman --debug version assert "$output" =~ " level=debug " "podman --debug gives debug output" - run_podman -D info + run_podman -D version assert "$output" =~ " level=debug " "podman -D gives debug output" - run_podman 1 --debug --log-level=panic info + run_podman 1 --debug --log-level=panic version is "$output" "Setting --log-level and --debug is not allowed" } diff --git a/test/system/030-run.bats b/test/system/030-run.bats index 5ff1fb29ba..9049a74fad 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -308,12 +308,10 @@ echo $rand | 0 | $rand for user in "--user=0" "--user=100"; do for keepid in "" ${keep}; do opts="$priv $user $keepid" - - for dir in /etc /usr;do - run_podman run --rm $opts $IMAGE stat -c '%u:%g:%n' $dir - remove_same_dev_warning # grumble - is "$output" "0:0:$dir" "run $opts ($dir)" - done + run_podman run --rm $opts $IMAGE stat -c '%u:%g:%n' $dir /etc /usr + remove_same_dev_warning # grumble + is "${lines[0]}" "0:0:/etc" "run $opts /etc" + is "${lines[1]}" "0:0:/usr" "run $opts /usr" done done done diff --git a/test/system/040-ps.bats b/test/system/040-ps.bats index 5259299ecc..3d829ffcf0 100644 --- a/test/system/040-ps.bats +++ b/test/system/040-ps.bats @@ -142,25 +142,38 @@ load helpers run_podman ps --external is "${#lines[@]}" "1" "setup check: no storage containers at start of test" - # Force a buildah timeout; this leaves a buildah container behind - local t0=$SECONDS - PODMAN_TIMEOUT=5 run_podman 124 build -t thiswillneverexist - < ctr:$dest - RUNNING)" + is "${lines[*]}" "${randomcontent[*]}" "$description (cp -> ctr:$dest - RUNNING)" done < <(parse_table "$tests") run_podman rm -t 0 -f destrunning # CREATED container + run_podman create --name destcreated --workdir=/srv $cpimage sleep infinity while read src dest dest_fullname description; do - run_podman create --name destcreated --workdir=/srv $cpimage sleep infinity run_podman cp $srcdir/$src destcreated:$dest - run_podman start destcreated - run_podman exec destcreated cat $dest_fullname/hostfile0 $dest_fullname/hostfile1 - is "$(echo $output)" "${randomcontent[*]}" "$description (cp -> ctr:$dest - CREATED)" - run_podman rm -t 0 -f destcreated + # tests checks are done below done < <(parse_table "$tests") + # Now do the test checks, it is a bit ugly that we do this over two loops but this + # makes the test faster as we do not have to start/stop the container on every iteration. + run_podman start destcreated + while read src dest dest_fullname description; do + run_podman exec destcreated cat $dest_fullname/hostfile0 $dest_fullname/hostfile1 + is "${lines[*]}" "${randomcontent[*]}" "$description (cp -> ctr:$dest - CREATED)" + done < <(parse_table "$tests") + run_podman rm -t 0 -f destcreated + run_podman create --name destnotdir --workdir=/srv $cpimage sleep infinity run_podman 125 cp $srcdir destnotdir:/etc/os-release is "$output" "Error: destination must be a directory when copying a directory" "cannot copy directory to file" diff --git a/test/system/070-build.bats b/test/system/070-build.bats index 6f77feb79e..8926ac0fdd 100644 --- a/test/system/070-build.bats +++ b/test/system/070-build.bats @@ -246,7 +246,7 @@ FROM $IMAGE RUN echo hi EOF - local count=30 + local count=10 for i in $(seq --format '%02g' 1 $count); do timeout --foreground -v --kill=10 60 \ $PODMAN build -t i$i $PODMAN_TMPDIR &> $PODMAN_TMPDIR/log.$i & @@ -360,11 +360,11 @@ LABEL $label_name=$label_value WORKDIR $workdir # Test for #7094 - chowning of invalid symlinks -RUN mkdir -p /a/b/c -RUN ln -s /no/such/nonesuch /a/b/c/badsymlink -RUN ln -s /bin/mydefaultcmd /a/b/c/goodsymlink -RUN touch /a/b/c/myfile -RUN chown -h 1:2 /a/b/c/badsymlink /a/b/c/goodsymlink && chown -h 4:5 /a/b/c/myfile +RUN mkdir -p /a/b/c && \ + ln -s /no/such/nonesuch /a/b/c/badsymlink && \ + ln -s /bin/mydefaultcmd /a/b/c/goodsymlink && \ + touch /a/b/c/myfile && \ + chown -h 1:2 /a/b/c/badsymlink /a/b/c/goodsymlink && chown -h 4:5 /a/b/c/myfile VOLUME /a/b/c # Test for environment passing and override @@ -374,17 +374,16 @@ ENV MYENV3 this-should-be-overridden-by-env-file ENV MYENV4 this-should-be-overridden-by-cmdline ENV http_proxy http-proxy-in-image ENV ftp_proxy ftp-proxy-in-image + ADD mycmd /bin/mydefaultcmd -RUN chmod 755 /bin/mydefaultcmd -RUN chown 2:3 /bin/mydefaultcmd - -RUN $CAT_SECRET - -RUN echo explicit-build-arg=\$arg_explicit -RUN echo implicit-build-arg=\$arg_implicit +RUN chmod 755 /bin/mydefaultcmd && \ + chown 2:3 /bin/mydefaultcmd && \ + $CAT_SECRET && \ + echo explicit-build-arg=\$arg_explicit && \ + echo implicit-build-arg=\$arg_implicit && \ + cat /etc/resolv.conf CMD ["/bin/mydefaultcmd","$s_echo"] -RUN cat /etc/resolv.conf EOF # The goal is to test that a missing value will be inherited from @@ -458,7 +457,8 @@ EOF --env-file=$PODMAN_TMPDIR/env-file1 \ --env-file=$PODMAN_TMPDIR/env-file2 \ build_test \ - printenv http_proxy https_proxy ftp_proxy + sh -c "printenv http_proxy https_proxy ftp_proxy && + pwd" is "${lines[0]}" "http-proxy-in-env-file" "env-file overrides env" is "${lines[1]}" "https-proxy-in-env-file" "env-file sets proxy var" @@ -469,8 +469,7 @@ EOF fi # test that workdir is set for command-line commands also - run_podman run --rm build_test pwd - is "$output" "$workdir" "pwd command in container" + is "${lines[3]}" "$workdir" "pwd command in container" # Determine buildah version, so we can confirm it gets into Labels # Multiple --format options confirm command-line override (last one wins) @@ -494,10 +493,8 @@ Cmd[0] | /bin/mydefaultcmd Cmd[1] | $s_echo WorkingDir | $workdir Labels.$label_name | $label_value +Labels.\"io.buildah.version\" | $buildah_version " - # FIXME: 2021-02-24: Fixed in buildah #3036; re-enable this once podman - # vendors in a newer buildah! - # Labels.\"io.buildah.version\" | $buildah_version parse_table "$tests" | while read field expect; do actual=$(jq -r ".[0].Config.$field" <<<"$output") @@ -509,19 +506,18 @@ Labels.$label_name | $label_value # get here because any 'podman run' on a volume that had symlinks, # be they dangling or valid, would barf with # Error: chown /_data/symlink: ENOENT - run_podman run --rm build_test stat -c'%u:%g:%N' /a/b/c/badsymlink - is "$output" "1:2:'/a/b/c/badsymlink' -> '/no/such/nonesuch'" \ + run_podman run --rm build_test \ + stat -c'%u:%g:%N' /a/b/c/badsymlink \ + /a/b/c/goodsymlink \ + /bin/mydefaultcmd \ + /a/b/c/myfile + + is "${lines[0]}" "1:2:'/a/b/c/badsymlink' -> '/no/such/nonesuch'" \ "bad symlink to nonexistent file is chowned and preserved" - - run_podman run --rm build_test stat -c'%u:%g:%N' /a/b/c/goodsymlink - is "$output" "1:2:'/a/b/c/goodsymlink' -> '/bin/mydefaultcmd'" \ + is "${lines[1]}" "1:2:'/a/b/c/goodsymlink' -> '/bin/mydefaultcmd'" \ "good symlink to existing file is chowned and preserved" - - run_podman run --rm build_test stat -c'%u:%g' /bin/mydefaultcmd - is "$output" "2:3" "target of symlink is not chowned" - - run_podman run --rm build_test stat -c'%u:%g:%N' /a/b/c/myfile - is "$output" "4:5:/a/b/c/myfile" "file in volume is chowned" + is "${lines[2]}" "2:3:/bin/mydefaultcmd" "target of symlink is not chowned" + is "${lines[3]}" "4:5:/a/b/c/myfile" "file in volume is chowned" # Hey, as long as we have an image with lots of layers, let's # confirm that 'image tree' works as expected diff --git a/test/system/252-quadlet.bats b/test/system/252-quadlet.bats index bf1f7450e7..7821172169 100644 --- a/test/system/252-quadlet.bats +++ b/test/system/252-quadlet.bats @@ -150,7 +150,9 @@ function remove_secret() { cat > $quadlet_file < $quadlet_container_file <