1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

[llvm-ar][test] Add to thin archive test coverage

This diff adds test coverage for thin archives including additions to
existing tests. In some cases I have updated the formats of these tests
to better match other tests in the archive.

Differential Revision: https://reviews.llvm.org/D70969
This commit is contained in:
gbreynoo 2019-12-04 16:17:42 +00:00
parent 9000efd589
commit cf0bee260d
6 changed files with 136 additions and 82 deletions

View File

@ -1,31 +1,36 @@
## Test extract operation.
# XFAIL: system-darwin
RUN: rm -rf %t && mkdir -p %t/extracted/
# RUN: rm -rf %t && mkdir -p %t/extracted/
# Extracting from an empty archive should not warn or error:
RUN: llvm-ar cr %t/empty.a
RUN: llvm-ar xv %t/empty.a 2>&1 | count 0
## Extracting from an empty archive should not warn or error:
# RUN: llvm-ar cr %t/empty.a
# RUN: llvm-ar xv %t/empty.a 2>&1 | count 0
RUN: echo filea > %t/a.txt
RUN: echo fileb > %t/b.txt
RUN: llvm-ar rc %t/archive.a %t/a.txt %t/b.txt
# RUN: echo filea > %t/a.txt
# RUN: echo fileb > %t/b.txt
# RUN: llvm-ar rc %t/archive.a %t/a.txt %t/b.txt
# Single member:
RUN: cd %t/extracted && llvm-ar xv %t/archive.a a.txt | FileCheck %s --check-prefix=A
RUN: diff %t/a.txt %t/extracted/a.txt
A: x - a.txt
## Single member:
# RUN: cd %t/extracted && llvm-ar xv %t/archive.a a.txt | FileCheck %s --check-prefix=A
# RUN: diff %t/a.txt %t/extracted/a.txt
# A: x - a.txt
# All members:
RUN: rm %t/extracted/a.txt
RUN: cd %t/extracted && llvm-ar xv %t/archive.a | FileCheck %s --check-prefix=AB
RUN: diff %t/a.txt %t/extracted/a.txt
RUN: diff %t/b.txt %t/extracted/b.txt
AB: x - a.txt
AB: x - b.txt
## All members:
# RUN: rm %t/extracted/a.txt
# RUN: cd %t/extracted && llvm-ar xv %t/archive.a | FileCheck %s --check-prefix=AB
# RUN: diff %t/a.txt %t/extracted/a.txt
# RUN: diff %t/b.txt %t/extracted/b.txt
# AB: x - a.txt
# AB: x - b.txt
# No output if 'v' is not specified.
RUN: rm a.txt b.txt
RUN: llvm-ar x %t/archive.a 2>&1 | count 0
RUN: diff %t/a.txt %t/extracted/a.txt
RUN: diff %t/b.txt %t/extracted/b.txt
## Thin archive
# RUN: llvm-ar Trc %t/thin-archive.a
# RUN: not llvm-ar x %t/thin-archive.a 2>&1 | FileCheck %s --check-prefix=THIN
# THIN: extracting from a thin archive is not supported
## No output if 'v' is not specified.
# RUN: rm a.txt b.txt
# RUN: llvm-ar x %t/archive.a 2>&1 | count 0
# RUN: diff %t/a.txt %t/extracted/a.txt
# RUN: diff %t/b.txt %t/extracted/b.txt

View File

@ -0,0 +1,8 @@
## Test archives do not convert to thin archives.
# RUN: rm -rf %t && mkdir -p %t
# RUN: llvm-ar qc %t/archive.a %s
# RUN: not llvm-ar qT %t/archive.a %s 2>&1 | FileCheck %s
# RUN: not llvm-ar rT %t/archive.a %s 2>&1 | FileCheck %s
# CHECK: error: cannot convert a regular archive to a thin one

View File

@ -0,0 +1,17 @@
## Test llvm-ar errors when thin archive members are missing.
# RUN: rm -rf %t-archive.a
# RUN: echo contents > %t-temp.txt
## File is not in archive.
# RUN: llvm-ar qT %t-archive.a
# RUN: not llvm-ar p %t-archive.a %t-temp.txt 2>&1 | FileCheck %s -DPATH=%t-temp.txt --check-prefix=MISSING
# MISSING: error: '[[PATH]]' was not found
## File has been deleted.
# RUN: llvm-ar qT %t-archive.a %t-temp.txt
# RUN: rm %t-temp.txt
# RUN: not llvm-ar p %t-archive.a 2>&1 | FileCheck %s --check-prefix=DELETED
# DELETED: error: {{[Nn]}}o such file or directory

View File

