Skip to content

Conversation

Thalley
Copy link
Contributor

@Thalley Thalley commented Sep 29, 2025

Modify the unit tests to use the native_sim board instead of the unit_testing board.
The native_sim board allows us to use the kernel in a more regular way, while still being able to treat the tests as unittest.

To support mocking we cannot rely on the default
Kconfig options and values. The required Kconfig options to satisfy dependencies are overridden in the Kconfig file and the necessary Kconfig files are sourced.
We cannot enable e.g. CONFIG_BT as that would attempt to pull in a lot of files we do not want in this test.

This commit also removes unused includes in the CMakelists, and cleans up the code.
Since the kernel is actually running, we also need to support that e.g. k_work items are actually scheduled, and that we have to wait for them to finish. test_drain_syswq has been implemented as a way to drain the system workqueue before we check for callbacks or perform subsequent actions.

@Thalley
Copy link
Contributor Author

Thalley commented Sep 29, 2025

See #96590 for the complete refactor

@Thalley Thalley marked this pull request as ready for review September 29, 2025 18:28
@zephyrbot zephyrbot added area: Bluetooth area: Bluetooth Audio area: Tests Issues related to a particular existing or missing test labels Sep 29, 2025
@nashif nashif assigned Thalley and unassigned nashif Sep 29, 2025
Modify the unit tests to use the native_sim board instead of the
unit_testing board.
The native_sim board allows us to use the kernel in a more
regular way, while still being able to treat the tests as
unittest.

To support mocking we cannot rely on the default
Kconfig options and values. The required Kconfig options
to satisfy dependencies are overridden in the Kconfig
file and the necessary Kconfig files are sourced.
We cannot enable e.g. CONFIG_BT as that would attempt
to pull in a lot of files we do not want in this test.

This commit also removes unused includes in the CMakelists,
and cleans up the code.
Since the kernel is actually running, we also need to support
that e.g. k_work items are actually scheduled, and that we have
to wait for them to finish. test_drain_syswq has been implemented
as a way to drain the system workqueue before we check for
callbacks or perform subsequent actions.

Signed-off-by: Emil Gydesen <[email protected]>
Copy link

sonarqubecloud bot commented Oct 7, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth Audio area: Bluetooth area: Tests Issues related to a particular existing or missing test
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

3 participants