summaryrefslogtreecommitdiff
path: root/test/system/030-run.bats
diff options
context:
space:
mode:
Diffstat (limited to 'test/system/030-run.bats')
-rw-r--r--test/system/030-run.bats92
1 files changed, 91 insertions, 1 deletions
diff --git a/test/system/030-run.bats b/test/system/030-run.bats
index 766948ecc..6b6964c63 100644
--- a/test/system/030-run.bats
+++ b/test/system/030-run.bats
@@ -303,8 +303,36 @@ echo $rand | 0 | $rand
# This would always work on root, but is new behavior on rootless: #6829
# adds a user entry to /etc/passwd
+ whoami=$(id -un)
run_podman run --rm --userns=keep-id $IMAGE id -un
- is "$output" "$(id -un)" "username on container with keep-id"
+ is "$output" "$whoami" "username on container with keep-id"
+
+ # Setting user should also set $HOME (#8013).
+ # Test setup below runs three cases: one with an existing home dir
+ # and two without (one without any volume mounts, one with a misspelled
+ # username). In every case, initial cwd should be /home/podman because
+ # that's the container-defined WORKDIR. In the case of an existing
+ # home dir, $HOME and ~ (passwd entry) will be /home/user; otherwise
+ # they should be /home/podman.
+ if is_rootless; then
+ tests="
+ | /home/podman /home/podman /home/podman | no vol mount
+/home/x$whoami | /home/podman /home/podman /home/podman | bad vol mount
+/home/$whoami | /home/podman /home/$whoami /home/$whoami | vol mount
+"
+ while read vol expect name; do
+ opts=
+ if [[ "$vol" != "''" ]]; then
+ opts="-v $vol"
+ fi
+ run_podman run --rm $opts --userns=keep-id \
+ $IMAGE sh -c 'echo $(pwd;printenv HOME;echo ~)'
+ is "$output" "$expect" "run with --userns=keep-id and $name sets \$HOME"
+ done < <(parse_table "$tests")
+
+ # Clean up volumes
+ run_podman volume rm -a
+ fi
# --privileged should make no difference
run_podman run --rm --privileged --userns=keep-id $IMAGE id -un
@@ -385,6 +413,17 @@ json-file | f
else
is "$output" "" "LogPath (driver=$driver)"
fi
+
+ if [[ $driver != 'none' ]]; then
+ run_podman logs myctr
+ is "$output" "$msg" "check that podman logs works as expected"
+ else
+ run_podman 125 logs myctr
+ if ! is_remote; then
+ is "$output" ".*this container is using the 'none' log driver, cannot read logs.*" \
+ "podman logs does not work with none log driver"
+ fi
+ fi
run_podman rm myctr
done < <(parse_table "$tests")
@@ -432,4 +471,55 @@ json-file | f
is "$output" "$expect" "podman run with --tz=local, matches host"
}
+# run with --runtime should preserve the named runtime
+@test "podman run : full path to --runtime is preserved" {
+ skip_if_remote "podman-remote does not support --runtime option"
+
+ # Get configured runtime
+ run_podman info --format '{{.Host.OCIRuntime.Path}}'
+ runtime="$output"
+
+ # Assumes that /var/tmp is not mounted noexec; this is usually safe
+ new_runtime="/var/tmp/myruntime$(random_string 12)"
+ cp --preserve $runtime $new_runtime
+
+ run_podman run -d --runtime "$new_runtime" $IMAGE sleep 60
+ cid="$output"
+
+ run_podman inspect --format '{{.OCIRuntime}}' $cid
+ is "$output" "$new_runtime" "podman inspect shows configured runtime"
+ run_podman kill $cid
+ run_podman rm $cid
+ rm -f $new_runtime
+}
+
+# Regression test for issue #8082
+@test "podman run : look up correct image name" {
+ # Create a 2nd tag for the local image. Force to lower case, and apply it.
+ local newtag="localhost/$(random_string 10)/$(random_string 8)"
+ newtag=${newtag,,}
+ run_podman tag $IMAGE $newtag
+
+ # Create a container with the 2nd tag and make sure that it's being
+ # used. #8082 always inaccurately used the 1st tag.
+ run_podman create $newtag
+ cid="$output"
+
+ run_podman inspect --format "{{.ImageName}}" $cid
+ is "$output" "$newtag" "container .ImageName is the container-create name"
+
+ # Same thing, but now with a :tag, and making sure it works with --name
+ newtag2="${newtag}:$(random_string 6|tr A-Z a-z)"
+ run_podman tag $IMAGE $newtag2
+
+ cname="$(random_string 14|tr A-Z a-z)"
+ run_podman create --name $cname $newtag2
+ run_podman inspect --format "{{.ImageName}}" $cname
+ is "$output" "$newtag2" "container .ImageName is the container-create name"
+
+ # Clean up.
+ run_podman rm $cid $cname
+ run_podman untag $IMAGE $newtag $newtag2
+}
+
# vim: filetype=sh