From 1948b6efc3c20b56972cce137158556302dca968 Mon Sep 17 00:00:00 2001 From: Ville Vesilehto Date: Fri, 23 May 2025 19:23:14 +0300 Subject: [PATCH] test: skip certain network-specific tests on non-Linux (#7318) Add conditional test skipping for bind and readme tests that rely on Linux-specific loopback interface behavior. These tests reference network configurations that may not exist on for e.g. macOS or other platforms, causing spurious test failures. Signed-off-by: Ville Vesilehto --- plugin/bind/setup_test.go | 7 +++++++ test/readme_test.go | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/plugin/bind/setup_test.go b/plugin/bind/setup_test.go index e8c87b8fe..858edf2d1 100644 --- a/plugin/bind/setup_test.go +++ b/plugin/bind/setup_test.go @@ -1,6 +1,7 @@ package bind import ( + "runtime" "testing" "github.com/coredns/caddy" @@ -8,6 +9,12 @@ import ( ) func TestSetup(t *testing.T) { + // Skip on non-Linux systems as some tests refer to for e.g. loopback interfaces which + // are not present on all systems. + if runtime.GOOS != "linux" { + t.Skipf("Skipping bind test on %s", runtime.GOOS) + } + for i, test := range []struct { config string expected []string diff --git a/test/readme_test.go b/test/readme_test.go index 36e6cde94..8a77bd6be 100644 --- a/test/readme_test.go +++ b/test/readme_test.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "path/filepath" + "runtime" "strconv" "strings" "testing" @@ -45,6 +46,12 @@ PrivateKey: f03VplaIEA+KHI9uizlemUSbUJH86hPBPjmcUninPoM= // While we're at it - we also check the README.md itself. It should at least have the sections: // Name, Description, Syntax and Examples. See plugin.md for more details. func TestReadme(t *testing.T) { + // Skip on non-Linux systems as some tests refer to for e.g. loopback interfaces which + // are not present on all systems. + if runtime.GOOS != "linux" { + t.Skipf("Skipping readme test on %s", runtime.GOOS) + } + port := 30053 caddy.Quiet = true dnsserver.Quiet = true