[ELF][test] Clean up print-archive-stats.s

This commit is contained in:
Fangrui Song 2022-07-26 14:36:09 -07:00
parent 3928e89c31
commit e27a029ed0
1 changed files with 20 additions and 18 deletions

View File

@ -1,35 +1,37 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
# RUN: echo '.globl weak; weak:' | llvm-mc -filetype=obj -triple=x86_64 - -o %tweak.o
# RUN: echo '.global foo; foo:' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o
# RUN: echo '.global bar; bar:' | llvm-mc -filetype=obj -triple=x86_64 - -o %t2.o
# RUN: echo '.global baz; baz:' | llvm-mc -filetype=obj -triple=x86_64 - -o %t3.o
# RUN: rm -f %tweak.a && llvm-ar rc %tweak.a %tweak.o
# RUN: rm -f %t1.a && llvm-ar rc %t1.a %t1.o %t2.o %t3.o
# RUN: rm -rf %t && split-file %s %t && cd %t
# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o
# RUN: echo '.globl weak; weak:' | llvm-mc -filetype=obj -triple=x86_64 - -o weak.o
# RUN: echo '.global foo; foo:' | llvm-mc -filetype=obj -triple=x86_64 - -o 1.o
# RUN: echo '.global bar; bar:' | llvm-mc -filetype=obj -triple=x86_64 - -o 2.o
# RUN: echo '.global baz; baz:' | llvm-mc -filetype=obj -triple=x86_64 - -o 3.o
# RUN: rm -f weak.a && llvm-ar rc weak.a weak.o
# RUN: rm -f 1.a && llvm-ar rc 1.a 1.o 2.o 3.o
# RUN: ld.lld %t.o %tweak.a %t1.a --print-archive-stats=%t.txt -o /dev/null
# RUN: FileCheck --input-file=%t.txt -DT=%t %s --match-full-lines --strict-whitespace
# RUN: ld.lld a.o %t/weak.a 1.a --print-archive-stats=a.txt -o /dev/null
# RUN: FileCheck --input-file=a.txt -DT=%t %s --match-full-lines --strict-whitespace
## Fetches 0 member from %tweak.a and 2 members from %t1.a
## Fetches 0 member from %t/weak.a and 2 members from %t1.a
# CHECK:members extracted archive
# CHECK-NEXT:1 0 [[T]]weak.a
# CHECK-NEXT:3 2 [[T]]1.a
# CHECK-NEXT:1 0 [[T]]/weak.a
# CHECK-NEXT:3 2 1.a
## - means stdout.
# RUN: ld.lld %t.o %tweak.a %t1.a --print-archive-stats=- -o /dev/null | diff %t.txt -
# RUN: ld.lld a.o %t/weak.a 1.a --print-archive-stats=- -o /dev/null | diff a.txt -
## The second %t1.a has 0 fetched member.
# RUN: ld.lld %t.o %tweak.a %t1.a %t1.a --print-archive-stats=- -o /dev/null | \
## The second 1.a has 0 fetched member.
# RUN: ld.lld a.o %t/weak.a 1.a 1.a --print-archive-stats=- -o /dev/null | \
# RUN: FileCheck --check-prefix=CHECK2 %s
# CHECK2: members extracted archive
# CHECK2-NEXT: 1 0 {{.*}}weak.a
# CHECK2-NEXT: 3 2 {{.*}}1.a
# CHECK2-NEXT: 3 0 {{.*}}1.a
# CHECK2-NEXT: 3 2 1.a
# CHECK2-NEXT: 3 0 1.a
# RUN: not ld.lld -shared %t.o --print-archive-stats=/ -o /dev/null 2>&1 | FileCheck --check-prefix=ERR %s
# RUN: not ld.lld -shared a.o --print-archive-stats=/ -o /dev/null 2>&1 | FileCheck --check-prefix=ERR %s
# ERR: error: --print-archive-stats=: cannot open /: {{.*}}
#--- a.s
.globl _start
.weak weak
_start: