## Check how obj2yaml dumps regular archives.
## Check how we dump an empty archive.
# RUN: yaml2obj %s --docnum=1 -o %t.empty.a
# RUN: obj2yaml %t.empty.a > %t.stdout.yaml
# RUN: obj2yaml %t.empty.a -o %t.file.yaml 2>&1 | count 0
# RUN: FileCheck --input-file=%t.stdout.yaml %s --check-prefix=EMPTY
# RUN: diff %t.stdout.yaml %t.file.yaml
# EMPTY: --- !Arch
# EMPTY-NEXT: Members: []
# EMPTY-NEXT: ...
--- !Arch
Members: []
## Check how we dump archives with multiple members.
## Check we don't dump excessive spaces when dumping fields.
## Check we don't dump fields with values that are equal to default values.
## Check how we dump empty field values.
# RUN: yaml2obj %s --docnum=2 -o %t.multiple.a
# RUN: obj2yaml %t.multiple.a | FileCheck %s --check-prefix=MULTIPLE
# MULTIPLE: --- !Arch
# MULTIPLE-NEXT: Members:
# MULTIPLE-NEXT: - Name: 'bbb/'
# MULTIPLE-NEXT: LastModified: '1'
# MULTIPLE-NEXT: UID: '2'
# MULTIPLE-NEXT: GID: '3'
# MULTIPLE-NEXT: AccessMode: '644'
# MULTIPLE-NEXT: Size: '6'
# MULTIPLE-NEXT: Content: 20616161200A
# MULTIPLE-NEXT: - Name: 'dddd/'
# MULTIPLE-NEXT: LastModified: '4'
# MULTIPLE-NEXT: UID: '5'
# MULTIPLE-NEXT: GID: '6'
# MULTIPLE-NEXT: AccessMode: '987'
# MULTIPLE-NEXT: Size: '7'
# MULTIPLE-NEXT: Content: 2063636363200A
# MULTIPLE-NEXT: PaddingByte: 0xA
# MULTIPLE-NEXT: - LastModified: ''
# MULTIPLE-NEXT: UID: ''
# MULTIPLE-NEXT: GID: ''
# MULTIPLE-NEXT: AccessMode: ''
# MULTIPLE-NEXT: Terminator: ''
# MULTIPLE-NEXT: Content: ''
# MULTIPLE-NEXT: - {}
# MULTIPLE-NEXT: ...
--- !Arch
Members:
- Name: 'bbb/'
LastModified: '1'
UID: '2'
GID: '3'
AccessMode: '644'
Size: '6'
Terminator: "`\n"
Content: 20616161200A ## " aaa \n"
- Name: 'dddd/'
LastModified: '4'
UID: '5'
GID: '6'
AccessMode: '987'
Size: '7'
Terminator: "`\n"
Content: 2063636363200A ## " cccc \n"
PaddingByte: 0x0A
## All fields are empty (where possible).
- Name: ''
LastModified: ''
UID: ''
GID: ''
AccessMode: ''
Size: '0'
Terminator: ''
Content: ''
## All fields are explicitly set to the default values.
- Name: ''
LastModified: '0'
UID: '0'
GID: '0'
AccessMode: '0'
Size: '0'
Terminator: "`\n"
Content: ""
...
## Check we report an error for non-regular archives.
# RUN: yaml2obj %s --docnum=3 -o %t.not.regular.a
# RUN: not obj2yaml %t.not.regular.a 2>&1 | \
# RUN: FileCheck %s -DFILE=%t.not.regular.a --check-prefix=NOT-REGULAR-ERR
# NOT-REGULAR-ERR: Error reading file: [[FILE]]: only regular archives are supported
--- !Arch
Magic: "!<thin>\n"
Members:
- {}
## Check we report an error when unable to read the header of an archive member.
# RUN: yaml2obj %s --docnum=4 -o %t.truncated.a
# RUN: not obj2yaml %t.truncated.a 2>&1 | \
# RUN: FileCheck %s -DFILE=%t.truncated.a --check-prefix=TRUNCATED-ERR
# TRUNCATED-ERR: Error reading file: [[FILE]]: unable to read the header of a child at offset 0x8
--- !Arch
Content: "00"
## Check we report an error when unable to read the data of an archive member.
# RUN: yaml2obj %s --docnum=5 -o %t.entdata.a
# RUN: not obj2yaml %t.entdata.a 2>&1 | \
# RUN: FileCheck %s -DFILE=%t.entdata.a --check-prefix=ENTDATA-ERR
# ENTDATA-ERR: Error reading file: [[FILE]]: unable to read the data of a child at offset 0x8 of size 1: the remaining archive size is 0
--- !Arch
Members:
- Size: [[SIZE='1']]
## Check we report an error when unable to read the size of an archive member.
# RUN: yaml2obj %s --docnum=5 -DSIZE='x' -o %t.entsize.a
# RUN: not obj2yaml %t.entsize.a 2>&1 | \
# RUN: FileCheck %s -DFILE=%t.entsize.a --check-prefix=ENTSIZE-ERR
# ENTSIZE-ERR: Error reading file: [[FILE]]: unable to read the size of a child at offset 0x8 as integer: "x"
## Check we don't try to dump the padding byte when the size of the content is odd and
## the content ends at the end of a file.
# RUN: yaml2obj %s --docnum=6 -DCONTENT="61" -o %t.no.padding.byte.a
# RUN: obj2yaml %t.no.padding.byte.a | FileCheck %s --check-prefix=NO-PADDING-BYTE
# NO-PADDING-BYTE: --- !Arch
# NO-PADDING-BYTE-NEXT: Members:
# NO-PADDING-BYTE-NEXT: - Size: '1'
# NO-PADDING-BYTE-NEXT: Content: '61'
# NO-PADDING-BYTE-NEXT: ...
--- !Arch
Members:
- Size: '1'
Content: [[CONTENT]]
## Check we dump the padding byte when the size of the content is odd and the content ends
## before the end of a file.
# RUN: yaml2obj %s --docnum=6 -DCONTENT="610A" -o %t.padding.byte.a
# RUN: obj2yaml %t.padding.byte.a | FileCheck %s --check-prefix=PADDING-BYTE
# PADDING-BYTE: --- !Arch
# PADDING-BYTE-NEXT: Members:
# PADDING-BYTE-NEXT: - Size: '1'
# PADDING-BYTE-NEXT: Content: '61'
# PADDING-BYTE-NEXT: PaddingByte: 0xA
# PADDING-BYTE-NEXT: ...