internal/pkg/testdata: check network
All checks were successful
Test / Create distribution (push) Successful in 55s
Test / Sandbox (push) Successful in 3m9s
Test / ShareFS (push) Successful in 4m49s
Test / Sandbox (race detector) (push) Successful in 5m23s
Test / Hakurei (push) Successful in 5m33s
Test / Hpkg (push) Successful in 5m42s
Test / Hakurei (race detector) (push) Successful in 7m22s
Test / Flake checks (push) Successful in 1m48s

This validates hostNet state.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-01-06 21:32:10 +09:00
parent 156096ac98
commit 53d80f4b66
2 changed files with 16 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
package pkg_test
//go:generate go build -tags testtool -ldflags "-extldflags='-static'" -o testdata/testtool ./testdata
//go:generate env CGO_ENABLED=0 go build -tags testtool -o testdata/testtool ./testdata
import (
_ "embed"

View File

@@ -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")