container/autoroot: check host path equivalence by value
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m21s
Test / Hakurei (push) Successful in 3m8s
Test / Hpkg (push) Successful in 4m12s
Test / Sandbox (race detector) (push) Successful in 4m25s
Test / Hakurei (race detector) (push) Successful in 5m1s
Test / Flake checks (push) Successful in 1m28s

This will never return true otherwise unless the equivalent paths happen to be interned by the caller.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-08-20 02:03:18 +09:00
parent c81c9a9d75
commit 375acb476d
3 changed files with 123 additions and 1 deletions

View File

@@ -2,6 +2,61 @@ package container
import "testing"
func TestAutoRootOp(t *testing.T) {
checkOpsBuilder(t, []opsBuilderTestCase{
{"pd", new(Ops).Root(MustAbs("/"), "048090b6ed8f9ebb10e275ff5d8c0659", BindWritable), Ops{
&AutoRootOp{
Host: MustAbs("/"),
Prefix: "048090b6ed8f9ebb10e275ff5d8c0659",
Flags: BindWritable,
},
}},
})
checkOpIs(t, []opIsTestCase{
{"zero", new(AutoRootOp), new(AutoRootOp), false},
{"internal ne", &AutoRootOp{
Host: MustAbs("/"),
Prefix: ":3",
Flags: BindWritable,
}, &AutoRootOp{
Host: MustAbs("/"),
Prefix: ":3",
Flags: BindWritable,
resolved: []Op{new(BindMountOp)},
}, true},
{"differs", &AutoRootOp{
Host: MustAbs("/"),
Prefix: "\x00",
Flags: BindWritable,
}, &AutoRootOp{
Host: MustAbs("/"),
Prefix: ":3",
Flags: BindWritable,
}, false},
{"equals", &AutoRootOp{
Host: MustAbs("/"),
Prefix: ":3",
Flags: BindWritable,
}, &AutoRootOp{
Host: MustAbs("/"),
Prefix: ":3",
Flags: BindWritable,
}, true},
})
checkOpMeta(t, []opMetaTestCase{
{"root", &AutoRootOp{
Host: MustAbs("/"),
Prefix: ":3",
Flags: BindWritable,
}, "setting up", `auto root "/" prefix :3 flags 0x2`},
})
}
func TestIsAutoRootBindable(t *testing.T) {
testCases := []struct {
name string