## Check how yaml2obj creates archives. ## Check we create an empty archive when neither "Members" nor "Content" are specified. # RUN: yaml2obj --docnum=1 %s -o %t.empty.a # RUN: llvm-ar t %t.empty.a | FileCheck %s --allow-empty --implicit-check-not={{.}} # RUN: wc -c < %t.empty.a | FileCheck %s --check-prefix=EMPTY-SIZE # RUN: od -t x1 -v %t.empty.a | FileCheck %s --ignore-case --check-prefix=EMPTY-DATA # EMPTY-SIZE: 8{{$}} # EMPTY-DATA: 21 3c 61 72 63 68 3e 0a --- !Arch Magic: "[[MAGIC=!\n]]" Content: [[CONTENT=]] Members: [[MEMBERS=]] ## Check we report an error when both "Content" and "Members" keys are used together. # RUN: not yaml2obj --docnum=1 -DMEMBERS="[]" -DCONTENT="00" %s 2>&1 | FileCheck %s --check-prefix=BOTH ## BOTH: error: "Content" and "Members" cannot be used together ## Check we can use the "Content" key alone. # RUN: yaml2obj --docnum=1 -DCONTENT="12" %s -o %t.content.a # RUN: wc -c < %t.content.a | FileCheck %s --check-prefix=CONTENT-SIZE # RUN: od -t x1 -v %t.content.a | FileCheck %s --ignore-case --check-prefix=CONTENT # CONTENT-SIZE: 9{{$}} # CONTENT: 21 3c 61 72 63 68 3e 0a 12 ## Check we can specify magic bytes of size greater than the normal size (size of "!\n"). # RUN: yaml2obj --docnum=1 -DMAGIC="123456789" %s -o %t.magic2.a # RUN: wc -c < %t.magic2.a | FileCheck %s --check-prefix=MAGIC-SIZE-GR # RUN: od -t x1 -v %t.magic2.a | FileCheck %s --ignore-case --check-prefix=MAGIC-DATA-GR # MAGIC-SIZE-GR: 9{{$}} # MAGIC-DATA-GR: 31 32 33 34 35 36 37 38 39 ## Check we can specify magic bytes of size less than the normal size (size of "!\n"). # RUN: yaml2obj --docnum=1 -DMAGIC="1234567" %s -o %t.magic3.a # RUN: wc -c < %t.magic3.a | FileCheck %s --check-prefix=MAGIC-SIZE-LESS # RUN: od -t x1 -v %t.magic3.a | FileCheck %s --ignore-case --check-prefix=MAGIC-DATA-LESS # MAGIC-SIZE-LESS: 7{{$}} # MAGIC-DATA-LESS: 31 32 33 34 35 36 37 ## Check we can produce a valid archive with multiple members. ## Check we are able to omit the "Magic" key and this defaults to "!\n". # RUN: yaml2obj --docnum=2 %s -o %t.two.a # RUN: llvm-ar -t %t.two.a | FileCheck %s --check-prefix=TWO # RUN: FileCheck --input-file=%t.two.a %s \ # RUN: --match-full-lines --strict-whitespace --check-prefix=TWO-DATA # TWO: {{^}}bbbbbbbbbbbbbbb{{$}} # TWO-NEXT: {{^}}a{{$}} # TWO-NOT: {{.}} # TWO-DATA:! # TWO-DATA-NEXT:bbbbbbbbbbbbbbb/1234567890abqwertyasdfgh876543217 ` # TWO-DATA-NEXT: cccc {{$}} # TWO-DATA-NEXT:za/ 1 2 3 456 6 ` # TWO-DATA-NEXT: aaa {{$}} # TWO-DATA-NOT:{{.}} --- !Arch Members: ## An arbitrary entry where each of fields has maximum allowed length. - Name: 'bbbbbbbbbbbbbbb/' LastModified: '1234567890ab' UID: 'qwerty' GID: 'asdfgh' AccessMode: '87654321' Size: '7' Terminator: "`\n" Content: "2063636363200A" PaddingByte: 0x7a ## 'z' ## An arbitrary entry to demonstrate that we use the 0x20 byte (space character) ## to fill gaps between field values. - Name: 'a/' LastModified: '1' UID: '2' GID: '3' AccessMode: '456' Size: '6' Terminator: "`\n" Content: "20616161200A" ## Check how we validate maximum sizes of fields. # RUN: not yaml2obj --docnum=3 -DNAME="123456789ABCDEF01" %s 2>&1 | \ # RUN: FileCheck %s --check-prefix=ERROR -DFIELD="Name" -DVAL=16 # RUN: not yaml2obj --docnum=3 -DLAST="123456789ABCD" %s 2>&1 | \ # RUN: FileCheck %s --check-prefix=ERROR -DFIELD="LastModified" -DVAL=12 # RUN: not yaml2obj --docnum=3 -DUID="1234567" %s 2>&1 | \ # RUN: FileCheck %s --check-prefix=ERROR -DFIELD="UID" -DVAL=6 # RUN: not yaml2obj --docnum=3 -DGID="1234567" %s 2>&1 | \ # RUN: FileCheck %s --check-prefix=ERROR -DFIELD="GID" -DVAL=6 # RUN: not yaml2obj --docnum=3 -DACCESSMODE="123456789" %s 2>&1 | \ # RUN: FileCheck %s --check-prefix=ERROR -DFIELD="AccessMode" -DVAL=8 # RUN: not yaml2obj --docnum=3 -DSIZE="123456789AB" %s 2>&1 | \ # RUN: FileCheck %s --check-prefix=ERROR -DFIELD="Size" -DVAL=10 # RUN: not yaml2obj --docnum=3 -DTERMINATOR="123" %s 2>&1 | \ # RUN: FileCheck %s --check-prefix=ERROR -DFIELD="Terminator" -DVAL=2 # ERROR: error: the maximum length of "[[FIELD]]" field is [[VAL]] --- !Arch Members: - Name: '[[NAME=""]]' LastModified: '[[LAST=""]]' UID: '[[UID=""]]' GID: '[[GID=""]]' AccessMode: '[[ACCESSMODE=""]]' Size: '[[SIZE=""]]' Terminator: '[[TERMINATOR=""]]' ## Check that all keys are optional for members. # RUN: yaml2obj --docnum=4 %s -o %t.all.defaults.a # RUN: FileCheck --input-file=%t.all.defaults.a %s \ # RUN: --match-full-lines --strict-whitespace --check-prefix=DEFAULTS # DEFAULTS:! # DEFAULTS-NEXT: 0 0 0 0 0 ` # DEFAULTS-NEXT: 0 0 0 0 0 ` # DEFAULTS-NOT:{{.}} --- !Arch Members: - {} - {}