]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/builtin_glob_archive.py
3 # Copyright 2014 Steven Watanabe
4 # Copyright 2015 Artur Shepilko
5 # Distributed under the Boost Software License, Version 1.0.
6 # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
8 # This tests the GLOB_ARCHIVE rule.
15 vms
= ( os
.name
== 'posix' and sys
.platform
== 'OpenVMS')
17 t
= BoostBuild
.Tester()
19 ## Setup test archive sources and symbols they contain.
23 "b_match.cpp" : ["b_match"],
24 "c/nopath_check.cpp" : ["nopath_check"],
25 "CaseCheck.cpp" : ["CaseCheck"],
26 "seq_check1.cpp" : ["seq_check1"],
27 "seq_check2.cpp" : ["seq_check2"],
28 "seq_check3.cpp" : ["seq_check3"],
29 "symbols_check.c" : ["symbol", "symbol_match"],
30 "members_and_symbols_check.c" : ["member_and_symbol_match"],
31 "symbol_case_check.c" : ["SymbolCaseCheck"],
32 "main_check.cpp" : ["main"]
36 def create_sources(path
, sources
):
38 f
= os
.path
.join(path
, s
)
40 output
= StringIO
.StringIO()
41 for sym
in sources
[s
] :
42 output
.write("int %s() { return 0; }\n" % sym
)
43 t
.write(f
, output
.getvalue())
46 def setup_archive(name
, sources
):
49 archive
= t
.adjust_names(name
)[0]
50 obj_suffix
= t
.adjust_names(".obj")[0]
51 output
= StringIO
.StringIO()
52 t
.write("jamroot.jam","")
55 """ % name
.split(".")[0])
56 ## sort the sources, so we can test order of the globbed members
57 for s
in sorted(sources
) :
64 t
.write("lib/jamfile.jam", output
.getvalue())
65 create_sources("lib", sources
)
66 t
.run_build_system(subdir
="lib")
67 built_archive
= "lib/bin/$toolset/debug*/%s" % name
68 t
.expect_addition(built_archive
)
69 t
.copy(built_archive
, name
)
73 def test_glob_archive(archives
, glob
, expected
, sort_results
= False):
74 output
= StringIO
.StringIO()
75 ## replace placeholders
76 glob
= glob
.replace("$archive1", archives
[0]).replace("$obj", obj_suffix
)
77 expected
= [ m
.replace("$archive1",
78 archives
[0]).replace("$obj", obj_suffix
) for m
in expected
]
79 if len(archives
) > 1 :
80 glob
= glob
.replace("$archive2", archives
[1]).replace("$obj", obj_suffix
)
81 expected
= [ m
.replace("$archive2",
82 archives
[1]).replace("$obj", obj_suffix
) for m
in expected
]
83 ## create test jamfile
84 if sort_results
: glob
= "[ SORT %s ]" % glob
92 t
.write("file.jam", output
.getvalue())
93 ## run test jamfile and match against expected results
94 if sort_results
: expected
.sort()
95 t
.run_build_system(["-ffile.jam"], stdout
="\n".join(expected
+ [""]))
100 setup_archive("auxilliary1.lib", sources
)
102 setup_archive("auxilliary2.lib", sources
)
105 ## all arguments empty
106 test_glob_archive([archive1
], "[ GLOB_ARCHIVE ]", [])
109 test_glob_archive([archive1
], "[ GLOB_ARCHIVE $archive1 : ]", [])
112 test_glob_archive([archive1
], "[ GLOB_ARCHIVE $archive1 : a ]", [])
115 test_glob_archive([archive1
], "[ GLOB_ARCHIVE $archive1 : a$obj ]",
116 ["$archive1(a$obj)"])
119 test_glob_archive([archive1
], "[ GLOB_ARCHIVE $archive1 : b.* ]",
120 ["$archive1(b$obj)"])
123 test_glob_archive([archive1
], "[ GLOB_ARCHIVE $archive1 : \\b?match[\.]* ]",
124 ["$archive1(b_match$obj)"])
127 test_glob_archive([archive1
], "[ GLOB_ARCHIVE $archive1 : b* ]",
128 ["$archive1(b$obj)", "$archive1(b_match$obj)"])
130 ## glob multiple patterns with multiple results.
131 test_glob_archive([archive1
], "[ GLOB_ARCHIVE $archive1 : b.* b_* ]",
132 ["$archive1(b$obj)", "$archive1(b_match$obj)"])
134 ## glob multiple archives and patterns.
135 test_glob_archive([archive1
, archive2
],
136 "[ GLOB_ARCHIVE $archive1 $archive2 : b.* b_* ]",
137 ["$archive1(b$obj)", "$archive1(b_match$obj)",
138 "$archive2(b$obj)", "$archive2(b_match$obj)"])
140 ## glob same archive multiple times.
141 test_glob_archive([archive1
, archive1
],
142 "[ GLOB_ARCHIVE $archive1 $archive2 $archive1 : b.* ]",
143 ["$archive1(b$obj)", "$archive2(b$obj)", "$archive1(b$obj)"])
145 ## returned archive member has no path, even though its source object-file did.
146 ## this is rather NT-specific, where members also store their object-file's path.
147 test_glob_archive([archive1
], "[ GLOB_ARCHIVE $archive1 : nopath_check$obj ]",
148 ["$archive1(nopath_check$obj)"])
150 ## case insensitive matching, when archives support case sensitive member names.
151 ## VMS implementation forces case-insensitive matching and downcased member names.
153 case_sensitive_members
= ( not vms
)
155 if case_sensitive_members
:
156 test_glob_archive([archive1
],
157 "[ GLOB_ARCHIVE $archive1 : casecheck$obj : true ]",
158 ["$archive1(CaseCheck$obj)"])
160 test_glob_archive([archive1
],
161 "[ GLOB_ARCHIVE $archive1 : CaseCheck$obj : false ]",
162 ["$archive1(casecheck$obj)"])
165 ## test the order of matched members, in general it should match the
166 ## insertion sequence.
167 test_glob_archive([archive1
], "[ GLOB_ARCHIVE $archive1 : seq_check*$obj ]",
168 ["$archive1(seq_check1$obj)", "$archive1(seq_check2$obj)",
169 "$archive1(seq_check3$obj)"])
172 ## glob members by symbols they contain.
173 ## Currently supported only on VMS.
174 symbol_glob_supported
= ( vms
)
176 if symbol_glob_supported
:
177 ## NOTE: generated symbols are compiler-dependent and may be specifically
178 ## mangled (as in C++ case), so globbing by exact symbol is non-trivial.
179 ## However, C-generated symbols are likely to have more portable names,
180 ## so for the glob-by-symbol tests we glob C-generated archive members.
182 ## glob members by exact symbol.
183 test_glob_archive([archive1
],
184 "[ GLOB_ARCHIVE $archive1 : : : symbol ]",
185 ["$archive1(symbols_check$obj)"])
187 ## glob members by symbol wildcard.
188 test_glob_archive([archive1
],
189 "[ GLOB_ARCHIVE $archive1 : : : symbol_* ]",
190 ["$archive1(symbols_check$obj)"])
192 ## glob members by member pattern AND symbol pattern.
193 test_glob_archive([archive1
],
194 "[ GLOB_ARCHIVE $archive1 : *symbol* : : *member* ]",
195 ["$archive1(members_and_symbols_check$obj)"])
197 ## case insensitive symbol glob.
198 test_glob_archive([archive1
],
199 "[ GLOB_ARCHIVE $archive1 : : true : symbolcasecheck ]",
200 ["$archive1(symbol_case_check$obj)"])
202 ## glob member that contains main symbol.
203 test_glob_archive([archive1
],
204 "[ GLOB_ARCHIVE $archive1 : : : main _main ]",
205 ["$archive1(main_check$obj)"])
208 test_glob_archive([archive1
],
209 "[ GLOB_ARCHIVE $archive1 : : : symbol ]",