@@ -30,16 +30,33 @@ func TestExecIn(t *testing.T) {
30
30
// Execute a first process in the container
31
31
stdinR , stdinW , err := os .Pipe ()
32
32
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 )
33
41
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 ,
39
48
}
40
49
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
43
60
ok (t , err )
44
61
45
62
buffers := newStdBuffers ()
@@ -55,8 +72,6 @@ func TestExecIn(t *testing.T) {
55
72
err = container .Run (ps )
56
73
ok (t , err )
57
74
waitProcess (ps , t )
58
- _ = stdinW .Close ()
59
- waitProcess (process , t )
60
75
61
76
out := buffers .Stdout .String ()
62
77
if ! strings .Contains (out , "cat" ) || ! strings .Contains (out , "ps" ) {
@@ -242,23 +257,35 @@ func TestExecInTTY(t *testing.T) {
242
257
// Execute a first process in the container
243
258
stdinR , stdinW , err := os .Pipe ()
244
259
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 )
245
268
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 ,
251
275
}
252
276
err = container .Run (process )
253
- _ = stdinR .Close ()
254
277
defer func () {
278
+ _ , _ = stdinW .Write ([]byte ("hello" ))
255
279
_ = stdinW .Close ()
256
280
if _ , err := process .Wait (); err != nil {
257
281
t .Log (err )
258
282
}
259
283
}()
260
284
ok (t , err )
261
285
286
+ err = <- ch
287
+ ok (t , err )
288
+
262
289
ps := & libcontainer.Process {
263
290
Cwd : "/" ,
264
291
Args : []string {"ps" },
0 commit comments