Skip to content

test(unikernels): add unit test coverage for linux backend#613

Open
theycallmeaabie wants to merge 1 commit intourunc-dev:mainfrom
theycallmeaabie:add-test-coverage-unikernels-linux
Open

test(unikernels): add unit test coverage for linux backend#613
theycallmeaabie wants to merge 1 commit intourunc-dev:mainfrom
theycallmeaabie:add-test-coverage-unikernels-linux

Conversation

@theycallmeaabie
Copy link
Copy Markdown

Description

Adds linux_test.go with comprehensive unit tests for pkg/unikontainers/unikernels/linux.go.
These additions significantly improve test coverage for linux.go, bringing it to approximately 99%.

Related issues

#96

How was this tested?

Tests were executed using:

go test -cover ./pkg/unikontainers/unikernels/...

  • All 36 subtests passed successfully

LLM usage

Gemini 3.1 was used for assistance, all the code is manually reviewed and edited.

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: theycallmeaabie <theycallmeaabie@gmail.com>
Copilot AI review requested due to automatic review settings May 3, 2026 11:40
@netlify
Copy link
Copy Markdown

netlify Bot commented May 3, 2026

Deploy Preview for urunc canceled.

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

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a dedicated unit test suite for the Linux unikernel backend in pkg/unikontainers/unikernels, aiming to improve confidence in linux.go behavior around boot parameter generation, monitor CLI wiring, urunit config generation, and initialization paths.

Changes:

  • Add unit tests for Linux backend helpers such as filesystem support, subnet checks, command-line parsing, and network configuration.
  • Add behavior-focused tests for monitor block/CLI argument generation and kernel command-line construction across rootfs and urunit modes.
  • Add initialization tests for urunit config creation and selected error propagation paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +513 to +520
err := l.Init(types.UnikernelParams{
CmdLine: []string{"/usr/bin/urunit"},
Rootfs: types.RootfsParams{
Type: "initrd",
MonRootfs: filepath.Join(tmp, "does-not-exist"),
Path: "initrd.cpio",
},
})
Comment on lines +47 to +60
fs string
want bool
}{
{"ext2", true},
{"ext3", true},
{"ext4", true},
{"9pfs", true},
{"virtiofs", true},
{"xfs", false},
{"btrfs", false},
{"", false},
}
for _, c := range cases {
t.Run(c.fs, func(t *testing.T) {
Comment on lines +147 to +153
t.Run("surrounding whitespace is trimmed before quoting check", func(t *testing.T) {
t.Parallel()
l := &Linux{}
err := l.parseCmdLine([]string{" /bin/sh ", " -c "})
require.NoError(t, err)
assert.Equal(t, "/bin/sh", l.App)
assert.Equal(t, "-c", l.Command)
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