FIRCLSMachOBinaryTests.m 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2019 Google
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import "Crashlytics/UnitTests/FIRCLSMachO/FIRCLSMachOBinaryTests.h"
  15. #import "Crashlytics/Shared/FIRCLSMachO/FIRCLSMachOBinary.h"
  16. @implementation FIRCLSMachOBinaryTests
  17. - (NSString*)resourcePath {
  18. #if SWIFT_PACKAGE
  19. NSBundle* bundle = SWIFTPM_MODULE_BUNDLE;
  20. return [bundle.resourcePath stringByAppendingPathComponent:@"machO_data"];
  21. #else
  22. NSBundle* bundle = [NSBundle bundleForClass:[self class]];
  23. return bundle.resourcePath;
  24. #endif
  25. }
  26. - (NSURL*)URLForResource:(NSString*)resource {
  27. NSString* path;
  28. path = [[self resourcePath] stringByAppendingPathComponent:resource];
  29. return [NSURL fileURLWithPath:path];
  30. }
  31. - (void)testInstanceIdentifierForSingleArchdSYM {
  32. FIRCLSMachOBinary* binary;
  33. binary = [[FIRCLSMachOBinary alloc] initWithURL:[self URLForResource:@"x86_64-executable"]];
  34. XCTAssertEqualObjects([binary instanceIdentifier], @"442eb836efe1f56bf8a65b2a0a78b2f8d3e792e7",
  35. @"");
  36. }
  37. - (void)testInstanceIdentifierForMultipleArchitectures {
  38. FIRCLSMachOBinary* binary;
  39. binary = [[FIRCLSMachOBinary alloc] initWithURL:[self URLForResource:@"armv7-armv7s-executable"]];
  40. XCTAssertEqualObjects([binary instanceIdentifier], @"80cc0ec0af8a0169831abcc73177eb2b57990bc0",
  41. @"");
  42. }
  43. @end