Skip to content

Commit

Permalink
Make timeouts in ResetCommisionnee log the node ID involved. (#37087)
Browse files Browse the repository at this point in the history
In some of our tests we have dozens of commissionees, so when one of them times
out on RemoveFabric it's really hard to tell which one.
  • Loading branch information
bzbarsky-apple authored Jan 16, 2025
1 parent f9c7a8d commit 184127e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2873,7 +2873,7 @@ - (void)doTestSubscriptionPoolWithSize:(NSInteger)subscriptionPoolSize deviceOnb
// Reset our commissionees.
for (NSNumber * deviceID in orderedDeviceIDs) {
__auto_type * baseDevice = [MTRBaseDevice deviceWithNodeID:deviceID controller:controller];
ResetCommissionee(baseDevice, queue, self, kTimeoutInSeconds);
ResetCommissioneeWithNodeID(baseDevice, queue, self, kTimeoutInSeconds, deviceID);
}

[controller shutdown];
Expand Down
4 changes: 2 additions & 2 deletions src/darwin/Framework/CHIPTests/MTRSwiftDeviceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ class MTRSwiftDeviceTests : XCTestCase {
}

static override func tearDown() {
ResetCommissionee(sConnectedDevice, DispatchQueue.main, nil, UInt16(DeviceConstants.timeoutInSeconds))

XCTAssertNotNil(sConnectedDevice)
ResetCommissionee(sConnectedDevice!, DispatchQueue.main, nil, UInt16(DeviceConstants.timeoutInSeconds))
let controller = sController
XCTAssertNotNil(controller)
controller!.shutdown()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,12 @@

#pragma once

void ResetCommissionee(MTRBaseDevice * device, dispatch_queue_t queue, XCTestCase * testcase, uint16_t commandTimeout);
NS_ASSUME_NONNULL_BEGIN

void ResetCommissionee(MTRBaseDevice * device, dispatch_queue_t queue, XCTestCase * _Nullable testcase, uint16_t commandTimeout);

// MTRBaseDevice does not expose its node ID, so for now just allow callers to
// pass that in out-of-band.
void ResetCommissioneeWithNodeID(MTRBaseDevice * device, dispatch_queue_t queue, XCTestCase * _Nullable testcase, uint16_t commandTimeout, NSNumber * _Nullable nodeID);

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#import "MTRTestResetCommissioneeHelper.h"

void ResetCommissionee(MTRBaseDevice * device, dispatch_queue_t queue, XCTestCase * testcaseUnused, uint16_t commandTimeout)
void ResetCommissioneeWithNodeID(MTRBaseDevice * device, dispatch_queue_t queue, XCTestCase * testcaseUnused, uint16_t commandTimeout, NSNumber * _Nullable nodeID)
{
// Put the device back in the state we found it: open commissioning window, no fabrics commissioned.
// Get our current fabric index, for later deletion.
Expand Down Expand Up @@ -65,5 +65,11 @@ void ResetCommissionee(MTRBaseDevice * device, dispatch_queue_t queue, XCTestCas
[removeFabricExpectation fulfill];
}];

XCTAssertEqual([XCTWaiter waitForExpectations:@[ removeFabricExpectation ] timeout:commandTimeout], XCTWaiterResultCompleted);
XCTAssertEqual([XCTWaiter waitForExpectations:@[ removeFabricExpectation ] timeout:commandTimeout], XCTWaiterResultCompleted,
"Resetting commissionnee 0x%llx", nodeID.unsignedLongLongValue);
}

void ResetCommissionee(MTRBaseDevice * device, dispatch_queue_t queue, XCTestCase * testcaseUnused, uint16_t commandTimeout)
{
return ResetCommissioneeWithNodeID(device, queue, testcaseUnused, commandTimeout, nil);
}

0 comments on commit 184127e

Please sign in to comment.