diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-08-20 02:03:18 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-08-20 02:14:39 +0900 |
| commit | 375acb476d36cac8e122ae8c45628bd8e7e0f0ca (patch) | |
| tree | 59899fe31c847724ac1a0d4055420a0a751c3ab0 /container/autoroot_test.go | |
| parent | c81c9a9d75f179988cf858b85fe2de71bf9c2ff4 (diff) | |
container/autoroot: check host path equivalence by value
This will never return true otherwise unless the equivalent paths happen to be interned by the caller.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/autoroot_test.go')
| -rw-r--r-- | container/autoroot_test.go | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/container/autoroot_test.go b/container/autoroot_test.go index 7e9d1477..77440ace 100644 --- a/container/autoroot_test.go +++ b/container/autoroot_test.go @@ -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 |
