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

Function TestAdditionalGroups

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

Source from the content-addressed store, hash-verified

383}
384
385func TestAdditionalGroups(t *testing.T) {
386 if testing.Short() {
387 return
388 }
389
390 config := newTemplateConfig(t, nil)
391 container, err := newContainer(t, config)
392 ok(t, err)
393 defer destroyContainer(container)
394
395 var stdout strings.Builder
396 pconfig := libcontainer.Process{
397 Cwd: "/",
398 Args: []string{"sh", "-c", "id", "-Gn"},
399 Env: standardEnvironment,
400 Stdin: nil,
401 Stdout: &stdout,
402 Stderr: new(strings.Builder),
403 AdditionalGroups: []int{3333, 99999},
404 Init: true,
405 }
406 err = container.Run(&pconfig)
407 ok(t, err)
408
409 // Wait for process
410 waitProcess(&pconfig, t)
411
412 outputGroups := stdout.String()
413
414 // Check that the groups output has the groups that we specified.
415 for _, gid := range pconfig.AdditionalGroups {
416 if !strings.Contains(outputGroups, strconv.Itoa(gid)) {
417 t.Errorf("Listed groups do not contain gid %d as expected: %v", gid, outputGroups)
418 }
419 }
420}
421
422func TestFreeze(t *testing.T) {
423 for _, systemd := range []bool{true, false} {

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…