Files
felhom-controller/controller/internal/system/mountdead_test.go
T

27 lines
1.1 KiB
Go

//go:build linux
package system
import "testing"
// Lines measured on Tester 1 2026-10-14 (K4): a live ext4, a dead one (`shutdown`), and a returned drive stacked on
// top of the dead one — only the TOP mount decides.
const k4Mountinfo = `120 99 8:33 / /mnt/felhom-drives/media_a rw,relatime shared:60 master:1 - ext4 /dev/sdc1 rw
121 99 8:49 / /mnt/felhom-drives/media_b rw,relatime shared:61 master:2 - ext4 /dev/sdd1 rw,shutdown
122 99 8:65 / /mnt/felhom-drives/media_c rw,relatime shared:62 master:3 - ext4 /dev/sde1 rw,shutdown
130 122 8:81 / /mnt/felhom-drives/media_c rw,relatime shared:70 master:4 - ext4 /dev/sdf1 rw`
func TestMountIsShutdown_K4(t *testing.T) {
for path, want := range map[string]bool{
"/mnt/felhom-drives/media_a": false, // live
"/mnt/felhom-drives/media_b": true, // pulled: dead
"/mnt/felhom-drives/media_c": false, // came back ON TOP of the dead mount: the top is live
"/mnt/felhom-drives/media_c/": false,
"/mnt/felhom-drives/nothing": false, // not a mount at all: not „dead"
} {
if got := mountinfoShutdown(k4Mountinfo, path); got != want {
t.Errorf("%s: dead=%v, want %v", path, got, want)
}
}
}