@@ -126,3 +126,36 @@ func (suite *PouchStopSuite) TestStopMultiContainers(c *check.C) {
126126 c .Assert (string (result [0 ].State .Status ), check .Equals , "stopped" )
127127
128128}
129+
130+ // TestStopPidValue ensure stopped container's pid is 0
131+ func (suite * PouchStopSuite ) TestStopPidValue (c * check.C ) {
132+ name := "test-stop-pid-value"
133+
134+ command .PouchRun ("run" , "-d" , "--name" , name , busyboxImage , "top" ).Assert (c , icmd .Success )
135+ defer DelContainerForceMultyTime (c , name )
136+
137+ // test stop a created container
138+ command .PouchRun ("stop" , name ).Assert (c , icmd .Success )
139+
140+ output := command .PouchRun ("inspect" , name ).Stdout ()
141+ result := []types.ContainerJSON {}
142+ if err := json .Unmarshal ([]byte (output ), & result ); err != nil {
143+ c .Errorf ("failed to decode inspect output: %v" , err )
144+ }
145+ c .Assert (result [0 ].State .Pid , check .Equals , int64 (0 ))
146+ }
147+
148+ // TestAutoStopPidValue ensure stopped container's pid is 0
149+ func (suite * PouchStopSuite ) TestAutoStopPidValue (c * check.C ) {
150+ name := "test-auto-stop-pid-value"
151+
152+ command .PouchRun ("run" , "--name" , name , busyboxImage , "echo" , "hi" ).Assert (c , icmd .Success )
153+ defer DelContainerForceMultyTime (c , name )
154+
155+ output := command .PouchRun ("inspect" , name ).Stdout ()
156+ result := []types.ContainerJSON {}
157+ if err := json .Unmarshal ([]byte (output ), & result ); err != nil {
158+ c .Errorf ("failed to decode inspect output: %v" , err )
159+ }
160+ c .Assert (result [0 ].State .Pid , check .Equals , int64 (0 ))
161+ }
0 commit comments