forked from nygard/class-dump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestFatFile_Intel32_64.m
99 lines (78 loc) · 2.93 KB
/
TestFatFile_Intel32_64.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// -*- mode: ObjC -*-
// This file is part of class-dump, a utility for examining the Objective-C segment of Mach-O files.
// Copyright (C) 1997-2019 Steve Nygard.
#import <XCTest/XCTest.h>
#import "CDFatArch.h"
#import "CDFatFile.h"
#import "CDMachOFile.h"
@interface TestFatFile_Intel32_64 : XCTestCase
@end
@implementation TestFatFile_Intel32_64
{
CDFatFile *_fatFile;
CDFatArch *_arch_i386;
CDFatArch *_arch_x86_64;
CDMachOFile *_macho_i386;
CDMachOFile *_macho_x86_64;
}
- (void)setUp;
{
[super setUp];
// Set-up code here.
_fatFile = [[CDFatFile alloc] init];
_macho_i386 = [[CDMachOFile alloc] init];
_macho_i386.cputype = CPU_TYPE_X86;
_macho_i386.cpusubtype = CPU_SUBTYPE_386;
_arch_i386 = [[CDFatArch alloc] initWithMachOFile:_macho_i386];
[_fatFile addArchitecture:_arch_i386];
_macho_x86_64 = [[CDMachOFile alloc] init];
_macho_x86_64.cputype = CPU_TYPE_X86_64;
_macho_x86_64.cpusubtype = CPU_SUBTYPE_386;
_arch_x86_64 = [[CDFatArch alloc] initWithMachOFile:_macho_x86_64];
[_fatFile addArchitecture:_arch_x86_64];
}
- (void)tearDown;
{
// Tear-down code here.
_fatFile = nil;
_arch_i386 = nil;
_arch_x86_64 = nil;
_macho_i386 = nil;
_macho_x86_64 = nil;
[super tearDown];
}
#pragma mark -
- (void)test_bestMatchIntel64;
{
CDArch arch = { CPU_TYPE_X86_64, CPU_SUBTYPE_386 };
BOOL result = [_fatFile bestMatchForArch:&arch];
XCTAssertTrue(result, @"Didn't find a best match for x86_64");
XCTAssertTrue(arch.cputype == CPU_TYPE_X86_64, @"Best match cputype should be CPU_TYPE_X86_64");
XCTAssertTrue(arch.cpusubtype == CPU_SUBTYPE_386, @"Best match cpusubtype should be CPU_SUBTYPE_386");
}
#if 0
// We don't build 32-bit any more, so this test case shouldn't come up.
- (void)test_bestMatchIntel32;
{
CDArch arch = { CPU_TYPE_X86, CPU_SUBTYPE_386 };
BOOL result = [_intel_32_64 bestMatchForArch:&arch];
XCTAssertTrue(result, @"Didn't find a best match for i386");
XCTAssertTrue(arch.cputype == CPU_TYPE_X86, @"Best match cputype should be CPU_TYPE_X86");
XCTAssertTrue(arch.cpusubtype == CPU_SUBTYPE_386, @"Best match cpusubtype should be CPU_SUBTYPE_386");
}
#endif
- (void)test_machOFileWithArch_x86_64;
{
CDArch arch = { CPU_TYPE_X86_64, CPU_SUBTYPE_386 };
CDMachOFile *machOFile = [_fatFile machOFileWithArch:arch];
XCTAssertNotNil(machOFile, @"The Mach-O file shouldn't be nil", NULL);
XCTAssertEqual(machOFile, _macho_x86_64, @"Didn't find correct Mach-O file");
}
- (void)test_machOFileWithArch_i386;
{
CDArch arch = { CPU_TYPE_X86, CPU_SUBTYPE_386 };
CDMachOFile *machOFile = [_fatFile machOFileWithArch:arch];
XCTAssertNotNil(machOFile, @"The Mach-O file shouldn't be nil");
XCTAssertEqual(machOFile, _macho_i386, @"Didn't find correct Mach-O file");
}
@end