run_windows_validation.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env python3
  2. """Run the real Windows Qt binary with bundled DLLs; fixtures never touch BMC."""
  3. import argparse
  4. import json
  5. import os
  6. from pathlib import Path
  7. import subprocess
  8. parser = argparse.ArgumentParser()
  9. parser.add_argument('--release', type=Path, default=Path(r'C:\Users\Administrator\delivery\XJKJ-STL-Qt-Clean-0.8.1.1.dev0'))
  10. args = parser.parse_args()
  11. app = args.release / 'app'
  12. evidence = args.release / 'evidence'
  13. evidence.mkdir(exist_ok=True)
  14. env = dict(os.environ, QT_QPA_PLATFORM='offscreen', STL_QT_DISABLE_SERIAL='1')
  15. env['PATH'] = os.path.join(env.get('SystemRoot', r'C:\Windows'), 'System32') + ';' + env.get('SystemRoot', r'C:\Windows')
  16. for key in ('QT_PLUGIN_PATH', 'QT_QPA_PLATFORM_PLUGIN_PATH', 'QTDIR', 'STL_QT_CONFIG_DIR', 'STL_QT_PLANS_FILE', 'STL_QT_BACKEND_URL'):
  17. env.pop(key, None)
  18. summary = []
  19. for mode in ['fixture', 'fixture-amt', 'fixture-fail', 'fixture-unexpected-boot', 'fixture-silent', 'read-only']:
  20. label = 'windows-qt-' + mode
  21. report = evidence / (label + '.json')
  22. command = [str(app / 'QtCleanProbe.exe'), '--mode', mode, '--report', str(report),
  23. '--screenshot', str(evidence / (label + '.png')), '--timeout', '45']
  24. if mode == 'read-only':
  25. command.extend(['--url', 'ws://192.168.2.79:8080/ws?view=qt-clean'])
  26. with (evidence / (label + '.log')).open('w', encoding='utf-8') as out:
  27. process = subprocess.run(command, cwd=app, env=env, stdout=out, stderr=subprocess.STDOUT, timeout=65)
  28. data = json.loads(report.read_text(encoding='utf-8')) if report.exists() else {}
  29. negative = mode in ('fixture-fail', 'fixture-unexpected-boot')
  30. passed = process.returncode == (1 if negative else 0) and data.get('pass') is not negative
  31. if negative:
  32. passed = passed and data.get('checks', {}).get('no_firmware_execution_failure') is False
  33. if mode == 'fixture-unexpected-boot':
  34. passed = passed and data.get('checks', {}).get('unexpected_boot_failure_is_prompt') is True
  35. passed = passed and data.get('checks', {}).get('unexpected_boot_stopped_with_pending_stage') is True
  36. row = {'mode': mode, 'exit_code': process.returncode, 'expected_negative': negative,
  37. 'passed': passed, 'checks': len(data.get('checks', {})),
  38. 'elapsed_ms': data.get('elapsed_ms'),
  39. 'false_checks': [key for key, value in data.get('checks', {}).items() if value is False]}
  40. summary.append(row)
  41. print(json.dumps(row), flush=True)
  42. result = {'passed': all(row['passed'] for row in summary), 'os': os.name,
  43. 'uses_bundled_runtime_without_sdk_path': True, 'scenarios': summary}
  44. (evidence / 'windows-qt-validation-summary.json').write_text(json.dumps(result, indent=2) + '\n', encoding='utf-8')
  45. raise SystemExit(0 if result['passed'] else 1)