diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-01-06 23:34:43 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-01-06 23:45:08 +0900 |
| commit | 0df87ab1117bf4da5163ad486a82628f1bada7ed (patch) | |
| tree | 48745fe27c4c3694c1313bb9030188458fbdd328 /internal/pkg/testdata/main.go | |
| parent | aa0a949cefd8c1a1519d892f87aac3119389e271 (diff) | |
internal/pkg: automatic overlay mount on tmp
This sets up the last Artifact to target /tmp as a writable overlay mount backed by the host side temp directory. This is useful for an Artifact containing source code to be built for another Artifact for example.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg/testdata/main.go')
| -rw-r--r-- | internal/pkg/testdata/main.go | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/internal/pkg/testdata/main.go b/internal/pkg/testdata/main.go index bbf23400..4f3d047e 100644 --- a/internal/pkg/testdata/main.go +++ b/internal/pkg/testdata/main.go @@ -39,11 +39,19 @@ func main() { if !slices.Equal(wantEnv, os.Environ()) { log.Fatalf("Environ: %q, want %q", os.Environ(), wantEnv) } - const wantExec = "/opt/bin/testtool" + + var overlayTmp bool + const ( + wantExec = "/opt/bin/testtool" + wantExecOverlay = "/tmp/bin/testtool" + ) if got, err := os.Executable(); err != nil { log.Fatalf("Executable: error = %v", err) } else if got != wantExec { - log.Fatalf("Executable: %q, want %q", got, wantExec) + if got != wantExecOverlay { + log.Fatalf("Executable: %q, want %q", got, wantExec) + } + overlayTmp = true } wantHostname := "cure" @@ -105,7 +113,6 @@ func main() { if path.Base(lowerdir) != checksumEmptyDir { log.Fatal("unexpected artifact checksum") } - } else { if hostNet { ident = "I3T53NtN6HPAyyodHtq2B0clcsoS1nPdvCEb-Zc5K-hoqFGL2od1mftHhwG7gX1S" @@ -126,7 +133,16 @@ func main() { } } - next() // testtool artifact + if !overlayTmp { + next() // testtool artifact + } else { + ident = "3ELJ8l42g6XeIoLGR9LheVhMIwSIleD6VrhsliBuon5DAdBOwFSMqd7aiUI4fll7" + + next() + if path.Base(m.Root) != checksumEmptyDir || m.Target != "/tmp" { + log.Fatal("unexpected artifact checksum") + } + } next() if path.Base(m.Root) != ident || m.Target != "/work" { @@ -134,8 +150,16 @@ func main() { } next() - if path.Base(m.Root) != ident || m.Target != "/tmp" { - log.Fatal("unexpected temp mount entry") + if !overlayTmp { + if path.Base(m.Root) != ident || m.Target != "/tmp" { + log.Fatal("unexpected temp mount entry") + } + } else { + // testtool artifact + if m.Root != "/" || m.Target != "/tmp" || + m.Source != "overlay" || m.FsType != "overlay" { + log.Fatal("unexpected temp mount entry") + } } next() |
