"""Synthetic guard fixtures only; these tests are not desktop acceptance evidence."""
import copy
import hashlib
import json
from pathlib import Path
import tempfile
import unittest
from CheckAcceptance import compare, verify_raw
STANDARD = json.loads(Path(__file__).with_name('Standard.json').read_text())
def fixture(platform):
# Compact but complete structural fixture, with the real standard's 30s,
# five runs, 240 Hz cadence and sample counts.
run = {'activeSeconds': 30, 'warmupSeconds': 5, 'changedFrames': 7201,
'displayIntervalsMs': [1000/240]*7200, 'inputToDisplayMs': [8.0]*100,
'errors': 0, 'lostInputs': 0, 'tearing': False, 'readyMs': 100,
'contentSha256': '1'*64, 'actionsSha256': '2'*64}
return {'platform': platform, 'measurementLayer': 'PhysicalDisplay', 'physicalScanout': True,
'width': 3840, 'height': 2160, 'refreshMilliHz': 240000, 'rawEvidenceVerified': True,
'context': dict(machine='fixture', monitor='fixture', cable='fixture', scaling=200,
inputRateHz=1000, powerPolicy='fixture', loadProfile='fixture'),
'workloads': {x['Id']: [copy.deepcopy(run) for _ in range(5)] for x in STANDARD['Workloads']}}
class AcceptanceGuards(unittest.TestCase):
def setUp(self):
self.before, self.after = fixture('Windows'), fixture('XFESystem')
def test_structural_control(self):
self.assertTrue(compare(self.before, self.after)['WindowsFluidityParityPassed'])
def test_missing_and_wrong_modes(self):
for field, value in [('width',1280), ('height',800), ('refreshMilliHz',60000),
('refreshMilliHz',None), ('physicalScanout',False),
('measurementLayer','FramebufferCopy'), ('rawEvidenceVerified',False)]:
with self.subTest(field=field, value=value):
after = copy.deepcopy(self.after); after[field] = value
self.assertFalse(compare(self.before, after)['WindowsFluidityParityPassed'])
def test_incomplete_pilot_cannot_pass(self):
self.after['workloads']['pointer'] = self.after['workloads']['pointer'][:1]
self.assertFalse(compare(self.before, self.after)['WindowsFluidityParityPassed'])
def test_renderer_target_and_duplicate_frames_cannot_pass(self):
self.after['physicalScanout'] = False
self.after['measurementLayer'] = 'SoftwarePresent'
result = compare(self.before, self.after)
self.assertFalse(result['WindowsFluidityParityPassed']); self.assertFalse(result['Physical240HzVerified'])
def test_invalid_and_missing_run_evidence(self):
changes = [('activeSeconds',2), ('warmupSeconds',0), ('errors',1), ('lostInputs',1), ('tearing',True),
('inputToDisplayMs',[]), ('displayIntervalsMs',[0]*7200), ('changedFrames',9000),
('contentSha256','different'), ('actionsSha256','different')]
for field, value in changes:
with self.subTest(field=field):
after = copy.deepcopy(self.after); after['workloads']['pointer'][0][field] = value
self.assertFalse(compare(self.before, after)['WindowsFluidityParityPassed'])
def test_tail_latency_and_slow_ready_fail(self):
for field, value, workload in [('displayIntervalsMs',[8.0]*7200,'pointer'),
('inputToDisplayMs',[50.0]*100,'text-typing'),
('readyMs',9000,'cold-editor')]:
with self.subTest(field=field):
after=copy.deepcopy(self.after); after['workloads'][workload][0][field]=value
self.assertFalse(compare(self.before, after)['WindowsFluidityParityPassed'])
def test_missing_test_conditions_fail(self):
self.after['context']['scaling']=100
self.assertFalse(compare(self.before, self.after)['WindowsFluidityParityPassed'])
def test_raw_hash_and_canonical_sample_binding(self):
with tempfile.TemporaryDirectory() as directory:
root=Path(directory); path=root/'Raw.json'
raw=json.dumps({'Kind':'XfeCanonicalPhysicalWorkloads','workloads':self.after['workloads']}).encode()
path.write_bytes(raw)
self.after['rawEvidence']=[{'Path':path.name,'Sha256':hashlib.sha256(raw).hexdigest()}]
verify_raw(self.after,root)
self.after['workloads']['pointer'][0]['readyMs']=42
with self.assertRaises(ValueError): verify_raw(self.after,root)
path.write_bytes(b'changed')
with self.assertRaises(ValueError): verify_raw(self.after,root)
if __name__ == '__main__': unittest.main()
"""Synthetic guard fixtures only; these tests are not desktop acceptance evidence."""
import copy
import hashlib
import json
from pathlib import Path
import tempfile
import unittest
from CheckAcceptance import compare, verify_raw
STANDARD = json.loads(Path(__file__).with_name('Standard.json').read_text())
def fixture(platform):
# Compact but complete structural fixture, with the real standard's 30s,
# five runs, 240 Hz cadence and sample counts.
run = {'activeSeconds': 30, 'warmupSeconds': 5, 'changedFrames': 7201,
'displayIntervalsMs': [1000/240]*7200, 'inputToDisplayMs': [8.0]*100,
'errors': 0, 'lostInputs': 0, 'tearing': False, 'readyMs': 100,
'contentSha256': '1'*64, 'actionsSha256': '2'*64}
return {'platform': platform, 'measurementLayer': 'PhysicalDisplay', 'physicalScanout': True,
'width': 3840, 'height': 2160, 'refreshMilliHz': 240000, 'rawEvidenceVerified': True,
'context': dict(machine='fixture', monitor='fixture', cable='fixture', scaling=200,
inputRateHz=1000, powerPolicy='fixture', loadProfile='fixture'),
'workloads': {x['Id']: [copy.deepcopy(run) for _ in range(5)] for x in STANDARD['Workloads']}}
class AcceptanceGuards(unittest.TestCase):
def setUp(self):
self.before, self.after = fixture('Windows'), fixture('XFESystem')
def test_structural_control(self):
self.assertTrue(compare(self.before, self.after)['WindowsFluidityParityPassed'])
def test_missing_and_wrong_modes(self):
for field, value in [('width',1280), ('height',800), ('refreshMilliHz',60000),
('refreshMilliHz',None), ('physicalScanout',False),
('measurementLayer','FramebufferCopy'), ('rawEvidenceVerified',False)]:
with self.subTest(field=field, value=value):
after = copy.deepcopy(self.after); after[field] = value
self.assertFalse(compare(self.before, after)['WindowsFluidityParityPassed'])
def test_incomplete_pilot_cannot_pass(self):
self.after['workloads']['pointer'] = self.after['workloads']['pointer'][:1]
self.assertFalse(compare(self.before, self.after)['WindowsFluidityParityPassed'])
def test_renderer_target_and_duplicate_frames_cannot_pass(self):
self.after['physicalScanout'] = False
self.after['measurementLayer'] = 'SoftwarePresent'
result = compare(self.before, self.after)
self.assertFalse(result['WindowsFluidityParityPassed']); self.assertFalse(result['Physical240HzVerified'])
def test_invalid_and_missing_run_evidence(self):
changes = [('activeSeconds',2), ('warmupSeconds',0), ('errors',1), ('lostInputs',1), ('tearing',True),
('inputToDisplayMs',[]), ('displayIntervalsMs',[0]*7200), ('changedFrames',9000),
('contentSha256','different'), ('actionsSha256','different')]
for field, value in changes:
with self.subTest(field=field):
after = copy.deepcopy(self.after); after['workloads']['pointer'][0][field] = value
self.assertFalse(compare(self.before, after)['WindowsFluidityParityPassed'])
def test_tail_latency_and_slow_ready_fail(self):
for field, value, workload in [('displayIntervalsMs',[8.0]*7200,'pointer'),
('inputToDisplayMs',[50.0]*100,'text-typing'),
('readyMs',9000,'cold-editor')]:
with self.subTest(field=field):
after=copy.deepcopy(self.after); after['workloads'][workload][0][field]=value
self.assertFalse(compare(self.before, after)['WindowsFluidityParityPassed'])
def test_missing_test_conditions_fail(self):
self.after['context']['scaling']=100
self.assertFalse(compare(self.before, self.after)['WindowsFluidityParityPassed'])
def test_raw_hash_and_canonical_sample_binding(self):
with tempfile.TemporaryDirectory() as directory:
root=Path(directory); path=root/'Raw.json'
raw=json.dumps({'Kind':'XfeCanonicalPhysicalWorkloads','workloads':self.after['workloads']}).encode()
path.write_bytes(raw)
self.after['rawEvidence']=[{'Path':path.name,'Sha256':hashlib.sha256(raw).hexdigest()}]
verify_raw(self.after,root)
self.after['workloads']['pointer'][0]['readyMs']=42
with self.assertRaises(ValueError): verify_raw(self.after,root)
path.write_bytes(b'changed')
with self.assertRaises(ValueError): verify_raw(self.after,root)
if __name__ == '__main__': unittest.main()