summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/e2e/run_networking_test.go76
-rw-r--r--test/e2e/run_selinux_test.go9
-rw-r--r--test/e2e/run_test.go8
-rw-r--r--test/e2e/run_userns_test.go7
-rw-r--r--test/e2e/untag_test.go76
-rw-r--r--test/system/015-help.bats63
-rw-r--r--test/system/020-tag.bats35
-rw-r--r--test/system/120-load.bats6
-rw-r--r--test/system/helpers.bash14
9 files changed, 202 insertions, 92 deletions
diff --git a/test/e2e/run_networking_test.go b/test/e2e/run_networking_test.go
index 4fad85f00..afba12ccd 100644
--- a/test/e2e/run_networking_test.go
+++ b/test/e2e/run_networking_test.go
@@ -71,10 +71,9 @@ var _ = Describe("Podman run networking", func() {
inspectOut := podmanTest.InspectContainer(name)
Expect(len(inspectOut)).To(Equal(1))
Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Equal(int32(80)))
- Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80)))
- Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("tcp"))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal(""))
+ Expect(len(inspectOut[0].NetworkSettings.Ports["80/tcp"])).To(Equal(1))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Equal("80"))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal(""))
})
It("podman run -p 8080:80", func() {
@@ -84,10 +83,9 @@ var _ = Describe("Podman run networking", func() {
inspectOut := podmanTest.InspectContainer(name)
Expect(len(inspectOut)).To(Equal(1))
Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Equal(int32(8080)))
- Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80)))
- Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("tcp"))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal(""))
+ Expect(len(inspectOut[0].NetworkSettings.Ports["80/tcp"])).To(Equal(1))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Equal("8080"))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal(""))
})
It("podman run -p 80/udp", func() {
@@ -97,10 +95,9 @@ var _ = Describe("Podman run networking", func() {
inspectOut := podmanTest.InspectContainer(name)
Expect(len(inspectOut)).To(Equal(1))
Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Equal(int32(80)))
- Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80)))
- Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("udp"))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal(""))
+ Expect(len(inspectOut[0].NetworkSettings.Ports["80/udp"])).To(Equal(1))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostPort).To(Equal("80"))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostIP).To(Equal(""))
})
It("podman run -p 127.0.0.1:8080:80", func() {
@@ -110,10 +107,9 @@ var _ = Describe("Podman run networking", func() {
inspectOut := podmanTest.InspectContainer(name)
Expect(len(inspectOut)).To(Equal(1))
Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Equal(int32(8080)))
- Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80)))
- Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("tcp"))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal("127.0.0.1"))
+ Expect(len(inspectOut[0].NetworkSettings.Ports["80/tcp"])).To(Equal(1))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Equal("8080"))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("127.0.0.1"))
})
It("podman run -p 127.0.0.1:8080:80/udp", func() {
@@ -123,10 +119,9 @@ var _ = Describe("Podman run networking", func() {
inspectOut := podmanTest.InspectContainer(name)
Expect(len(inspectOut)).To(Equal(1))
Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Equal(int32(8080)))
- Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80)))
- Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("udp"))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal("127.0.0.1"))
+ Expect(len(inspectOut[0].NetworkSettings.Ports["80/udp"])).To(Equal(1))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostPort).To(Equal("8080"))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostIP).To(Equal("127.0.0.1"))
})
It("podman run -p [::1]:8080:80/udp", func() {
@@ -136,10 +131,9 @@ var _ = Describe("Podman run networking", func() {
inspectOut := podmanTest.InspectContainer(name)
Expect(len(inspectOut)).To(Equal(1))
Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Equal(int32(8080)))
- Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80)))
- Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("udp"))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal("::1"))
+ Expect(len(inspectOut[0].NetworkSettings.Ports["80/udp"])).To(Equal(1))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostPort).To(Equal("8080"))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostIP).To(Equal("::1"))
})
It("podman run -p [::1]:8080:80/tcp", func() {
@@ -149,10 +143,9 @@ var _ = Describe("Podman run networking", func() {
inspectOut := podmanTest.InspectContainer(name)
Expect(len(inspectOut)).To(Equal(1))
Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Equal(int32(8080)))
- Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80)))
- Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("tcp"))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal("::1"))
+ Expect(len(inspectOut[0].NetworkSettings.Ports["80/tcp"])).To(Equal(1))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Equal("8080"))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal("::1"))
})
It("podman run --expose 80 -P", func() {
@@ -162,10 +155,9 @@ var _ = Describe("Podman run networking", func() {
inspectOut := podmanTest.InspectContainer(name)
Expect(len(inspectOut)).To(Equal(1))
Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Not(Equal(int32(0))))
- Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80)))
- Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("tcp"))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal(""))
+ Expect(len(inspectOut[0].NetworkSettings.Ports["80/tcp"])).To(Equal(1))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Not(Equal("0")))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal(""))
})
It("podman run --expose 80/udp -P", func() {
@@ -175,10 +167,9 @@ var _ = Describe("Podman run networking", func() {
inspectOut := podmanTest.InspectContainer(name)
Expect(len(inspectOut)).To(Equal(1))
Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Not(Equal(int32(0))))
- Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80)))
- Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("udp"))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal(""))
+ Expect(len(inspectOut[0].NetworkSettings.Ports["80/udp"])).To(Equal(1))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostPort).To(Not(Equal("0")))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/udp"][0].HostIP).To(Equal(""))
})
It("podman run --expose 80 -p 80", func() {
@@ -188,10 +179,9 @@ var _ = Describe("Podman run networking", func() {
inspectOut := podmanTest.InspectContainer(name)
Expect(len(inspectOut)).To(Equal(1))
Expect(len(inspectOut[0].NetworkSettings.Ports)).To(Equal(1))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostPort).To(Equal(int32(80)))
- Expect(inspectOut[0].NetworkSettings.Ports[0].ContainerPort).To(Equal(int32(80)))
- Expect(inspectOut[0].NetworkSettings.Ports[0].Protocol).To(Equal("tcp"))
- Expect(inspectOut[0].NetworkSettings.Ports[0].HostIP).To(Equal(""))
+ Expect(len(inspectOut[0].NetworkSettings.Ports["80/tcp"])).To(Equal(1))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostPort).To(Equal("80"))
+ Expect(inspectOut[0].NetworkSettings.Ports["80/tcp"][0].HostIP).To(Equal(""))
})
It("podman run network expose host port 80 to container port 8000", func() {
@@ -214,7 +204,7 @@ var _ = Describe("Podman run networking", func() {
results := podmanTest.Podman([]string{"inspect", "-l"})
results.Wait(30)
Expect(results.ExitCode()).To(Equal(0))
- Expect(results.OutputToString()).To(ContainSubstring(": 80,"))
+ Expect(results.OutputToString()).To(ContainSubstring(`"80/tcp":`))
})
It("podman run network expose duplicate host port results in error", func() {
@@ -229,7 +219,9 @@ var _ = Describe("Podman run networking", func() {
Expect(inspect.ExitCode()).To(Equal(0))
containerConfig := inspect.InspectContainerToJSON()
- Expect(containerConfig[0].NetworkSettings.Ports[0].HostPort).ToNot(Equal(80))
+ Expect(containerConfig[0].NetworkSettings.Ports).To(Not(BeNil()))
+ Expect(containerConfig[0].NetworkSettings.Ports["80/tcp"]).To(Not(BeNil()))
+ Expect(containerConfig[0].NetworkSettings.Ports["80/tcp"][0].HostPort).ToNot(Equal(80))
})
It("podman run hostname test", func() {
diff --git a/test/e2e/run_selinux_test.go b/test/e2e/run_selinux_test.go
index 358137aa9..8b33a05b2 100644
--- a/test/e2e/run_selinux_test.go
+++ b/test/e2e/run_selinux_test.go
@@ -177,4 +177,13 @@ var _ = Describe("Podman run", func() {
Expect(session.OutputToString()).To(Equal(session1.OutputToString()))
})
+ It("podman run --privileged and --security-opt SELinux options", func() {
+ session := podmanTest.Podman([]string{"run", "-it", "--privileged", "--security-opt", "label=type:spc_t", "--security-opt", "label=level:s0:c1,c2", ALPINE, "cat", "/proc/self/attr/current"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ match, _ := session.GrepString("spc_t")
+ Expect(match).To(BeTrue())
+ match2, _ := session.GrepString("s0:c1,c2")
+ Expect(match2).To(BeTrue())
+ })
})
diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go
index 90179964d..42754bab4 100644
--- a/test/e2e/run_test.go
+++ b/test/e2e/run_test.go
@@ -1039,4 +1039,12 @@ USER mail`
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
})
+
+ It("podman run --privileged and --group-add", func() {
+ groupName := "kvm"
+ session := podmanTest.Podman([]string{"run", "-t", "-i", "--group-add", groupName, "--privileged", fedoraMinimal, "groups"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(strings.Contains(session.OutputToString(), groupName)).To(BeTrue())
+ })
})
diff --git a/test/e2e/run_userns_test.go b/test/e2e/run_userns_test.go
index 5b9a99daa..be0981408 100644
--- a/test/e2e/run_userns_test.go
+++ b/test/e2e/run_userns_test.go
@@ -89,6 +89,13 @@ var _ = Describe("Podman UserNS support", func() {
Expect(ok).To(BeTrue())
})
+ It("podman --userns=keep-id root owns /usr", func() {
+ session := podmanTest.Podman([]string{"run", "--userns=keep-id", "alpine", "stat", "-c%u", "/usr"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(session.OutputToString()).To(Equal("0"))
+ })
+
It("podman --userns=keep-id --user root:root", func() {
session := podmanTest.Podman([]string{"run", "--userns=keep-id", "--user", "root:root", "alpine", "id", "-u"})
session.WaitWithDefaultTimeout()
diff --git a/test/e2e/untag_test.go b/test/e2e/untag_test.go
index dc1a6208e..8a1c8091d 100644
--- a/test/e2e/untag_test.go
+++ b/test/e2e/untag_test.go
@@ -23,13 +23,6 @@ var _ = Describe("Podman untag", func() {
podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup()
podmanTest.RestoreAllArtifacts()
-
- for _, tag := range []string{"test", "foo", "bar"} {
- session := podmanTest.PodmanNoCache([]string{"tag", ALPINE, tag})
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).To(Equal(0))
- }
-
})
AfterEach(func() {
@@ -40,34 +33,63 @@ var _ = Describe("Podman untag", func() {
})
It("podman untag all", func() {
- session := podmanTest.PodmanNoCache([]string{"untag", ALPINE})
+ tags := []string{ALPINE, "registry.com/foo:bar", "localhost/foo:bar"}
+
+ cmd := []string{"tag"}
+ cmd = append(cmd, tags...)
+ session := podmanTest.PodmanNoCache(cmd)
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- results := podmanTest.PodmanNoCache([]string{"images", ALPINE})
- results.WaitWithDefaultTimeout()
- Expect(results.ExitCode()).To(Equal(0))
- Expect(results.OutputToStringArray()).To(HaveLen(1))
- })
+ // Make sure that all tags exists.
+ for _, t := range tags {
+ session = podmanTest.PodmanNoCache([]string{"image", "exists", t})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ }
- It("podman untag single", func() {
- session := podmanTest.PodmanNoCache([]string{"untag", ALPINE, "localhost/test:latest"})
+ // No arguments -> remove all tags.
+ session = podmanTest.PodmanNoCache([]string{"untag", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- results := podmanTest.PodmanNoCache([]string{"images"})
- results.WaitWithDefaultTimeout()
- Expect(results.ExitCode()).To(Equal(0))
- Expect(results.OutputToStringArray()).To(HaveLen(6))
- Expect(results.LineInOuputStartsWith("docker.io/library/alpine")).To(BeTrue())
- Expect(results.LineInOuputStartsWith("localhost/foo")).To(BeTrue())
- Expect(results.LineInOuputStartsWith("localhost/bar")).To(BeTrue())
- Expect(results.LineInOuputStartsWith("localhost/test")).To(BeFalse())
+ // Make sure that none of tags exists anymore.
+ for _, t := range tags {
+ session = podmanTest.PodmanNoCache([]string{"image", "exists", t})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(1))
+ }
})
- It("podman untag not enough arguments", func() {
- session := podmanTest.PodmanNoCache([]string{"untag"})
- session.WaitWithDefaultTimeout()
- Expect(session.ExitCode()).NotTo(Equal(0))
+ It("podman tag/untag - tag normalization", func() {
+ tests := []struct {
+ tag, normalized string
+ }{
+ {"registry.com/image:latest", "registry.com/image:latest"},
+ {"registry.com/image", "registry.com/image:latest"},
+ {"image:latest", "localhost/image:latest"},
+ {"image", "localhost/image:latest"},
+ }
+
+ // Make sure that the user input is normalized correctly for
+ // `podman tag` and `podman untag`.
+ for _, tt := range tests {
+ session := podmanTest.PodmanNoCache([]string{"tag", ALPINE, tt.tag})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.PodmanNoCache([]string{"image", "exists", tt.normalized})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.PodmanNoCache([]string{"untag", ALPINE, tt.tag})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.PodmanNoCache([]string{"image", "exists", tt.normalized})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(1))
+ }
})
+
})
diff --git a/test/system/015-help.bats b/test/system/015-help.bats
index 42d3bd3ec..14af8e1a4 100644
--- a/test/system/015-help.bats
+++ b/test/system/015-help.bats
@@ -25,7 +25,7 @@ function podman_commands() {
function check_help() {
local count=0
- local subcommands_found=0
+ local -A found
for cmd in $(podman_commands "$@"); do
# Human-readable podman command string, with multiple spaces collapsed
@@ -44,24 +44,37 @@ function check_help() {
# If usage ends in '[command]', recurse into subcommands
if expr "$usage" : '.*\[command\]$' >/dev/null; then
- subcommands_found=$(expr $subcommands_found + 1)
+ found[subcommands]=1
check_help "$@" $cmd
continue
fi
- # If usage ends in '[flag]', command takes no more arguments.
- # Confirm that by running with 'invalid-arg' and expecting failure.
- if expr "$usage" : '.*\[flags\]$' >/dev/null; then
+ # 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"
+ 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"
+ fi
+
+ # If usage lists no arguments (strings in ALL CAPS), confirm
+ # by running with 'invalid-arg' and expecting failure.
+ if ! expr "$usage" : '.*[A-Z]' >/dev/null; then
if [ "$cmd" != "help" ]; then
dprint "$command_string invalid-arg"
run_podman 125 "$@" $cmd invalid-arg
is "$output" "Error: .* takes no arguments" \
"'$command_string' with extra (invalid) arguments"
fi
+ found[takes_no_args]=1
fi
- # If usage has required arguments, try running without them
- if expr "$usage" : '.*\[flags\] [A-Z]' >/dev/null; then
+ # 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]'.
+ if expr "$usage" : '[^A-Z]\+ [A-Z]' >/dev/null; then
# Exceptions: these commands don't work rootless
if is_rootless; then
# "pause is not supported for rootless containers"
@@ -80,6 +93,31 @@ function check_help() {
run_podman 125 "$@" $cmd </dev/null
is "$output" "Error:.* \(require\|specif\|must\|provide\|need\|choose\|accepts\)" \
"'$command_string' without required arg"
+
+ found[required_args]=1
+ fi
+
+ # Commands with fixed number of arguments (i.e. no ellipsis): count
+ # the required args, then invoke with one extra. We should get a
+ # usage error.
+ if ! expr "$usage" : ".*\.\.\."; then
+ # "podman help" can take infinite args, so skip that one
+ if [ "$cmd" != "help" ]; then
+ # Get the args part of the command line; this should be
+ # everything from the first CAPITAL LETTER onward. We
+ # don't actually care about the letter itself, so just
+ # make it 'X'. And we don't care about [OPTIONAL] brackets
+ # either. What we do care about is stuff like 'IMAGE | CTR'
+ # which is actually one argument; convert to 'IMAGE-or-CTR'
+ local rhs=$(sed -e 's/^[^A-Z]\+[A-Z]/X/' -e 's/ | /-or-/g' <<<"$usage")
+ local n_args=$(wc -w <<<"$rhs")
+
+ run_podman 125 "$@" $cmd $(seq --format='x%g' 0 $n_args)
+ is "$output" "Error:.* \(takes no arguments\|requires exactly $n_args arg\|accepts at most\|too many arguments\|accepts $n_args arg(s), received\|accepts between .* and .* arg(s), received \)" \
+ "'$command_string' with >$n_args arguments"
+
+ found[fixed_args]=1
+ fi
fi
count=$(expr $count + 1)
@@ -101,9 +139,14 @@ function check_help() {
[ $count -gt 0 ] || \
die "Internal error: no commands found in 'podman help $@' list"
- # At least the top level must have some subcommands
- if [ -z "$*" -a $subcommands_found -eq 0 ]; then
- die "Internal error: did not find any podman subcommands"
+ # Sanity check: make sure the special loops above triggered at least once.
+ # (We've had situations where a typo makes the conditional never run)
+ if [ -z "$*" ]; then
+ for i in subcommands required_args takes_no_args fixed_args; do
+ if [[ -z ${found[$i]} ]]; then
+ die "Internal error: '$i' subtest did not trigger"
+ fi
+ done
fi
}
diff --git a/test/system/020-tag.bats b/test/system/020-tag.bats
new file mode 100644
index 000000000..7593ad68f
--- /dev/null
+++ b/test/system/020-tag.bats
@@ -0,0 +1,35 @@
+#!/usr/bin/env bats
+
+load helpers
+
+# helper function for "podman tag/untag" test
+function _tag_and_check() {
+ local tag_as="$1"
+ local check_as="$2"
+
+ run_podman tag $IMAGE $tag_as
+ run_podman image exists $check_as
+ run_podman untag $IMAGE $check_as
+ run_podman 1 image exists $check_as
+}
+
+@test "podman tag/untag" {
+ # Test a fully-qualified image reference.
+ _tag_and_check registry.com/image:latest registry.com/image:latest
+
+ # Test a reference without tag and make sure ":latest" is appended.
+ _tag_and_check registry.com/image registry.com/image:latest
+
+ # Test a tagged short image and make sure "localhost/" is prepended.
+ _tag_and_check image:latest localhost/image:latest
+
+ # Test a short image without tag and make sure "localhost/" is
+ # prepended and ":latest" is appended.
+ _tag_and_check image localhost/image:latest
+
+ # Test error case.
+ run_podman 125 untag $IMAGE registry.com/foo:bar
+ is "$output" "Error: \"registry.com/foo:bar\": no such tag"
+}
+
+# vim: filetype=sh
diff --git a/test/system/120-load.bats b/test/system/120-load.bats
index f290c1888..afa5ab473 100644
--- a/test/system/120-load.bats
+++ b/test/system/120-load.bats
@@ -107,10 +107,4 @@ verify_iid_and_name() {
"Diagnostic from 'podman load' without redirection or -i"
}
-@test "podman load - at most 1 arg(s)" {
- run_podman 125 load 1 2 3
- is "$output" \
- "Error: accepts at most 1 arg(s), received 3"
-}
-
# vim: filetype=sh
diff --git a/test/system/helpers.bash b/test/system/helpers.bash
index 7e6f1c1ca..5301644d6 100644
--- a/test/system/helpers.bash
+++ b/test/system/helpers.bash
@@ -2,12 +2,6 @@
# Podman command to run; may be podman-remote
PODMAN=${PODMAN:-podman}
-# If it's a relative path, convert to absolute; otherwise tests can't cd out
-if [[ "$PODMAN" =~ / ]]; then
- if [[ ! "$PODMAN" =~ ^/ ]]; then
- PODMAN=$(realpath $PODMAN)
- fi
-fi
# Standard image to use for most tests
PODMAN_TEST_IMAGE_REGISTRY=${PODMAN_TEST_IMAGE_REGISTRY:-"quay.io"}
@@ -22,6 +16,12 @@ IMAGE=$PODMAN_TEST_IMAGE_FQN
# Default timeout for a podman command.
PODMAN_TIMEOUT=${PODMAN_TIMEOUT:-60}
+# Prompt to display when logging podman commands; distinguish root/rootless
+_LOG_PROMPT='$'
+if [ $(id -u) -eq 0 ]; then
+ _LOG_PROMPT='#'
+fi
+
###############################################################################
# BEGIN setup/teardown tools
@@ -138,7 +138,7 @@ function run_podman() {
esac
# stdout is only emitted upon error; this echo is to help a debugger
- echo "\$ $PODMAN $*"
+ echo "$_LOG_PROMPT $PODMAN $*"
# BATS hangs if a subprocess remains and keeps FD 3 open; this happens
# if podman crashes unexpectedly without cleaning up subprocesses.
run timeout --foreground -v --kill=10 $PODMAN_TIMEOUT $PODMAN "$@" 3>/dev/null