mirror of
https://github.com/containers/podman.git
synced 2025-12-19 07:09:39 +08:00
Merge pull request #18657 from arizvisa/GH-18120
Added the "--out" parameter and fixed an issue with "--noout" which prevented stdout from being written to.
This commit is contained in:
@@ -239,6 +239,36 @@ run_podman --noout system connection ls
|
||||
is "$output" "" "output should be empty"
|
||||
}
|
||||
|
||||
# Tests --noout to ensure that the output fd can be written to.
|
||||
@test "podman --noout is actually writing to /dev/null" {
|
||||
skip_if_remote "unshare only works locally"
|
||||
skip_if_not_rootless "unshare requires rootless"
|
||||
run_podman --noout unshare ls
|
||||
is "$output" "" "output should be empty"
|
||||
}
|
||||
|
||||
@test "podman version --out writes matching version to a json" {
|
||||
run_podman version
|
||||
|
||||
# copypasta from version check. we're doing this to extract the version.
|
||||
if expr "${lines[0]}" : "Client: *" >/dev/null; then
|
||||
lines=("${lines[@]:1}")
|
||||
fi
|
||||
|
||||
# get the version number so that we have something to compare with.
|
||||
IFS=: read version_key version_number <<<"${lines[0]}"
|
||||
is "$version_key" "Version" "Version line"
|
||||
|
||||
# now we can output everything as some json. we can't use PODMAN_TMPDIR since basic_setup
|
||||
# isn't being used in setup() due to being unable to trust podman-images or podman-rm.
|
||||
outfile=$(mktemp -p ${BATS_TEST_TMPDIR} veroutXXXXXXXX)
|
||||
run_podman --out $outfile version -f json
|
||||
|
||||
# extract the version from the file.
|
||||
run jq -r --arg field "$version_key" '.Client | .[$field]' $outfile
|
||||
is "$output" ${version_number} "Version matches"
|
||||
}
|
||||
|
||||
@test "podman - shutdown engines" {
|
||||
run_podman --log-level=debug run --rm $IMAGE true
|
||||
is "$output" ".*Shutting down engines.*"
|
||||
|
||||
@@ -518,6 +518,37 @@ json-file | f
|
||||
is "$output" "" "output should be empty"
|
||||
}
|
||||
|
||||
@test "podman --out run should save the container id" {
|
||||
outfile=${PODMAN_TMPDIR}/out-results
|
||||
|
||||
# first we'll need to run something, write its output to a file, and then read its contents.
|
||||
run_podman --out $outfile run -d --name test $IMAGE echo hola
|
||||
is "$output" "" "output should be redirected"
|
||||
run_podman wait test
|
||||
|
||||
# compare the container id against the one in the file
|
||||
run_podman container inspect --format '{{.Id}}' test
|
||||
is "$output" "$(<$outfile)" "container id should match"
|
||||
|
||||
run_podman --out /dev/null rm test
|
||||
is "$output" "" "output should be empty"
|
||||
}
|
||||
|
||||
@test "podman --out create should save the container id" {
|
||||
outfile=${PODMAN_TMPDIR}/out-results
|
||||
|
||||
# first we'll need to run something, write its output to a file, and then read its contents.
|
||||
run_podman --out $outfile create --name test $IMAGE echo hola
|
||||
is "$output" "" "output should be redirected"
|
||||
|
||||
# compare the container id against the one in the file
|
||||
run_podman container inspect --format '{{.Id}}' test
|
||||
is "$output" "$(<$outfile)" "container id should match"
|
||||
|
||||
run_podman --out /dev/null rm test
|
||||
is "$output" "" "output should be empty"
|
||||
}
|
||||
|
||||
# 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.
|
||||
|
||||
Reference in New Issue
Block a user