Enhance BLE testing with fakes, stubs, and platform support#947
Draft
Mearman wants to merge 21 commits intocoredevices:mainfrom
Draft
Enhance BLE testing with fakes, stubs, and platform support#947Mearman wants to merge 21 commits intocoredevices:mainfrom
Mearman wants to merge 21 commits intocoredevices:mainfrom
Conversation
a3969ab to
76cd0fa
Compare
Require commit messages to use path-based areas (e.g., fw/drivers/hrm) or known short areas (e.g., ci, docs, treewide) rather than conventional commit types like feat:, fix:, chore:. Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
Append -darwin suffix to fixture filenames on macOS to handle rendering differences in font libraries. Linux (CI) uses standard ~platform naming to match existing fixtures. Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
Use memcpy for BD_ADDR_t address fields instead of direct assignment, which was causing incorrect address comparisons in whitelist operations. Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
Add run-tests-docker.sh to run tests in Docker matching CI environment, and generate-linux-fixtures.sh to generate Linux-specific test fixtures. Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
5c331bb to
be55eb1
Compare
Document the cross-platform fixture naming scheme, Docker testing workflow, and troubleshooting for CI vs local test discrepancies. Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
be55eb1 to
951d0aa
Compare
Restore platform suffix on Linux (e.g. ~spalding) while keeping the additional -darwin suffix for macOS local development. This matches the naming convention of the PNG fixture files in the repository. Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
- gatt_client_subscriptions: check if gatt_subscriptions is NULL before dereferencing when prepending to the list - ppogatt: distinguish between retriable and permanent GATT errors during meta characteristic read; only retry on timeout/resource errors, immediately fail on permission/handle errors Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
- Add conditional compilation for Bluetopia headers (SS1BTPS, L2CAPAPI) - Move bt_driver_gatt and bt_driver_gatt_client_discovery implementations to .c files to break circular header dependencies - Add stub implementations for bt_driver CCCD handling - Update gap_le_advert stubs with advertising data functions - Add DiscoveryJobQueue cleanup stub implementation Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
When Bluetopia headers (GAPAPI, GATTAPI) are unavailable (non-BTSTACK builds), provide dummy implementations so tests can compile. This enables running BLE-related tests without the full Bluetooth stack dependencies. Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
- Enable previously broken BLE tests (gatt_client_subscriptions, gatt_client_discovery, gap_le_advert, ppogatt, kernel_le_client) - Add compiler normalisation flags for consistent test results - Fix include path (../include → ../src/include) - Disable DUMA on macOS ARM - Create platform-specific failure directories to prevent contamination - Skip Xbit processing when platform-specific PNG files exist Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
530a835 to
8208065
Compare
Rename BTDeviceAddressToBDADDR that takes BTDeviceAddress to prv_get_addr_octets to avoid conflict with the stub version that takes const uint8_t* when HCIAPI is not available. Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
Update test files to pass the new watchdog_timer parameter. Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
Link bt_driver_gatt and gap_le_advert stubs to resolve undefined reference errors in BLE tests. Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
The sh library has a bug on macOS with Python 3.11 that causes an OverflowError in os.closerange when calling pip.freeze. Using subprocess.check_output avoids this issue. Signed-off-by: Joseph Mearman <[email protected]>
- Update gap_le_connection_add() calls with 4th argument - Fix include path for stubs_bluetopia_interface.h - Add static keyword to prevent multiple definition errors - Remove reference to non-existent stubs_gap_le_advert.c Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
- Add static inline to bt_driver_advert_* functions in stubs_gap_le_advert.h to prevent multiple definition linker errors - Fix gatt_client_discovery_cleanup_by_connection signature in fake_gatt_client_discovery.c to match the real function signature Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
This fixes undefined reference errors for bt_driver_advert_* functions. Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
Remove 'static inline' from stub functions in stubs_gap_le_advert.h and stubs_gatt_client_discovery.h so they generate linkable symbols. When real source files like gap_le_advert.c are compiled, they call these driver functions. With static inline, the compiler can't inline across translation units, so the linker can't find the symbols. By removing static inline, these become regular functions that can be linked against from compiled source files. Fixes test failures in: - test_gap_le_advert - test_gatt_client_discovery - test_gatt_client_accessors Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
The stub was calling undefined GAP API functions (GAP_LE_Set_Advertising_Data and GAP_LE_Set_Scan_Response_Data) which caused linker errors. Simplify the stub to be a no-op, which is sufficient for test purposes. Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
Add stub implementations for bt_driver_gatt_* functions that only had declarations. This fixes linker errors when real source files call these driver functions. Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
The test file declares this function as extern but it was not defined. Add a stub implementation that checks NumberOfCharacteristics > 0. Co-authored-by: Claude <[email protected]> Signed-off-by: Joseph Mearman <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces significant improvements to the test fakes for Bluetooth stack APIs, making them more robust and portable across environments where the real Bluetopia headers are not available (such as Linux or Docker). The changes add conditional compilation and dummy implementations for GAPAPI, GATTAPI, HCIAPI, and SS1BTPS, ensuring tests can run regardless of the presence of these headers. Additionally, error handling and subscription cleanup logic are improved in the BLE client code.
Test Fakes Portability and Robustness
fake_GAPAPI.c,fake_GAPAPI.h,fake_GATTAPI.c,fake_GATTAPI.h,fake_HCIAPI.c,fake_gap_le_connect_params.c, andstubs_HCIAPI.hto detect header availability and provide dummy type definitions and stub implementations when the real APIs are missing. This ensures test code builds and runs in all environments. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]BLE Client Error Handling
prv_handle_meta_readto distinguish between retriable and permanent GATT errors, ensuring clients are deleted immediately on permanent errors and retried only for recoverable ones. [1] [2]Subscription Management
Minor Fixes
statusparameter infake_gatt_put_discovery_complete_eventfromuint8_ttouint16_tfor accuracy.