example_test.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from __future__ import unicode_literals
  2. import re
  3. import ttfw_idf
  4. from tiny_test_fw import Utility
  5. @ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32c3'])
  6. def test_examples_base_mac_address(env, extra_data):
  7. dut = env.get_dut('base_mac_address', 'examples/system/base_mac_address')
  8. dut.start_app()
  9. dut.expect('BASE_MAC: Base MAC Address read from EFUSE BLK0', timeout=30)
  10. hex_r = r', '.join((r'0x([0-9a-f]{1,2})',) * 6)
  11. mac_m = dut.expect(re.compile(r'BASE_MAC: Using "' + hex_r + r'" as base MAC address'), timeout=5)
  12. Utility.console_log('BASE_MAC detected: {}'.format(':'.join(mac_m)))
  13. def get_expected_mac_string(increment):
  14. '''
  15. Return the string representation of the MAC address mac_m with the last octet incremented.
  16. mac_m is an array of strings in hexa-decimal format without the '0x' prefix.
  17. '''
  18. return ', '.join(['0x{}'.format(m) for m in mac_m[:-1]] + [hex(int(mac_m[-1], 16) + increment)])
  19. dut.expect_all('WIFI_STA MAC: ' + get_expected_mac_string(0),
  20. 'SoftAP MAC: ' + get_expected_mac_string(1),
  21. 'BT MAC: ' + get_expected_mac_string(2),
  22. 'Ethernet MAC: ' + get_expected_mac_string(3),
  23. timeout=10)
  24. if __name__ == '__main__':
  25. test_examples_base_mac_address()