1## Test quick append
2
3# RUN: rm -rf %t && mkdir -p %t
4# RUN: yaml2obj %s -o %t/1.o --docnum=1
5# RUN: yaml2obj %s -o %t/2.o --docnum=2
6
7## Append single member:
8# RUN: llvm-ar qc %t/single.a %t/1.o
9# RUN: llvm-ar t %t/single.a \
10# RUN:   | FileCheck %s --check-prefix=SINGLE --match-full-lines --implicit-check-not {{.}}
11
12# SINGLE: 1.o{{$}}
13
14# RUN: llvm-nm --print-armap %t/single.a \
15# RUN:   | FileCheck %s --check-prefix=SINGLE-SYM
16
17# SINGLE-SYM: symbol1
18
19## Append multiple members:
20# RUN: llvm-ar qc %t/multiple.a %t/1.o %t/2.o
21# RUN: llvm-ar t %t/multiple.a \
22# RUN:   | FileCheck %s --check-prefix=MULTIPLE --match-full-lines --implicit-check-not {{.}}
23
24# MULTIPLE:      1.o{{$}}
25# MULTIPLE-NEXT: 2.o{{$}}
26
27# RUN: llvm-nm --print-armap %t/multiple.a \
28# RUN:   | FileCheck %s --check-prefix=MULTIPLE-SYM
29
30# MULTIPLE-SYM:      symbol1 in 1.o
31# MULTIPLE-SYM-NEXT: symbol2 in 2.o
32
33## Append same member:
34# RUN: llvm-ar qc %t/same.a %t/1.o %t/1.o
35# RUN: llvm-ar t %t/same.a \
36# RUN:   | FileCheck %s --check-prefix=SAME -DFILE=%t/2.o --match-full-lines --implicit-check-not {{.}}
37
38# SAME:      1.o{{$}}
39# SAME-NEXT: 1.o{{$}}
40
41# RUN: llvm-nm --print-armap %t/same.a \
42# RUN:   | FileCheck %s --check-prefix=SAME-SYM
43
44# SAME-SYM:      symbol1 in 1.o
45# SAME-SYM-NEXT: symbol1 in 1.o
46
47## Append without member:
48# RUN: llvm-ar qc %t/without.a
49# RUN: llvm-ar t %t/without.a | count 0
50
51# RUN: llvm-nm --print-armap %t/without.a | count 0
52
53## No archive:
54# RUN: not llvm-ar qc 2>&1 \
55# RUN:   | FileCheck %s --check-prefix=NO-ARCHIVE
56
57# NO-ARCHIVE: error: an archive name must be specified
58
59## Member does not exist:
60# RUN: not llvm-ar qc %t/missing.a %t/missing.txt 2>&1 \
61# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt
62
63# MISSING-FILE: error: [[FILE]]: {{[nN]}}o such file or directory
64
65## Create and append members to a thin archive:
66# RUN: llvm-ar qcT %t/thin-multiple.a %t/1.o
67# RUN: llvm-ar qcT %t/thin-multiple.a %t/2.o
68# RUN: llvm-ar t %t/thin-multiple.a \
69# RUN:   | FileCheck %s --check-prefix=MULTIPLE
70
71# RUN: llvm-ar qcT %t/thin-same.a %t/1.o %t/1.o
72# RUN: llvm-ar t %t/thin-same.a \
73# RUN:   | FileCheck %s --check-prefix=SAME
74
75--- !ELF
76FileHeader:
77  Class:   ELFCLASS64
78  Data:    ELFDATA2LSB
79  Type:    ET_REL
80  Machine: EM_X86_64
81Sections:
82  - Name: .text
83    Type: SHT_PROGBITS
84Symbols:
85  - Name:    symbol1
86    Binding: STB_GLOBAL
87    Section: .text
88
89--- !ELF
90FileHeader:
91  Class:   ELFCLASS64
92  Data:    ELFDATA2LSB
93  Type:    ET_REL
94  Machine: EM_X86_64
95Sections:
96  - Name: .text
97    Type: SHT_PROGBITS
98Symbols:
99  - Name:    symbol2
100    Binding: STB_GLOBAL
101    Section: .text
102