aboutsummaryrefslogtreecommitdiffhomepage
path: root/hst/fsbind_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-12 04:38:45 +0900
committerOphestra <cat@gensokyo.uk>2025-08-14 04:52:49 +0900
commit99ac96511bed17f48d908db3d00a1f48579ba011 (patch)
tree30d404efb7256c9f053f64192068637d6b846db4 /hst/fsbind_test.go
parente99d7affb0c128fa82722f9b3d79c99b5e5918cd (diff)
hst/fs: interface filesystem config
This allows mount points to be represented by different underlying structs. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'hst/fsbind_test.go')
-rw-r--r--hst/fsbind_test.go66
1 files changed, 66 insertions, 0 deletions
diff --git a/hst/fsbind_test.go b/hst/fsbind_test.go
new file mode 100644
index 00000000..22a6d9aa
--- /dev/null
+++ b/hst/fsbind_test.go
@@ -0,0 +1,66 @@
+package hst_test
+
+import (
+ "testing"
+
+ "hakurei.app/container"
+ "hakurei.app/hst"
+)
+
+func TestFSBind(t *testing.T) {
+ checkFs(t, "bind", []fsTestCase{
+ {"nil", (*hst.FSBind)(nil), nil, nil, nil, "<invalid>"},
+
+ {"full", &hst.FSBind{
+ Dst: m("/dev"),
+ Src: m("/mnt/dev"),
+ Optional: true,
+ Device: true,
+ }, container.Ops{&container.BindMountOp{
+ Source: m("/mnt/dev"),
+ Target: m("/dev"),
+ Flags: container.BindWritable | container.BindDevice | container.BindOptional,
+ }}, m("/dev"), ms("/mnt/dev"),
+ "d+/mnt/dev:/dev"},
+
+ {"full write dev", &hst.FSBind{
+ Dst: m("/dev"),
+ Src: m("/mnt/dev"),
+ Write: true,
+ Device: true,
+ }, container.Ops{&container.BindMountOp{
+ Source: m("/mnt/dev"),
+ Target: m("/dev"),
+ Flags: container.BindWritable | container.BindDevice,
+ }}, m("/dev"), ms("/mnt/dev"),
+ "d*/mnt/dev:/dev"},
+
+ {"full write", &hst.FSBind{
+ Dst: m("/tmp"),
+ Src: m("/mnt/tmp"),
+ Write: true,
+ }, container.Ops{&container.BindMountOp{
+ Source: m("/mnt/tmp"),
+ Target: m("/tmp"),
+ Flags: container.BindWritable,
+ }}, m("/tmp"), ms("/mnt/tmp"),
+ "w*/mnt/tmp:/tmp"},
+
+ {"full no flags", &hst.FSBind{
+ Dst: m("/etc"),
+ Src: m("/mnt/etc"),
+ }, container.Ops{&container.BindMountOp{
+ Source: m("/mnt/etc"),
+ Target: m("/etc"),
+ }}, m("/etc"), ms("/mnt/etc"),
+ "*/mnt/etc:/etc"},
+
+ {"nil dst", &hst.FSBind{
+ Src: m("/"),
+ }, container.Ops{&container.BindMountOp{
+ Source: m("/"),
+ Target: m("/"),
+ }}, m("/"), ms("/"),
+ "*/"},
+ })
+}