MCPcopy Create free account
hub / github.com/containerd/nerdctl / TestRunWithInit

Function TestRunWithInit

cmd/nerdctl/container/container_run_linux_test.go:282–313  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

280}
281
282func TestRunWithInit(t *testing.T) {
283 t.Parallel()
284 testutil.DockerIncompatible(t)
285 testutil.RequireExecutable(t, "tini-custom")
286 base := testutil.NewBase(t)
287
288 container := testutil.Identifier(t)
289 base.Cmd("run", "-d", "--name", container, testutil.AlpineImage, "sleep", nerdtest.Infinity).AssertOK()
290 defer base.Cmd("rm", "-f", container).Run()
291
292 base.Cmd("stop", "--time=3", container).AssertOK()
293 // Unable to handle TERM signal, be killed when timeout
294 assert.Equal(t, base.InspectContainer(container).State.ExitCode, 137)
295
296 // Test with --init-path
297 container1 := container + "-1"
298 base.Cmd("run", "-d", "--name", container1, "--init-binary", "tini-custom",
299 testutil.AlpineImage, "sleep", nerdtest.Infinity).AssertOK()
300 defer base.Cmd("rm", "-f", container1).Run()
301
302 base.Cmd("stop", "--time=3", container1).AssertOK()
303 assert.Equal(t, base.InspectContainer(container1).State.ExitCode, 143)
304
305 // Test with --init
306 container2 := container + "-2"
307 base.Cmd("run", "-d", "--name", container2, "--init",
308 testutil.AlpineImage, "sleep", nerdtest.Infinity).AssertOK()
309 defer base.Cmd("rm", "-f", container2).Run()
310
311 base.Cmd("stop", "--time=3", container2).AssertOK()
312 assert.Equal(t, base.InspectContainer(container2).State.ExitCode, 143)
313}
314
315func TestRunTTY(t *testing.T) {
316 const sttyPartialOutput = "speed 38400 baud"

Callers

nothing calls this directly

Calls 8

CmdMethod · 0.95
InspectContainerMethod · 0.95
DockerIncompatibleFunction · 0.92
RequireExecutableFunction · 0.92
NewBaseFunction · 0.92
IdentifierFunction · 0.92
AssertOKMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…