MCPcopy
hub / github.com/google/gvisor / TestCreateMountNamespace

Function TestCreateMountNamespace

runsc/boot/loader_test.go:469–511  ·  view source on GitHub ↗

Test that MountNamespace can be created with various specs.

(t *testing.T)

Source from the content-addressed store, hash-verified

467
468// Test that MountNamespace can be created with various specs.
469func TestCreateMountNamespace(t *testing.T) {
470 for _, tc := range createMountTestcases() {
471 t.Run(tc.name, func(t *testing.T) {
472 spec := testSpec()
473 spec.Mounts = tc.spec.Mounts
474 spec.Root = tc.spec.Root
475
476 t.Logf("Using root: %q", spec.Root.Path)
477 l, loaderCleanup, err := createLoader(testConfig(), spec)
478 if err != nil {
479 t.Fatalf("failed to create loader: %v", err)
480 }
481 defer l.Destroy()
482 defer loaderCleanup()
483
484 l.mu.Lock()
485 defer l.mu.Unlock()
486 mntr := l.newContainerMounter(&l.root)
487 ctx := l.k.SupervisorContext()
488 creds := auth.NewRootCredentials(l.root.procArgs.Credentials.UserNamespace)
489 mns, err := mntr.mountAll(ctx, creds, l.root.spec, l.root.conf, &l.root.procArgs)
490 if err != nil {
491 t.Fatalf("mountAll: %v", err)
492 }
493
494 root := mns.Root(ctx)
495 defer root.DecRef(ctx)
496 for _, p := range tc.expectedPaths {
497 target := &vfs.PathOperation{
498 Root: root,
499 Start: root,
500 Path: fspath.Parse(p),
501 }
502
503 if d, err := l.k.VFS().GetDentryAt(ctx, l.root.procArgs.Credentials, target, &vfs.GetDentryOptions{}); err != nil {
504 t.Errorf("expected path %v to exist with spec %v, but got error %v", p, tc.spec, err)
505 } else {
506 d.DecRef(ctx)
507 }
508 }
509 })
510 }
511}
512
513type createMountPointTestCase struct {
514 name string

Callers

nothing calls this directly

Calls 15

NewRootCredentialsFunction · 0.92
ParseFunction · 0.92
createMountTestcasesFunction · 0.85
testSpecFunction · 0.85
createLoaderFunction · 0.85
testConfigFunction · 0.85
newContainerMounterMethod · 0.80
SupervisorContextMethod · 0.80
mountAllMethod · 0.80
VFSMethod · 0.80
RunMethod · 0.65
LogfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…