mirror of
https://github.com/prometheus/prometheus.git
synced 2026-05-05 04:16:15 +02:00
util/runtime: let TestFsType tolerate filesystems absent from FsType map
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 <alliasgher123@gmail.com>
This commit is contained in:
parent
53a811bef4
commit
366ee531bb
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user