MCPcopy Index your code
hub / github.com/moby/moby / TestRunState

Method TestRunState

integration-cli/docker_cli_run_test.go:1553–1587  ·  view source on GitHub ↗
(c *testing.T)

Source from the content-addressed store, hash-verified

1551}
1552
1553func (s *DockerCLIRunSuite) TestRunState(c *testing.T) {
1554 // TODO Windows: This needs some rework as Windows busybox does not support top
1555 testRequires(c, DaemonIsLinux)
1556 id := cli.DockerCmd(c, "run", "-d", "busybox", "top").Stdout()
1557 id = strings.TrimSpace(id)
1558
1559 state := inspectField(c, id, "State.Running")
1560 if state != "true" {
1561 c.Fatal("Container state is 'not running'")
1562 }
1563 pid1 := inspectField(c, id, "State.Pid")
1564 if pid1 == "0" {
1565 c.Fatal("Container state Pid 0")
1566 }
1567
1568 cli.DockerCmd(c, "stop", id)
1569 state = inspectField(c, id, "State.Running")
1570 if state != "false" {
1571 c.Fatal("Container state is 'running'")
1572 }
1573 pid2 := inspectField(c, id, "State.Pid")
1574 if pid2 == pid1 {
1575 c.Fatalf("Container state Pid %s, but expected %s", pid2, pid1)
1576 }
1577
1578 cli.DockerCmd(c, "start", id)
1579 state = inspectField(c, id, "State.Running")
1580 if state != "true" {
1581 c.Fatal("Container state is 'not running'")
1582 }
1583 pid3 := inspectField(c, id, "State.Pid")
1584 if pid3 == pid1 {
1585 c.Fatalf("Container state Pid %s, but expected %s", pid2, pid1)
1586 }
1587}
1588
1589// Test for #1737
1590func (s *DockerCLIRunSuite) TestRunCopyVolumeUIDGID(c *testing.T) {

Callers

nothing calls this directly

Calls 4

DockerCmdFunction · 0.92
testRequiresFunction · 0.85
inspectFieldFunction · 0.85
StdoutMethod · 0.45

Tested by

no test coverage detected