run_qt_fixtures.py 1.8 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env python3
  2. import json
  3. import os
  4. from pathlib import Path
  5. import subprocess
  6. release = Path('/home/user/XJKJ-STL-qt-clean-0.8.0')
  7. binary = release / 'qt-client/build-probe/QtCleanProbe'
  8. evidence = release / 'evidence'
  9. env = dict(os.environ, QT_QPA_PLATFORM='offscreen')
  10. env.pop('LD_LIBRARY_PATH', None)
  11. summary = []
  12. for mode in ['fixture', 'fixture-amt', 'fixture-fail', 'fixture-unexpected-boot']:
  13. report = evidence / ('qt-' + mode + '.json')
  14. with (evidence / ('qt-' + mode + '.log')).open('w') as out:
  15. p = subprocess.run([str(binary), '--mode', mode, '--report', str(report),
  16. '--screenshot', str(evidence / ('qt-' + mode + '.png')), '--timeout', '45'],
  17. env=env, stdout=out, stderr=subprocess.STDOUT, timeout=60)
  18. data = json.loads(report.read_text()) if report.exists() else {}
  19. negative = mode in ('fixture-fail', 'fixture-unexpected-boot')
  20. passed = p.returncode == (1 if negative else 0) and data.get('pass') is not negative
  21. if negative:
  22. passed = passed and data.get('checks', {}).get('no_firmware_execution_failure') is False
  23. if mode == 'fixture-unexpected-boot':
  24. passed = passed and data.get('checks', {}).get('unexpected_boot_failure_is_prompt') is True
  25. passed = passed and data.get('checks', {}).get('unexpected_boot_stopped_with_pending_stage') is True
  26. row = {'mode': mode, 'exit_code': p.returncode, 'expected_negative': negative,
  27. 'passed': passed, 'checks': len(data.get('checks', {})),
  28. 'false_checks': [key for key, value in data.get('checks', {}).items() if value is False]}
  29. summary.append(row)
  30. print(json.dumps(row), flush=True)
  31. (evidence / 'qt-fixtures-summary.json').write_text(json.dumps(summary, indent=2) + '\n')
  32. raise SystemExit(0 if all(row['passed'] for row in summary) else 1)