-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(initrd): assert contents of CPIO archive #953
Conversation
cacd442
to
32cedbd
Compare
) | ||
|
||
func TestNewFromDirectory(t *testing.T) { | ||
const rootDir = "testdata/rootfs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const rootDir = "testdata/rootfs" | |
const rootDir = filepath.Join("testdata", "rootfs") |
r := cpio.NewReader(openFile(t, irdPath)) | ||
|
||
expectHeaders := map[string]cpio.Header{ | ||
"/entrypoint.sh": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how the reader handles paths on Windows, I guess we can leave like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a chance to go test ./initrd
since you have Go already set up on Windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[...]
go: downloading golang.org/x/text v0.12.0
--- FAIL: TestNewFromDirectory (0.02s)
directory_test.go:83: Encountered unexpected file in cpio archive: testdata/rootfs
directory_test.go:83: Encountered unexpected file in cpio archive: \entrypoint.sh
directory_test.go:83: Encountered unexpected file in cpio archive: \etc
directory_test.go:83: Encountered unexpected file in cpio archive: \etc\app.conf
directory_test.go:83: Encountered unexpected file in cpio archive: \lib
directory_test.go:83: Encountered unexpected file in cpio archive: \lib\libtest.so.1
directory_test.go:83: Encountered unexpected file in cpio archive: \lib\libtest.so.1.0.0
directory_test.go:34: Failed to remove initrd file D:\Temporary\2117131240: remove D:\Temporary\2117131240: The process cannot access the file because it is being used by another process.
FAIL
FAIL kraftkit.sh/initrd 0.425s
FAIL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line Failed to remove initrd file D:\Temporary\2117131240: remove D:\Temporary\2117131240: The process cannot access the file because it is being used by another process.
means that os.Remove()
was called before all references to the file were closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS C:\Users\Cezar\kraftkit> gh pr checkout 953 --force
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 4 (delta 2), reused 4 (delta 2), pack-reused 0
Unpacking objects: 100% (4/4), 1.63 KiB | 104.00 KiB/s, done.
From https://github.com/unikraft/kraftkit
* branch refs/pull/953/head -> FETCH_HEAD
HEAD is now at 0edcb4d test(initrd): assert contents of CPIO archive
PS C:\Users\Cezar\kraftkit> go test ./initrd
--- FAIL: TestNewFromDirectory (0.01s)
directory_test.go:83: Encountered unexpected file in cpio archive: testdata/rootfs
directory_test.go:83: Encountered unexpected file in cpio archive: \entrypoint.sh
directory_test.go:83: Encountered unexpected file in cpio archive: \etc
directory_test.go:83: Encountered unexpected file in cpio archive: \etc\app.conf
directory_test.go:83: Encountered unexpected file in cpio archive: \lib
directory_test.go:83: Encountered unexpected file in cpio archive: \lib\libtest.so.1
directory_test.go:83: Encountered unexpected file in cpio archive: \lib\libtest.so.1.0.0
directory_test.go:34: Failed to remove initrd file: remove D:\Temporary\1822746801: The process cannot access the file because it is being used by another process.
FAIL
FAIL kraftkit.sh/initrd 0.407s
FAIL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure these are defers though, it uses t.Cleanup
which maybe has different functionality?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleanup works the same as defer, except they are scheduled for execution at the end of the test, as opposed to the end of a function.
It would fail in the CI (on Linux) if the code was problematic, because on Linux you also need to call f.Close()
otherwise you get the same error. Yet, it fails only on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those errors are not checked in Kraftkit:
Lines 68 to 71 in 0d09e39
defer f.Close() | |
writer := cpio.NewWriter(f) | |
defer writer.Close() |
For all that I know, the problem could be there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely possible 🤷
Signed-off-by: Antoine Cotten <antoine@unikraft.io>
32cedbd
to
0edcb4d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will merge as is and we (or @nderjung) come back and fix the 2 problems later
Reviewed-by: Cezar Craciunoiu cezar.craciunoiu@unikraft.io
Approved-by: Cezar Craciunoiu cezar.craciunoiu@unikraft.io
Prerequisite checklist
make fmt
on your commit series before opening this PR;Description of changes
Asserts that CPIO archives are created correctly.