Skip to content

test(hypervisors): cover Qemu.BuildExecCmd#597

Open
parthdagia05 wants to merge 1 commit intourunc-dev:mainfrom
parthdagia05:test/hypervisors-qemu-buildexeccmd
Open

test(hypervisors): cover Qemu.BuildExecCmd#597
parthdagia05 wants to merge 1 commit intourunc-dev:mainfrom
parthdagia05:test/hypervisors-qemu-buildexeccmd

Conversation

@parthdagia05
Copy link
Copy Markdown

Description

Qemu.BuildExecCmd in pkg/unikontainers/hypervisors/qemu.go didn't have any direct unit-test coverage, so this PR adds qemu_test.go that walks through the main branches the function actually exercises:

  • Static flags that should always be present
  • Memory default fallback and custom values
  • vCPU handling (omits -smp when zero, sets it correctly otherwise)
  • Seccomp on / off
  • Architecture-specific machine type (-M virt on arm64)
  • Networking: empty TapDev, generic tap setup, custom MonitorNetCli, and vhost on/off
  • Initrd present / absent
  • Sharedfs: 9pfs, virtiofs, and none
  • Block devices: no blocks, generic, and ExactArgs verbatim path
  • MonitorCli extras (ExtraInitrd, OtherArgs)
  • vsock with VAccelType set
  • The -append rule for the kernel command line

A small fakeUnikernel stub keeps the tests focused on BuildExecCmd itself rather than pulling in any real unikernel implementation.

Related issues

  • Fixes #

How was this tested?

  • go test ./pkg/unikontainers/hypervisors/... passes locally
  • go build ./... passes
  • All sub-tests use t.Parallel() and assert against the joined command string

LLM usage

Used Anthropic's Claude Opus 4.6 to help research the function's branches and shape the test cases around the actual code paths.

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.

Walks through the main code paths the function exercises — static flags,
memory, vCPUs, network (incl. vhost), initrd, sharedfs, block devices,
vsock, and the kernel command append rule.

Signed-off-by: Parth Dagia <parth.24bcs10414@sst.scaler.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 1, 2026

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit 5eff619
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/69f4f7ba8cafa80009e88662

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.

1 participant