Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cdc_acm): mock open/close device #87

Merged
merged 1 commit into from
Dec 20, 2024

Conversation

peter-marcisovsky
Copy link
Collaborator

@peter-marcisovsky peter-marcisovsky commented Nov 15, 2024

Description

This MR, as a part of USB Class drivers testing, uses callback functions to some functions from from usb_host.c, used for device opening and closing.

Cmock framework defines callbacks, as user-defined functions which are called whenever a certain mocked function is called, to which a callback function is registered to.

This is useful for us, for example, when we want to "open" a USB device during a class driver host test.

Since the whole USB stack is mocked, usb_host_devcie_open just calls an empty cmock function. But we can register a callback to the usb_host_devcie_open function, which will "open" a mocked USB device. Once the USB device is opened, we can use it for further host testing.

A developer must define USB devices he want's to have "connected" during a test case by himself, at the beginning of a host test case. One can do so by calling usb_host_mock_add_device and passing a device's device and config desc and a desired device address.

Changes

  • Added host tests:
    • Device opening test_device_opening.cpp - We are testing device opening/closing itself
    • Device interfaction test_device_interaction.cpp - We are testing interaction of already opened device with the CDC-ACM driver
  • Test fixtures:
    • CDC-ACM driver mock API for host testing, implements functions
    • mock_cdc_acm_host_install mock_cdc_acm_host_uninstall - Installs/Uninstalls CDC-ACM driver on mocked USB component
    • mock_cdc_acm_host_open mock_cdc_acm_host_close - Opens/Closes mocked CDC device in the CDC-ACM driver
    • mock_cdc_acm_host_data_tx_blocking - Submits mocked transfer to already opened mocked device

Related

  • Blocking change: USB Mock in esp-idf must be updated first
  • IDF-11343 USB class testing: USB Host device list mock

Testing


Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

@peter-marcisovsky peter-marcisovsky self-assigned this Nov 15, 2024
@peter-marcisovsky peter-marcisovsky added the Status: In Progress Issue is being worked on label Nov 15, 2024
@peter-marcisovsky peter-marcisovsky force-pushed the feat/cdc_acm_mock_open_device branch 3 times, most recently from 96b95b0 to 937027f Compare November 26, 2024 12:49
@peter-marcisovsky peter-marcisovsky marked this pull request as ready for review November 26, 2024 12:51
@peter-marcisovsky peter-marcisovsky added Status: Reviewing Issue is being reviewed and removed Status: In Progress Issue is being worked on labels Nov 26, 2024
@peter-marcisovsky
Copy link
Collaborator Author

There are 2 sub-folders for host tests now:

  • descriptors parsing tests : this tests use USB and Freertos components mocked
  • device itneractions tests : this tests use only mocked USB, Freertos is real component

For this reason, the tests must have been regrouped

@peter-marcisovsky peter-marcisovsky force-pushed the feat/cdc_acm_mock_open_device branch from c765ba2 to 803aaef Compare December 3, 2024 21:58
Copy link
Collaborator

@tore-espressif tore-espressif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job @peter-marcisovsky !

@peter-marcisovsky
Copy link
Collaborator Author

CI failing, because we don't have the changes from esp-idf merged into the master.

First we merge feature(usb_host): cmock add device and wait for the docker image update.
Then, once the CI passes, we merge this MR.

@peter-marcisovsky peter-marcisovsky force-pushed the feat/cdc_acm_mock_open_device branch 3 times, most recently from 7d5d5ca to 16912b6 Compare December 20, 2024 10:05
    - Opening and closing mocked USB devices
    - Interaction with mocked USB devices
@peter-marcisovsky peter-marcisovsky force-pushed the feat/cdc_acm_mock_open_device branch from 16912b6 to ffdb0dc Compare December 20, 2024 12:07
@peter-marcisovsky peter-marcisovsky merged commit e013116 into master Dec 20, 2024
31 checks passed
@peter-marcisovsky peter-marcisovsky deleted the feat/cdc_acm_mock_open_device branch December 20, 2024 13:46
@peter-marcisovsky peter-marcisovsky added Status: Done Issue is done internally and removed Status: Reviewing Issue is being reviewed labels Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Done Issue is done internally
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants