## This file contains test cases for generating Fat Mach-O binaries.

## a) Test that yaml2obj emits Fat Mach-O binary and obj2yaml converts it
## back to YAML file.

# RUN: yaml2obj --docnum=1 %s | obj2yaml | FileCheck %s

--- !fat-mach-o
FatHeader:       
  magic:           0xCAFEBABE
  nfat_arch:       2
FatArchs:        
  - cputype:         0x00000007
    cpusubtype:      0x00000003
    offset:          0x0000000000001000
    size:            15244
    align:           12
  - cputype:         0x01000007
    cpusubtype:      0x80000003
    offset:          0x0000000000005000
    size:            15380
    align:           12
Slices:          
  - FileHeader:      
      magic:           0xFEEDFACE
      cputype:         0x00000007
      cpusubtype:      0x00000003
      filetype:        0x00000002
      ncmds:           0
      sizeofcmds:      0
      flags:           0x01218085
  - FileHeader:      
      magic:           0xFEEDFACF
      cputype:         0x01000007
      cpusubtype:      0x80000003
      filetype:        0x00000002
      ncmds:           0
      sizeofcmds:      0
      flags:           0x00218085
      reserved:        0x00000000
...


#CHECK: --- !fat-mach-o
#CHECK: FatHeader:       
#CHECK:   magic:           0xCAFEBABE
#CHECK:   nfat_arch:       2
#CHECK: FatArchs:        
#CHECK:   - cputype:         0x7
#CHECK:     cpusubtype:      0x3
#CHECK:     offset:          0x1000
#CHECK:     size:            15244
#CHECK:     align:           12
#CHECK:   - cputype:         0x1000007
#CHECK:     cpusubtype:      0x80000003
#CHECK:     offset:          0x5000
#CHECK:     size:            15380
#CHECK:     align:           12
#CHECK: Slices:          
#CHECK:   - !mach-o
#CHECK:     FileHeader:      
#CHECK:       magic:           0xFEEDFACE
#CHECK:       cputype:         0x7
#CHECK:       cpusubtype:      0x3
#CHECK:       filetype:        0x2
#CHECK:       ncmds:           0
#CHECK:       sizeofcmds:      0
#CHECK:       flags:           0x1218085
#CHECK:   - !mach-o
#CHECK:     FileHeader:        
#CHECK:       magic:           0xFEEDFACF
#CHECK:       cputype:         0x1000007
#CHECK:       cpusubtype:      0x80000003
#CHECK:       filetype:        0x2
#CHECK:       ncmds:           0
#CHECK:       sizeofcmds:      0
#CHECK:       flags:           0x218085
#CHECK:       reserved:        0x0
#CHECK: ...

## b) Test that yaml2obj emits an error message if the number of 'FatArchs' is less than
## the number of 'Slices'.

# RUN: not yaml2obj --docnum=2 %s -o %t2.fat-macho 2>&1 | FileCheck %s --check-prefix=ERROR

# ERROR: yaml2obj: error: cannot write 'Slices' if not described in 'FatArches'

--- !fat-mach-o
FatHeader:
  magic:     0xCAFEBABE
  nfat_arch: 2
FatArchs:
  ## 2 FatArchs are expected.
  - cputype:    0x00000007
    cpusubtype: 0x00000003
    offset:     0x0000000000001000
    size:       0
    align:      0
Slices:
  - FileHeader:
      magic:      0xFEEDFACE
      cputype:    0x00000007
      cpusubtype: 0x00000003
      filetype:   0x00000002
      ncmds:      0
      sizeofcmds: 0
      flags:      0x00000000
  - FileHeader:
      magic:      0xFEEDFACE
      cputype:    0x00000007
      cpusubtype: 0x00000003
      filetype:   0x00000002
      ncmds:      0
      sizeofcmds: 0
      flags:      0x00000000
