package backup import ( "path/filepath" "strings" ) // oneDrivePerSubtree is the test stand-in for system.SamePhysicalDevice (st_dev equality). // // Why it exists: the real predicate asks "are these two paths on the same physical disk?", and // Tier-2's whole purpose is to refuse a target that is. On a host where every t.TempDir() lands on // one filesystem — DooPlex, and any CI box with a single volume — a fixture's "usb" and "flash" // dirs share one st_dev, so the guard correctly refuses them and the off-drive tests can never // exercise their subject. This models what the fixture is actually depicting: one drive per // directory subtree, so two paths share a device only when one contains the other (a path inside a // drive IS on that drive). Unrelated subtrees are distinct devices, exactly as real mountpoints are. // // It does NOT relax any assertion — the guard still runs, still refuses same-device targets (see // TestSharesTier2NeverTargetsItsOwnSourceDrive, which passes under this seam), and production keeps // using the real st_dev check because the seam is nil there. func oneDrivePerSubtree(a, b string) bool { a, b = filepath.Clean(a), filepath.Clean(b) if a == b { return true } sep := string(filepath.Separator) return strings.HasPrefix(a, b+sep) || strings.HasPrefix(b, a+sep) }