test(unikontainers): add unit tests for mount and shared_fs utilities#815
Open
Nachiket-Roy wants to merge 2 commits into
Open
test(unikontainers): add unit tests for mount and shared_fs utilities#815Nachiket-Roy wants to merge 2 commits into
Nachiket-Roy wants to merge 2 commits into
Conversation
Extract OS and unix syscalls (Mount, Mknod, Stat, Chmod, Open, Close, Chown, MkdirAll, and RunningInUserNS) to package-level hook variables. Add mount_test.go to cover tmpfs creation, device node setup, bind-mounts, parent private remounts, and flag accumulation. Related-to: urunc-dev#96 Signed-off-by: Nachiket Roy <nachiket.roy.2@gmail.com>
Extract spawnProcess to a package-level spawnProcessHook. Add shared_fs_test.go to cover memory size boundaries (with decimal MB divisor), path adjustment, preStart process parameter validation, and postSetup happy/failure paths. Related-to: urunc-dev#96 Signed-off-by: Nachiket Roy <nachiket.roy.2@gmail.com>
✅ Deploy Preview for urunc canceled.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces unit tests to cover previously untested logic in the
mount.goandshared_fs.gofiles of theunikontainerspackage.To facilitate testing without requiring root privileges or mutating the host filesystem/processes:
Mount,Mknod,Stat,Chmod,Open,Close,os.Chmod,os.MkdirAll,os.Chown,RunningInUserNS, andspawnProcess) into package-level hook variables insidemount.goandshared_fs.go.mount_test.go): Added coverage forcreateTmpfs,setupDev(both namespace check and failure branches),fileFromHost(both bind mount/remount and copy branches),mapMountFlag,mapRootfsPropagationFlag,prepareRoot, andmountVolumes(asserting exact flag accumulation and propagation operations).shared_fs_test.go): Added coverage for path adjustment, memory-based tmpfs allocation size (confirming decimal MB divisor),preStart(directly validating construction of options and arguments), andpostSetup(complete happy paths for VirtioFS/9pfs and error wrapping paths for all steps).Note: Thread safety has been preserved. Tests that temporarily mutate package-level variables are serialized, while pure non-mutating tests continue to run in parallel (
t.Parallel()).Related issues
How was this tested?
Tested locally by verifying correct format, static analysis, and race-detector execution:
go fmt ./pkg/unikontainers/... go vet ./... go test -race ./pkg/unikontainers/...Output:
LLM usage
Assisted by Claude sonnet .
Checklist
make lint).make test_ctr,make test_nerdctl,make test_docker,make test_crictl).