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