diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-01-08 07:36:01 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-01-08 07:55:09 +0900 |
| commit | 7bd4d7d0e6937c858e5c960931ae81e2fe59195a (patch) | |
| tree | 91167880b2bd34d1425cdad5c95f8b527966c766 /internal/pkg/exec_test.go | |
| parent | b3c30bcc51bc41feb58bf88c54a0fdd792fcc0c0 (diff) | |
internal/pkg: support explicit overlay mount
This removes all but the /work/ auto overlay behaviour and enables much greater flexibility. This also renames ExecContainerPath to ExecPath so it is easier to type.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg/exec_test.go')
| -rw-r--r-- | internal/pkg/exec_test.go | 82 |
1 files changed, 17 insertions, 65 deletions
diff --git a/internal/pkg/exec_test.go b/internal/pkg/exec_test.go index 17172ea2..d0a54576 100644 --- a/internal/pkg/exec_test.go +++ b/internal/pkg/exec_test.go @@ -11,7 +11,6 @@ import ( "testing" "hakurei.app/container/check" - "hakurei.app/container/fhs" "hakurei.app/container/stub" "hakurei.app/hst" "hakurei.app/internal/pkg" @@ -50,20 +49,20 @@ func TestExec(t *testing.T) { check.MustAbs("/opt/bin/testtool"), []string{"testtool"}, - pkg.MustPath("/file", newStubFile( + pkg.MustPath("/file", false, newStubFile( pkg.KindHTTPGet, pkg.ID{0xfe, 0}, nil, nil, nil, )), - pkg.MustPath("/.hakurei", stubArtifact{ + pkg.MustPath("/.hakurei", false, stubArtifact{ kind: pkg.KindTar, params: []byte("empty directory"), cure: func(c *pkg.CureContext) error { return os.MkdirAll(c.GetWorkDir().String(), 0700) }, }), - pkg.MustPath("/opt", testtool), + pkg.MustPath("/opt", false, testtool), ), ignorePathname, wantChecksumOffline, nil}, {"error passthrough", pkg.NewExec( @@ -76,7 +75,7 @@ func TestExec(t *testing.T) { check.MustAbs("/opt/bin/testtool"), []string{"testtool"}, - pkg.MustPath("/proc/nonexistent", stubArtifact{ + pkg.MustPath("/proc/nonexistent", false, stubArtifact{ kind: pkg.KindTar, params: []byte("doomed artifact"), cure: func(c *pkg.CureContext) error { @@ -95,7 +94,7 @@ func TestExec(t *testing.T) { check.MustAbs("/opt/bin/testtool"), []string{"testtool"}, - pkg.ExecContainerPath{}, + pkg.ExecPath{}, ), nil, pkg.Checksum{}, os.ErrInvalid}, }) @@ -116,7 +115,7 @@ func TestExec(t *testing.T) { } testtoolDestroy(t, base, c) - }, pkg.MustDecode("7PoPpWLjFPXIymbuIYLZAzOpCYr-2PN4CZ11jFdO-mDlnZNgFO3JyOtK8HW8Jxvm")}, + }, pkg.MustDecode("UiV6kMz7KrTsc_yphiyQzFLqjRanHxUOwrBMtkKuWo4mOO6WgPFAcoUEeSp7eVIW")}, {"net", nil, func(t *testing.T, base *check.Absolute, c *pkg.Cache) { c.SetStrict(true) @@ -139,25 +138,25 @@ func TestExec(t *testing.T) { check.MustAbs("/opt/bin/testtool"), []string{"testtool", "net"}, - pkg.MustPath("/file", newStubFile( + pkg.MustPath("/file", false, newStubFile( pkg.KindHTTPGet, pkg.ID{0xfe, 0}, nil, nil, nil, )), - pkg.MustPath("/.hakurei", stubArtifact{ + pkg.MustPath("/.hakurei", false, stubArtifact{ kind: pkg.KindTar, params: []byte("empty directory"), cure: func(c *pkg.CureContext) error { return os.MkdirAll(c.GetWorkDir().String(), 0700) }, }), - pkg.MustPath("/opt", testtool), + pkg.MustPath("/opt", false, testtool), ), ignorePathname, wantChecksum, nil}, }) testtoolDestroy(t, base, c) - }, pkg.MustDecode("bBQVFIt0FnOulljgpLnGtuzHSFgwiCMjc4pmc4rHRqXKQ60Q5aBVYp5f6aH9VdZi")}, + }, pkg.MustDecode("ek4K-0d4iRSArkY2TCs3WK34DbiYeOmhE_4vsJTSu_6roY4ZF3YG6eKRooal-i1o")}, {"overlay root", nil, func(t *testing.T, base *check.Absolute, c *pkg.Cache) { c.SetStrict(true) @@ -177,61 +176,19 @@ func TestExec(t *testing.T) { check.MustAbs("/opt/bin/testtool"), []string{"testtool"}, - pkg.MustPath("/", stubArtifact{ + pkg.MustPath("/", true, stubArtifact{ kind: pkg.KindTar, params: []byte("empty directory"), cure: func(c *pkg.CureContext) error { return os.MkdirAll(c.GetWorkDir().String(), 0700) }, }), - pkg.MustPath("/opt", testtool), + pkg.MustPath("/opt", false, testtool), ), ignorePathname, wantChecksumOffline, nil}, }) testtoolDestroy(t, base, c) - }, pkg.MustDecode("gFT9kprYBqEJKifJIl2sHn_3TgULWVLTU4DrYAHiGcRmcdFRZ0YtjiROW820cAEc")}, - - {"overlay temp", nil, func(t *testing.T, base *check.Absolute, c *pkg.Cache) { - c.SetStrict(true) - testtool, testtoolDestroy := newTesttool() - - msg := message.New(log.New(os.Stderr, "container: ", 0)) - msg.SwapVerbose(testing.Verbose()) - - cureMany(t, c, []cureStep{ - {"container", pkg.NewExec( - t.Context(), - msg, - 0, - nil, - pkg.AbsWork, - []string{"HAKUREI_TEST=1", "HAKUREI_ROOT=1"}, - check.MustAbs("/tmp/bin/testtool"), - []string{"testtool"}, - - pkg.MustPath("/", stubArtifact{ - kind: pkg.KindTar, - params: []byte("empty directory"), - cure: func(c *pkg.CureContext) error { - return os.MkdirAll(c.GetWorkDir().String(), 0700) - }, - }), - pkg.MustPath("/tmp/", stubArtifact{ - kind: pkg.KindTar, - params: []byte("empty directory"), - cure: func(c *pkg.CureContext) error { - return os.MkdirAll(c.GetWorkDir().String(), 0700) - }, - }), - pkg.ExecContainerPath{ - P: fhs.AbsTmp, - A: testtool, - }, - ), ignorePathname, wantChecksumOffline, nil}, - }) - - testtoolDestroy(t, base, c) - }, pkg.MustDecode("_r1IBeMWCkLwQ9Im9w0tV9_CWIOfQlXkkP2CogPHLmZp_AB6W3_8HVZqDV00dNAm")}, + }, pkg.MustDecode("VIqqpf0ip9jcyw63i6E8lCMGUcLivQBe4Bevt3WusNac-1MSy5bzB647qGUBzl-W")}, {"overlay work", nil, func(t *testing.T, base *check.Absolute, c *pkg.Cache) { c.SetStrict(true) @@ -251,29 +208,24 @@ func TestExec(t *testing.T) { check.MustAbs("/work/bin/testtool"), []string{"testtool"}, - pkg.MustPath("/", stubArtifact{ + pkg.MustPath("/", true, stubArtifact{ kind: pkg.KindTar, params: []byte("empty directory"), cure: func(c *pkg.CureContext) error { return os.MkdirAll(c.GetWorkDir().String(), 0700) }, - }), - pkg.MustPath("/work/", stubArtifact{ + }), pkg.MustPath("/work/", false, stubArtifact{ kind: pkg.KindTar, params: []byte("empty directory"), cure: func(c *pkg.CureContext) error { return os.MkdirAll(c.GetWorkDir().String(), 0700) }, - }), - pkg.ExecContainerPath{ - P: pkg.AbsWork, - A: testtool, - }, + }), pkg.Path(pkg.AbsWork, false /* ignored */, testtool), ), ignorePathname, wantChecksumOffline, nil}, }) testtoolDestroy(t, base, c) - }, pkg.MustDecode("-DrfvuB9gUAT-Tgw6V1KjFyosYGMGKJW7KMZFF1Ew8jZ9LJ82FtXf0wTgM3fO0oD")}, + }, pkg.MustDecode("RibudsoY1X4_dtshfvL5LYfCPcxVnP0ikOn3yBHzOrt6BpevQiANLJF6Xua76-gM")}, }) } |
