mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add support for docker exec to return cmd exitStatus
Note - only support the non-detached mode of exec right now. Another PR will add -d support. Closes #8703 Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
parent
d7626e97b6
commit
90928eb114
9 changed files with 204 additions and 3 deletions
|
@ -213,3 +213,20 @@ func TestExecEnv(t *testing.T) {
|
|||
|
||||
logDone("exec - exec inherits correct env")
|
||||
}
|
||||
|
||||
func TestExecExitStatus(t *testing.T) {
|
||||
runCmd := exec.Command(dockerBinary, "run", "-d", "--name", "top", "busybox", "top")
|
||||
if out, _, _, err := runCommandWithStdoutStderr(runCmd); err != nil {
|
||||
t.Fatal(out, err)
|
||||
}
|
||||
|
||||
// Test normal (non-detached) case first
|
||||
cmd := exec.Command(dockerBinary, "exec", "top", "sh", "-c", "exit 23")
|
||||
ec, _ := runCommand(cmd)
|
||||
|
||||
if ec != 23 {
|
||||
t.Fatalf("Should have had an ExitCode of 23, not: %d", ec)
|
||||
}
|
||||
|
||||
logDone("exec - exec non-zero ExitStatus")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue