diff --git a/initrd/directory_test.go b/initrd/directory_test.go index 9fcc69928..29af9f639 100644 --- a/initrd/directory_test.go +++ b/initrd/directory_test.go @@ -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) } @@ -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)) diff --git a/initrd/testdata/rootfs/a/b/c/d b/initrd/testdata/rootfs/a/b/c/d deleted file mode 100644 index 3fa0d4b98..000000000 --- a/initrd/testdata/rootfs/a/b/c/d +++ /dev/null @@ -1 +0,0 @@ -Hello, World diff --git a/initrd/testdata/rootfs/a/b/c/e-symlink b/initrd/testdata/rootfs/a/b/c/e-symlink deleted file mode 120000 index cd1426d19..000000000 --- a/initrd/testdata/rootfs/a/b/c/e-symlink +++ /dev/null @@ -1 +0,0 @@ -./d \ No newline at end of file diff --git a/initrd/testdata/rootfs/a/b/c/f-hardlink b/initrd/testdata/rootfs/a/b/c/f-hardlink deleted file mode 100644 index 3fa0d4b98..000000000 --- a/initrd/testdata/rootfs/a/b/c/f-hardlink +++ /dev/null @@ -1 +0,0 @@ -Hello, World diff --git a/initrd/testdata/rootfs/a/b/c/g-recursive-symlink b/initrd/testdata/rootfs/a/b/c/g-recursive-symlink deleted file mode 120000 index 945c9b46d..000000000 --- a/initrd/testdata/rootfs/a/b/c/g-recursive-symlink +++ /dev/null @@ -1 +0,0 @@ -. \ No newline at end of file