Skip to content

Commit d4e565f

Browse files
author
Mirror Bot
committed
Mirror from private (71c952b4)
1 parent 8f7f00c commit d4e565f

3 files changed

Lines changed: 72 additions & 12 deletions

File tree

‎Tests/WhatCableCoreTests/SnapshotCorpusTests.swift‎

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,20 +114,49 @@ struct SnapshotCorpusTests {
114114
#expect(throws: TypedValue.DecodeError.self) { try RegistrySnapshot(Self.file([other])) }
115115
}
116116

117-
@Test("Every linked run's snapshot loads complete")
117+
@Test("Every linked run's snapshot loads complete, or stopped or missing as the contract allows")
118118
func linkedRunsLoad() throws {
119119
// No research-data link (private; absent on a fresh clone or the public repo) is a legitimate skip. A
120120
// runs folder that exists but holds no runs is a broken link, and must
121121
// fail rather than pass on nothing.
122+
//
123+
// Two shapes are not complete snapshots and are still correct
124+
// (first met 2026-11-12):
125+
// - stopped with `identifiers_incomplete`: FORMAT.md lets any probe
126+
// stop that way, header then footer, no records, `step` naming the
127+
// lookup that failed. Every probe on an Intel Mac with Bluetooth
128+
// does (an Intel iMac run, step `bluetooth`).
129+
// - no snapshot file in a run the worker never confirmed (`run.json`
130+
// summary absent or not complete): the ingest writes such a run
131+
// once it is over 24 hours old, with whatever probes reached KV.
132+
// A confirmed run without a snapshot, or any other stop, still fails.
122133
var isDir: ObjCBool = false
123134
guard FileManager.default.fileExists(atPath: SnapshotCorpus.root.path, isDirectory: &isDir), isDir.boolValue else { return }
124135
let runs = SnapshotCorpus.allRuns()
125136
#expect(!runs.isEmpty, "\(SnapshotCorpus.root.path) exists but holds no runs")
137+
var complete = 0
126138
for run in runs {
127-
let file = try #require(try SnapshotCorpus.load(run: run, probe: "50_registry_snapshot"),
128-
"\(run.lastPathComponent) has no 50_registry_snapshot.jsonl")
129-
#expect(file.isComplete, "\(run.lastPathComponent): snapshot was cut off")
130-
#expect(try RegistrySnapshot(file).entries.count > 0, "\(run.lastPathComponent): no entries")
139+
let name = run.lastPathComponent
140+
guard let file = try SnapshotCorpus.load(run: run, probe: "50_registry_snapshot") else {
141+
let meta = try? JSONSerialization.jsonObject(
142+
with: Data(contentsOf: run.appendingPathComponent("run.json"))) as? [String: Any]
143+
let summary = meta?["summary"] as? [String: Any]
144+
#expect(meta != nil, "\(name) has no 50_registry_snapshot.jsonl and no readable run.json")
145+
#expect(summary?["complete"] as? Bool != true,
146+
"\(name) has no 50_registry_snapshot.jsonl though the worker confirmed the run complete")
147+
continue
148+
}
149+
if file.footer?["status"] as? String == "stopped",
150+
file.footer?["reason"] as? String == "identifiers_incomplete" {
151+
#expect(file.records.isEmpty, "\(name): stopped for identifiers but holds records")
152+
let step = file.footer?["step"] as? String ?? ""
153+
#expect(step.count > 0, "\(name): stopped for identifiers with no step")
154+
continue
155+
}
156+
#expect(file.isComplete, "\(name): snapshot was cut off")
157+
#expect(try RegistrySnapshot(file).entries.count > 0, "\(name): no entries")
158+
complete += 1
131159
}
160+
#expect(runs.isEmpty || complete > 0, "no linked run has a complete snapshot: checked nothing")
132161
}
133162
}

