example_test.py 852 B

123456789101112131415161718192021222324252627
  1. from __future__ import unicode_literals
  2. import re
  3. import ttfw_idf
  4. @ttfw_idf.idf_example_test(env_tag='Example_WIFI')
  5. def test_examples_icmp_echo(env, extra_data):
  6. dut = env.get_dut('icmp_echo', 'examples/protocols/icmp_echo')
  7. dut.start_app()
  8. dut.expect('example_connect: Connected to')
  9. dut.expect('esp>')
  10. dut.write('ping www.espressif.com')
  11. ip_re = r'\.'.join((r'\d{1,3}',) * 4)
  12. ip = dut.expect(re.compile(r'64 bytes from ({}) icmp_seq=1 ttl=\d+ time=\d+ ms'.format(ip_re)))[0]
  13. # expect at least one more (there could be lost packets)
  14. dut.expect(re.compile(r'64 bytes from {} icmp_seq=[2-5] ttl=\d+ time='.format(ip)))
  15. dut.expect(re.compile(r'5 packets transmitted, [2-5] received, \d{1,3}% packet loss'))
  16. dut.write('')
  17. dut.expect('esp>')
  18. if __name__ == '__main__':
  19. test_examples_icmp_echo()