@ -1,84 +1,89 @@
## Test Print output
# XFAIL: system-darwin
RUN: rm -rf %t && mkdir -p %t
RUN: echo file1 > %t/1.txt
RUN: echo file2 > %t/2.txt
RUN: echo file3 > %t/3.txt
# RUN: rm -rf %t && mkdir -p %t
# RUN: echo file1 > %t/1.txt
# RUN: echo file2 > %t/2.txt
# RUN: echo file3 > %t/3.txt
RUN: llvm-ar -rc %t/archive.a %t/1.txt %t/2.txt %t/3.txt
# RUN: llvm-ar -rc %t/archive.a %t/1.txt %t/2.txt %t/3.txt
# Print without member:
RUN: llvm-ar p %t/archive.a \
RUN: | FileCheck %s --check-prefix=WITHOUT --match-full-lines --implicit-check-not {{.}}
## Print without member:
# RUN: llvm-ar p %t/archive.a \
# RUN: | FileCheck %s --check-prefix=WITHOUT --match-full-lines --implicit-check-not {{.}}
WITHOUT: file1
WITHOUT-NEXT: file2
WITHOUT-NEXT: file3
# WITHOUT: file1
# WITHOUT-NEXT: file2
# WITHOUT-NEXT: file3
RUN: llvm-ar pv %t/archive.a \
RUN: | FileCheck %s --check-prefix=WITHOUT-VERBOSE --match-full-lines --implicit-check-not {{.}}
# RUN: llvm-ar pv %t/archive.a \
# RUN: | FileCheck %s --check-prefix=WITHOUT-VERBOSE --match-full-lines --implicit-check-not {{.}}
WITHOUT-VERBOSE: Printing 1.txt
WITHOUT-VERBOSE-NEXT: file1
WITHOUT-VERBOSE-NEXT: Printing 2.txt
WITHOUT-VERBOSE-NEXT: file2
WITHOUT-VERBOSE-NEXT: Printing 3.txt
WITHOUT-VERBOSE-NEXT: file3
# WITHOUT-VERBOSE: Printing 1.txt
# WITHOUT-VERBOSE-NEXT: file1
# WITHOUT-VERBOSE-NEXT: Printing 2.txt
# WITHOUT-VERBOSE-NEXT: file2
# WITHOUT-VERBOSE-NEXT: Printing 3.txt
# WITHOUT-VERBOSE-NEXT: file3
# Print single member:
RUN: llvm-ar p %t/archive.a %t/2.txt \
RUN: | FileCheck %s --check-prefix=SINGLE --match-full-lines --implicit-check-not {{.}}
## Print single member:
# RUN: llvm-ar p %t/archive.a %t/2.txt \
# RUN: | FileCheck %s --check-prefix=SINGLE --match-full-lines --implicit-check-not {{.}}
SINGLE: file2
# SINGLE: file2
RUN: llvm-ar pv %t/archive.a %t/2.txt \
RUN: | FileCheck %s --check-prefix=SINGLE-VERBOSE --match-full-lines --implicit-check-not {{.}}
# RUN: llvm-ar pv %t/archive.a %t/2.txt \
# RUN: | FileCheck %s --check-prefix=SINGLE-VERBOSE --match-full-lines --implicit-check-not {{.}}
SINGLE-VERBOSE: Printing 2.txt
SINGLE-VERBOSE-NEXT: file2
# SINGLE-VERBOSE: Printing 2.txt
# SINGLE-VERBOSE-NEXT: file2
# Print multiple members:
RUN: llvm-ar p %t/archive.a %t/2.txt %t/1.txt \
RUN: | FileCheck %s --check-prefix=MULTIPLE --match-full-lines --implicit-check-not {{.}}
## Print multiple members:
# RUN: llvm-ar p %t/archive.a %t/2.txt %t/1.txt \
# RUN: | FileCheck %s --check-prefix=MULTIPLE --match-full-lines --implicit-check-not {{.}}
MULTIPLE: file1
MULTIPLE-NEXT: file2
# MULTIPLE: file1
# MULTIPLE-NEXT: file2
RUN: llvm-ar pv %t/archive.a %t/2.txt %t/1.txt \
RUN: | FileCheck %s --check-prefix=MULTIPLE-VERBOSE --match-full-lines --implicit-check-not {{.}}
# RUN: llvm-ar pv %t/archive.a %t/2.txt %t/1.txt \
# RUN: | FileCheck %s --check-prefix=MULTIPLE-VERBOSE --match-full-lines --implicit-check-not {{.}}
MULTIPLE-VERBOSE: Printing 1.txt
MULTIPLE-VERBOSE-NEXT: file1
MULTIPLE-VERBOSE-NEXT: Printing 2.txt
MULTIPLE-VERBOSE-NEXT: file2
# MULTIPLE-VERBOSE: Printing 1.txt
# MULTIPLE-VERBOSE-NEXT: file1
# MULTIPLE-VERBOSE-NEXT: Printing 2.txt
# MULTIPLE-VERBOSE-NEXT: file2
# Print same member:
RUN: not llvm-ar p %t/archive.a %t/2.txt %t/2.txt 2>&1 \
RUN: | FileCheck %s --check-prefix=SAME -DFILE=%t/2.txt
## Print same member:
# RUN: not llvm-ar p %t/archive.a %t/2.txt %t/2.txt 2>&1 \
# RUN: | FileCheck %s --check-prefix=SAME -DFILE=%t/2.txt
SAME-DAG: file2
SAME-DAG: error: '[[FILE]]' was not found
# SAME-DAG: file2
# SAME-DAG: error: '[[FILE]]' was not found
# Print same member when containing multiple members with shared name:
llvm-ar -q %t/archive.a %t/2.txt
RUN: not llvm-ar p %t/archive.a %t/2.txt %t/2.txt 2>&1 \
RUN: | FileCheck %s --check-prefix=SAME -DFILE=%t/2.txt
## Print same member when containing multiple members with shared name:
# llvm-ar -q %t/archive.a %t/2.txt
# RUN: not llvm-ar p %t/archive.a %t/2.txt %t/2.txt 2>&1 \
# RUN: | FileCheck %s --check-prefix=SAME -DFILE=%t/2.txt
# No archive:
RUN: not llvm-ar p 2>&1 \
RUN: | FileCheck %s --check-prefix=NO-ARCHIVE
## No archive:
# RUN: not llvm-ar p 2>&1 \
# RUN: | FileCheck %s --check-prefix=NO-ARCHIVE
#
# NO-ARCHIVE: error: an archive name must be specified
NO-ARCHIVE: error: an archive name must be specified
## Archive does not exist:
# RUN: not llvm-ar p %t/missing.a 2>&1 \
# RUN: | FileCheck %s --check-prefix=MISSING-ARCHIVE -DARCHIVE=%t/missing.a
# Archive does not exist:
RUN: not llvm-ar p %t/missing.a 2>&1 \
RUN: | FileCheck %s --check-prefix=MISSING-ARCHIVE -DARCHIVE=%t/missing.a
# MISSING-ARCHIVE: error: error loading '[[ARCHIVE]]': {{[nN]}}o such file or directory
MISSING-ARCHIVE: error: error loading '[[ARCHIVE]]': {{[nN]}}o such file or directory
## Member does not exist:
# RUN: not llvm-ar p %t/archive.a %t-missing.txt 2>&1 \
# RUN: | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t-missing.txt
# Member does not exist:
RUN: not llvm-ar p %t/archive.a %t-missing.txt 2>&1 \
RUN: | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t-missing.txt
# MISSING-FILE: error: '[[FILE]]' was not found
MISSING-FILE: error: '[[FILE]]' was not found
## Print thin archive:
# RUN: llvm-ar Trc %t/thin-archive.a %t/1.txt %t/2.txt %t/3.txt
# RUN: llvm-ar p %t/archive.a %t/2.txt \
# RUN: | FileCheck %s --check-prefix=SINGLE --match-full-lines --implicit-check-not {{.}}

