//go:build linux

package system

import (
	"syscall"
	"testing"
)

// The statfs seam wires f_type into the classifier; a statfs error yields UNKNOWN (fail open), not
// a stub verdict.
func TestClassifyPathFS_Seam(t *testing.T) {
	orig := statfsFn
	t.Cleanup(func() { statfsFn = orig })

	statfsFn = func(_ string, st *syscall.Statfs_t) error { st.Type = 0x6969; return nil }
	if got := ClassifyPathFS("/anything"); got != FSClassNetwork {
		t.Errorf("nfs magic → %q, want network", got)
	}
	statfsFn = func(_ string, st *syscall.Statfs_t) error { st.Type = 0x0187; return nil }
	if got := ClassifyPathFS("/anything"); got != FSClassAutofs {
		t.Errorf("autofs magic → %q, want autofs", got)
	}
	statfsFn = func(_ string, _ *syscall.Statfs_t) error { return syscall.EIO }
	if got := ClassifyPathFS("/anything"); got != FSClassUnknown {
		t.Errorf("statfs error → %q, want unknown (fail open, never stub)", got)
	}
}

// Real-IO: a plain local directory MUST classify as a stub — this is the exact state the RCA's
// guest reboot produced, and the verdict everything downstream keys on.
func TestClassifyPathFS_RealLocalDirIsStub(t *testing.T) {
	if got := ClassifyPathFS(t.TempDir()); got != FSClassStub {
		t.Fatalf("a plain local dir must classify as stub, got %q", got)
	}
}
