1## Check how obj2yaml dumps regular archives. 2 3## Check how we dump an empty archive. 4 5# RUN: yaml2obj %s --docnum=1 -o %t.empty.a 6# RUN: obj2yaml %t.empty.a > %t.stdout.yaml 7# RUN: obj2yaml %t.empty.a -o %t.file.yaml 2>&1 | count 0 8# RUN: FileCheck --input-file=%t.stdout.yaml %s --check-prefix=EMPTY 9# RUN: diff %t.stdout.yaml %t.file.yaml 10 11# EMPTY: --- !Arch 12# EMPTY-NEXT: Members: [] 13# EMPTY-NEXT: ... 14 15--- !Arch 16Members: [] 17 18## Check how we dump archives with multiple members. 19## Check we don't dump excessive spaces when dumping fields. 20## Check we don't dump fields with values that are equal to default values. 21## Check how we dump empty field values. 22 23# RUN: yaml2obj %s --docnum=2 -o %t.multiple.a 24# RUN: obj2yaml %t.multiple.a | FileCheck %s --check-prefix=MULTIPLE 25 26# MULTIPLE: --- !Arch 27# MULTIPLE-NEXT: Members: 28# MULTIPLE-NEXT: - Name: 'bbb/' 29# MULTIPLE-NEXT: LastModified: '1' 30# MULTIPLE-NEXT: UID: '2' 31# MULTIPLE-NEXT: GID: '3' 32# MULTIPLE-NEXT: AccessMode: '644' 33# MULTIPLE-NEXT: Size: '6' 34# MULTIPLE-NEXT: Content: 20616161200A 35# MULTIPLE-NEXT: - Name: 'dddd/' 36# MULTIPLE-NEXT: LastModified: '4' 37# MULTIPLE-NEXT: UID: '5' 38# MULTIPLE-NEXT: GID: '6' 39# MULTIPLE-NEXT: AccessMode: '987' 40# MULTIPLE-NEXT: Size: '7' 41# MULTIPLE-NEXT: Content: 2063636363200A 42# MULTIPLE-NEXT: PaddingByte: 0xA 43# MULTIPLE-NEXT: - LastModified: '' 44# MULTIPLE-NEXT: UID: '' 45# MULTIPLE-NEXT: GID: '' 46# MULTIPLE-NEXT: AccessMode: '' 47# MULTIPLE-NEXT: Terminator: '' 48# MULTIPLE-NEXT: Content: '' 49# MULTIPLE-NEXT: - {} 50# MULTIPLE-NEXT: ... 51 52--- !Arch 53Members: 54 - Name: 'bbb/' 55 LastModified: '1' 56 UID: '2' 57 GID: '3' 58 AccessMode: '644' 59 Size: '6' 60 Terminator: "`\n" 61 Content: 20616161200A ## " aaa \n" 62 - Name: 'dddd/' 63 LastModified: '4' 64 UID: '5' 65 GID: '6' 66 AccessMode: '987' 67 Size: '7' 68 Terminator: "`\n" 69 Content: 2063636363200A ## " cccc \n" 70 PaddingByte: 0x0A 71## All fields are empty (where possible). 72 - Name: '' 73 LastModified: '' 74 UID: '' 75 GID: '' 76 AccessMode: '' 77 Size: '0' 78 Terminator: '' 79 Content: '' 80## All fields are explicitly set to the default values. 81 - Name: '' 82 LastModified: '0' 83 UID: '0' 84 GID: '0' 85 AccessMode: '0' 86 Size: '0' 87 Terminator: "`\n" 88 Content: "" 89... 90 91## Check we report an error for non-regular archives. 92 93# RUN: yaml2obj %s --docnum=3 -o %t.not.regular.a 94# RUN: not obj2yaml %t.not.regular.a 2>&1 | \ 95# RUN: FileCheck %s -DFILE=%t.not.regular.a --check-prefix=NOT-REGULAR-ERR 96 97# NOT-REGULAR-ERR: Error reading file: [[FILE]]: only regular archives are supported 98 99--- !Arch 100Magic: "!<thin>\n" 101Members: 102 - {} 103 104## Check we report an error when unable to read the header of an archive member. 105 106# RUN: yaml2obj %s --docnum=4 -o %t.truncated.a 107# RUN: not obj2yaml %t.truncated.a 2>&1 | \ 108# RUN: FileCheck %s -DFILE=%t.truncated.a --check-prefix=TRUNCATED-ERR 109 110# TRUNCATED-ERR: Error reading file: [[FILE]]: unable to read the header of a child at offset 0x8 111 112--- !Arch 113Content: "00" 114 115## Check we report an error when unable to read the data of an archive member. 116 117# RUN: yaml2obj %s --docnum=5 -o %t.entdata.a 118# RUN: not obj2yaml %t.entdata.a 2>&1 | \ 119# RUN: FileCheck %s -DFILE=%t.entdata.a --check-prefix=ENTDATA-ERR 120 121# 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 122 123--- !Arch 124Members: 125 - Size: [[SIZE='1']] 126 127## Check we report an error when unable to read the size of an archive member. 128 129# RUN: yaml2obj %s --docnum=5 -DSIZE='x' -o %t.entsize.a 130# RUN: not obj2yaml %t.entsize.a 2>&1 | \ 131# RUN: FileCheck %s -DFILE=%t.entsize.a --check-prefix=ENTSIZE-ERR 132 133# ENTSIZE-ERR: Error reading file: [[FILE]]: unable to read the size of a child at offset 0x8 as integer: "x" 134 135## Check we don't try to dump the padding byte when the size of the content is odd and 136## the content ends at the end of a file. 137 138# RUN: yaml2obj %s --docnum=6 -DCONTENT="61" -o %t.no.padding.byte.a 139# RUN: obj2yaml %t.no.padding.byte.a | FileCheck %s --check-prefix=NO-PADDING-BYTE 140 141# NO-PADDING-BYTE: --- !Arch 142# NO-PADDING-BYTE-NEXT: Members: 143# NO-PADDING-BYTE-NEXT: - Size: '1' 144# NO-PADDING-BYTE-NEXT: Content: '61' 145# NO-PADDING-BYTE-NEXT: ... 146 147--- !Arch 148Members: 149 - Size: '1' 150 Content: [[CONTENT]] 151 152## Check we dump the padding byte when the size of the content is odd and the content ends 153## before the end of a file. 154 155# RUN: yaml2obj %s --docnum=6 -DCONTENT="610A" -o %t.padding.byte.a 156# RUN: obj2yaml %t.padding.byte.a | FileCheck %s --check-prefix=PADDING-BYTE 157 158# PADDING-BYTE: --- !Arch 159# PADDING-BYTE-NEXT: Members: 160# PADDING-BYTE-NEXT: - Size: '1' 161# PADDING-BYTE-NEXT: Content: '61' 162# PADDING-BYTE-NEXT: PaddingByte: 0xA 163# PADDING-BYTE-NEXT: ... 164