diff options
Diffstat (limited to 'test/system')
-rw-r--r-- | test/system/015-help.bats | 36 | ||||
-rw-r--r-- | test/system/030-run.bats | 59 | ||||
-rw-r--r-- | test/system/090-events.bats | 27 | ||||
-rw-r--r-- | test/system/250-systemd.bats | 2 | ||||
-rw-r--r-- | test/system/260-sdnotify.bats | 2 |
5 files changed, 102 insertions, 24 deletions
diff --git a/test/system/015-help.bats b/test/system/015-help.bats index 651fdcd09..22db8be8a 100644 --- a/test/system/015-help.bats +++ b/test/system/015-help.bats @@ -6,7 +6,7 @@ # provides its own --help output. If the usage message ends in '[command]', # treat it as a subcommand, and recurse into its own list of sub-subcommands. # -# Any usage message that ends in '[flags]' is interpreted as a command +# Any usage message that ends in '[options]' is interpreted as a command # that takes no further arguments; we confirm by running with 'invalid-arg' # and confirming that it exits with error status and message. # @@ -17,7 +17,7 @@ load helpers function podman_commands() { dprint "$@" run_podman help "$@" |\ - awk '/^Available Commands:/{ok=1;next}/^Flags:/{ok=0}ok { print $1 }' |\ + awk '/^Available Commands:/{ok=1;next}/^Options:/{ok=0}ok { print $1 }' |\ grep . "$output" } @@ -42,7 +42,7 @@ function check_help() { # e.g. 'podman ps' should not show 'podman container ps' in usage # Trailing space in usage handles 'podman system renumber' which - # has no ' [flags]' + # has no ' [options]' is "$usage " " $command_string .*" "Usage string matches command" # If usage ends in '[command]', recurse into subcommands @@ -52,25 +52,25 @@ function check_help() { continue fi - # We had someone write upper-case '[FLAGS]' once. Prevent it. - if expr "$usage" : '.*\[FLAG' >/dev/null; then - die "'flags' string must be lower-case in usage: $usage" + # We had someone write upper-case '[OPTIONS]' once. Prevent it. + if expr "$usage" : '.*\[OPTION' >/dev/null; then + die "'options' string must be lower-case in usage: $usage" fi - # We had someone do 'podman foo ARG [flags]' one time. Yeah, no. - if expr "$usage" : '.*[A-Z].*\[flag' >/dev/null; then - die "'flags' must precede arguments in usage: $usage" + # We had someone do 'podman foo ARG [options]' one time. Yeah, no. + if expr "$usage" : '.*[A-Z].*\[option' >/dev/null; then + die "'options' must precede arguments in usage: $usage" fi - # Cross-check: if usage includes '[flags]', there must be a - # longer 'Flags:' section in the full --help output; vice-versa, - # if 'Flags:' is in full output, usage line must have '[flags]'. - if expr "$usage" : '.*\[flag' >/dev/null; then - if ! expr "$full_help" : ".*Flags:" >/dev/null; then - die "$command_string: Usage includes '[flags]' but has no 'Flags:' subsection" + # Cross-check: if usage includes '[options]', there must be a + # longer 'Options:' section in the full --help output; vice-versa, + # if 'Options:' is in full output, usage line must have '[options]'. + if expr "$usage" : '.*\[option' >/dev/null; then + if ! expr "$full_help" : ".*Options:" >/dev/null; then + die "$command_string: Usage includes '[options]' but has no 'Options:' subsection" fi - elif expr "$full_help" : ".*Flags:" >/dev/null; then - die "$command_string: --help has 'Flags:' section but no '[flags]' in synopsis" + elif expr "$full_help" : ".*Options:" >/dev/null; then + die "$command_string: --help has 'Options:' section but no '[options]' in synopsis" fi # If usage lists no arguments (strings in ALL CAPS), confirm @@ -102,7 +102,7 @@ function check_help() { # If usage has required arguments, try running without them. # The expression here is 'first capital letter is not in [BRACKETS]'. - # It is intended to handle 'podman foo [flags] ARG' but not ' [ARG]'. + # It is intended to handle 'podman foo [options] ARG' but not ' [ARG]'. if expr "$usage" : '[^A-Z]\+ [A-Z]' >/dev/null; then # Exceptions: these commands don't work rootless if is_rootless; then diff --git a/test/system/030-run.bats b/test/system/030-run.bats index 9f4037730..6b6964c63 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -413,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") @@ -462,15 +473,53 @@ json-file | f # run with --runtime should preserve the named runtime @test "podman run : full path to --runtime is preserved" { - skip_if_cgroupsv1 - skip_if_remote - run_podman run -d --runtime '/usr/bin/crun' $IMAGE sleep 60 + 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" "/usr/bin/crun" - + 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 diff --git a/test/system/090-events.bats b/test/system/090-events.bats new file mode 100644 index 000000000..8a9db41fa --- /dev/null +++ b/test/system/090-events.bats @@ -0,0 +1,27 @@ +#!/usr/bin/env bats -*- bats -*- +# +# tests for podman events functionality +# + +load helpers + +@test "events with a filter by label" { + skip_if_remote "FIXME: -remote does not include labels in event output" + cname=test-$(random_string 30 | tr A-Z a-z) + labelname=$(random_string 10) + labelvalue=$(random_string 15) + + run_podman run --label $labelname=$labelvalue --name $cname --rm $IMAGE ls + + expect=".* container start [0-9a-f]\+ (image=$IMAGE, name=$cname,.* ${labelname}=${labelvalue}" + run_podman events --filter type=container --filter container=$cname --filter label=${labelname}=${labelvalue} --filter event=start --stream=false + is "$output" "$expect" "filtering by container name and label" + + # Same thing, but without the container-name filter + run_podman events --filter type=container --filter label=${labelname}=${labelvalue} --filter event=start --stream=false + is "$output" "$expect" "filtering just by label" + + # Now filter just by container name, no label + run_podman events --filter type=container --filter container=$cname --filter event=start --stream=false + is "$output" "$expect" "filtering just by label" +} diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats index 9bd3e15a1..ac3ae2f98 100644 --- a/test/system/250-systemd.bats +++ b/test/system/250-systemd.bats @@ -42,7 +42,7 @@ function teardown() { cname=$(random_string) # See #7407 for --pull=always. - run_podman create --pull=always --name $cname --label "io.containers.autoupdate=image" --detach $IMAGE top + run_podman create --pull=always --name $cname --label "io.containers.autoupdate=image" $IMAGE top run_podman generate systemd --new $cname echo "$output" > "$UNIT_FILE" diff --git a/test/system/260-sdnotify.bats b/test/system/260-sdnotify.bats index 2ddeda96a..c99ba4fa6 100644 --- a/test/system/260-sdnotify.bats +++ b/test/system/260-sdnotify.bats @@ -107,6 +107,7 @@ function _assert_mainpid_is_conmon() { # Done. Stop container, clean up. run_podman exec $cid touch /stop + run_podman wait $cid run_podman rm $cid _stop_socat } @@ -142,6 +143,7 @@ function _assert_mainpid_is_conmon() { # Done. Stop container, clean up. run_podman exec $cid touch /stop + run_podman wait $cid run_podman rm $cid run_podman rmi $_FEDORA _stop_socat |