Skip to content

test(unikontainers): add unit tests for pure functions#723

Open
mdryaan wants to merge 1 commit into
urunc-dev:mainfrom
mdryaan:test/unikontainers-pure-functions
Open

test(unikontainers): add unit tests for pure functions#723
mdryaan wants to merge 1 commit into
urunc-dev:mainfrom
mdryaan:test/unikontainers-pure-functions

Conversation

@mdryaan
Copy link
Copy Markdown
Contributor

@mdryaan mdryaan commented May 25, 2026

Description

Adds unit tests for three sets of pure functions in pkg/unikontainers that have real conditional logic but no test coverage.
TestMapRootfsPropagationFlagmount_test.go Covers all 8 valid propagation flag names (shared, rshared, slave, rslave, private, rprivate, unbindable, runbindable) asserting the exact unix flag value returned, plus one subtest for an unknown value asserting a non-nil error.

TestChooseTmpfsSizeshared_fs_test.go Covers the 9pfs constant path, two virtiofs cases with typical memory (256 MB, 512 MB) verifying the MiB-to-MB conversion and 1 MiB overhead, and the zero-memory edge case.

TestInt32msgSerialize / TestBytemsgSerializeipc_message_test.go Covers int32msg serialization (length, type, and value fields at thecorrect byte offsets) and bytemsg serialization (aligned buffer length, header fields, value bytes). Includes a subtest for the oversized-value panic path in bytemsg that asserts a netlinkError is raised when Len() exceeds math.MaxUint16.

Related issues

How was this tested?

go test -count=1 ./pkg/unikontainers/... -v
-run "TestMapRootfsPropagationFlag|TestChooseTmpfsSize|TestInt32msgSerialize|TestBytemsgSerialize"
All 16 subtests pass. Linter passes (make lint, 0 issues).
Build passes (make).

LLM usage

Claude Sonnet 4.6 was used to assist in identifying untested functions and understanding the codebase structure. All code was manually reviewed and understood 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: Md Raiyan <alikhurshid842001@gmail.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 25, 2026

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit b70e91f
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6a13ff197771630008e93c27

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