util/runtime: simplify TestFsType to check != 0 instead of _MAGIC

Signed-off-by: alliasgher <alliasgher123@gmail.com>
This commit is contained in:
alliasgher
2026-04-14 20:26:13 +05:00
parent 48f4a41e38
commit 6994b4cb4e

View File

@@ -17,7 +17,6 @@ package runtime
import (
"os"
"strings"
"testing"
"github.com/stretchr/testify/require"
@@ -29,15 +28,11 @@ func TestFsType(t *testing.T) {
path, err := os.Getwd()
require.NoError(t, err)
// FsType returns a named constant (e.g. EXT4_SUPER_MAGIC) for known
// filesystems, or a lowercase-hex fallback for unknown ones. Either way
// the result must be non-zero for a real path. See #18471.
fsType = FsType(path)
// If FsType returns a hex string the filesystem is not in the known map.
// Skip rather than fail so that CI on unusual filesystems does not
// spuriously break. The test is still exercised on known filesystems.
// See prometheus/prometheus#18471.
if !strings.Contains(fsType, "_MAGIC") {
t.Skipf("filesystem type %q not in known map, skipping strict format check", fsType)
}
require.Contains(t, fsType, "_MAGIC")
require.NotEqual(t, "0", fsType)
fsType = FsType("/no/where/to/be/found")
require.Equal(t, "0", fsType)