example_test.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from __future__ import print_function
  2. import os
  3. import sys
  4. import subprocess
  5. try:
  6. import IDF
  7. except ImportError:
  8. # this is a test case write with tiny-test-fw.
  9. # to run test cases outside tiny-test-fw,
  10. # we need to set environment variable `TEST_FW_PATH`,
  11. # then get and insert `TEST_FW_PATH` to sys path before import FW module
  12. test_fw_path = os.getenv('TEST_FW_PATH')
  13. if test_fw_path and test_fw_path not in sys.path:
  14. sys.path.insert(0, test_fw_path)
  15. import IDF
  16. @IDF.idf_example_test(env_tag='Example_WIFI')
  17. def test_otatool_example(env, extra_data):
  18. dut = env.get_dut('otatool', 'examples/system/ota/otatool')
  19. # Verify factory firmware
  20. dut.start_app()
  21. dut.expect("OTA Tool Example")
  22. dut.expect("Example end")
  23. # Close connection to DUT
  24. dut.receive_thread.exit()
  25. dut.port_inst.close()
  26. script_path = os.path.join(os.getenv("IDF_PATH"), "examples", "system", "ota", "otatool", "otatool_example.py")
  27. binary_path = ""
  28. for flash_file in dut.app.flash_files:
  29. if "otatool.bin" in flash_file[1]:
  30. binary_path = flash_file[1]
  31. break
  32. subprocess.check_call([sys.executable, script_path, "--binary", binary_path])
  33. if __name__ == '__main__':
  34. test_otatool_example()