From 53d80f4b66848b046c4852e502779796e260463d Mon Sep 17 00:00:00 2001 From: Ophestra Date: Tue, 6 Jan 2026 21:32:10 +0900 Subject: internal/pkg/testdata: check network This validates hostNet state. Signed-off-by: Ophestra --- internal/pkg/testdata/main.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'internal/pkg/testdata') diff --git a/internal/pkg/testdata/main.go b/internal/pkg/testdata/main.go index 2a0144f3..257d748f 100644 --- a/internal/pkg/testdata/main.go +++ b/internal/pkg/testdata/main.go @@ -3,10 +3,13 @@ package main import ( + "errors" "log" + "net" "os" "path" "slices" + "syscall" "hakurei.app/container/fhs" "hakurei.app/container/vfs" @@ -67,6 +70,18 @@ func main() { } } + if _, err := net.Dial("tcp", "127.0.0.1:0"); err == nil { + log.Fatal("Dial unexpectedly succeeded") + } else if hostNet { + if !errors.Is(err, syscall.ECONNREFUSED) { + log.Fatalf("Dial: error = %v", err) + } + } else { + if !errors.Is(err, syscall.ENETUNREACH) { + log.Fatalf("Dial: error = %v", err) + } + } + log.Println(m) if m.Root != "/sysroot" || m.Target != "/" { log.Fatal("unexpected root mount entry") -- cgit v1.3.1