mirror of
https://github.com/opencontainers/runc.git
synced 2025-10-14 11:43:56 +08:00
libc/int: add/use runContainerOk wrapper
This is to de-duplicate the code that checks that err is nil and that the exit code is zero. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -212,6 +212,22 @@ func runContainer(t *testing.T, config *configs.Config, args ...string) (buffers
|
||||
return
|
||||
}
|
||||
|
||||
// runContainerOk is a wrapper for runContainer, simplifying its use for cases
|
||||
// when the run is expected to succeed and return exit code of 0.
|
||||
func runContainerOk(t *testing.T, config *configs.Config, args ...string) *stdBuffers {
|
||||
buffers, exitCode, err := runContainer(t, config, args...)
|
||||
|
||||
t.Helper()
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %s", buffers, err)
|
||||
}
|
||||
if exitCode != 0 {
|
||||
t.Fatalf("exit code not 0. code %d stderr %q", exitCode, buffers.Stderr)
|
||||
}
|
||||
|
||||
return buffers
|
||||
}
|
||||
|
||||
func destroyContainer(container *libcontainer.Container) {
|
||||
_ = container.Destroy()
|
||||
}
|
||||
|
Reference in New Issue
Block a user