From cf962a1c94d9d62f3274aef28c0f8d92c4955e0f Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 2 May 2024 14:15:50 -0400 Subject: [PATCH] Re-enable the leak detection in MTRTestCase, now that the test leaks are fixed. --- .../Framework/CHIPTests/MTRPerControllerStorageTests.m | 8 ++++---- src/darwin/Framework/CHIPTests/TestHelpers/MTRTestCase.mm | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m b/src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m index 19f114f7877d23..06968b00292ef4 100644 --- a/src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m +++ b/src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m @@ -187,6 +187,10 @@ @implementation MTRPerControllerStorageTests { - (void)setUp { + // Set detectLeaks true first, in case our superclass wants to do something + // in setUp when it's set. + self.detectLeaks = YES; + // Per-test setup, runs before each test. [super setUp]; [self setContinueAfterFailure:NO]; @@ -353,8 +357,6 @@ - (nullable MTRDeviceController *)startControllerWithRootKeys:(MTRTestKeys *)roo - (void)test001_BasicControllerStartup { - self.detectLeaks = YES; - __auto_type * factory = [MTRDeviceControllerFactory sharedInstance]; XCTAssertNotNil(factory); @@ -403,8 +405,6 @@ - (void)test001_BasicControllerStartup - (void)test002_TryStartingTwoControllersWithSameNodeID { - self.detectLeaks = YES; - __auto_type * rootKeys = [[MTRTestKeys alloc] init]; XCTAssertNotNil(rootKeys); diff --git a/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestCase.mm b/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestCase.mm index b4cf92b1ee3322..1dd1fea675b46c 100644 --- a/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestCase.mm +++ b/src/darwin/Framework/CHIPTests/TestHelpers/MTRTestCase.mm @@ -27,7 +27,6 @@ @implementation MTRTestCase */ - (void)tearDown { -#if 0 #if defined(ENABLE_LEAK_DETECTION) && ENABLE_LEAK_DETECTION if (_detectLeaks) { int pid = getpid(); @@ -35,7 +34,6 @@ - (void)tearDown int ret = system(cmd.UTF8String); XCTAssertEqual(ret, 0, "LEAKS DETECTED"); } -#endif #endif [super tearDown];