Skip to content

Commit

Permalink
Add more test cases to the OTA provider test (#27874)
Browse files Browse the repository at this point in the history
* Add more test cases to the OTA provider test

- Add a test to update and verify the default OTA provider

- Add a test for  BDX transfer between the provider and two OTA requestors

- Add a test for incremental OTA update

* Restyled by whitespace

* Restyled by clang-format

* Apply suggestions from code review

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

* Review comments

* Add check for discriminator 1113 to MTRCommissionableBrowserTests.m

* Restyled by clang-format

* Fix kExpectedDiscoveredDevicesCount for MTRCommissionableBrowserTests and onboarding payload for ota requestor 3 for MTROTAProviderTests

* Decommission device3 after OTA tests are done

* Update src/darwin/Framework/CHIPTests/MTROTAProviderTests.m

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

* Apply suggestions from code review

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

* Addressed review comments

* Apply suggestions from code review

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

* more review comments

---------

Co-authored-by: Restyled.io <commits@restyled.io>
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
  • Loading branch information
3 people authored and pull[bot] committed Oct 18, 2023
1 parent dd10ff4 commit 5136401
Showing 3 changed files with 563 additions and 29 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/darwin.yaml
Original file line number Diff line number Diff line change
@@ -95,10 +95,12 @@ jobs:
- name: Build example OTA Provider
run: |
scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/debug chip_config_network_layer_ble=false
- name: Build OTA image files with software version number 5
- name: Build OTA image files with software version number 5 and 10
run: |
scripts/examples/gn_build_example.sh examples/ota-requestor-app/linux out/debug chip_config_network_layer_ble=false non_spec_compliant_ota_action_delay_floor=0 chip_device_config_device_software_version=5 chip_device_config_device_software_version_string='"5.0"'
cp out/debug/chip-ota-requestor-app /tmp/ota-test005-raw-image
cp out/debug/chip-ota-requestor-app /tmp/ota-raw-image-v5
scripts/examples/gn_build_example.sh examples/ota-requestor-app/linux out/debug chip_config_network_layer_ble=false non_spec_compliant_ota_action_delay_floor=0 chip_device_config_device_software_version=10 chip_device_config_device_software_version_string='"10.0"'
cp out/debug/chip-ota-requestor-app /tmp/ota-raw-image-v10
- name: Build example OTA Requestor
run: |
scripts/examples/gn_build_example.sh examples/ota-requestor-app/linux out/debug chip_config_network_layer_ble=false non_spec_compliant_ota_action_delay_floor=0
@@ -120,6 +122,7 @@ jobs:
# And a different port from the test harness too; the test harness uses port 5541.
../../../out/debug/chip-ota-requestor-app --interface-id -1 --secured-device-port 5542 --discriminator 1111 --KVS /tmp/chip-ota-requestor-kvs1 --otaDownloadPath /tmp/chip-ota-requestor-downloaded-image1 --autoApplyImage > >(tee /tmp/darwin/framework-tests/ota-requestor-app-1.log) 2> >(tee /tmp/darwin/framework-tests/ota-requestor-app-err-1.log >&2) &
../../../out/debug/chip-ota-requestor-app --interface-id -1 --secured-device-port 5543 --discriminator 1112 --KVS /tmp/chip-ota-requestor-kvs2 --otaDownloadPath /tmp/chip-ota-requestor-downloaded-image2 --autoApplyImage > >(tee /tmp/darwin/framework-tests/ota-requestor-app-2.log) 2> >(tee /tmp/darwin/framework-tests/ota-requestor-app-err-2.log >&2) &
../../../out/debug/chip-ota-requestor-app --interface-id -1 --secured-device-port 5544 --discriminator 1113 --KVS /tmp/chip-ota-requestor-kvs3 --otaDownloadPath /tmp/chip-ota-requestor-downloaded-image3 --autoApplyImage > >(tee /tmp/darwin/framework-tests/ota-requestor-app-3.log) 2> >(tee /tmp/darwin/framework-tests/ota-requestor-app-err-3.log >&2) &
# Disable BLE because the app does not have the permission to use
# it and that may crash the CI.
#
10 changes: 6 additions & 4 deletions src/darwin/Framework/CHIPTests/MTRCommissionableBrowserTests.m
Original file line number Diff line number Diff line change
@@ -29,10 +29,11 @@
static const uint16_t kTestProductId2 = 0x8001u;
static const uint16_t kTestDiscriminator1 = 1111u;
static const uint16_t kTestDiscriminator2 = 1112u;
static const uint16_t kTestDiscriminator3 = 3840u;
static const uint16_t kTestDiscriminator4 = 3839u;
static const uint16_t kTestDiscriminator3 = 1113u;
static const uint16_t kTestDiscriminator4 = 3840u;
static const uint16_t kTestDiscriminator5 = 3839u;
static const uint16_t kDiscoverDeviceTimeoutInSeconds = 10;
static const uint16_t kExpectedDiscoveredDevicesCount = 4;
static const uint16_t kExpectedDiscoveredDevicesCount = 5;

// Singleton controller we use.
static MTRDeviceController * sController = nil;
@@ -77,7 +78,8 @@ - (void)controller:(MTRDeviceController *)controller didFindCommissionableDevice
XCTAssertEqualObjects(vendorId, @(kTestVendorId));
XCTAssertTrue([productId isEqual:@(kTestProductId1)] || [productId isEqual:@(kTestProductId2)]);
XCTAssertTrue([discriminator isEqual:@(kTestDiscriminator1)] || [discriminator isEqual:@(kTestDiscriminator2)] ||
[discriminator isEqual:@(kTestDiscriminator3)] || [discriminator isEqual:@(kTestDiscriminator4)]);
[discriminator isEqual:@(kTestDiscriminator3)] || [discriminator isEqual:@(kTestDiscriminator4)] ||
[discriminator isEqual:@(kTestDiscriminator5)]);
XCTAssertEqual(commissioningMode, YES);

NSLog(@"Found Device (%@) with discriminator: %@ (vendor: %@, product: %@)", instanceName, discriminator, vendorId, productId);
Loading

0 comments on commit 5136401

Please sign in to comment.