summaryrefslogtreecommitdiff
path: root/test/system
diff options
context:
space:
mode:
Diffstat (limited to 'test/system')
-rw-r--r--test/system/001-basic.bats20
-rw-r--r--test/system/300-cli-parsing.bats14
-rw-r--r--test/system/800-config.bats80
-rw-r--r--test/system/helpers.bash3
4 files changed, 113 insertions, 4 deletions
diff --git a/test/system/001-basic.bats b/test/system/001-basic.bats
index 721fb4bca..582efa058 100644
--- a/test/system/001-basic.bats
+++ b/test/system/001-basic.bats
@@ -33,6 +33,23 @@ function setup() {
fi
}
+@test "podman info" {
+ # These will be displayed on the test output stream, offering an
+ # at-a-glance overview of important system configuration details
+ local -a want=(
+ 'Arch:{{.Host.Arch}}'
+ 'OS:{{.Host.Distribution.Distribution}}{{.Host.Distribution.Version}}'
+ 'Runtime:{{.Host.OCIRuntime.Name}}'
+ 'Rootless:{{.Host.Security.Rootless}}'
+ 'Events:{{.Host.EventLogger}}'
+ 'Logdriver:{{.Host.LogDriver}}'
+ 'Cgroups:{{.Host.CgroupsVersion}}+{{.Host.CgroupManager}}'
+ 'Net:{{.Host.NetworkBackend}}'
+ )
+ run_podman info --format "$(IFS='/' echo ${want[@]})"
+ echo "# $output" >&3
+}
+
@test "podman --context emits reasonable output" {
# All we care about here is that the command passes
@@ -88,7 +105,8 @@ function setup() {
# ...but no matter what, --remote is never allowed after subcommand
PODMAN="${podman_non_remote} ${podman_args[@]}" run_podman 125 version --remote
- is "$output" "Error: unknown flag: --remote" "podman version --remote"
+ is "$output" "Error: unknown flag: --remote
+See 'podman version --help'" "podman version --remote"
}
@test "podman-remote: defaults" {
diff --git a/test/system/300-cli-parsing.bats b/test/system/300-cli-parsing.bats
index 92c073102..ec493d3d8 100644
--- a/test/system/300-cli-parsing.bats
+++ b/test/system/300-cli-parsing.bats
@@ -12,4 +12,18 @@ load helpers
run_podman run --rm --label 'true="false"' $IMAGE true
}
+@test "podman flag error" {
+ local name="podman"
+ if is_remote; then
+ name="podman-remote"
+ fi
+ run_podman 125 run -h
+ is "$output" "Error: flag needs an argument: 'h' in -h
+See '$name run --help'" "expected error output"
+
+ run_podman 125 bad --invalid
+ is "$output" "Error: unknown flag: --invalid
+See '$name --help'" "expected error output"
+}
+
# vim: filetype=sh
diff --git a/test/system/800-config.bats b/test/system/800-config.bats
new file mode 100644
index 000000000..f5b4e9570
--- /dev/null
+++ b/test/system/800-config.bats
@@ -0,0 +1,80 @@
+#!/usr/bin/env bats -*- bats -*-
+#
+# Test specific configuration options and overrides
+#
+
+load helpers
+
+@test "podman CONTAINERS_CONF - CONTAINERS_CONF in conmon" {
+ skip_if_remote "can't check conmon environment over remote"
+
+ # Get the normal runtime for this host
+ run_podman info --format '{{ .Host.OCIRuntime.Name }}'
+ runtime="$output"
+ run_podman info --format "{{ .Host.OCIRuntime.Path }}"
+ ocipath="$output"
+
+ # Make an innocuous containers.conf in a non-standard location
+ conf_tmp="$PODMAN_TMPDIR/containers.conf"
+ cat >$conf_tmp <<EOF
+[engine]
+runtime="$runtime"
+[engine.runtimes]
+$runtime = ["$ocipath"]
+EOF
+ CONTAINERS_CONF="$conf_tmp" run_podman run -d $IMAGE sleep infinity
+ cid="$output"
+
+ CONTAINERS_CONF="$conf_tmp" run_podman inspect "$cid" --format "{{ .State.ConmonPid }}"
+ conmon="$output"
+
+ output="$(tr '\0' '\n' < /proc/$conmon/environ | grep '^CONTAINERS_CONF=')"
+ is "$output" "CONTAINERS_CONF=$conf_tmp"
+
+ # Clean up
+ # Oddly, sleep can't be interrupted with SIGTERM, so we need the
+ # "-f -t 0" to force a SIGKILL
+ CONTAINERS_CONF="$conf_tmp" run_podman rm -f -t 0 "$cid"
+}
+
+@test "podman CONTAINERS_CONF - override runtime name" {
+ skip_if_remote "Can't set CONTAINERS_CONF over remote"
+
+ # Get the path of the normal runtime
+ run_podman info --format "{{ .Host.OCIRuntime.Path }}"
+ ocipath="$output"
+
+ export conf_tmp="$PODMAN_TMPDIR/nonstandard_runtime_name.conf"
+ cat > $conf_tmp <<EOF
+[engine]
+runtime = "nonstandard_runtime_name"
+[engine.runtimes]
+nonstandard_runtime_name = ["$ocipath"]
+EOF
+
+ CONTAINERS_CONF="$conf_tmp" run_podman run -d --rm $IMAGE true
+ cid="$output"
+
+ # We need to wait for the container to finish before we can check
+ # if it was cleaned up properly. But in the common case that the
+ # container completes fast, and the cleanup *did* happen properly
+ # the container is now gone. So, we need to ignore "no such
+ # container" errors from podman wait.
+ CONTAINERS_CONF="$conf_tmp" run_podman '?' wait "$cid"
+ if [[ $status != 0 ]]; then
+ is "$output" "Error:.*no such container" "unexpected error from podman wait"
+ fi
+
+ # The --rm option means the container should no longer exist.
+ # However https://github.com/containers/podman/issues/12917 meant
+ # that the container cleanup triggered by conmon's --exit-cmd
+ # could fail, leaving the container in place.
+ #
+ # We verify that the container is indeed gone, by checking that a
+ # podman rm *fails* here - and it has the side effect of cleaning
+ # up in the case this test fails.
+ CONTAINERS_CONF="$conf_tmp" run_podman 1 rm "$cid"
+ is "$output" "Error:.*no such container"
+}
+
+# vim: filetype=sh
diff --git a/test/system/helpers.bash b/test/system/helpers.bash
index c622a5172..ee5f73867 100644
--- a/test/system/helpers.bash
+++ b/test/system/helpers.bash
@@ -37,9 +37,6 @@ fi
# while retaining the ability to include these if they so desire.
# Some CI systems set this to runc, overriding the default crun.
-# Although it would be more elegant to override options in run_podman(),
-# we instead override $PODMAN itself because some tests (170-run-userns)
-# have to invoke $PODMAN directly.
if [[ -n $OCI_RUNTIME ]]; then
if [[ -z $CONTAINERS_CONF ]]; then
# FIXME: BATS provides no mechanism for end-of-run cleanup[1]; how