example_test.py 1020 B

123456789101112131415161718192021222324252627282930313233
  1. # Need Python 3 string formatting functions
  2. from __future__ import print_function
  3. import os
  4. import sys
  5. try:
  6. import IDF
  7. except ImportError:
  8. # The test cause is dependent on the Tiny Test Framework. Ensure the
  9. # `TEST_FW_PATH` environment variable is set to `$IDF_PATH/tools/tiny-test-fw`
  10. test_fw_path = os.getenv("TEST_FW_PATH")
  11. if test_fw_path and test_fw_path not in sys.path:
  12. sys.path.insert(0, test_fw_path)
  13. import IDF
  14. # CAN Self Test Example constants
  15. STR_EXPECT = ("CAN Self Test: Driver installed", "CAN Self Test: Driver uninstalled")
  16. EXPECT_TIMEOUT = 20
  17. @IDF.idf_example_test(env_tag='Example_CAN1')
  18. def test_can_self_test_example(env, extra_data):
  19. # Get device under test, flash and start example. "dut1" must be defined in EnvConfig
  20. dut = env.get_dut('dut1', 'examples/peripherals/can/can_self_test')
  21. dut.start_app()
  22. for string in STR_EXPECT:
  23. dut.expect(string, timeout=EXPECT_TIMEOUT)
  24. if __name__ == '__main__':
  25. test_can_self_test_example()