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

Function TestProcessEnv

libcontainer/integration/exec_test.go:234–276  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

232}
233
234func TestProcessEnv(t *testing.T) {
235 if testing.Short() {
236 return
237 }
238
239 config := newTemplateConfig(t, nil)
240 container, err := newContainer(t, config)
241 ok(t, err)
242 defer destroyContainer(container)
243
244 var stdout strings.Builder
245 pconfig := libcontainer.Process{
246 Cwd: "/",
247 Args: []string{"sh", "-c", "env"},
248 Env: []string{
249 "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
250 "HOSTNAME=integration",
251 "TERM=xterm",
252 "FOO=BAR",
253 },
254 Stdin: nil,
255 Stdout: &stdout,
256 Stderr: new(strings.Builder),
257 Init: true,
258 }
259 err = container.Run(&pconfig)
260 ok(t, err)
261
262 // Wait for process
263 waitProcess(&pconfig, t)
264
265 outputEnv := stdout.String()
266
267 // Check that the environment has the key/value pair we added
268 if !strings.Contains(outputEnv, "FOO=BAR") {
269 t.Fatal("Environment doesn't have the expected FOO=BAR key/value pair: ", outputEnv)
270 }
271
272 // Make sure that HOME is set
273 if !strings.Contains(outputEnv, "HOME=/root") {
274 t.Fatal("Environment doesn't have HOME set: ", outputEnv)
275 }
276}
277
278func TestProcessEmptyCaps(t *testing.T) {
279 if testing.Short() {

Callers

nothing calls this directly

Calls 8

newTemplateConfigFunction · 0.85
newContainerFunction · 0.85
okFunction · 0.85
destroyContainerFunction · 0.85
waitProcessFunction · 0.85
ContainsMethod · 0.80
RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…