Skip to content

test(hypervisors): add unit tests for CloudHypervisor#617

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

test(hypervisors): add unit tests for CloudHypervisor#617
r0hansaxena wants to merge 1 commit into
urunc-dev:mainfrom
r0hansaxena:test/cloud-hypervisor

Conversation

@r0hansaxena
Copy link
Copy Markdown

@r0hansaxena r0hansaxena commented May 4, 2026

Description

Adds unit tests for the CloudHypervisor VMM backend, covering BuildExecCmd and the simpler interface methods (UsesKVM, Ok, Path, PreExec, SupportsSharedfs). Tests are table-driven and cover all flag-generation branches including memory, networking, block devices, initrd, virtiofs and vsock.

Related issues

How was this tested?

Ran unit tests locally:

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

All 20 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.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 4, 2026

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit df20eb8
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/69f8c542baf45a000868efcd

Signed-off-by: r0hansaxena <rohansxn8772@gmail.com>
@r0hansaxena r0hansaxena force-pushed the test/cloud-hypervisor branch from 4d233e4 to df20eb8 Compare May 4, 2026 16:11
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 TestCloudHypervisorUsesKVM(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 a small and straightforward action through unit tests

assert.True(t, newTestCH().UsesKVM())
}

func TestCloudHypervisorOk(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 such a unit test.

assert.NoError(t, newTestCH().Ok())
}

func TestCloudHypervisorPath(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.

This tests the function that you created before...

assert.Equal(t, "/usr/bin/cloud-hypervisor", newTestCH().Path())
}

func TestCloudHypervisorPreExec(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 a small and straightforward action through unit tests

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.

Please do not add new files for mocking functions.

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