test_fw_6400_v1_entrypoint.py 1.5 KB

1234567891011121314151617181920212223242526
  1. from pathlib import Path
  2. from unittest import mock
  3. import json
  4. import pytest
  5. from tools import fw_cli
  6. @pytest.mark.parametrize('target,unit_code,rtl_code,expected',[
  7. ('6400',0,0,0),('6400',0,7,7),('all',5,0,5),('all',0,7,7)])
  8. def test_current_regression_routes_and_retains_failures(tmp_path,target,unit_code,rtl_code,expected):
  9. calls=[]
  10. def process(command,**kwargs):
  11. calls.append(command)
  12. xml=Path(next(x.split('=',1)[1] for x in command if x.startswith('--junitxml=')))
  13. xml.write_text(f'<testsuites><testsuite tests="1" failures="{int(unit_code!=0)}" errors="0"/></testsuites>')
  14. fake=mock.Mock();fake.wait.return_value=unit_code;return fake
  15. with mock.patch.object(fw_cli.sys,'platform','linux'),mock.patch.object(fw_cli,'_generate_one'),\
  16. mock.patch.object(fw_cli,'source_identity',return_value={'source_kind':'fixture'}),\
  17. mock.patch.object(fw_cli.subprocess,'Popen',side_effect=process),\
  18. mock.patch.object(fw_cli,'cmd_diagnose',return_value=rtl_code) as rtl:
  19. assert fw_cli.main(['test',target,'--run-root',str(tmp_path/'run')])==expected
  20. assert '-m' in calls[0] and 'pytest' in calls[0]
  21. assert not any('run_6400_v1.py' in x or 'run_verification_matrix.py' in x for x in calls[0])
  22. assert rtl.call_args.args[0].target==('all' if target=='all' else '6400-front-rear')
  23. report=json.loads((tmp_path/'run/RESULT.json').read_text())
  24. assert report['status']==('PASS' if expected==0 else 'FAIL')
  25. assert report['complete'] is True