137 lines · yaml
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.a6# 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-SIZE8# RUN: od -t x1 -v %t.empty.a | FileCheck %s --ignore-case --check-prefix=EMPTY-DATA9 10# EMPTY-SIZE: 8{{$}}11# EMPTY-DATA: 21 3c 61 72 63 68 3e 0a12 13--- !Arch14Magic: "[[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=BOTH21 22## BOTH: error: "Content" and "Members" cannot be used together23 24## Check we can use the "Content" key alone.25 26# RUN: yaml2obj --docnum=1 -DCONTENT="12" %s -o %t.content.a27# RUN: wc -c < %t.content.a | FileCheck %s --check-prefix=CONTENT-SIZE28# RUN: od -t x1 -v %t.content.a | FileCheck %s --ignore-case --check-prefix=CONTENT29 30# CONTENT-SIZE: 9{{$}}31# CONTENT: 21 3c 61 72 63 68 3e 0a 1232 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.a36# RUN: wc -c < %t.magic2.a | FileCheck %s --check-prefix=MAGIC-SIZE-GR37# RUN: od -t x1 -v %t.magic2.a | FileCheck %s --ignore-case --check-prefix=MAGIC-DATA-GR38 39# MAGIC-SIZE-GR: 9{{$}}40# MAGIC-DATA-GR: 31 32 33 34 35 36 37 38 3941 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.a45# RUN: wc -c < %t.magic3.a | FileCheck %s --check-prefix=MAGIC-SIZE-LESS46# RUN: od -t x1 -v %t.magic3.a | FileCheck %s --ignore-case --check-prefix=MAGIC-DATA-LESS47 48# MAGIC-SIZE-LESS: 7{{$}}49# MAGIC-DATA-LESS: 31 32 33 34 35 36 3750 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.a55# RUN: llvm-ar -t %t.two.a | FileCheck %s --check-prefix=TWO56# RUN: FileCheck --input-file=%t.two.a %s \57# RUN: --match-full-lines --strict-whitespace --check-prefix=TWO-DATA58 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--- !Arch71Members: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=1697# RUN: not yaml2obj --docnum=3 -DLAST="123456789ABCD" %s 2>&1 | \98# RUN: FileCheck %s --check-prefix=ERROR -DFIELD="LastModified" -DVAL=1299# RUN: not yaml2obj --docnum=3 -DUID="1234567" %s 2>&1 | \100# RUN: FileCheck %s --check-prefix=ERROR -DFIELD="UID" -DVAL=6101# RUN: not yaml2obj --docnum=3 -DGID="1234567" %s 2>&1 | \102# RUN: FileCheck %s --check-prefix=ERROR -DFIELD="GID" -DVAL=6103# RUN: not yaml2obj --docnum=3 -DACCESSMODE="123456789" %s 2>&1 | \104# RUN: FileCheck %s --check-prefix=ERROR -DFIELD="AccessMode" -DVAL=8105# RUN: not yaml2obj --docnum=3 -DSIZE="123456789AB" %s 2>&1 | \106# RUN: FileCheck %s --check-prefix=ERROR -DFIELD="Size" -DVAL=10107# RUN: not yaml2obj --docnum=3 -DTERMINATOR="123" %s 2>&1 | \108# RUN: FileCheck %s --check-prefix=ERROR -DFIELD="Terminator" -DVAL=2109 110# ERROR: error: the maximum length of "[[FIELD]]" field is [[VAL]]111 112--- !Arch113Members: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.a125# RUN: FileCheck --input-file=%t.all.defaults.a %s \126# RUN: --match-full-lines --strict-whitespace --check-prefix=DEFAULTS127 128# DEFAULTS:!<arch>129# DEFAULTS-NEXT: 0 0 0 0 0 `130# DEFAULTS-NEXT: 0 0 0 0 0 `131# DEFAULTS-NOT:{{.}}132 133--- !Arch134Members:135 - {}136 - {}137