1 ## Check how yaml2obj creates archives.
3 ## Check we create an empty archive when neither "Members" nor "Content" are specified.
5 # RUN: yaml2obj --docnum=1 %s -o %t.empty.a
6 # RUN: llvm-ar t %t.empty.a | FileCheck %s --allow-empty --implicit-check-not={{.}}
7 # RUN: wc -c < %t.empty.a | FileCheck %s --check-prefix=EMPTY-SIZE
8 # RUN: od -t x1 -v %t.empty.a | FileCheck %s --ignore-case --check-prefix=EMPTY-DATA
11 # EMPTY-DATA: 21 3c 61 72 63 68 3e 0a
14 Magic: "[[MAGIC=!<arch>\n]]"
15 Content: [[CONTENT=<none>]]
16 Members: [[MEMBERS=<none>]]
18 ## Check we report an error when both "Content" and "Members" keys are used together.
20 # RUN: not yaml2obj --docnum=1 -DMEMBERS="[]" -DCONTENT="00" %s 2>&1 | FileCheck %s --check-prefix=BOTH
22 ## BOTH: error: "Content" and "Members" cannot be used together
24 ## Check we can use the "Content" key alone.
26 # RUN: yaml2obj --docnum=1 -DCONTENT="12" %s -o %t.content.a
27 # RUN: wc -c < %t.content.a | FileCheck %s --check-prefix=CONTENT-SIZE
28 # RUN: od -t x1 -v %t.content.a | FileCheck %s --ignore-case --check-prefix=CONTENT
30 # CONTENT-SIZE: 9{{$}}
31 # CONTENT: 21 3c 61 72 63 68 3e 0a 12
33 ## Check we can specify magic bytes of size greater than the normal size (size of "!<arch>\n").
35 # RUN: yaml2obj --docnum=1 -DMAGIC="123456789" %s -o %t.magic2.a
36 # RUN: wc -c < %t.magic2.a | FileCheck %s --check-prefix=MAGIC-SIZE-GR
37 # RUN: od -t x1 -v %t.magic2.a | FileCheck %s --ignore-case --check-prefix=MAGIC-DATA-GR
39 # MAGIC-SIZE-GR: 9{{$}}
40 # MAGIC-DATA-GR: 31 32 33 34 35 36 37 38 39
42 ## Check we can specify magic bytes of size less than the normal size (size of "!<arch>\n").
44 # RUN: yaml2obj --docnum=1 -DMAGIC="1234567" %s -o %t.magic3.a
45 # RUN: wc -c < %t.magic3.a | FileCheck %s --check-prefix=MAGIC-SIZE-LESS
46 # RUN: od -t x1 -v %t.magic3.a | FileCheck %s --ignore-case --check-prefix=MAGIC-DATA-LESS
48 # MAGIC-SIZE-LESS: 7{{$}}
49 # MAGIC-DATA-LESS: 31 32 33 34 35 36 37
51 ## Check we can produce a valid archive with multiple members.
52 ## Check we are able to omit the "Magic" key and this defaults to "!<arch>\n".
54 # RUN: yaml2obj --docnum=2 %s -o %t.two.a
55 # RUN: llvm-ar -t %t.two.a | FileCheck %s --check-prefix=TWO
56 # RUN: FileCheck --input-file=%t.two.a %s \
57 # RUN: --match-full-lines --strict-whitespace --check-prefix=TWO-DATA
59 # TWO: {{^}}bbbbbbbbbbbbbbb{{$}}
60 # TWO-NEXT: {{^}}a{{$}}
64 # TWO-DATA-NEXT:bbbbbbbbbbbbbbb/1234567890abqwertyasdfgh876543217 `
65 # TWO-DATA-NEXT: cccc {{$}}
66 # TWO-DATA-NEXT:za/ 1 2 3 456 6 `
67 # TWO-DATA-NEXT: aaa {{$}}
72 ## An arbitrary entry where each of fields has maximum allowed length.
73 - Name: 'bbbbbbbbbbbbbbb/'
74 LastModified: '1234567890ab'
77 AccessMode: '87654321'
80 Content: "2063636363200A"
81 PaddingByte: 0x7a ## 'z'
82 ## An arbitrary entry to demonstrate that we use the 0x20 byte (space character)
83 ## to fill gaps between field values.
91 Content: "20616161200A"
93 ## Check how we validate maximum sizes of fields.
95 # RUN: not yaml2obj --docnum=3 -DNAME="123456789ABCDEF01" %s 2>&1 | \
96 # RUN: FileCheck %s --check-prefix=ERROR -DFIELD="Name" -DVAL=16
97 # RUN: not yaml2obj --docnum=3 -DLAST="123456789ABCD" %s 2>&1 | \
98 # RUN: FileCheck %s --check-prefix=ERROR -DFIELD="LastModified" -DVAL=12
99 # RUN: not yaml2obj --docnum=3 -DUID="1234567" %s 2>&1 | \
100 # RUN: FileCheck %s --check-prefix=ERROR -DFIELD="UID" -DVAL=6
101 # RUN: not yaml2obj --docnum=3 -DGID="1234567" %s 2>&1 | \
102 # RUN: FileCheck %s --check-prefix=ERROR -DFIELD="GID" -DVAL=6
103 # RUN: not yaml2obj --docnum=3 -DACCESSMODE="123456789" %s 2>&1 | \
104 # RUN: FileCheck %s --check-prefix=ERROR -DFIELD="AccessMode" -DVAL=8
105 # RUN: not yaml2obj --docnum=3 -DSIZE="123456789AB" %s 2>&1 | \
106 # RUN: FileCheck %s --check-prefix=ERROR -DFIELD="Size" -DVAL=10
107 # RUN: not yaml2obj --docnum=3 -DTERMINATOR="123" %s 2>&1 | \
108 # RUN: FileCheck %s --check-prefix=ERROR -DFIELD="Terminator" -DVAL=2
110 # ERROR: error: the maximum length of "[[FIELD]]" field is [[VAL]]
114 - Name: '[[NAME=""]]'
115 LastModified: '[[LAST=""]]'
118 AccessMode: '[[ACCESSMODE=""]]'
120 Terminator: '[[TERMINATOR=""]]'
122 ## Check that all keys are optional for members.
124 # RUN: yaml2obj --docnum=4 %s -o %t.all.defaults.a
125 # RUN: FileCheck --input-file=%t.all.defaults.a %s \
126 # RUN: --match-full-lines --strict-whitespace --check-prefix=DEFAULTS
129 # DEFAULTS-NEXT: 0 0 0 0 0 `
130 # DEFAULTS-NEXT: 0 0 0 0 0 `