Skip to content

Commit a5d547c

Browse files
feat(class/cdc): Add parsing host tests
1 parent 994a397 commit a5d547c

16 files changed

+1273
-2
lines changed

.build-test-rules.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ device/esp_tinyusb:
55
host/class:
66
enable:
77
- if: SOC_USB_OTG_SUPPORTED == 1
8+
9+
host/class/cdc/usb_host_cdc_acm/host_test:
10+
enable:
11+
- if: IDF_TARGET in ["linux"] and (IDF_VERSION_MAJOR >= 5 and IDF_VERSION_MINOR >= 4)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Build and Run USB Host test
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * SAT' # Saturday midnight
6+
pull_request:
7+
types: [opened, reopened, synchronize]
8+
9+
jobs:
10+
build:
11+
name: Build
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
idf_ver: ["latest"]
16+
runs-on: ubuntu-20.04
17+
container: espressif/idf:${{ matrix.idf_ver }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
submodules: 'true'
22+
- name: Build USB Test Application
23+
shell: bash
24+
run: |
25+
. ${IDF_PATH}/export.sh
26+
pip install pytest pytest-cpp idf-build-apps==2.4.3 --upgrade
27+
idf-build-apps find --target linux
28+
idf-build-apps build --target linux
29+
pytest host/class/cdc/usb_host_cdc_acm/host_test/build_linux

.github/workflows/build_and_run_test_app_usb.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ jobs:
6363
PIP_EXTRA_INDEX_URL: "https://dl.espressif.com/pypi/"
6464
run: pip install --only-binary cryptography pytest-embedded pytest-embedded-serial-esp pytest-embedded-idf pyserial pyusb
6565
- name: Run USB Test App on target
66-
run: pytest --target=${{ matrix.idf_target }} -m usb_host --build-dir=build_${{ matrix.idf_target }}
66+
run: pytest --embedded-services esp,idf --target=${{ matrix.idf_target }} -m usb_host --build-dir=build_${{ matrix.idf_target }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
3+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
4+
set(COMPONENTS main)
5+
6+
list(APPEND EXTRA_COMPONENT_DIRS
7+
"$ENV{IDF_PATH}/tools/mocks/usb/"
8+
"$ENV{IDF_PATH}/tools/mocks/freertos/"
9+
)
10+
11+
project(host_test_usb_cdc)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
| Supported Targets | Linux |
2+
| ----------------- | ----- |
3+
4+
# Description
5+
6+
This directory contains test code for `USB Host CDC-ACM` driver. Namely:
7+
* Descriptor parsing
8+
9+
Tests are written using [Catch2](https://github.com/catchorg/Catch2) test framework, use CMock, so you must install Ruby on your machine to run them.
10+
11+
# Build
12+
13+
Tests build regularly like an idf project. Currently only working on Linux machines.
14+
15+
```
16+
idf.py --preview set-target linux
17+
idf.py build
18+
```
19+
20+
# Run
21+
22+
The build produces an executable in the build folder.
23+
24+
Just run:
25+
26+
```
27+
./build/host_test_usb_cdc.elf
28+
```
29+
30+
The test executable have some options provided by the test framework.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
idf_component_register(SRC_DIRS .
2+
REQUIRES cmock usb
3+
INCLUDE_DIRS .
4+
PRIV_INCLUDE_DIRS "../../private_include"
5+
WHOLE_ARCHIVE)
6+
7+
# Currently 'main' for IDF_TARGET=linux is defined in freertos component.
8+
# Since we are using a freertos mock here, need to let Catch2 provide 'main'.
9+
target_link_libraries(${COMPONENT_LIB} PRIVATE Catch2WithMain)

0 commit comments

Comments
 (0)