internal/pkg: known checksum exec artifact
All checks were successful
Test / Create distribution (push) Successful in 53s
Test / Sandbox (push) Successful in 2m57s
Test / ShareFS (push) Successful in 4m48s
Test / Sandbox (race detector) (push) Successful in 5m21s
Test / Hakurei (push) Successful in 5m31s
Test / Hpkg (push) Successful in 5m26s
Test / Hakurei (race detector) (push) Successful in 7m33s
Test / Flake checks (push) Successful in 1m49s

This optionally attaches an output checksum to an execArtifact and enables host networking for the resulting container.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-01-06 20:57:43 +09:00
parent ceb75538cf
commit 156096ac98
5 changed files with 179 additions and 8 deletions

View File

@@ -16,7 +16,13 @@ func main() {
log.SetFlags(0)
log.SetPrefix("testtool: ")
if wantArgs := []string{"testtool"}; !slices.Equal(os.Args, wantArgs) {
var hostNet bool
wantArgs := []string{"testtool"}
if len(os.Args) == 2 {
hostNet = true
wantArgs = []string{"testtool", "net"}
}
if !slices.Equal(os.Args, wantArgs) {
log.Fatalf("Args: %q, want %q", os.Args, wantArgs)
}
if wantEnv := []string{
@@ -31,6 +37,22 @@ func main() {
log.Fatalf("Executable: %q, want %q", got, wantExec)
}
wantHostname := "cure"
if hostNet {
wantHostname += "-net"
}
if hostname, err := os.Hostname(); err != nil {
log.Fatalf("Hostname: error = %v", err)
} else if hostname != wantHostname {
log.Fatalf("Hostname: %q, want %q", hostname, wantHostname)
}
ident := "oHuqV7p0v1Vd8IdAzjyYM8sfCS0P2LR5tfv5cb6Gbf2ZWUm8Ec-7hYPJ_qr183m7"
if hostNet {
ident = "I3T53NtN6HPAyyodHtq2B0clcsoS1nPdvCEb-Zc5K-hoqFGL2od1mftHhwG7gX1S"
}
var m *vfs.MountInfo
if f, err := os.Open(fhs.Proc + "self/mountinfo"); err != nil {
log.Fatalf("Open: error = %v", err)
@@ -64,14 +86,12 @@ func main() {
next() // testtool artifact
next()
if path.Base(m.Root) !=
"oHuqV7p0v1Vd8IdAzjyYM8sfCS0P2LR5tfv5cb6Gbf2ZWUm8Ec-7hYPJ_qr183m7" || m.Target != "/work" {
if path.Base(m.Root) != ident || m.Target != "/work" {
log.Fatal("unexpected work mount entry")
}
next()
if path.Base(m.Root) !=
"oHuqV7p0v1Vd8IdAzjyYM8sfCS0P2LR5tfv5cb6Gbf2ZWUm8Ec-7hYPJ_qr183m7" || m.Target != "/tmp" {
if path.Base(m.Root) != ident || m.Target != "/tmp" {
log.Fatal("unexpected temp mount entry")
}
@@ -97,7 +117,11 @@ func main() {
os.Exit(1)
}
if err := os.WriteFile("check", []byte{0}, 0400); err != nil {
checkData := []byte{0}
if hostNet {
checkData = []byte("net")
}
if err := os.WriteFile("check", checkData, 0400); err != nil {
log.Fatal(err)
}
}