Skip to content

Commit

Permalink
fix(initrd): Remove the rootfs directly from the testdata directory
Browse files Browse the repository at this point in the history
The contents are already stored within the tarball so this can just
be simply extracted.  Without this, build environments such as those
provided by GitHub run into "Too many levels of symbolic links"
errors.

Signed-off-by: Alexander Jung <alex@unikraft.io>
  • Loading branch information
nderjung committed Jan 13, 2025
1 parent 396dfdf commit 75d18dd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
10 changes: 8 additions & 2 deletions initrd/directory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ import (
"os"
"testing"

"kraftkit.sh/archive"
"kraftkit.sh/cpio"
"kraftkit.sh/initrd"
)

func TestNewFromDirectory(t *testing.T) {
const rootDir = "testdata/rootfs"
if err := archive.Unarchive("testdata/rootfs.tar.gz", "testdata/rootfs"); err != nil {
t.Fatal("Unarchive:", err)
}

ctx := context.Background()

ird, err := initrd.NewFromDirectory(ctx, rootDir)
ird, err := initrd.NewFromDirectory(ctx, "testdata/rootfs")
if err != nil {
t.Fatal("NewFromDirectory:", err)
}
Expand All @@ -32,6 +35,9 @@ func TestNewFromDirectory(t *testing.T) {
if err := os.Remove(irdPath); err != nil {
t.Fatal("Failed to remove initrd file:", err)
}
if err := os.RemoveAll("testdata/rootfs"); err != nil {
t.Fatal("Failed to remove rootfs directory:", err)
}
})

r := cpio.NewReader(openFile(t, irdPath))
Expand Down
1 change: 0 additions & 1 deletion initrd/testdata/rootfs/a/b/c/d

This file was deleted.

1 change: 0 additions & 1 deletion initrd/testdata/rootfs/a/b/c/e-symlink

This file was deleted.

1 change: 0 additions & 1 deletion initrd/testdata/rootfs/a/b/c/f-hardlink

This file was deleted.

1 change: 0 additions & 1 deletion initrd/testdata/rootfs/a/b/c/g-recursive-symlink

This file was deleted.

0 comments on commit 75d18dd

Please sign in to comment.