-
Notifications
You must be signed in to change notification settings - Fork 82
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
Introduce an E2E testing framework #258
Open
mtjhrc
wants to merge
6
commits into
containers:main
Choose a base branch
from
mtjhrc:tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
d97941d
to
0a08462
Compare
5d4e48e
to
e20a964
Compare
These bindings are useful for the testing framework. It could also be nice to publish them on crates.io in the future. Imported from https://github.com/AsahiLinux/muvm/ Signed-off-by: Matej Hrica <[email protected]>
Make sure we can build the krun-sys crate in the CI, by installing the dependencies. The krun-sys bindings are currently not built on the macOS CI (missing llvm/clang dependency). Signed-off-by: Matej Hrica <[email protected]>
Add a tests directory containing an E2E testing framework. The tests are E2E in the sense that they use the public API of libkrun to start a VM and run a test program in the guest. Note that currently this is very limited, because there are no other userspace executables or libraries (not even libc) in the guest apart from `guest-agent`. `guest-agent` is a statically linked Rust executable, that executes the guest part of each test. In the future this can be extended to run tests with specific images which would allow the use of system libraries by the test program. This also introduces 2 tests: test_vm_config - asserts the VM is constructed with the correct number of CPUs and amount of memory. This also serves as an example how the tests can be parameterized. test_vsock_guest_connect - This tests the guest connecting to a vsock port created by the `krun_add_vsock_port` API. Signed-off-by: Matej Hrica <[email protected]>
The build targets only depend on the init binary target, so running `make` after changing some other part of the source code doesn't trigger a rebuild. Make the LIBRARY_RELEASE_* and LIBRARY_DEBUG_* targets .PHONY to make sure the library is always rebuilt when running `make`. Signed-off-by: Matej Hrica <[email protected]>
The install target needs to depend on the generation of the libkrun.pc file, this is because the libkrun.pc file might already exists and be generated, but it could be made using a different PREFIX, which would lead to the installed libkrun.pc pointing to the wrong prefix. Signed-off-by: Matej Hrica <[email protected]>
Intruduce a test target in Makefile, that runs the e2e tests agains the built binary. Signed-off-by: Matej Hrica <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a testing framework for writing (mostly) end-to-end tests using libkrun.
The tests are E2E in the sense that they use the public API of libkrun to start a VM and run a test program in the guest. Note that currently this is very limited, because there are no other userspace executables or libraries (not even libc) in the guest apart from
guest-agent
.guest-agent
is a statically linked Rust executable, that executes the guest part of each test.In the future this can be extended to run tests with specific images which would allow the use of system libraries by the test program.
This also introduces 2 tests:
test-vm-config
- asserts the VM is constructed with the correct number of CPUs and amount of memory. This also serves as an example how tests can be parameterized.vsock-guest-connect
- This tests the guest connecting to a vsock port created by thekrun_add_vsock_port
API.You can run these tests using
make test
.Note: Currently these tests won't be ran on CI, because we need a CI that supports nested virtualization.