Skip to content

test(hypervisors): add unit tests for HVT#618

Open
r0hansaxena wants to merge 1 commit into
urunc-dev:mainfrom
r0hansaxena:test/hvt
Open

test(hypervisors): add unit tests for HVT#618
r0hansaxena wants to merge 1 commit into
urunc-dev:mainfrom
r0hansaxena:test/hvt

Conversation

@r0hansaxena
Copy link
Copy Markdown

@r0hansaxena r0hansaxena commented May 4, 2026

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:

go test ./pkg/unikontainers/hypervisors/ -v -run "TestHVT"

All 13 test cases passed. Full package tests also pass:

go test ./pkg/... ./internal/...

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

  • I have read the contribution guide.
  • The linter passes locally (make lint).
  • The e2e tests of at least one tool pass locally (make test_ctr, make test_nerdctl, make test_docker, make test_crictl).
  • If LLMs were used: I have read the llm policy.

Signed-off-by: r0hansaxena <rohansxn8772@gmail.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 4, 2026

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit 658e507
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/69f8850bafa0ab00082f284a

Copy link
Copy Markdown
Contributor

@cmainas cmainas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @r0hansaxena ,

thank you for the PR. I have added some comments.

}
}

func TestHVTUsesKVM(t *testing.T) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason to test such small and straightforward function as a unit test.

assert.False(t, h.SupportsSharedfs(""))
}

func TestHVTPath(t *testing.T) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason to test such small and straightforward function as a unit test.

assert.ErrorIs(t, newTestHVT().Ok(), ErrVMMNotInstalled)
}

func TestHVTPreExecNoSeccomp(t *testing.T) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not really see the value of this test.

wantAbsent []string
}{
{
name: "binary path is first element",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"},
},
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test does not check if the kernel path and the command are last. It simply checks if they exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants