Skip to content

Commit

Permalink
Sanitiser support for MacOS tests
Browse files Browse the repository at this point in the history
Summary: Sanitisers need some special handling to load their runtime libs earlier in the process initialisation. The code that finds the path to these libs was not handling MacOS test bundles' structure correctly and causing test listing and execution to fail.

Reviewed By: sodastsai

Differential Revision: D59277659

fbshipit-source-id: c1c847466f5ef4812509596689cd936d0b9fe991
  • Loading branch information
jbardini authored and facebook-github-bot committed Jul 2, 2024
1 parent c0ad626 commit 96d8a27
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions XCTestBootstrap/Utility/FBOToolDynamicLibs.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,26 @@ @implementation FBOToolDynamicLibs

+ (FBFuture<NSArray *> *)findFullPathForSanitiserDyldInBundle:(NSString *)bundlePath onQueue:(nonnull dispatch_queue_t)queue {
return [[FBOToolOperation listSanitiserDylibsRequiredByBundle:bundlePath onQueue:queue] onQueue:queue map:^id _Nonnull(NSArray<NSString *> * _Nonnull libsList) {

NSString *clanLocation = [FBXcodeConfiguration.developerDirectory stringByAppendingPathComponent:@"Toolchains/XcodeDefault.xctoolchain/usr/lib/clang"];
NSError *error = nil;
NSArray<NSURL *> *fileList = [self filesInDirectory:[NSURL fileURLWithPath:clanLocation] error:&error];

if ([fileList count] == 0 || error) {
if(error == nil) return [[FBControlCoreError
describeFormat:@"No clang version found in %@", clanLocation] failFuture];
return [FBFuture futureWithError:error];
}

NSString *libsFolder = [NSString pathWithComponents: @[[fileList[0] path], @"lib/darwin/"]];

NSMutableSet<NSString *> *bundleLibsNames = nil;

NSString *bundleFrameworksFolder = [bundlePath stringByAppendingPathComponent:@"Frameworks"];
if(![[NSFileManager defaultManager] fileExistsAtPath:bundleFrameworksFolder]) {
bundleFrameworksFolder = [bundlePath stringByAppendingPathComponent:@"Contents/Frameworks"];
}

NSArray<NSURL *> *bundleLibs = [self filesInDirectory:[NSURL fileURLWithPath:bundleFrameworksFolder] error:&error];
NSMutableSet<NSString *> *bundleLibsNames = nil;
if (bundleLibs) {
bundleLibsNames = [NSMutableSet setWithCapacity:bundleLibs.count];
for(NSURL *libURL in bundleLibs) {
Expand All @@ -49,7 +53,7 @@ @implementation FBOToolDynamicLibs
}
[libraries addObject:libPath];
}

return libraries;
}];
}
Expand Down

0 comments on commit 96d8a27

Please sign in to comment.