MCPcopy
hub / github.com/opencontainers/runc / runContainer

Function runContainer

libcontainer/integration/utils_test.go:176–209  ·  view source on GitHub ↗

runContainer runs the container with the specific config and arguments buffers are returned containing the STDOUT and STDERR output for the run along with the exit code and any go error

(t testing.TB, config *configs.Config, args ...string)

Source from the content-addressed store, hash-verified

174// buffers are returned containing the STDOUT and STDERR output for the run
175// along with the exit code and any go error
176func runContainer(t testing.TB, config *configs.Config, args ...string) (buffers *stdBuffers, exitCode int, err error) {
177 container, err := newContainer(t, config)
178 if err != nil {
179 return nil, -1, err
180 }
181 defer destroyContainer(container)
182 buffers = newStdBuffers()
183 process := &libcontainer.Process{
184 Cwd: "/",
185 Args: args,
186 Env: standardEnvironment,
187 Stdout: buffers.Stdout,
188 Stderr: buffers.Stderr,
189 Init: true,
190 }
191
192 err = container.Run(process)
193 if err != nil {
194 return buffers, -1, err
195 }
196 ps, err := process.Wait()
197 if err != nil {
198 return buffers, -1, err
199 }
200 status := ps.Sys().(syscall.WaitStatus)
201 if status.Exited() {
202 exitCode = status.ExitStatus()
203 } else if status.Signaled() {
204 exitCode = -int(status.Signal())
205 } else {
206 return buffers, -1, err
207 }
208 return buffers, exitCode, err
209}
210
211// runContainerOk is a wrapper for runContainer, simplifying its use for cases
212// when the run is expected to succeed and return exit code of 0.

Callers 8

runContainerOkFunction · 0.85
TestIPCBadPathFunction · 0.85
testCpuSharesFunction · 0.85
testPidsFunction · 0.85

Calls 6

WaitMethod · 0.95
newContainerFunction · 0.85
destroyContainerFunction · 0.85
newStdBuffersFunction · 0.85
RunMethod · 0.65
SignalMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…