pytest_usb_host_msc.py 942 B

123456789101112131415161718192021222324252627
  1. # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: CC0-1.0
  3. import pytest
  4. from pytest_embedded import Dut
  5. @pytest.mark.esp32s2
  6. @pytest.mark.esp32s3
  7. @pytest.mark.usb_host_flash_disk
  8. def test_usb_host_msc_example(dut: Dut) -> None:
  9. # Check result of file_operations()
  10. dut.expect_exact("example: Read from file '/usb/esp/test.txt': 'Hello World!'")
  11. # Check result of speed_test()
  12. write_throughput = float(dut.expect(r'example: Write speed ([0-9]*[.]?[0-9]+) MiB')[1].decode())
  13. read_throughput = float(dut.expect(r'example: Read speed ([0-9]*[.]?[0-9]+) MiB')[1].decode())
  14. # These values should be updated for HS targets
  15. if write_throughput > 0.9:
  16. print('Write throughput put OK')
  17. else:
  18. print('write throughput too slow!')
  19. if read_throughput > 1.0:
  20. print('Read throughput put OK')
  21. else:
  22. print('Read throughput too slow!')