From 156096ac987f5ec8be8dbf65332c4d61e675f3cf Mon Sep 17 00:00:00 2001 From: Ophestra Date: Tue, 6 Jan 2026 20:57:43 +0900 Subject: internal/pkg: known checksum exec artifact This optionally attaches an output checksum to an execArtifact and enables host networking for the resulting container. Signed-off-by: Ophestra --- internal/pkg/testdata/main.go | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'internal/pkg/testdata') diff --git a/internal/pkg/testdata/main.go b/internal/pkg/testdata/main.go index d63acdbd..2a0144f3 100644 --- a/internal/pkg/testdata/main.go +++ b/internal/pkg/testdata/main.go @@ -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) } } -- cgit v1.3.1