aboutsummaryrefslogtreecommitdiffhomepage
path: root/hst/fslink_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-25 21:31:45 +0900
committerOphestra <cat@gensokyo.uk>2025-08-25 21:57:38 +0900
commit26cafe3e8066d9ae65230ff0aa17a5533cfa92f8 (patch)
tree59d19335710976b7246b8ea3b1ff484a3de08f45 /hst/fslink_test.go
parent125f150784f78db8c3323167c3a638cc1bad086e (diff)
hst/fs: implement link fstype
Symlinks do not require special treatment, and doing this allows placing links in order. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'hst/fslink_test.go')
-rw-r--r--hst/fslink_test.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/hst/fslink_test.go b/hst/fslink_test.go
new file mode 100644
index 00000000..c8583544
--- /dev/null
+++ b/hst/fslink_test.go
@@ -0,0 +1,49 @@
+package hst_test
+
+import (
+ "testing"
+
+ "hakurei.app/container"
+ "hakurei.app/hst"
+)
+
+func TestFSLink(t *testing.T) {
+ checkFs(t, []fsTestCase{
+ {"nil", (*hst.FSLink)(nil), false, nil, nil, nil, "<invalid>"},
+ {"zero", new(hst.FSLink), false, nil, nil, nil, "<invalid>"},
+
+ {"deref rel", &hst.FSLink{Target: m("/"), Linkname: ":3", Dereference: true}, false, nil, nil, nil, "<invalid>"},
+ {"deref", &hst.FSLink{
+ Target: m("/run/current-system"),
+ Linkname: "/run/current-system",
+ Dereference: true,
+ }, true, container.Ops{
+ &container.SymlinkOp{
+ Target: m("/run/current-system"),
+ LinkName: "/run/current-system",
+ Dereference: true,
+ },
+ }, m("/run/current-system"), nil,
+ "&/run/current-system:*/run/current-system"},
+
+ {"direct", &hst.FSLink{
+ Target: m("/etc/mtab"),
+ Linkname: "/proc/mounts",
+ }, true, container.Ops{
+ &container.SymlinkOp{
+ Target: m("/etc/mtab"),
+ LinkName: "/proc/mounts",
+ },
+ }, m("/etc/mtab"), nil, "&/etc/mtab:/proc/mounts"},
+
+ {"direct rel", &hst.FSLink{
+ Target: m("/etc/mtab"),
+ Linkname: "../proc/mounts",
+ }, true, container.Ops{
+ &container.SymlinkOp{
+ Target: m("/etc/mtab"),
+ LinkName: "../proc/mounts",
+ },
+ }, m("/etc/mtab"), nil, "&/etc/mtab:../proc/mounts"},
+ })
+}