example_test.py 953 B

1234567891011121314151617181920212223242526272829
  1. # This example code is in the Public Domain (or CC0 licensed, at your option.)
  2. # Unless required by applicable law or agreed to in writing, this
  3. # software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  4. # CONDITIONS OF ANY KIND, either express or implied.
  5. # -*- coding: utf-8 -*-
  6. from __future__ import print_function, unicode_literals
  7. import re
  8. import ttfw_idf
  9. @ttfw_idf.idf_example_test(env_tag='Example_GENERIC')
  10. def test_examples_asio_chat(env, _): # type: (ttfw_idf.TinyFW.Env, None) -> None
  11. msg = 'asio-chat: received hi'
  12. dut = env.get_dut('asio_chat', 'examples/protocols/asio/asio_chat')
  13. # start the test and expect the client to receive back it's original data
  14. dut.start_app()
  15. dut.expect(re.compile(r'{}'.format('Waiting for input')), timeout=30)
  16. dut.write(msg)
  17. dut.write('exit')
  18. dut.expect(re.compile(r'{}'.format(msg)), timeout=30)
  19. if __name__ == '__main__':
  20. test_examples_asio_chat()