test(hypervisors): add unit tests for HVT#618
Conversation
Signed-off-by: r0hansaxena <rohansxn8772@gmail.com>
✅ Deploy Preview for urunc canceled.
|
cmainas
left a comment
There was a problem hiding this comment.
Hello @r0hansaxena ,
thank you for the PR. I have added some comments.
| } | ||
| } | ||
|
|
||
| func TestHVTUsesKVM(t *testing.T) { |
There was a problem hiding this comment.
No reason to test such small and straightforward function as a unit test.
| assert.False(t, h.SupportsSharedfs("")) | ||
| } | ||
|
|
||
| func TestHVTPath(t *testing.T) { |
There was a problem hiding this comment.
No reason to test such small and straightforward function as a unit test.
| assert.Equal(t, "/usr/bin/solo5-hvt", newTestHVT().Path()) | ||
| } | ||
|
|
||
| func TestHVTOkBinaryNotFound(t *testing.T) { |
There was a problem hiding this comment.
No reason to test such small and straightforward function as a unit test.
| assert.ErrorIs(t, newTestHVT().Ok(), ErrVMMNotInstalled) | ||
| } | ||
|
|
||
| func TestHVTPreExecNoSeccomp(t *testing.T) { |
There was a problem hiding this comment.
I do not really see the value of this test.
| wantAbsent []string | ||
| }{ | ||
| { | ||
| name: "binary path is first element", |
There was a problem hiding this comment.
This test does not check if the element is the binary path, it simply check if the binary path exists as an element.
| }, | ||
| wantContain: []string{"--dumpcore"}, | ||
| }, | ||
| { |
There was a problem hiding this comment.
This test does not check if the kernel path and the command are last. It simply checks if they exist.
Description
Adds unit tests for the HVT VMM backend, covering BuildExecCmd and the interface methods (UsesKVM, SupportsSharedfs, Path, Ok, PreExec). Tests verify memory configuration, networking, block devices, extra monitor args and the binary not found error case.
Related issues
How was this tested?
Ran unit tests locally:
All 13 test cases passed. Full package tests also pass:
Linter passes locally (make lint, 0 issues).
LLM usage
Claude Sonnet 4.6 was used to assist with writing the tests. All code was reviewed and tested locally before submission.
Checklist
make lint).make test_ctr,make test_nerdctl,make test_docker,make test_crictl).