|
| 1 | +## This test checks that the -filelist option works correctly. |
| 2 | + |
| 3 | +# RUN: yaml2obj %S/Inputs/input1.yaml -o %t-input1.o |
| 4 | +# RUN: yaml2obj %S/Inputs/input2.yaml -o %t-input2.o |
| 5 | + |
| 6 | +## Passing files in a listfile: |
| 7 | +# RUN: echo %t-input1.o > %t.files.txt |
| 8 | +# RUN: echo %t-input2.o >> %t.files.txt |
| 9 | +# RUN: llvm-libtool-darwin -static -o %t.lib -filelist %t.files.txt |
| 10 | + |
| 11 | +## Check that binaries are present: |
| 12 | +# RUN: llvm-ar t %t.lib | \ |
| 13 | +# RUN: FileCheck %s --check-prefix=CHECK-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp |
| 14 | + |
| 15 | +# CHECK-NAMES: [[PREFIX]]-input1.o |
| 16 | +# CHECK-NAMES-NEXT: [[PREFIX]]-input2.o |
| 17 | + |
| 18 | +## Check that symbols are present: |
| 19 | +# RUN: llvm-nm --print-armap %t.lib | \ |
| 20 | +# RUN: FileCheck %s --check-prefix=CHECK-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines |
| 21 | + |
| 22 | +# CHECK-SYMBOLS: Archive map |
| 23 | +# CHECK-SYMBOLS-NEXT: _symbol1 in [[PREFIX]]-input1.o |
| 24 | +# CHECK-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o |
| 25 | +# CHECK-SYMBOLS-EMPTY: |
| 26 | + |
| 27 | +# RUN: rm -rf %t/dirname && mkdir -p %t/dirname |
| 28 | +# RUN: yaml2obj %S/Inputs/input1.yaml -o %t/dirname/%basename_t.tmp-input1.o |
| 29 | +# RUN: echo %basename_t.tmp-input1.o > %t.files.txt |
| 30 | + |
| 31 | +## Passing in dirname: |
| 32 | +# RUN: llvm-libtool-darwin -static -o %t.lib -filelist %t.files.txt,%t/dirname |
| 33 | +# RUN: llvm-ar t %t.lib | \ |
| 34 | +# RUN: FileCheck %s --check-prefix=DIRNAME-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp |
| 35 | +# RUN: llvm-nm --print-armap %t.lib | \ |
| 36 | +# RUN: FileCheck %s --check-prefix=DIRNAME-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines |
| 37 | + |
| 38 | +# DIRNAME-NAMES: [[PREFIX]]-input1.o |
| 39 | + |
| 40 | +# DIRNAME-SYMBOLS: Archive map |
| 41 | +# DIRNAME-SYMBOLS-NEXT: _symbol1 in [[PREFIX]]-input1.o |
| 42 | +# DIRNAME-SYMBOLS-EMPTY: |
| 43 | + |
| 44 | +## Passing both -filelist option and object file as input: |
| 45 | +# RUN: llvm-libtool-darwin -static -o %t.lib -filelist %t.files.txt,%t/dirname %t-input2.o |
| 46 | +# RUN: llvm-ar t %t.lib | \ |
| 47 | +# RUN: FileCheck %s --check-prefix=REVERSE-NAMES --implicit-check-not={{.}} -DPREFIX=%basename_t.tmp |
| 48 | +# RUN: llvm-nm --print-armap %t.lib | \ |
| 49 | +# RUN: FileCheck %s --check-prefix=REVERSE-SYMBOLS -DPREFIX=%basename_t.tmp --match-full-lines |
| 50 | + |
| 51 | +# REVERSE-NAMES: [[PREFIX]]-input2.o |
| 52 | +# REVERSE-NAMES-NEXT: [[PREFIX]]-input1.o |
| 53 | + |
| 54 | +# REVERSE-SYMBOLS: Archive map |
| 55 | +# REVERSE-SYMBOLS-NEXT: _symbol2 in [[PREFIX]]-input2.o |
| 56 | +# REVERSE-SYMBOLS-NEXT: _symbol1 in [[PREFIX]]-input1.o |
| 57 | +# REVERSE-SYMBOLS-EMPTY: |
| 58 | + |
| 59 | +## Check that an error is thrown when a file in the filelist doesn't exist in the cwd and no dirname is specified: |
| 60 | +# RUN: echo 'no-such-file' > %t.invalid-list.txt |
| 61 | +# RUN: not llvm-libtool-darwin -static -o %t.lib -filelist %t.invalid-list.txt 2>&1 | \ |
| 62 | +# RUN: FileCheck %s --check-prefix=FILE-ERROR -DFILE=no-such-file |
| 63 | + |
| 64 | +# FILE-ERROR: error: '[[FILE]]': {{[nN]}}o such file or directory |
| 65 | + |
| 66 | +## Check that an error is thrown when the directory exists but does not contain the requested file: |
| 67 | +# RUN: not llvm-libtool-darwin -static -o %t.lib -filelist %t.invalid-list.txt,%t/dirname 2>&1 | \ |
| 68 | +# RUN: FileCheck %s --check-prefix=DIR-ERROR -DDIR=%t/dirname -DFILE=no-such-file |
| 69 | + |
| 70 | +# DIR-ERROR: error: '[[DIR]]{{[/\\]}}[[FILE]]': {{[nN]}}o such file or directory |
| 71 | + |
| 72 | +## Check that an error is thrown when a file is in the cwd but dirname is specified: |
| 73 | +# RUN: yaml2obj %S/Inputs/input2.yaml -o %basename_t.tmp-input2.o |
| 74 | +# RUN: echo %basename_t.tmp-input2.o > %t.files-cwd.txt |
| 75 | +# RUN: not llvm-libtool-darwin -static -o %t.lib -filelist %t.files-cwd.txt,%t/dirname 2>&1 | \ |
| 76 | +# RUN: FileCheck %s --check-prefix=DIR-ERROR -DDIR=%t/dirname -DFILE=%basename_t.tmp-input2.o |
| 77 | + |
| 78 | +## Check that an error is thrown when the directory doesn't exist: |
| 79 | +# RUN: not llvm-libtool-darwin -static -o %t.lib -filelist %t.files-cwd.txt,%t/Invalid-Dir 2>&1 | \ |
| 80 | +# RUN: FileCheck %s --check-prefix=DIR-ERROR -DDIR=%t/Invalid-Dir -DFILE=%basename_t.tmp-input2.o |
| 81 | + |
| 82 | +## Check that an error is thrown when the filelist is empty: |
| 83 | +# RUN: touch %t.empty-list |
| 84 | +# RUN: not llvm-libtool-darwin -static -o %t.lib -filelist %t.empty-list 2>&1 | \ |
| 85 | +# RUN: FileCheck %s --check-prefix=EMPTY-ERROR -DFILE=%t.empty-list |
| 86 | + |
| 87 | +# EMPTY-ERROR: error: file list file: '[[FILE]]' is empty |
| 88 | + |
| 89 | +## Check that an error is thrown when the filelist contains a blank line: |
| 90 | +# RUN: echo %t-input2.o > %t.blank-line.txt |
| 91 | +# RUN: echo '' >> %t.blank-line.txt |
| 92 | +# RUN: not llvm-libtool-darwin -static -o %t.lib -filelist %t.blank-line.txt 2>&1 | \ |
| 93 | +# RUN: FileCheck %s --check-prefix=EMPTY-FILENAME -DFILE=%t.blank-line.txt |
| 94 | + |
| 95 | +# EMPTY-FILENAME: error: file list file: '[[FILE]]': filename cannot be empty |
| 96 | + |
| 97 | +## Check that an error is thrown when the filelist contains a line with only spaces: |
| 98 | +# RUN: echo %t-input2.o > %t.space-line.txt |
| 99 | +# RUN: echo " " >> %t.space-line.txt |
| 100 | +# RUN: not llvm-libtool-darwin -static -o %t.lib -filelist %t.space-line.txt 2>&1 | \ |
| 101 | +# RUN: FileCheck %s --check-prefix=FILE-ERROR -DFILE=' ' --strict-whitespace |
| 102 | + |
| 103 | +## Filelist option specified more than once: |
| 104 | +# RUN: touch %t.list1.txt and %t.list2.txt |
| 105 | +# RUN: not llvm-libtool-darwin -static -o %t.lib -filelist %t.list1.txt -filelist %t.list2.txt 2>&1 | \ |
| 106 | +# RUN: FileCheck %s --check-prefix=DUPLICATE-ERROR |
| 107 | + |
| 108 | +# DUPLICATE-ERROR: for the --filelist option: may only occur zero or one times! |
0 commit comments