From b231e3412e7d37d9680229e3782e28161792c7f8 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Thu, 4 Jan 2018 08:53:46 -0500 Subject: Fix handling of exit codes Signed-off-by: Daniel J Walsh Closes: #183 Approved by: TomSweeneyRedHat --- test/podman_attach.bats | 6 +++--- test/podman_exec.bats | 4 ++-- test/podman_kill.bats | 2 +- test/podman_pause.bats | 10 +++++----- test/podman_rmi.bats | 2 +- test/podman_run_exit.bats | 46 ++++++++++++++++++++++++++++++++++++++++++++++ test/podman_start.bats | 4 ++-- test/podman_stats.bats | 2 +- test/podman_stop.bats | 2 +- test/podman_top.bats | 6 +++--- test/podman_wait.bats | 2 +- 11 files changed, 66 insertions(+), 20 deletions(-) create mode 100644 test/podman_run_exit.bats (limited to 'test') diff --git a/test/podman_attach.bats b/test/podman_attach.bats index 9baaf339c..8676b2e43 100644 --- a/test/podman_attach.bats +++ b/test/podman_attach.bats @@ -13,14 +13,14 @@ function setup() { @test "attach to a bogus container" { run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} attach foobar" echo "$output" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] } @test "attach to non-running container" { ${PODMAN_BINARY} ${PODMAN_OPTIONS} create --name foobar -d -i ${ALPINE} ls run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} attach foobar" echo "$output" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] } @test "attach to multiple containers" { @@ -28,5 +28,5 @@ function setup() { ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --name foobar2 -d -i ${ALPINE} /bin/sh run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} attach foobar1 foobar2" echo "$output" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] } diff --git a/test/podman_exec.bats b/test/podman_exec.bats index 76114aa0a..2d6a42704 100644 --- a/test/podman_exec.bats +++ b/test/podman_exec.bats @@ -13,13 +13,13 @@ function setup() { @test "exec into a bogus container" { run ${PODMAN_BINARY} ${PODMAN_OPTIONS} exec foobar ls echo "$output" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] } @test "exec without command should fail" { run ${PODMAN_BINARY} ${PODMAN_OPTIONS} exec foobar echo "$output" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] } @test "exec simple command" { diff --git a/test/podman_kill.bats b/test/podman_kill.bats index 449603905..1ccf373bb 100644 --- a/test/podman_kill.bats +++ b/test/podman_kill.bats @@ -58,7 +58,7 @@ function setup() { run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} ps" [ "$status" -eq 0 ] run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} kill -s foobar $ctr_id" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} ps --no-trunc" [ "$status" -eq 0 ] } diff --git a/test/podman_pause.bats b/test/podman_pause.bats index 52add0397..49db0c2aa 100644 --- a/test/podman_pause.bats +++ b/test/podman_pause.bats @@ -13,13 +13,13 @@ function teardown() { @test "pause a bogus container" { run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} pause foobar" echo "$output" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] } @test "unpause a bogus container" { run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} unpause foobar" echo "$output" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] } @test "pause a created container by id" { @@ -61,7 +61,7 @@ function teardown() { ctr_id=`echo "$output" | tail -n 1` run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} unpause $ctr_id" echo "$output" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} rm -f $ctr_id" echo "$output" [ "$status" -eq 0 ] @@ -78,7 +78,7 @@ function teardown() { [ "$status" -eq 0 ] run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} rm $ctr_id" echo "$output" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} rm --force $ctr_id" echo "$output" [ "$status" -eq 0 ] @@ -94,7 +94,7 @@ function teardown() { [ "$status" -eq 0 ] run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} stop $ctr_id" echo "$output" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} unpause $ctr_id" echo "$output" [ "$status" -eq 0 ] diff --git a/test/podman_rmi.bats b/test/podman_rmi.bats index dabf2f0e8..e800a0388 100644 --- a/test/podman_rmi.bats +++ b/test/podman_rmi.bats @@ -19,7 +19,7 @@ function pullImages() { @test "podman rmi bogus image" { run ${PODMAN_BINARY} $PODMAN_OPTIONS rmi debian:6.0.10 echo "$output" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] } @test "podman rmi image with fq name" { diff --git a/test/podman_run_exit.bats b/test/podman_run_exit.bats new file mode 100644 index 000000000..02ccb56ec --- /dev/null +++ b/test/podman_run_exit.bats @@ -0,0 +1,46 @@ +#!/usr/bin/env bats + +load helpers + +function teardown() { + cleanup_test +} + +function setup() { + copy_images +} + +@test "run exit125 test" { + run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run --foobar ${ALPINE} ls $tmp + echo $output + echo $status != 125 + [ $status -eq 125 ] +} + +@test "run exit126 test" { + run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run ${ALPINE} foobar + echo $output + echo $status != 126 + [ "$status" -eq 126 ] +} + +@test "run exit127 test" { + run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run ${ALPINE} /etc + echo $output + echo $status != 127 + [ "$status" -eq 127 ] +} + +@test "run exit0 test" { + run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run ${ALPINE} ps + echo $output + echo $status != 0 + [ "$status" -eq 0 ] +} + +@test "run exit50 test" { + run ${PODMAN_BINARY} ${PODMAN_OPTIONS} run ${ALPINE} sh -c "exit 50" + echo $output + echo $status != 50 + [ "$status" -eq 50 ] +} diff --git a/test/podman_start.bats b/test/podman_start.bats index 50cbf43dc..71afc83ff 100644 --- a/test/podman_start.bats +++ b/test/podman_start.bats @@ -13,7 +13,7 @@ function teardown() { @test "start bogus container" { run ${PODMAN_BINARY} ${PODMAN_OPTIONS} start 1234 echo "$output" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] } @test "start single container by id" { @@ -46,5 +46,5 @@ function teardown() { ${PODMAN_BINARY} ${PODMAN_OPTIONS} create --name foobar2 -d ${ALPINE} ls run ${PODMAN_BINARY} ${PODMAN_OPTIONS} start -a foobar1 foobar2 echo "$output" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] } diff --git a/test/podman_stats.bats b/test/podman_stats.bats index 91ef62f6b..7bdd0ee63 100644 --- a/test/podman_stats.bats +++ b/test/podman_stats.bats @@ -19,7 +19,7 @@ function setup() { @test "stats with bogus container id" { run ${PODMAN_BINARY} ${PODMAN_OPTIONS} stats --no-stream 123 echo "$output" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] } @test "stats on a running container" { diff --git a/test/podman_stop.bats b/test/podman_stop.bats index b505d8827..498d71838 100644 --- a/test/podman_stop.bats +++ b/test/podman_stop.bats @@ -13,7 +13,7 @@ function setup() { @test "stop a bogus container" { run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} stop foobar" echo "$output" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] } @test "stop a running container by id" { diff --git a/test/podman_top.bats b/test/podman_top.bats index e592a0e22..a8b92cd44 100644 --- a/test/podman_top.bats +++ b/test/podman_top.bats @@ -13,13 +13,13 @@ function setup() { @test "top without container name or id" { run ${PODMAN_BINARY} ${PODMAN_OPTIONS} top echo "$output" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] } @test "top a bogus container" { run ${PODMAN_BINARY} ${PODMAN_OPTIONS} top foobar echo "$output" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] } @test "top non-running container by id with defaults" { @@ -28,7 +28,7 @@ function setup() { ctr_id="$output" run bash -c "${PODMAN_BINARY} ${PODMAN_OPTIONS} top $ctr_id" echo "$output" - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] } @test "top running container by id with defaults" { diff --git a/test/podman_wait.bats b/test/podman_wait.bats index 2ebf1d58d..3109ce91e 100644 --- a/test/podman_wait.bats +++ b/test/podman_wait.bats @@ -14,7 +14,7 @@ function teardown() { run ${PODMAN_BINARY} ${PODMAN_OPTIONS} wait 12343 echo $output echo $status - [ "$status" -eq 1 ] + [ "$status" -eq 125 ] } @test "wait on a stopped container" { -- cgit v1.2.3-54-g00ecf