|
|
@@ -318,6 +318,60 @@ if (-not $ack.seq_match -or -not $ack.cmd_match) { throw "formal ack mismatch" }
|
|
|
|
|
|
self.assertEqual(result.returncode, 0, result.stderr + result.stdout)
|
|
|
|
|
|
+ def test_collect_j6_host_sensor_real_fan_ptc_marks_clear_queue_results_as_pre_sram_noise(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 Clear-HostAckQueue")
|
|
|
+ helper_end = script.index("function Update-PreflightEpochReady")
|
|
|
+ helpers = script[helper_start:helper_end]
|
|
|
+
|
|
|
+ with tempfile.TemporaryDirectory() as tmp:
|
|
|
+ probe_path = Path(tmp) / "probe.ps1"
|
|
|
+ probe_path.write_text(
|
|
|
+ helpers
|
|
|
+ + """
|
|
|
+$preflight = New-StartupPreflightRecord
|
|
|
+$ackQueue = New-Object System.Collections.Generic.Queue[object]
|
|
|
+$ackQueue.Enqueue([ordered]@{
|
|
|
+ ack_line = "OK seq=0000000D cmd=STATUS"
|
|
|
+ raw = "OK seq=0000000D cmd=STATUS"
|
|
|
+ token = "OK seq=0000000D cmd=STATUS"
|
|
|
+ class = "ok"
|
|
|
+ seq = 13
|
|
|
+ cmd = "STATUS"
|
|
|
+ ack_offset = 25
|
|
|
+ response_offset = 25
|
|
|
+ delimiter = "CR"
|
|
|
+ timestamp = (Get-Date).ToUniversalTime().ToString("o")
|
|
|
+}) | Out-Null
|
|
|
+$moreStale = @(Clear-HostAckQueue $ackQueue)
|
|
|
+foreach ($ack in $moreStale) {
|
|
|
+ Set-AckMetadata $ack "pre_sram_noise" $true
|
|
|
+ Add-PreSramNoise $preflight "ack" $ack
|
|
|
+}
|
|
|
+if ($moreStale.Count -ne 1) { throw "unexpected stale count $($moreStale.Count)" }
|
|
|
+if ($moreStale[0] -is [array]) { throw "stale ack was nested array" }
|
|
|
+if (-not $moreStale[0].pre_sram_noise) { throw "pre_sram_noise was not set" }
|
|
|
+if ($preflight.pre_sram_noise_count -ne 1) { throw "preflight noise count was $($preflight.pre_sram_noise_count)" }
|
|
|
+if ($preflight.pre_sram_noise[0].ack_line -ne "OK seq=0000000D cmd=STATUS") { throw "wrong pre_sram noise ack" }
|
|
|
+""",
|
|
|
+ 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:
|