example_test.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from __future__ import print_function
  2. import os
  3. import sys
  4. import subprocess
  5. try:
  6. import IDF
  7. from IDF.IDFDUT import ESP32DUT
  8. except ImportError:
  9. test_fw_path = os.getenv('TEST_FW_PATH')
  10. if test_fw_path and test_fw_path not in sys.path:
  11. sys.path.insert(0, test_fw_path)
  12. import IDF
  13. @IDF.idf_example_test(env_tag='Example_WIFI')
  14. def test_examples_parttool(env, extra_data):
  15. dut = env.get_dut('parttool', 'examples/storage/parttool', dut_class=ESP32DUT)
  16. dut.start_app(False)
  17. # Verify factory firmware
  18. dut.expect("Partitions Tool Example")
  19. dut.expect("Example end")
  20. # Close connection to DUT
  21. dut.receive_thread.exit()
  22. dut.port_inst.close()
  23. # Run the example python script
  24. script_path = os.path.join(os.getenv("IDF_PATH"), "examples", "storage", "parttool", "parttool_example.py")
  25. binary_path = ""
  26. for flash_file in dut.app.flash_files:
  27. if "parttool.bin" in flash_file[1]:
  28. binary_path = flash_file[1]
  29. break
  30. subprocess.check_call([sys.executable, script_path, "--binary", binary_path])
  31. if __name__ == '__main__':
  32. test_examples_parttool()