#!/usr/bin/env python3 # Copyright (C) 2026 Yusuke Oda # SPDX-License-Identifier: AGPL-3.0-only """Validate DX09 prepared states against the pre-existing 120-second records.""" from pathlib import Path import json import subprocess ROOT = Path(__file__).resolve().parents[2] CODE = Path(__file__).resolve().parent old = json.loads((ROOT / 'dynamics/results/silence-state.json').read_text())['cases'] plan = json.loads((CODE / 'plan.json').read_text()) records = [] for job in plan['jobs']: argv = [str(ROOT / job['argv'][0]), *job['argv'][1:-1], '0'] row = json.loads(subprocess.check_output(argv, text=True)) reference = next(x for x in old if x['component'] == 'Compressor' and x['method'] == row['method'] and x['precision'] == row['precision'] and x['flush'] == row['flush']) expected = reference['states'][-1] assert row['prepared_state']['values'] == expected['values'], job['id'] assert row['prepared_state']['subnormal'] == expected['subnormal'], job['id'] assert row['peak'] == row['rms'] == 0 and row['mxcsr_restored'] for key in ['elapsed_ns', 'ns_per_frame', 'burn_in_ns', 'burn_in_cycles']: row.pop(key) row['prepared_state_matches_existing_silence'] = True records.append(row) destination = CODE / 'results' destination.mkdir(exist_ok=True) (destination / 'validation.json').write_text(json.dumps({'passed': True, 'cases': records}, indent=2) + '\n') print(json.dumps({'passed': True, 'cases': len(records)}))