pytest_usb_host.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: CC0-1.0
  3. from typing import Tuple
  4. import pytest
  5. from pytest_embedded_idf.dut import IdfDut
  6. @pytest.mark.esp32s2
  7. @pytest.mark.esp32s3
  8. @pytest.mark.usb_host
  9. @pytest.mark.parametrize('count', [
  10. 2,
  11. ], indirect=True)
  12. def test_usb_host(dut: Tuple[IdfDut, IdfDut]) -> None:
  13. device = dut[0]
  14. host = dut[1]
  15. # 1.1 Prepare USB device for CDC test
  16. device.expect_exact('Press ENTER to see the list of tests.')
  17. device.write('[cdc_acm_device]')
  18. device.expect_exact('USB initialization DONE')
  19. # 1.2 Run CDC test
  20. host.expect_exact('Press ENTER to see the list of tests.')
  21. host.write('[cdc_acm]')
  22. host.expect_unity_test_output()
  23. host.expect_exact("Enter next test, or 'enter' to see menu")
  24. # 2.1 Prepare USB device for MSC test
  25. device.serial.hard_reset()
  26. device.expect_exact('Press ENTER to see the list of tests.')
  27. device.write('[usb_msc_device]')
  28. device.expect_exact('USB initialization DONE')
  29. # 2.2 Run MSC test
  30. host.write('[usb_msc]')
  31. host.expect_unity_test_output()
  32. host.expect_exact("Enter next test, or 'enter' to see menu")