forked from security/hakurei
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>
43 lines
904 B
Go
43 lines
904 B
Go
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)) }
|