forked from security/hakurei
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>
This commit is contained in:
42
container/path_test.go
Normal file
42
container/path_test.go
Normal file
@@ -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)) }
|
||||
Reference in New Issue
Block a user