1## Check how yaml2obj creates archives. 2 3## Check we create an empty archive when neither "Members" nor "Content" are specified. 4 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 9 10# EMPTY-SIZE: 8{{$}} 11# EMPTY-DATA: 21 3c 61 72 63 68 3e 0a 12 13--- !Arch 14Magic: "[[MAGIC=!<arch>\n]]" 15Content: [[CONTENT=<none>]] 16Members: [[MEMBERS=<none>]] 17 18## Check we report an error when both "Content" and "Members" keys are used together. 19 20# RUN: not yaml2obj --docnum=1 -DMEMBERS="[]" -DCONTENT="00" %s 2>&1 | FileCheck %s --check-prefix=BOTH 21 22## BOTH: error: "Content" and "Members" cannot be used together 23 24## Check we can use the "Content" key alone. 25 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 29 30# CONTENT-SIZE: 9{{$}} 31# CONTENT: 21 3c 61 72 63 68 3e 0a 12 32 33## Check we can specify magic bytes of size greater than the normal size (size of "!<arch>\n"). 34 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 38 39# MAGIC-SIZE-GR: 9{{$}} 40# MAGIC-DATA-GR: 31 32 33 34 35 36 37 38 39 41 42## Check we can specify magic bytes of size less than the normal size (size of "!<arch>\n"). 43 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 47 48# MAGIC-SIZE-LESS: 7{{$}} 49# MAGIC-DATA-LESS: 31 32 33 34 35 36 37 50 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". 53 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 58 59# TWO: {{^}}bbbbbbbbbbbbbbb{{$}} 60# TWO-NEXT: {{^}}a{{$}} 61# TWO-NOT: {{.}} 62 63# TWO-DATA:!<arch> 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 {{$}} 68# TWO-DATA-NOT:{{.}} 69 70--- !Arch 71Members: 72## An arbitrary entry where each of fields has maximum allowed length. 73 - Name: 'bbbbbbbbbbbbbbb/' 74 LastModified: '1234567890ab' 75 UID: 'qwerty' 76 GID: 'asdfgh' 77 AccessMode: '87654321' 78 Size: '7' 79 Terminator: "`\n" 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. 84 - Name: 'a/' 85 LastModified: '1' 86 UID: '2' 87 GID: '3' 88 AccessMode: '456' 89 Size: '6' 90 Terminator: "`\n" 91 Content: "20616161200A" 92 93## Check how we validate maximum sizes of fields. 94 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 109 110# ERROR: error: the maximum length of "[[FIELD]]" field is [[VAL]] 111 112--- !Arch 113Members: 114 - Name: '[[NAME=""]]' 115 LastModified: '[[LAST=""]]' 116 UID: '[[UID=""]]' 117 GID: '[[GID=""]]' 118 AccessMode: '[[ACCESSMODE=""]]' 119 Size: '[[SIZE=""]]' 120 Terminator: '[[TERMINATOR=""]]' 121 122## Check that all keys are optional for members. 123 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 127 128# DEFAULTS:!<arch> 129# DEFAULTS-NEXT: 0 0 0 0 0 ` 130# DEFAULTS-NEXT: 0 0 0 0 0 ` 131# DEFAULTS-NOT:{{.}} 132 133--- !Arch 134Members: 135 - {} 136 - {} 137