|
@@ -147,6 +147,120 @@ class RemoteScriptTests(unittest.TestCase):
|
|
|
]:
|
|
]:
|
|
|
self.assertIn(marker, output)
|
|
self.assertIn(marker, output)
|
|
|
|
|
|
|
|
|
|
+ def test_collect_j6_host_sensor_real_fan_ptc_handles_discarded_ack_arrays(self) -> None:
|
|
|
|
|
+ powershell = shutil.which("powershell")
|
|
|
|
|
+ if powershell is None:
|
|
|
|
|
+ self.skipTest("PowerShell is not available")
|
|
|
|
|
+
|
|
|
|
|
+ script_path = ROOT / "tools" / "remote" / "collect-j6-host-sensor-real-fan-ptc.ps1"
|
|
|
|
|
+ script = script_path.read_text(encoding="utf-8-sig")
|
|
|
|
|
+ helper_start = script.index("function Read-HostPortAvailableLines")
|
|
|
|
|
+ helper_end = script.index("function Invoke-StartupPreflight")
|
|
|
|
|
+ helpers = script[helper_start:helper_end]
|
|
|
|
|
+
|
|
|
|
|
+ with tempfile.TemporaryDirectory() as tmp:
|
|
|
|
|
+ probe_path = Path(tmp) / "probe.ps1"
|
|
|
|
|
+ probe_path.write_text(
|
|
|
|
|
+ helpers
|
|
|
|
|
+ + """
|
|
|
|
|
+$hostRaw = New-Object System.Collections.Generic.List[byte]
|
|
|
|
|
+$hostWindow = New-Object System.Text.StringBuilder
|
|
|
|
|
+$hostReports = New-Object System.Collections.Generic.List[object]
|
|
|
|
|
+$queue = New-Object System.Collections.Generic.Queue[object]
|
|
|
|
|
+$queue.Enqueue([ordered]@{
|
|
|
|
|
+ ack_line = "OK seq=00000001 cmd=STATUS"
|
|
|
|
|
+ raw = "OK seq=00000001 cmd=STATUS"
|
|
|
|
|
+ token = "OK seq=00000001 cmd=STATUS"
|
|
|
|
|
+ class = "ok"
|
|
|
|
|
+ seq = 1
|
|
|
|
|
+ cmd = "STATUS"
|
|
|
|
|
+ ack_offset = 1
|
|
|
|
|
+ response_offset = 1
|
|
|
|
|
+ delimiter = "CR"
|
|
|
|
|
+ timestamp = (Get-Date).ToUniversalTime().ToString("o")
|
|
|
|
|
+}) | Out-Null
|
|
|
|
|
+$queue.Enqueue([ordered]@{
|
|
|
|
|
+ ack_line = "OK seq=00000001 cmd=PTCCH"
|
|
|
|
|
+ raw = "OK seq=00000001 cmd=PTCCH"
|
|
|
|
|
+ token = "OK seq=00000001 cmd=PTCCH"
|
|
|
|
|
+ class = "ok"
|
|
|
|
|
+ seq = 1
|
|
|
|
|
+ cmd = "PTCCH"
|
|
|
|
|
+ ack_offset = 10
|
|
|
|
|
+ response_offset = 10
|
|
|
|
|
+ delimiter = "CR"
|
|
|
|
|
+ timestamp = (Get-Date).ToUniversalTime().ToString("o")
|
|
|
|
|
+}) | Out-Null
|
|
|
|
|
+$serial = [pscustomobject]@{ BytesToRead = 0 }
|
|
|
|
|
+$ack = Read-HostAckLine $serial $hostRaw $hostWindow $hostReports $queue 5 200 1 "PTCCH"
|
|
|
|
|
+if ($ack.ack_line -ne "OK seq=00000001 cmd=PTCCH") { throw "candidate ack not returned: $($ack.ack_line)" }
|
|
|
|
|
+if ($ack.discarded_acks.Count -ne 1) { throw "discarded ack count was $($ack.discarded_acks.Count)" }
|
|
|
|
|
+if (-not $ack.discarded_acks[0].stale) { throw "discarded ack was not marked stale" }
|
|
|
|
|
+""",
|
|
|
|
|
+ encoding="utf-8",
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ result = subprocess.run(
|
|
|
|
|
+ [powershell, "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", str(probe_path)],
|
|
|
|
|
+ cwd=ROOT,
|
|
|
|
|
+ text=True,
|
|
|
|
|
+ capture_output=True,
|
|
|
|
|
+ check=False,
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ self.assertEqual(result.returncode, 0, result.stderr + result.stdout)
|
|
|
|
|
+
|
|
|
|
|
+ def test_collect_j6_host_sensor_real_fan_ptc_handles_timeout_discarded_ack_arrays(self) -> None:
|
|
|
|
|
+ powershell = shutil.which("powershell")
|
|
|
|
|
+ if powershell is None:
|
|
|
|
|
+ self.skipTest("PowerShell is not available")
|
|
|
|
|
+
|
|
|
|
|
+ script_path = ROOT / "tools" / "remote" / "collect-j6-host-sensor-real-fan-ptc.ps1"
|
|
|
|
|
+ script = script_path.read_text(encoding="utf-8-sig")
|
|
|
|
|
+ helper_start = script.index("function Read-HostPortAvailableLines")
|
|
|
|
|
+ helper_end = script.index("function Invoke-StartupPreflight")
|
|
|
|
|
+ helpers = script[helper_start:helper_end]
|
|
|
|
|
+
|
|
|
|
|
+ with tempfile.TemporaryDirectory() as tmp:
|
|
|
|
|
+ probe_path = Path(tmp) / "probe.ps1"
|
|
|
|
|
+ probe_path.write_text(
|
|
|
|
|
+ helpers
|
|
|
|
|
+ + """
|
|
|
|
|
+$hostRaw = New-Object System.Collections.Generic.List[byte]
|
|
|
|
|
+$hostWindow = New-Object System.Text.StringBuilder
|
|
|
|
|
+$hostReports = New-Object System.Collections.Generic.List[object]
|
|
|
|
|
+$queue = New-Object System.Collections.Generic.Queue[object]
|
|
|
|
|
+$queue.Enqueue([ordered]@{
|
|
|
|
|
+ ack_line = "OK seq=00000001 cmd=STATUS"
|
|
|
|
|
+ raw = "OK seq=00000001 cmd=STATUS"
|
|
|
|
|
+ token = "OK seq=00000001 cmd=STATUS"
|
|
|
|
|
+ class = "ok"
|
|
|
|
|
+ seq = 1
|
|
|
|
|
+ cmd = "STATUS"
|
|
|
|
|
+ ack_offset = 1
|
|
|
|
|
+ response_offset = 1
|
|
|
|
|
+ delimiter = "CR"
|
|
|
|
|
+ timestamp = (Get-Date).ToUniversalTime().ToString("o")
|
|
|
|
|
+}) | Out-Null
|
|
|
|
|
+$serial = [pscustomobject]@{ BytesToRead = 0 }
|
|
|
|
|
+$ack = Read-HostAckLine $serial $hostRaw $hostWindow $hostReports $queue 5 100 1 "PTCCH"
|
|
|
|
|
+if ($ack.class -ne "timeout") { throw "ack class was $($ack.class)" }
|
|
|
|
|
+if ($ack.discarded_acks.Count -ne 1) { throw "discarded ack count was $($ack.discarded_acks.Count)" }
|
|
|
|
|
+if (-not $ack.discarded_acks[0].stale) { throw "discarded ack was not marked stale" }
|
|
|
|
|
+""",
|
|
|
|
|
+ encoding="utf-8",
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ result = subprocess.run(
|
|
|
|
|
+ [powershell, "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", str(probe_path)],
|
|
|
|
|
+ cwd=ROOT,
|
|
|
|
|
+ text=True,
|
|
|
|
|
+ capture_output=True,
|
|
|
|
|
+ check=False,
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ self.assertEqual(result.returncode, 0, result.stderr + result.stdout)
|
|
|
|
|
+
|
|
|
def test_collect_j6_host_sensor_real_fan_ptc_preserves_empty_raw_replay_byte_array(self) -> None:
|
|
def test_collect_j6_host_sensor_real_fan_ptc_preserves_empty_raw_replay_byte_array(self) -> None:
|
|
|
powershell = shutil.which("powershell")
|
|
powershell = shutil.which("powershell")
|
|
|
if powershell is None:
|
|
if powershell is None:
|
|
@@ -330,6 +444,7 @@ if ($events[2].fields.cmd -ne "FANCH") { throw "ack cmd was $($events[2].fields.
|
|
|
"excluded_self_referential_file",
|
|
"excluded_self_referential_file",
|
|
|
]:
|
|
]:
|
|
|
self.assertIn(marker, script)
|
|
self.assertIn(marker, script)
|
|
|
|
|
+ self.assertNotIn("Set-ExecutionPolicy", script)
|
|
|
for marker in [
|
|
for marker in [
|
|
|
"formal-uart",
|
|
"formal-uart",
|
|
|
"j6-host-sensor-real-fan-ptc-formal-uart-debug921-v1",
|
|
"j6-host-sensor-real-fan-ptc-formal-uart-debug921-v1",
|
|
@@ -418,10 +533,16 @@ if ($events[2].fields.cmd -ne "FANCH") { throw "ack cmd was $($events[2].fields.
|
|
|
self.assertIn(f"-Profile {profile}", start_here)
|
|
self.assertIn(f"-Profile {profile}", start_here)
|
|
|
self.assertIn(f".\\bitstreams\\{bitstream.name}", start_here)
|
|
self.assertIn(f".\\bitstreams\\{bitstream.name}", start_here)
|
|
|
self.assertIn(f".\\td-receipts\\{td_receipt.name}", start_here)
|
|
self.assertIn(f".\\td-receipts\\{td_receipt.name}", start_here)
|
|
|
- self.assertIn(
|
|
|
|
|
- ".\\collector\\collect-j6-host-sensor-real-fan-ptc.ps1 -HostPort COM8 -DebugPort COM7",
|
|
|
|
|
- start_here,
|
|
|
|
|
|
|
+ self.assertIn("powershell.exe -NoProfile -ExecutionPolicy Bypass -File", start_here)
|
|
|
|
|
+ self.assertIn("-HostPort COM8 -DebugPort COM7", start_here)
|
|
|
|
|
+ self.assertNotIn("Set-ExecutionPolicy", start_here)
|
|
|
|
|
+ collect_template = (stage / "commands" / "collect-template.ps1").read_text(
|
|
|
|
|
+ encoding="utf-8-sig"
|
|
|
)
|
|
)
|
|
|
|
|
+ self.assertNotIn("Set-ExecutionPolicy", collect_template)
|
|
|
|
|
+ self.assertIn("-NoProfile", collect_template)
|
|
|
|
|
+ self.assertIn("-ExecutionPolicy Bypass", collect_template)
|
|
|
|
|
+ self.assertIn("-File .\\collector\\collect-j6-host-sensor-real-fan-ptc.ps1", collect_template)
|
|
|
self.assertNotIn("blocked_pin_conflict_with_locked_debug_uart", start_here)
|
|
self.assertNotIn("blocked_pin_conflict_with_locked_debug_uart", start_here)
|
|
|
|
|
|
|
|
manifest = json.loads((stage / "manifest.json").read_text(encoding="utf-8-sig"))
|
|
manifest = json.loads((stage / "manifest.json").read_text(encoding="utf-8-sig"))
|