Skip to content

Commit fc9b21e

Browse files
Fix test timeout due to resolving IPv4 non-locahost addresses.
1 parent 2eea04d commit fc9b21e

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/darwin/Framework/CHIP/MTRDeviceController.mm

+12
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,23 @@
5656

5757
#include <app-common/zap-generated/cluster-objects.h>
5858
#include <app/data-model/List.h>
59+
#include <app/server/Dnssd.h>
5960
#include <controller/CHIPDeviceController.h>
6061
#include <controller/CHIPDeviceControllerFactory.h>
6162
#include <controller/CommissioningWindowOpener.h>
6263
#include <credentials/FabricTable.h>
6364
#include <credentials/GroupDataProvider.h>
6465
#include <credentials/attestation_verifier/DacOnlyPartialAttestationVerifier.h>
6566
#include <credentials/attestation_verifier/DefaultDeviceAttestationVerifier.h>
67+
#include <inet/InetInterface.h>
6668
#include <lib/core/CHIPVendorIdentifiers.hpp>
6769
#include <platform/LockTracker.h>
6870
#include <platform/PlatformManager.h>
6971
#include <setup_payload/ManualSetupPayloadGenerator.h>
7072
#include <system/SystemClock.h>
7173

7274
#include <atomic>
75+
#include <dns_sd.h>
7376

7477
#import <os/lock.h>
7578

@@ -1342,6 +1345,15 @@ - (nullable NSNumber *)neededReadPrivilegeForClusterID:(NSNumber *)clusterID att
13421345
return nil;
13431346
}
13441347

1348+
#ifdef DEBUG
1349+
+ (void)forceLocalhostAdvertisingOnly
1350+
{
1351+
auto interfaceIndex = chip::Inet::InterfaceId::PlatformType(kDNSServiceInterfaceIndexLocalOnly);
1352+
auto interfaceId = chip::Inet::InterfaceId(interfaceIndex);
1353+
chip::app::DnssdServer::Instance().SetInterfaceId(interfaceId);
1354+
}
1355+
#endif // DEBUG
1356+
13451357
@end
13461358

13471359
/**

src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m

+12
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
static NSString * kOnboardingPayload = @"MT:-24J0AFN00KA0648G00";
3333
static const uint16_t kTestVendorId = 0xFFF1u;
3434

35+
#ifdef DEBUG
36+
@interface MTRDeviceController (Test)
37+
+ (void)forceLocalhostAdvertisingOnly;
38+
@end
39+
#endif // DEBUG
40+
3541
@interface MTRPerControllerStorageTestsControllerDelegate : NSObject <MTRDeviceControllerDelegate>
3642
@property (nonatomic, strong) XCTestExpectation * expectation;
3743
@property (nonatomic, strong) NSNumber * deviceID;
@@ -1043,6 +1049,12 @@ - (void)test007_TestMultipleControllers
10431049
// startControllerWithRootKeys into a test helper.
10441050
- (void)testControllerServer
10451051
{
1052+
#ifdef DEBUG
1053+
// Force our controllers to only advertise on localhost, to avoid DNS-SD
1054+
// crosstalk.
1055+
[MTRDeviceController forceLocalhostAdvertisingOnly];
1056+
#endif // DEBUG
1057+
10461058
__auto_type queue = dispatch_get_main_queue();
10471059

10481060
__auto_type * rootKeys = [[MTRTestKeys alloc] init];

0 commit comments

Comments
 (0)