example_test.py 1.1 KB

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