Skip to content

Commit 0607ae9

Browse files
Make the log download test self-contained.
It should not be depending on a helper app started in a particular way; it should just start that helper app itself.
1 parent f509f67 commit 0607ae9

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

.github/workflows/darwin.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ jobs:
111111
working-directory: src/darwin/Framework
112112
run: |
113113
mkdir -p /tmp/darwin/framework-tests
114-
echo "This is a simple log" > /tmp/darwin/framework-tests/end_user_support_log.txt
115-
../../../out/debug/all-clusters-app/chip-all-clusters-app --interface-id -1 --end_user_support_log /tmp/darwin/framework-tests/end_user_support_log.txt > >(tee /tmp/darwin/framework-tests/all-cluster-app.log) 2> >(tee /tmp/darwin/framework-tests/all-cluster-app-err.log >&2) &
114+
../../../out/debug/all-clusters-app/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) &
116115
117116
export TEST_RUNNER_ASAN_OPTIONS=__CURRENT_VALUE__:detect_stack_use_after_return=1
118117

src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m

+27-22
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
#import <Matter/Matter.h>
2424

2525
#import "MTRErrorTestUtils.h"
26+
#import "MTRTestCase+ServerAppRunner.h"
27+
#import "MTRTestCase.h"
2628
#import "MTRTestKeys.h"
27-
#import "MTRTestResetCommissioneeHelper.h"
2829
#import "MTRTestStorage.h"
2930

3031
#import <math.h> // For INFINITY
3132

3233
// system dependencies
33-
#import <XCTest/XCTest.h>
3434
#import <os/lock.h>
3535

3636
static uint16_t kTestVendorId = 0xFFF1u;
@@ -418,7 +418,8 @@ - (void)readAttributeCacheWithController:(id _Nullable)controller
418418
static const uint16_t kPairingTimeoutInSeconds = 30;
419419
static const uint16_t kTimeoutInSeconds = 3;
420420
static const uint64_t kDeviceId = 0x12344321;
421-
static NSString * kOnboardingPayload = @"MT:-24J0AFN00KA0648G00";
421+
static NSString * kOnboardingPayload = @"MT:Y.K90SO527JA0648G00";
422+
static NSString * kSimpleLogContent = @"This is a simple log\n";
422423
static const uint16_t kLocalPort = 5541;
423424

424425
// This test suite reuses a device object to speed up the test process for CI.
@@ -501,25 +502,38 @@ - (BOOL)unitTestShouldSkipExpectedValuesForWrite:(MTRDevice *)device
501502
}
502503
@end
503504

504-
@interface MTRXPCListenerSampleTests : XCTestCase
505+
@interface MTRXPCListenerSampleTests : MTRTestCase
505506

506507
@end
507508

508509
static BOOL sStackInitRan = NO;
509-
static BOOL sNeedsStackShutdown = YES;
510510

511511
@implementation MTRXPCListenerSampleTests
512512

513+
+ (void)setUp
514+
{
515+
// Global setup, runs once.
516+
[super setUp];
517+
518+
__auto_type * uniqueName = [[NSUUID UUID] UUIDString];
519+
__auto_type * uniquePath = [NSTemporaryDirectory() stringByAppendingPathComponent:uniqueName];
520+
[[NSFileManager defaultManager] createFileAtPath:uniquePath
521+
contents:[kSimpleLogContent dataUsingEncoding:NSUTF8StringEncoding]
522+
attributes:nil];
523+
BOOL started = [self startAppWithName:@"all-clusters"
524+
arguments:@[
525+
@"--end_user_support_log",
526+
uniquePath,
527+
]
528+
payload:kOnboardingPayload];
529+
XCTAssertTrue(started);
530+
}
531+
513532
+ (void)tearDown
514533
{
515534
// Global teardown, runs once
516-
if (sNeedsStackShutdown) {
517-
// We don't need to worry about ResetCommissionee. If we get here,
518-
// we're running only one of our test methods (using
519-
// -only-testing:MatterTests/MTROTAProviderTests/testMethodName), since
520-
// we did not run test999_TearDown.
521-
// [self shutdownStack];
522-
}
535+
[self shutdownStack];
536+
[super tearDown];
523537
}
524538

525539
- (void)setUp
@@ -591,8 +605,6 @@ - (void)initStack
591605

592606
+ (void)shutdownStack
593607
{
594-
sNeedsStackShutdown = NO;
595-
596608
[mSampleListener stop];
597609
mSampleListener = nil;
598610

@@ -1953,7 +1965,7 @@ - (void)test016_DownloadLog
19531965
NSError * readError;
19541966
NSString * fileContent = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&readError];
19551967
XCTAssertNil(readError);
1956-
XCTAssertEqualObjects(fileContent, @"This is a simple log\n");
1968+
XCTAssertEqualObjects(fileContent, kSimpleLogContent);
19571969
[expectation fulfill];
19581970
}];
19591971
[self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil];
@@ -2079,11 +2091,4 @@ - (void)test900_SubscribeClusterStateCache
20792091
[self waitForExpectations:@[ expectation ] timeout:kTimeoutInSeconds];
20802092
}
20812093

2082-
- (void)test999_TearDown
2083-
{
2084-
ResetCommissionee(
2085-
[MTRBaseDevice deviceWithNodeID:@(kDeviceId) controller:sController], dispatch_get_main_queue(), self, kTimeoutInSeconds);
2086-
[[self class] shutdownStack];
2087-
}
2088-
20892094
@end

0 commit comments

Comments
 (0)