example_test.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from __future__ import unicode_literals
  2. import os
  3. import re
  4. import ttfw_idf
  5. @ttfw_idf.idf_example_test(env_tag="test_jtag_arm")
  6. def test_examples_app_trace_to_host(env, extra_data):
  7. rel_project_path = os.path.join('examples', 'system', 'app_trace_to_host')
  8. dut = env.get_dut('app_trace_to_host', rel_project_path)
  9. idf_path = dut.app.get_sdk_path()
  10. proj_path = os.path.join(idf_path, rel_project_path)
  11. with ttfw_idf.OCDBackend(os.path.join(proj_path, 'openocd.log'), dut.app.target) as ocd:
  12. dut.start_app()
  13. dut.expect_all('example: Enabling ADC1 on channel 6 / GPIO34.',
  14. 'example: Enabling CW generator on DAC channel 1',
  15. 'example: Custom divider of RTC 8 MHz clock has been set.',
  16. 'example: Sampling ADC and sending data to the host...',
  17. re.compile(r'example: Collected \d+ samples in 20 ms.'),
  18. 'example: Sampling ADC and sending data to the UART...',
  19. re.compile(r'example: Sample:\d, Value:\d+'),
  20. re.compile(r'example: Collected \d+ samples in 20 ms.'),
  21. timeout=20)
  22. response = ocd.cmd_exec('esp apptrace start file://adc.log 0 9000 5 0 0')
  23. with open(os.path.join(proj_path, 'telnet.log'), 'w') as f:
  24. f.write(response)
  25. assert('Data: blocks incomplete 0, lost bytes: 0' in response)
  26. with ttfw_idf.CustomProcess(' '.join([os.path.join(idf_path, 'tools/esp_app_trace/logtrace_proc.py'),
  27. 'adc.log',
  28. os.path.join(dut.app.get_binary_path(rel_project_path),
  29. 'app_trace_to_host.elf')]),
  30. logfile='logtrace_proc.log') as logtrace:
  31. logtrace.pexpect_proc.expect_exact('Parse trace file')
  32. logtrace.pexpect_proc.expect_exact('Parsing completed.')
  33. logtrace.pexpect_proc.expect_exact('====================================================================')
  34. logtrace.pexpect_proc.expect(re.compile(r'example: Sample:\d+, Value:\d+'))
  35. logtrace.pexpect_proc.expect_exact('====================================================================')
  36. logtrace.pexpect_proc.expect(re.compile(r'Log records count: \d+'))
  37. if __name__ == '__main__':
  38. test_examples_app_trace_to_host()