@@ -30,16 +30,33 @@ func TestExecIn(t *testing.T) {
3030 // Execute a first process in the container
3131 stdinR , stdinW , err := os .Pipe ()
3232 ok (t , err )
33+ stdoutR , stdoutW , err := os .Pipe ()
34+ ok (t , err )
35+ defer stdinR .Close () //nolint: errcheck
36+ defer stdinW .Close () //nolint: errcheck
37+ defer stdoutR .Close () //nolint: errcheck
38+ defer stdoutW .Close () //nolint: errcheck
39+
40+ ch := waitStdOut (stdoutR )
3341 process := & libcontainer.Process {
34- Cwd : "/" ,
35- Args : []string {"cat" },
36- Env : standardEnvironment ,
37- Stdin : stdinR ,
38- Init : true ,
42+ Cwd : "/" ,
43+ Args : []string {"cat" , "/proc/self/cmdline" , "-" },
44+ Env : standardEnvironment ,
45+ Stdin : stdinR ,
46+ Stdout : stdoutW ,
47+ Init : true ,
3948 }
4049 err = container .Run (process )
41- _ = stdinR .Close ()
42- defer stdinW .Close () //nolint: errcheck
50+ defer func () {
51+ stdinW .Write ([]byte ("hello" ))
52+ _ = stdinW .Close ()
53+ if _ , err := process .Wait (); err != nil {
54+ t .Log (err )
55+ }
56+ }()
57+ ok (t , err )
58+
59+ err = <- ch
4360 ok (t , err )
4461
4562 buffers := newStdBuffers ()
@@ -55,8 +72,6 @@ func TestExecIn(t *testing.T) {
5572 err = container .Run (ps )
5673 ok (t , err )
5774 waitProcess (ps , t )
58- _ = stdinW .Close ()
59- waitProcess (process , t )
6075
6176 out := buffers .Stdout .String ()
6277 if ! strings .Contains (out , "cat" ) || ! strings .Contains (out , "ps" ) {
@@ -242,23 +257,35 @@ func TestExecInTTY(t *testing.T) {
242257 // Execute a first process in the container
243258 stdinR , stdinW , err := os .Pipe ()
244259 ok (t , err )
260+ stdoutR , stdoutW , err := os .Pipe ()
261+ ok (t , err )
262+ defer stdinR .Close () //nolint: errcheck
263+ defer stdinW .Close () //nolint: errcheck
264+ defer stdoutR .Close () //nolint: errcheck
265+ defer stdoutW .Close () //nolint: errcheck
266+
267+ ch := waitStdOut (stdoutR )
245268 process := & libcontainer.Process {
246- Cwd : "/" ,
247- Args : []string {"cat" },
248- Env : standardEnvironment ,
249- Stdin : stdinR ,
250- Init : true ,
269+ Cwd : "/" ,
270+ Args : []string {"cat" , "/proc/self/cmdline" , "-" },
271+ Env : standardEnvironment ,
272+ Stdin : stdinR ,
273+ Stdout : stdoutW ,
274+ Init : true ,
251275 }
252276 err = container .Run (process )
253- _ = stdinR .Close ()
254277 defer func () {
278+ stdinW .Write ([]byte ("hello" ))
255279 _ = stdinW .Close ()
256280 if _ , err := process .Wait (); err != nil {
257281 t .Log (err )
258282 }
259283 }()
260284 ok (t , err )
261285
286+ err = <- ch
287+ ok (t , err )
288+
262289 ps := & libcontainer.Process {
263290 Cwd : "/" ,
264291 Args : []string {"ps" },
0 commit comments