‎Tests/WhatCableDarwinTests/AppleTypeCPhyClassCoverageTests.swift‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@ import Testing
3333
// never report the leaf. Probe 41 still would, and its chain would no
3434
// longer contain the matched name, which is the miss this test is for.
3535
//
36-
// A leaf seen in probe 31 with no probe 41 row cannot be judged and is
37-
// reported as a miss too. Probe 41 has shipped in the test kit since
38-
// 2026-08-09, so a new chip arrives with both probes and a miss means "look".
36+
// A leaf seen in probe 31 with no probe 41 row is judged by probe 31 alone.
37+
// Probe 31 lists a leaf under its `AppleTypeCPhy[N]` headers only because
38+
// `IOServiceMatching("AppleTypeCPhy")` returned it, so the leaf is reached
39+
// exactly when the watcher still matches that base name. The renamed-base
40+
// miss above prints no such header, so it is still caught through probe 41.
41+
// This was a blanket miss until the first complete M3 Ultra capture
42+
// (`m3ultra_macos27.2`, 2026-11-12): an older client with no probe 41,
43+
// reporting `AppleT6032TypeCPhy` under the base header.
3944
@Suite("AppleTypeCPhy class coverage (probes 31 and 41)")
4045
struct AppleTypeCPhyClassCoverageTests {
4146

@@ -106,6 +111,8 @@ struct AppleTypeCPhyClassCoverageTests {
106111
}
107112

108113
let matched = Set(AppleTypeCPhyWatcher.candidateClasses)
114+
// The class probe 31 matches (`31_typec_phy_properties.c:131`).
115+
let probe31Base = "AppleTypeCPhy"
109116
// IOServiceMatching(X) returns X and every subclass of X. A leaf is
110117
// reached when the watcher matches it by name, or when every ancestry
111118
// chain the kernel has reported for it contains a matched class.
@@ -114,7 +121,11 @@ struct AppleTypeCPhyClassCoverageTests {
114121
// folder's older chain.
115122
func reached(_ leaf: String) -> Bool {
116123
if matched.contains(leaf) { return true }
117-
guard let leafChains = chains[leaf], !leafChains.isEmpty else { return false }
124+
guard let leafChains = chains[leaf], !leafChains.isEmpty else {
125+
// No kernel chain: probe 31's base-class header is the
126+
// evidence (see the header comment).
127+
return observed[leaf] != nil && matched.contains(probe31Base)
128+
}
118129
return leafChains.allSatisfy { chain in chain.contains(where: matched.contains) }
119130
}
120131
// Leaves from both probes. Probe 31 matches `AppleTypeCPhy` by the

‎Tests/WhatCableDarwinTests/DisplayTimingReaderProbeSweepTests.swift‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ import Testing
2424
// EDID's one SVD covers both, so a driven timing at exactly refresh/1.001 of
2525
// a declared VIC counts as declared. Those nodes are named and counted apart.
2626
//
27+
// A node can also publish a declared timing at its nominal rate. The Dell
28+
// U3224KB on `m3ultra_macos27.2` (2026-11-12) declares 6144x3456 in a DisplayID
29+
// Type I block at 1378.80 MHz over 6464 x 3555 totals, which is 60.00125 Hz;
30+
// its node carries the same totals and porches with a vertical PreciseSyncRate
31+
// of exactly 0x3c0000 (60.000 Hz), so totals times refresh is 28.8 kHz short of
32+
// the declared clock. When the claimed node's totals equal a declared mode's
33+
// and the refreshes differ by under 0.01 Hz, it is the declared mode with the
34+
// rate rounded, not an undeclared one. Those are named and counted apart too.
35+
//
2736
// The parser and the probe-33 pairing are shared with DisplayDiagnosticProbeSweepTests through CorpusDisplayProbes.swift.
2837

2938
@Suite("DisplayTimingReader -- probe-26 corpus sweep")
@@ -46,6 +55,7 @@ struct DisplayTimingReaderProbeSweepTests {
4655
var claimedNodes = 0
4756
var comparedExact = 0
4857
var alternateRate: [String] = []
58+
var nominalRate: [String] = []
4959
var mismatches: [String] = []
5060
var singleDepth = 0
5161
var nodesWithTiming = 0
@@ -82,6 +92,7 @@ struct DisplayTimingReaderProbeSweepTests {
8292
// (a match defect) is recorded rather than counted.
8393
var pool = nodes
8494
for (entry, port) in zip(ports, matched) {
95+
var claimedTiming: DisplayTimingReader.Timing?
8596
guard let mode = port.currentMode, let clock = mode.pixelClockHz else { continue }
8697
attachedPorts += 1
8798
let key = DisplayTimingReader.edidKey(from: entry.port.monitor?.edid ?? Data())
@@ -90,7 +101,7 @@ struct DisplayTimingReaderProbeSweepTests {
90101
$0.edidKey == key && $0.currentTiming?.pixelClockHz == clock
91102
&& (portSerial == 0 || ($0.serialNumber ?? 0) == 0 || $0.serialNumber == portSerial)
92103
}) {
93-
pool.remove(at: index)
104+
claimedTiming = pool.remove(at: index).currentTiming
94105
claimedNodes += 1
95106
} else {
96107
Issue.record("\(folder) block \(entry.block): attached a timing no unclaimed node explains (a node attached twice?)")
@@ -108,17 +119,26 @@ struct DisplayTimingReaderProbeSweepTests {
108119
&& abs(Double($0.pixelClockHz) / 1.001 - Double(clock)) <= 1000
109120
}
110121
if alternate { alternateRate.append(tag + " (declared at x1.001)"); continue }
122+
if let timing = claimedTiming, entry.edid.modes.contains(where: {
123+
$0.width == mode.width && $0.height == mode.height
124+
&& $0.hTotal == timing.hTotal && $0.vTotal == timing.vTotal
125+
&& abs($0.refreshHz - mode.refreshHz) < 0.01
126+
}) {
127+
nominalRate.append(tag + " (declared totals, rate rounded)")
128+
continue
129+
}
111130
mismatches.append(tag + " is not among the EDID's \(entry.edid.modes.count) declared modes")
112131
}
113132
for node in pool {
114133
unpaired.append("\(folder) \(node.edidKey) serial \(node.serialNumber ?? 0): no single probe-33 block with that EDID identity")
115134
}
116135
}
117136

118-
print("DisplayTimingReaderProbeSweep: \(foldersWithProbe26) folders with probe 26; \(nodesWithTables) external nodes with tables \(byClass); \(nodesWithTiming) with the current timing captured, \(notCaptured.count) not captured; \(attachedPorts) ports attached (\(claimedNodes) nodes claimed), \(unpaired.count) nodes unpaired; compared: \(comparedExact) exact, \(alternateRate.count) at the CTA alternate rate, \(mismatches.count) mismatches; \(singleDepth) timings with a single depth")
137+
print("DisplayTimingReaderProbeSweep: \(foldersWithProbe26) folders with probe 26; \(nodesWithTables) external nodes with tables \(byClass); \(nodesWithTiming) with the current timing captured, \(notCaptured.count) not captured; \(attachedPorts) ports attached (\(claimedNodes) nodes claimed), \(unpaired.count) nodes unpaired; compared: \(comparedExact) exact, \(alternateRate.count) at the CTA alternate rate, \(nominalRate.count) at a rounded rate, \(mismatches.count) mismatches; \(singleDepth) timings with a single depth")
119138
for line in notCaptured { print(" NOT CAPTURED \(line)") }
120139
for line in unpaired { print(" UNPAIRED \(line)") }
121140
for line in alternateRate { print(" ALTERNATE RATE \(line)") }
141+
for line in nominalRate { print(" ROUNDED RATE \(line)") }
122142
for line in mismatches { print(" MISMATCH \(line)") }
123143

124144
// Non-vacuity: a corpus that exists but yields no node must not pass quietly. The run
@@ -127,7 +147,7 @@ struct DisplayTimingReaderProbeSweepTests {
127147
#expect(nodesWithTables > 0, "no external node with tables: checked at least one")
128148
#expect(mismatches.isEmpty, "\(mismatches.count) driven timings the EDID does not declare:\n\(mismatches.joined(separator: "\n"))")
129149
#expect(attachedPorts == claimedNodes, "a port attached a timing no node explains: \(attachedPorts) ports for \(claimedNodes) nodes")
130-
#expect(comparedExact + alternateRate.count + mismatches.count == attachedPorts, "every attached port is compared")
150+
#expect(comparedExact + alternateRate.count + nominalRate.count + mismatches.count == attachedPorts, "every attached port is compared")
131151
#expect(claimedNodes + unpaired.count == nodesWithTiming, "every captured node is attached or named unpaired")
132152
#expect(nodesWithTiming + notCaptured.count == nodesWithTables, "every node is accounted for")
133153
}

0 commit comments

Comments
 (0)