test(hypervisors): add unit tests for SPT#622
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 ,
I have added some comments to your changes.
There was a problem hiding this comment.
Please do not use new files for helper functions that are for testing.
| } | ||
| } | ||
|
|
||
| func TestSPTUsesKVM(t *testing.T) { |
There was a problem hiding this comment.
No reason to test such small and straightforward function with a unit test.
| assert.False(t, s.SupportsSharedfs("")) | ||
| } | ||
|
|
||
| func TestSPTPath(t *testing.T) { |
There was a problem hiding this comment.
No reason to test such small and straightforward function with a unit test.
| assert.Equal(t, "/usr/bin/solo5-spt", newTestSPT().Path()) | ||
| } | ||
|
|
||
| func TestSPTOkBinaryNotFound(t *testing.T) { |
There was a problem hiding this comment.
No reason to test such small and straightforward function with a unit test.
| assert.ErrorIs(t, newTestSPT().Ok(), ErrVMMNotInstalled) | ||
| } | ||
|
|
||
| func TestSPTPreExec(t *testing.T) { |
There was a problem hiding this comment.
No reason to test such small and straightforward function with a unit test.
| wantAbsent []string | ||
| }{ | ||
| { | ||
| name: "binary path is first element", |
There was a problem hiding this comment.
This test does not check if the binary is indeed the first argument. It simply checks if it exists.
| name: "memory set from MemSizeB", | ||
| args: types.ExecArgs{ | ||
| UnikernelPath: "/unikernel.bin", | ||
| MemSizeB: 256 * 1000 * 1000, |
There was a problem hiding this comment.
Please use a different value than the default one.
| wantContain: []string{"--dumpcore"}, | ||
| }, | ||
| { | ||
| name: "unikernel path and command are last", |
There was a problem hiding this comment.
This test does not check if the command or the unikernel path are last. It simply checks if they exist
Description
Adds unit tests for the SPT 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?
All 13 unit tests pass locally. Full package tests pass. Linter passes (make lint, 0 issues).
LLM usage
LLM 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).