-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(initrd): Consolidate common test variables and methods
This commit homogenizes the tests such that they all use the same reference point. The expected headers list is common to all tests. The source of truth is the `rootfs.Dockerfile` and the directory contents was generated with: ```bash docker build -o ./rootfs -f ./rootfs.Dockerfile . ``` The tarball was generated subsequently like so: ```bash cd rootfs; tar --sort=name -czvf ../rootfs.tar.gz . ``` Signed-off-by: Alexander Jung <alex@unikraft.io>
- Loading branch information
Showing
15 changed files
with
71 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// Copyright (c) 2022, Unikraft GmbH and The KraftKit Authors. | ||
// Licensed under the BSD-3-Clause License (the "License"). | ||
// You may not use this file except in compliance with the License. | ||
|
||
package initrd_test | ||
|
||
import ( | ||
"io" | ||
"os" | ||
"testing" | ||
|
||
"kraftkit.sh/cpio" | ||
) | ||
|
||
var expectHeaders = map[string]cpio.Header{ | ||
"./a": { | ||
Mode: cpio.TypeDir, | ||
}, | ||
"./a/b": { | ||
Mode: cpio.TypeDir, | ||
}, | ||
"./a/b/c": { | ||
Mode: cpio.TypeDir, | ||
}, | ||
"./a/b/c/d": { | ||
Mode: cpio.TypeReg, | ||
Size: 13, | ||
}, | ||
"./a/b/c/e-symlink": { | ||
Mode: cpio.TypeSymlink, | ||
Linkname: "./d", | ||
}, | ||
"./a/b/c/f-hardlink": { | ||
Mode: cpio.TypeReg, | ||
Size: 0, | ||
}, | ||
"./a/b/c/g-recursive-symlink": { | ||
Mode: cpio.TypeSymlink, | ||
Linkname: ".", | ||
}, | ||
} | ||
|
||
// openFile opens a file for reading, and closes it when the test completes. | ||
func openFile(t *testing.T, path string) io.Reader { | ||
t.Helper() | ||
|
||
f, err := os.Open(path) | ||
if err != nil { | ||
t.Fatal("Failed to open file for reading:", err) | ||
} | ||
t.Cleanup(func() { | ||
if err := f.Close(); err != nil { | ||
t.Error("Failed to close file:", err) | ||
} | ||
}) | ||
|
||
return f | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello, World |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
./d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello, World |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.