View File

@ -62,6 +62,16 @@
# MISSING-FILE: error: [[FILE]]: {{[nN]}}o such file or directory
## Create and append members to a thin archive:
# RUN: llvm-ar qcT %t/thin-multiple.a %t/1.o
# RUN: llvm-ar qcT %t/thin-multiple.a %t/2.o
# RUN: llvm-ar t %t/thin-multiple.a \
# RUN: | FileCheck %s --check-prefix=MULTIPLE
# RUN: llvm-ar qcT %t/thin-same.a %t/1.o %t/1.o
# RUN: llvm-ar t %t/thin-same.a \
# RUN: | FileCheck %s --check-prefix=SAME
--- !ELF
FileHeader:
Class: ELFCLASS64

View File

@ -93,6 +93,15 @@
# MISSING-FILE: error: [[FILE]]: {{[Nn]}}o such file or directory
## Create and Replace member of thin archive:
# RUN: llvm-ar rcT %t/thin.a %t/1.o %t/2.o %t/3.o
# RUN: yaml2obj %s -o %t/1.o --docnum=4
# RUN: llvm-ar rT %t/thin.a %t/1.o
# RUN: llvm-ar t %t/thin.a | FileCheck %s --check-prefix=SINGLE
# RUN: llvm-nm --print-armap %t/thin.a \
# RUN: | FileCheck %s --check-prefix=SINGLE-SYM
--- !ELF
FileHeader:
Class: ELFCLASS64