feat(cdc_acm): mock open/close device #87
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theusb_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
test_device_opening.cpp
- We are testing device opening/closing itselftest_device_interaction.cpp
- We are testing interaction of already opened device with theCDC-ACM
drivermock_cdc_acm_host_install
mock_cdc_acm_host_uninstall
- Installs/UninstallsCDC-ACM
driver on mocked USB componentmock_cdc_acm_host_open
mock_cdc_acm_host_close
- Opens/Closes mocked CDC device in theCDC-ACM
drivermock_cdc_acm_host_data_tx_blocking
- Submits mocked transfer to already opened mocked deviceRelated
Testing
Checklist
Before submitting a Pull Request, please ensure the following: