Skip to content

Commit 6fa7332

Browse files
committed
Fix test
1 parent 0503c4b commit 6fa7332

2 files changed

Lines changed: 11 additions & 14 deletions

File tree

Sources/SentryCrash/Recording/SentryCrashBinaryImageCache.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,18 +212,14 @@ sentrycrashbic_addDyldNode(void)
212212
}
213213

214214
PublishedBinaryImage *entry = &g_images[idx];
215-
if (!sentrycrashdl_getBinaryImageForHeader((const void *)header, "dyld", &entry->image, false)) {
215+
if (!sentrycrashdl_getBinaryImageForHeader(
216+
(const void *)header, "dyld", &entry->image, false)) {
216217
// Decrement because we couldn't add the image
217218
atomic_fetch_sub_explicit(&g_next_index, 1, memory_order_relaxed);
218219
return;
219220
}
220221

221-
sentrycrashbic_cacheChangeCallback callback
222-
= atomic_load_explicit(&g_addedCallback, memory_order_acquire);
223222
atomic_store_explicit(&entry->ready, 1, memory_order_release);
224-
if (callback != NULL) {
225-
callback(&entry->image);
226-
}
227223
}
228224

229225
static void

Tests/SentryTests/SentryCrash/SentryCrashBinaryImageCacheTests.m

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,10 @@ - (void)testSentryBinaryImageCacheIntegration
289289
// by calling start, SentryBinaryImageCache will register a callback with
290290
// `SentryCrashBinaryImageCache` that should be called for every image already cached.
291291
NSMutableArray<NSString *> *paths = [NSMutableArray new];
292-
[imageCache.cache enumerateObjectsUsingBlock:^(SentryBinaryImageInfo * _Nonnull obj, NSUInteger __unused idx, BOOL * _Nonnull __unused stop) {
293-
[paths addObject:obj.name];
294-
}];
295-
XCTAssertEqual(5, imageCache.cache.count, @"Cache should start with 5 images but contained %@", paths);
292+
[imageCache.cache enumerateObjectsUsingBlock:^(SentryBinaryImageInfo *_Nonnull obj,
293+
NSUInteger __unused idx, BOOL *_Nonnull __unused stop) { [paths addObject:obj.name]; }];
294+
XCTAssertEqual(
295+
5, imageCache.cache.count, @"Cache should start with 5 images but contained %@", paths);
296296

297297
addBinaryImage([mach_headers_test_cache[5] pointerValue], 0);
298298
XCTAssertEqual(6, imageCache.cache.count);
@@ -311,10 +311,11 @@ - (void)assertBinaryImageCacheLength:(int)expected
311311
int counter = 0;
312312
sentrycrashbic_iterateOverImages(countNumberOfImagesInCache, &counter);
313313
NSMutableArray<NSString *> *paths = [NSMutableArray new];
314-
[SentryDependencyContainer.sharedInstance.binaryImageCache.cache enumerateObjectsUsingBlock:^(SentryBinaryImageInfo * _Nonnull obj, NSUInteger __unused idx, BOOL * _Nonnull __unused stop) {
315-
[paths addObject:obj.name];
316-
}];
317-
XCTAssertEqual(counter, expected, @"Cache should have %d images but contained %@", expected, paths);
314+
[SentryDependencyContainer.sharedInstance.binaryImageCache.cache
315+
enumerateObjectsUsingBlock:^(SentryBinaryImageInfo *_Nonnull obj, NSUInteger __unused idx,
316+
BOOL *_Nonnull __unused stop) { [paths addObject:obj.name]; }];
317+
XCTAssertEqual(
318+
counter, expected, @"Cache should have %d images but contained %@", expected, paths);
318319
}
319320

320321
- (void)assertCachedBinaryImages

0 commit comments

Comments
 (0)