@@ -30,16 +30,37 @@ 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
+ defer func () {
34
+ _ = stdinR .Close ()
35
+ _ = stdinW .Close ()
36
+ }()
37
+ stdoutR , stdoutW , err := os .Pipe ()
38
+ ok (t , err )
39
+ defer func () {
40
+ _ = stdoutR .Close ()
41
+ _ = stdoutW .Close ()
42
+ }()
43
+
44
+ ch := waitStdOut (stdoutR )
33
45
process := & libcontainer.Process {
34
- Cwd : "/" ,
35
- Args : []string {"cat" },
36
- Env : standardEnvironment ,
37
- Stdin : stdinR ,
38
- Init : true ,
46
+ Cwd : "/" ,
47
+ Args : []string {"cat" , "/proc/self/cmdline" , "-" },
48
+ Env : standardEnvironment ,
49
+ Stdin : stdinR ,
50
+ Stdout : stdoutW ,
51
+ Init : true ,
39
52
}
40
53
err = container .Run (process )
41
- _ = stdinR .Close ()
42
- defer stdinW .Close () //nolint: errcheck
54
+ defer func () {
55
+ _ , _ = stdinW .Write ([]byte ("hello" ))
56
+ _ = stdinW .Close ()
57
+ if _ , err := process .Wait (); err != nil {
58
+ t .Log (err )
59
+ }
60
+ }()
61
+ ok (t , err )
62
+
63
+ err = <- ch
43
64
ok (t , err )
44
65
45
66
buffers := newStdBuffers ()
@@ -55,8 +76,6 @@ func TestExecIn(t *testing.T) {
55
76
err = container .Run (ps )
56
77
ok (t , err )
57
78
waitProcess (ps , t )
58
- _ = stdinW .Close ()
59
- waitProcess (process , t )
60
79
61
80
out := buffers .Stdout .String ()
62
81
if ! strings .Contains (out , "cat" ) || ! strings .Contains (out , "ps" ) {
@@ -242,23 +261,39 @@ func TestExecInTTY(t *testing.T) {
242
261
// Execute a first process in the container
243
262
stdinR , stdinW , err := os .Pipe ()
244
263
ok (t , err )
264
+ defer func () {
265
+ _ = stdinR .Close ()
266
+ _ = stdinW .Close ()
267
+ }()
268
+ stdoutR , stdoutW , err := os .Pipe ()
269
+ ok (t , err )
270
+ defer func () {
271
+ _ = stdoutR .Close ()
272
+ _ = stdoutW .Close ()
273
+ }()
274
+
275
+ ch := waitStdOut (stdoutR )
245
276
process := & libcontainer.Process {
246
- Cwd : "/" ,
247
- Args : []string {"cat" },
248
- Env : standardEnvironment ,
249
- Stdin : stdinR ,
250
- Init : true ,
277
+ Cwd : "/" ,
278
+ Args : []string {"cat" , "/proc/self/cmdline" , "-" },
279
+ Env : standardEnvironment ,
280
+ Stdin : stdinR ,
281
+ Stdout : stdoutW ,
282
+ Init : true ,
251
283
}
252
284
err = container .Run (process )
253
- _ = stdinR .Close ()
254
285
defer func () {
286
+ _ , _ = stdinW .Write ([]byte ("hello" ))
255
287
_ = stdinW .Close ()
256
288
if _ , err := process .Wait (); err != nil {
257
289
t .Log (err )
258
290
}
259
291
}()
260
292
ok (t , err )
261
293
294
+ err = <- ch
295
+ ok (t , err )
296
+
262
297
ps := & libcontainer.Process {
263
298
Cwd : "/" ,
264
299
Args : []string {"ps" },
0 commit comments