fix test bundling bug
This commit is contained in:
+50
-15
@@ -11,6 +11,7 @@ except ModuleNotFoundError:
|
||||
smbclient = None
|
||||
|
||||
from db import DEVICE_DUT, DEVICE_REF, TestRecord
|
||||
from scanner import resolve_runtime_path
|
||||
|
||||
P2P_COE_REQUIRED_COLUMNS = [
|
||||
"Priority",
|
||||
@@ -96,6 +97,8 @@ def _normalize_input_path(path_value: str | Path) -> str:
|
||||
if not path:
|
||||
return path
|
||||
|
||||
path = str(resolve_runtime_path(path)).strip()
|
||||
|
||||
# Accept //server/share style and normalize to UNC for smbclient.
|
||||
if path.startswith("//"):
|
||||
return "\\\\" + path.lstrip("/").replace("/", "\\")
|
||||
@@ -104,6 +107,12 @@ def _normalize_input_path(path_value: str | Path) -> str:
|
||||
if re.match(r"^/\d{1,3}(?:\.\d{1,3}){3}/[^/]+", path):
|
||||
return "\\\\" + path.lstrip("/").replace("/", "\\")
|
||||
|
||||
if os.path.exists(path):
|
||||
return path
|
||||
|
||||
if path.startswith("/"):
|
||||
return path
|
||||
|
||||
return path
|
||||
|
||||
|
||||
@@ -372,9 +381,10 @@ def _parse_single_csv(
|
||||
test_type = _infer_test_type(test_id)
|
||||
rx_tx = _infer_rx_tx(test_id)
|
||||
rotation = _empty_to_none(_row_get(row, "Rotation"))
|
||||
power_mode = _empty_to_none(_row_get(row, "6GHz Power Mode"))
|
||||
has_coe_pair = _normalize_yes_no(_row_get(row, "COE Pair")) if csv_format == "p2p_coe" else False
|
||||
config = _build_config(row, csv_format)
|
||||
signature = _victim_band_signature(row) if csv_format == "p2p_coe" else None
|
||||
signature = _first_populated_p2p_signature(row) if csv_format == "p2p_coe" and test_type == "P2P" else None
|
||||
victim_band_source = "Victim Band" if csv_format == "p2p_coe" else "Band"
|
||||
victim_band = _normalize_victim_band(_row_get(row, victim_band_source))
|
||||
|
||||
@@ -392,6 +402,7 @@ def _parse_single_csv(
|
||||
test_type=test_type,
|
||||
rotation=rotation,
|
||||
rx_tx=rx_tx,
|
||||
power_mode=power_mode,
|
||||
has_coe_pair=has_coe_pair,
|
||||
coe_pairing=[],
|
||||
priority=priority,
|
||||
@@ -405,14 +416,18 @@ def _parse_single_csv(
|
||||
)
|
||||
records_with_signature.append((record, signature))
|
||||
|
||||
# Build COE pairing based on victim band signature and RX/TX+band suffix.
|
||||
# Build COE pairing based on full signature and RX/TX+band suffix.
|
||||
# Example key suffixes: RXAX, TXAX, RXBE, TXBE.
|
||||
coe_by_signature_and_suffix: dict[tuple, list[str]] = {}
|
||||
coe_by_signature_and_suffix: dict[tuple[tuple[str, ...], str], list[str]] = {}
|
||||
for record, signature in records_with_signature:
|
||||
if record.test_type == "COE" and signature is not None:
|
||||
if record.test_type == "COE":
|
||||
suffix = _extract_pairing_suffix(record.test_id)
|
||||
if suffix:
|
||||
key = (signature, suffix)
|
||||
if not suffix:
|
||||
continue
|
||||
|
||||
# Index all populated COE band signatures so any one can match the selected P2P signature.
|
||||
for coe_signature in _all_band_signatures(record.raw_payload or {}):
|
||||
key = (coe_signature, suffix)
|
||||
coe_by_signature_and_suffix.setdefault(key, []).append(record.test_id)
|
||||
|
||||
for record, signature in records_with_signature:
|
||||
@@ -420,7 +435,7 @@ def _parse_single_csv(
|
||||
if record.test_type == "P2P" and signature is not None:
|
||||
suffix = _extract_pairing_suffix(record.test_id)
|
||||
key = (signature, suffix) if suffix else None
|
||||
pairs = sorted(coe_by_signature_and_suffix.get(key, [])) if key else []
|
||||
pairs = sorted(set(coe_by_signature_and_suffix.get(key, []))) if key else []
|
||||
|
||||
for device in (DEVICE_DUT, DEVICE_REF):
|
||||
device_runtime_defaults = runtime_defaults_by_device.get(device, RUNTIME_DEFAULTS)
|
||||
@@ -431,6 +446,7 @@ def _parse_single_csv(
|
||||
test_type=record.test_type,
|
||||
rotation=record.rotation,
|
||||
rx_tx=record.rx_tx,
|
||||
power_mode=record.power_mode,
|
||||
has_coe_pair=bool(pairs),
|
||||
coe_pairing=pairs,
|
||||
priority=record.priority,
|
||||
@@ -493,13 +509,21 @@ def _empty_to_none(value: str | None) -> str | None:
|
||||
return cleaned if cleaned else None
|
||||
|
||||
|
||||
def _victim_band_signature(row: dict[str, str]) -> tuple[str, ...] | None:
|
||||
band = _normalize_victim_band(_row_get(row, "Victim Band"))
|
||||
if band is None:
|
||||
def _first_populated_p2p_signature(row: dict[str, str]) -> tuple[str, ...] | None:
|
||||
for band in ("5G", "6G", "2G"):
|
||||
signature = _band_signature(row, band)
|
||||
if signature is not None:
|
||||
return signature
|
||||
return None
|
||||
|
||||
|
||||
def _band_signature(row: dict[str, str], band: str) -> tuple[str, ...] | None:
|
||||
normalized_band = _normalize_victim_band(band)
|
||||
if normalized_band is None:
|
||||
return None
|
||||
|
||||
# Source CSVs may use either "5G_Test Point" or "5G Test Point" style headers.
|
||||
prefixes = (f"{band}_", f"{band} ")
|
||||
prefixes = (f"{normalized_band}_", f"{normalized_band} ")
|
||||
|
||||
def _pick_value(suffix: str) -> str:
|
||||
for prefix in prefixes:
|
||||
@@ -512,12 +536,24 @@ def _victim_band_signature(row: dict[str, str]) -> tuple[str, ...] | None:
|
||||
channel = _pick_value("Channel")
|
||||
rssi = _pick_value("RSSI")
|
||||
bandwidth = _pick_value("Bandwidth")
|
||||
direction = _pick_value("Direction")
|
||||
sta = _pick_value("STA")
|
||||
|
||||
# Direction is intentionally ignored for COE pairing matching.
|
||||
if not all([test_point, channel, rssi, bandwidth]):
|
||||
if not all([test_point, channel, rssi, bandwidth, direction, sta]):
|
||||
return None
|
||||
|
||||
return (band, test_point, channel, rssi, bandwidth)
|
||||
return (test_point, channel, bandwidth, rssi, direction, sta)
|
||||
|
||||
|
||||
def _all_band_signatures(row: dict[str, str]) -> list[tuple[str, ...]]:
|
||||
seen: set[tuple[str, ...]] = set()
|
||||
signatures: list[tuple[str, ...]] = []
|
||||
for band in ("5G", "6G", "2G"):
|
||||
signature = _band_signature(row, band)
|
||||
if signature is not None and signature not in seen:
|
||||
seen.add(signature)
|
||||
signatures.append(signature)
|
||||
return signatures
|
||||
|
||||
|
||||
def _normalize_victim_band(value: str | None) -> str | None:
|
||||
@@ -561,7 +597,6 @@ def _build_legacy_config(row: dict[str, str]) -> dict[str, dict[str, str | None]
|
||||
"sta": _empty_to_none(_row_get(row, "5G_STA")),
|
||||
},
|
||||
"6G": {
|
||||
"power_mode": _empty_to_none(_row_get(row, "6GHz Power Mode")),
|
||||
"test_point": _empty_to_none(_row_get(row, "6G_Test Point")),
|
||||
"channel": _empty_to_none(_row_get(row, "6G_Channel")),
|
||||
"bandwidth": _empty_to_none(_row_get(row, "6G_Bandwidth")),
|
||||
|
||||
Reference in New Issue
Block a user