Skip to content

Commit

Permalink
Improve management of OTA requestor apps in darwin tests. (#28674)
Browse files Browse the repository at this point in the history
* Improve management of OTA requestor apps in darwin tests.

Instead of relying on the apps to be started externally, just start them
directly from the test itself.  This removes the proliferation of test app
instances at runtime, except during this test, and makes it easier to run other
tests without paying the cost of all the compilation/setup for this one.

The change in MTROTAProviderDelegateBridge.mm is fixing a bug that was uncovered
by the changed tests: if we shut down our last controller, that incorrectly
cleared out mDelegateNotificationQueue on the BdxOTASender, and that state is
not restored until factory restart.  Since the queue is tied to the factory, not
controllers, nulling it out does not make sense here.

* Address review comment.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Nov 3, 2023
1 parent d24ea05 commit f31fa29
Show file tree
Hide file tree
Showing 4 changed files with 281 additions and 156 deletions.
15 changes: 1 addition & 14 deletions .github/workflows/darwin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,9 @@ 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 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-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
scripts/examples/gn_build_example.sh examples/ota-requestor-app/linux out/debug/ota-requestor-app chip_config_network_layer_ble=false non_spec_compliant_ota_action_delay_floor=0
- name: Delete Defaults
run: defaults delete com.apple.dt.xctest.tool
continue-on-error: true
Expand All @@ -116,13 +110,6 @@ jobs:
mkdir -p /tmp/darwin/framework-tests
../../../out/debug/chip-all-clusters-app --interface-id -1 > >(tee /tmp/darwin/framework-tests/all-cluster-app.log) 2> >(tee /tmp/darwin/framework-tests/all-cluster-app-err.log >&2) &
../../../out/debug/chip-all-clusters-app --interface-id -1 --dac_provider ../../../credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/test_case_vector.json --product-id 32768 --discriminator 3839 --secured-device-port 5539 --KVS /tmp/chip-all-clusters-app-kvs2 > >(tee /tmp/darwin/framework-tests/all-cluster-app-origin-vid.log) 2> >(tee /tmp/darwin/framework-tests/all-cluster-app-origin-vid-err.log >&2) &
# Make sure each ota-requestor is using a different port, discriminator, and KVS from
# all-clusters-app and from other requestors.
#
# 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.
#
Expand Down
1 change: 0 additions & 1 deletion src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ CHIP_ERROR Shutdown()

mExchangeMgr = nullptr;
mSystemLayer = nullptr;
mDelegateNotificationQueue = nil;

return CHIP_NO_ERROR;
}
Expand Down
13 changes: 4 additions & 9 deletions src/darwin/Framework/CHIPTests/MTRCommissionableBrowserTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@
static const uint16_t kTestVendorId = 0xFFF1u;
static const uint16_t kTestProductId1 = 0x8000u;
static const uint16_t kTestProductId2 = 0x8001u;
static const uint16_t kTestDiscriminator1 = 1111u;
static const uint16_t kTestDiscriminator2 = 1112u;
static const uint16_t kTestDiscriminator3 = 1113u;
static const uint16_t kTestDiscriminator4 = 3840u;
static const uint16_t kTestDiscriminator5 = 3839u;
static const uint16_t kTestDiscriminator1 = 3840u;
static const uint16_t kTestDiscriminator2 = 3839u;
static const uint16_t kDiscoverDeviceTimeoutInSeconds = 10;
static const uint16_t kExpectedDiscoveredDevicesCount = 5;
static const uint16_t kExpectedDiscoveredDevicesCount = 2;

// Singleton controller we use.
static MTRDeviceController * sController = nil;
Expand Down Expand Up @@ -77,9 +74,7 @@ - (void)controller:(MTRDeviceController *)controller didFindCommissionableDevice
XCTAssertEqual(instanceName.length, 16); // The instance name is random, so just ensure the len is right.
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:@(kTestDiscriminator5)]);
XCTAssertTrue([discriminator isEqual:@(kTestDiscriminator1)] || [discriminator isEqual:@(kTestDiscriminator2)]);
XCTAssertEqual(commissioningMode, YES);

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

0 comments on commit f31fa29

Please sign in to comment.