MCPcopy
hub / github.com/opencontainers/runc / TestExecInTTY

Function TestExecInTTY

libcontainer/integration/execin_test.go:227–317  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

225}
226
227func TestExecInTTY(t *testing.T) {
228 if testing.Short() {
229 return
230 }
231 t.Skip("racy; see https://github.com/opencontainers/runc/issues/2425")
232 config := newTemplateConfig(t, nil)
233 container, err := newContainer(t, config)
234 ok(t, err)
235 defer destroyContainer(container)
236
237 // Execute a first process in the container
238 stdinR, stdinW, err := os.Pipe()
239 ok(t, err)
240 process := &libcontainer.Process{
241 Cwd: "/",
242 Args: []string{"cat"},
243 Env: standardEnvironment,
244 Stdin: stdinR,
245 Init: true,
246 }
247 err = container.Run(process)
248 _ = stdinR.Close()
249 defer func() {
250 _ = stdinW.Close()
251 if _, err := process.Wait(); err != nil {
252 t.Log(err)
253 }
254 }()
255 ok(t, err)
256
257 ps := &libcontainer.Process{
258 Cwd: "/",
259 Args: []string{"ps"},
260 Env: standardEnvironment,
261 }
262
263 // Repeat to increase chances to catch a race; see
264 // https://github.com/opencontainers/runc/issues/2425.
265 for range 300 {
266 var stdout strings.Builder
267
268 parent, child, err := utils.NewSockPair("console")
269 ok(t, err)
270 ps.ConsoleSocket = child
271
272 done := make(chan (error))
273 go func() {
274 f, err := cmsg.RecvFile(parent)
275 if err != nil {
276 done <- fmt.Errorf("RecvFile: %w", err)
277 return
278 }
279 c, err := console.ConsoleFromFile(f)
280 if err != nil {
281 done <- fmt.Errorf("ConsoleFromFile: %w", err)
282 return
283 }
284 err = console.ClearONLCR(c.Fd())

Callers

nothing calls this directly

Calls 12

WaitMethod · 0.95
NewSockPairFunction · 0.92
RecvFileFunction · 0.92
newTemplateConfigFunction · 0.85
newContainerFunction · 0.85
okFunction · 0.85
destroyContainerFunction · 0.85
waitProcessFunction · 0.85
ContainsMethod · 0.80
RunMethod · 0.65
CloseMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…