aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/path_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-08 01:50:38 +0900
committerOphestra <cat@gensokyo.uk>2025-08-08 01:54:48 +0900
commitacffa76812eb2972f2478b55fe2ba1e0ae8fa41d (patch)
tree68b96726d3a2258b7128cfa9763f982c3350037f /container/path_test.go
parent8da76483e697f0a93577c8d661b6db274213a62c (diff)
container/ops: implement overlay op
There are significant limitations to using the overlay mount, and the implementation in the kernel is quite quirky. For now the Op is quite robust, however a higher level interface for it has not been decided yet. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/path_test.go')
-rw-r--r--container/path_test.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/container/path_test.go b/container/path_test.go
new file mode 100644
index 00000000..9af2d2f9
--- /dev/null
+++ b/container/path_test.go
@@ -0,0 +1,42 @@
+package container
+
+import "testing"
+
+func TestToSysroot(t *testing.T) {
+ testCases := []struct {
+ name string
+ want string
+ }{
+ {"", "/sysroot"},
+ {"/", "/sysroot"},
+ {"//etc///", "/sysroot/etc"},
+ }
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ if got := toSysroot(tc.name); got != tc.want {
+ t.Errorf("toSysroot: %q, want %q", got, tc.want)
+ }
+ })
+ }
+}
+
+func TestToHost(t *testing.T) {
+ testCases := []struct {
+ name string
+ want string
+ }{
+ {"", "/host"},
+ {"/", "/host"},
+ {"//etc///", "/host/etc"},
+ }
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ if got := toHost(tc.name); got != tc.want {
+ t.Errorf("toHost: %q, want %q", got, tc.want)
+ }
+ })
+ }
+}
+
+// InternalToHostOvlEscape exports toHost passed to escapeOverlayDataSegment.
+func InternalToHostOvlEscape(s string) string { return escapeOverlayDataSegment(toHost(s)) }