MCPcopy
hub / github.com/apptainer/apptainer / PersistentOverlay

Method PersistentOverlay

e2e/actions/actions.go:820–1013  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

818}
819
820func (c actionTests) PersistentOverlay(t *testing.T) {
821 e2e.EnsureImage(t, c.env)
822
823 require.Filesystem(t, "overlay")
824
825 require.Command(t, "mkfs.ext3")
826 require.Command(t, "mksquashfs")
827 require.Command(t, "dd")
828
829 // the order should not be changed, it'll cause permission denied error. RootProfile will create
830 // overlay folder with the permission other users can not access.
831 profiles := []e2e.Profile{e2e.UserProfile, e2e.UserNamespaceProfile, e2e.RootProfile}
832
833 // create the test dir
834 testdir, err := os.MkdirTemp(c.env.TestDir, "persitent-overlay-")
835 if err != nil {
836 t.Fatal(err)
837 }
838
839 defer e2e.Privileged(func(t *testing.T) {
840 if t.Failed() {
841 t.Logf("Not removing directory %s for test %s", testdir, t.Name())
842 return
843 }
844 err := os.RemoveAll(testdir)
845 if err != nil {
846 t.Logf("Error while removing directory %s for test %s: %#v", testdir, t.Name(), err)
847 }
848 })(t)
849
850 dir := filepath.Join(testdir, "overlay-dir")
851 ext3Img := filepath.Join(testdir, "ext3_fs.img")
852 squashfsImage := c.squashfsCreate(t, testdir)
853 sandboxImage := c.sandboxCreate(t, testdir)
854 embeddedSif := c.embeddedSifCreate(t, testdir)
855
856 tests := []struct {
857 name string
858 argv []string
859 fakeroot bool
860 exit int
861 dir string
862 }{
863 {
864 name: "overlay_create",
865 argv: []string{"--overlay", dir, c.env.ImagePath, "touch", "/dir_overlay"},
866 fakeroot: true,
867 exit: 0,
868 },
869 {
870 name: "overlay_ext3_create",
871 argv: []string{"--overlay", ext3Img, c.env.ImagePath, "touch", "/ext3_overlay"},
872 fakeroot: true,
873 exit: 0,
874 },
875 {
876 name: "overlay_multiple_create",
877 argv: []string{"--overlay", ext3Img, "--overlay", squashfsImage + ":ro", c.env.ImagePath, "touch", "/multiple_overlay_fs"},

Callers

nothing calls this directly

Calls 15

squashfsCreateMethod · 0.95
sandboxCreateMethod · 0.95
embeddedSifCreateMethod · 0.95
overlayRecreateMethod · 0.95
ext3RecreateMethod · 0.95
EnsureImageFunction · 0.92
FilesystemFunction · 0.92
CommandFunction · 0.92
PrivilegedFunction · 0.92
AsSubtestFunction · 0.92
WithProfileFunction · 0.92
WithDirFunction · 0.92

Tested by

no test coverage detected