1## This file contains test cases for generating Fat Mach-O binaries.
2
3## a) Test that yaml2obj emits Fat Mach-O binary and obj2yaml converts it
4## back to YAML file.
5
6# RUN: yaml2obj --docnum=1 %s | obj2yaml | FileCheck %s
7
8--- !fat-mach-o
9FatHeader:       
10  magic:           0xCAFEBABE
11  nfat_arch:       2
12FatArchs:        
13  - cputype:         0x00000007
14    cpusubtype:      0x00000003
15    offset:          0x0000000000001000
16    size:            15244
17    align:           12
18  - cputype:         0x01000007
19    cpusubtype:      0x80000003
20    offset:          0x0000000000005000
21    size:            15380
22    align:           12
23Slices:          
24  - FileHeader:
25      magic:           0xFEEDFACE
26      cputype:         0x00000007
27      cpusubtype:      0x00000003
28      filetype:        0x00000002
29      ncmds:           0
30      sizeofcmds:      0
31      flags:           0x01218085
32  - FileHeader:
33      magic:           0xFEEDFACF
34      cputype:         0x01000007
35      cpusubtype:      0x80000003
36      filetype:        0x00000002
37      ncmds:           0
38      sizeofcmds:      0
39      flags:           0x00218085
40      reserved:        0x00000000
41...
42
43
44#CHECK: --- !fat-mach-o
45#CHECK: FatHeader:
46#CHECK:   magic:           0xCAFEBABE
47#CHECK:   nfat_arch:       2
48#CHECK: FatArchs:
49#CHECK:   - cputype:         0x7
50#CHECK:     cpusubtype:      0x3
51#CHECK:     offset:          0x1000
52#CHECK:     size:            15244
53#CHECK:     align:           12
54#CHECK:   - cputype:         0x1000007
55#CHECK:     cpusubtype:      0x80000003
56#CHECK:     offset:          0x5000
57#CHECK:     size:            15380
58#CHECK:     align:           12
59#CHECK: Slices:
60#CHECK:   - !mach-o
61#CHECK:     FileHeader:
62#CHECK:       magic:           0xFEEDFACE
63#CHECK:       cputype:         0x7
64#CHECK:       cpusubtype:      0x3
65#CHECK:       filetype:        0x2
66#CHECK:       ncmds:           0
67#CHECK:       sizeofcmds:      0
68#CHECK:       flags:           0x1218085
69#CHECK:   - !mach-o
70#CHECK:     FileHeader:
71#CHECK:       magic:           0xFEEDFACF
72#CHECK:       cputype:         0x1000007
73#CHECK:       cpusubtype:      0x80000003
74#CHECK:       filetype:        0x2
75#CHECK:       ncmds:           0
76#CHECK:       sizeofcmds:      0
77#CHECK:       flags:           0x218085
78#CHECK:       reserved:        0x0
79#CHECK: ...
80
81## b) Test that yaml2obj emits an error message if the number of 'FatArchs' is less than
82## the number of 'Slices'.
83
84# RUN: not yaml2obj --docnum=2 %s -o %t2.fat-macho 2>&1 | FileCheck %s --check-prefix=ERROR
85
86# ERROR: yaml2obj: error: cannot write 'Slices' if not described in 'FatArches'
87
88--- !fat-mach-o
89FatHeader:
90  magic:     0xCAFEBABE
91  nfat_arch: 2
92FatArchs:
93  ## 2 FatArchs are expected.
94  - cputype:    0x00000007
95    cpusubtype: 0x00000003
96    offset:     0x0000000000001000
97    size:       0
98    align:      0
99Slices:
100  - FileHeader:
101      magic:      0xFEEDFACE
102      cputype:    0x00000007
103      cpusubtype: 0x00000003
104      filetype:   0x00000002
105      ncmds:      0
106      sizeofcmds: 0
107      flags:      0x00000000
108  - FileHeader:
109      magic:      0xFEEDFACE
110      cputype:    0x00000007
111      cpusubtype: 0x00000003
112      filetype:   0x00000002
113      ncmds:      0
114      sizeofcmds: 0
115      flags:      0x00000000
116