|
|
@@ -47,3 +47,48 @@ func TestListenNoPanicOnExit(t *testing.T) {
|
|
|
t.Fatal("Listen no terminó a tiempo")
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// #2231: la interfaz se descartaba siempre con el formato de `iw event -t`,
|
|
|
+// porque el resto tras el timestamp empieza por ": " y el índice 0 no pasaba
|
|
|
+// la condición. El campo vacío dejaba el log del agente sin radio.
|
|
|
+func TestParseLineFillsIface(t *testing.T) {
|
|
|
+ cases := []struct {
|
|
|
+ name string
|
|
|
+ line string
|
|
|
+ connected bool
|
|
|
+ mac string
|
|
|
+ iface string
|
|
|
+ }{
|
|
|
+ {
|
|
|
+ name: "new station",
|
|
|
+ line: "1726000000.123456: phy2-ap0: new station 5c:cf:7f:1c:0b:06",
|
|
|
+ connected: true,
|
|
|
+ mac: "5c:cf:7f:1c:0b:06",
|
|
|
+ iface: "phy2-ap0",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "del station",
|
|
|
+ line: "1726000001.654321: phy3-ap0: del station 88:13:bf:68:06:3c",
|
|
|
+ connected: false,
|
|
|
+ mac: "88:13:bf:68:06:3c",
|
|
|
+ iface: "phy3-ap0",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "no interface in the line",
|
|
|
+ line: "1726000002.000001: new station aa:bb:cc:dd:ee:ff",
|
|
|
+ connected: true,
|
|
|
+ mac: "aa:bb:cc:dd:ee:ff",
|
|
|
+ iface: "",
|
|
|
+ },
|
|
|
+ }
|
|
|
+ for _, c := range cases {
|
|
|
+ ev, ok := parseLine(c.line)
|
|
|
+ if !ok {
|
|
|
+ t.Errorf("%s: line not parsed", c.name)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if ev.Connected != c.connected || ev.MAC != c.mac || ev.Iface != c.iface {
|
|
|
+ t.Errorf("%s: got %+v, want connected=%v mac=%s iface=%q", c.name, ev, c.connected, c.mac, c.iface)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|