example_test.py 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. oocd_log_path = os.path.join(proj_path, 'openocd.log')
  12. with ttfw_idf.OCDProcess(oocd_log_path):
  13. with ttfw_idf.TelnetProcess(os.path.join(proj_path, 'telnet.log')) as telnet_p:
  14. dut.start_app()
  15. dut.expect_all('example: Enabling ADC1 on channel 6 / GPIO34.',
  16. 'example: Enabling CW generator on DAC channel 1',
  17. 'example: Custom divider of RTC 8 MHz clock has been set.',
  18. 'example: Sampling ADC and sending data to the host...',
  19. re.compile(r'example: Collected \d+ samples in 20 ms.'),
  20. 'example: Sampling ADC and sending data to the UART...',
  21. re.compile(r'example: Sample:\d, Value:\d+'),
  22. re.compile(r'example: Collected \d+ samples in 20 ms.'),
  23. timeout=20)
  24. telnet_p.pexpect_proc.sendline('esp apptrace start file://adc.log 0 9000 5 0 0')
  25. telnet_p.pexpect_proc.expect_exact('App trace params: from 2 cores, size 9000 bytes, '
  26. 'stop_tmo 5 s, poll period 0 ms, wait_rst 0, skip 0 bytes')
  27. telnet_p.pexpect_proc.expect_exact('Targets connected.')
  28. telnet_p.pexpect_proc.expect_exact('Targets disconnected.')
  29. telnet_p.pexpect_proc.expect_exact('Tracing is STOPPED. Size is 9000 of 9000 @')
  30. telnet_p.pexpect_proc.expect_exact('Data: blocks incomplete 0, lost bytes: 0')
  31. with open(oocd_log_path) as oocd_log:
  32. cores = 1 if dut.app.get_sdkconfig().get('CONFIG_FREERTOS_UNICORE', '').replace('"','') == 'y' else 2
  33. params_str = 'App trace params: from {} cores'.format(cores)
  34. for line in oocd_log:
  35. if params_str in line:
  36. break
  37. else:
  38. raise RuntimeError('"{}" could not be found in {}'.format(params_str, oocd_log_path))
  39. with ttfw_idf.CustomProcess(' '.join([os.path.join(idf_path, 'tools/esp_app_trace/logtrace_proc.py'),
  40. 'adc.log',
  41. os.path.join(dut.app.get_binary_path(rel_project_path),
  42. 'app_trace_to_host.elf')]),
  43. logfile='logtrace_proc.log') as logtrace:
  44. logtrace.pexpect_proc.expect_exact('Parse trace file')
  45. logtrace.pexpect_proc.expect_exact('Parsing completed.')
  46. logtrace.pexpect_proc.expect_exact('====================================================================')
  47. logtrace.pexpect_proc.expect(re.compile(r'example: Sample:\d+, Value:\d+'))
  48. logtrace.pexpect_proc.expect_exact('====================================================================')
  49. logtrace.pexpect_proc.expect(re.compile(r'Log records count: \d+'))
  50. if __name__ == '__main__':
  51. test_examples_app_trace_to_host()