From 366ee531bb628e5de470dd0b072ba46b997c37d1 Mon Sep 17 00:00:00 2001 From: Ali Date: Tue, 14 Apr 2026 01:21:26 +0500 Subject: [PATCH] util/runtime: let TestFsType tolerate filesystems absent from FsType map MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FsType() returns the known magic-name string when the filesystem is present in its internal map, and falls back to strconv.FormatInt(..., 16) otherwise. The test was asserting the *MAGIC regex only, so it failed whenever it happened to run on a filesystem not yet mapped — the downstream Arch Linux packager hit this with a btrfs subvolume. Extend the regex to accept either a magic-name or the numeric lowercase-hex fallback, keeping the test stable across OS upgrades and exotic filesystems. Fixes #18471 Signed-off-by: Ali --- util/runtime/statfs_unix_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/util/runtime/statfs_unix_test.go b/util/runtime/statfs_unix_test.go index 563bd1dfa6..4b9878f8bd 100644 --- a/util/runtime/statfs_unix_test.go +++ b/util/runtime/statfs_unix_test.go @@ -23,7 +23,12 @@ import ( "github.com/stretchr/testify/require" ) -var regexpFsType = regexp.MustCompile("^[A-Z][A-Z0-9_]*_MAGIC$") +// regexpFsType matches either a known magic-number constant name (e.g. +// EXT4_SUPER_MAGIC) or the lowercase-hex numeric fallback that FsType +// returns for filesystems not present in its table. The numeric fallback +// branch keeps the test green on machines that run on filesystems the +// map hasn't been updated for yet (see prometheus/prometheus#18471). +var regexpFsType = regexp.MustCompile("^([A-Z][A-Z0-9_]*_MAGIC|[0-9a-f]+)$") func TestFsType(t *testing.T) { var fsType string