1 ## Test extract operation.
4 # RUN: rm -rf %t && mkdir -p %t/extracted/
6 ## Extracting from an empty archive should not warn or error:
7 # RUN: llvm-ar cr --format=gnu %t/empty.a
8 # RUN: llvm-ar xv %t/empty.a 2>&1 | count 0
10 # RUN: echo filea > %t/a.txt
11 # RUN: echo fileb > %t/b.txt
12 # RUN: llvm-ar rc %t/archive.a %t/a.txt %t/b.txt
15 # RUN: cd %t/extracted && llvm-ar xv %t/archive.a a.txt | FileCheck %s --check-prefix=A
16 # RUN: diff %t/a.txt %t/extracted/a.txt
20 # RUN: rm %t/extracted/a.txt
21 # RUN: cd %t/extracted && llvm-ar xv %t/archive.a | FileCheck %s --check-prefix=AB
22 # RUN: diff %t/a.txt %t/extracted/a.txt
23 # RUN: diff %t/b.txt %t/extracted/b.txt
28 # RUN: llvm-ar Trc %t/thin-archive.a
29 # RUN: not llvm-ar x %t/thin-archive.a 2>&1 | FileCheck %s --check-prefix=THIN
30 # THIN: extracting from a thin archive is not supported
32 ## No output if 'v' is not specified.
34 # RUN: llvm-ar x %t/archive.a 2>&1 | count 0
35 # RUN: diff %t/a.txt %t/extracted/a.txt
36 # RUN: diff %t/b.txt %t/extracted/b.txt
38 ## --output specifies the directory to extract archive members to. `1/2` is created by llvm-ar.
39 # RUN: llvm-ar --output=1/2 x %t/archive.a
40 # RUN: diff %t/a.txt %t/extracted/1/2/a.txt
41 # RUN: diff %t/b.txt %t/extracted/1/2/b.txt
43 ## --output can be used with an absolute path and can be specified elsewhere on the command line.
45 # RUN: llvm-ar xv %t/archive.a a.txt --output %t/extracted/1/2/../2 | FileCheck %s --check-prefix=OUTPUT-A
46 # RUN: diff %t/a.txt %t/extracted/1/2/a.txt
47 # OUTPUT-A: x - {{.*}}extracted{{.*}}a.txt
49 # RUN: not llvm-ar x --output=%t/a.txt %t/archive.a 2>&1 | FileCheck %s --check-prefix=OUTPUT-NOTDIR
50 # RUN: not llvm-ar x --output=%t/b.txt/a.txt %t/archive.a 2>&1 | FileCheck %s --check-prefix=OUTPUT-NOTDIR
51 # OUTPUT-NOTDIR: error: '{{.*}}a.txt' is not a directory
53 # RUN: not llvm-ar rc --output=1/2 %t/archive.a %t/a.txt 2>&1 | FileCheck %s --check-prefix=OUTPUT-ERR
54 # OUTPUT-ERR: error: --output is only applicable to the 'x' operation