[tests] Add support for a link_flags lit parameter.
- This is useful for testing with custom ABI libraries. - Patch by Michael van der Westhuizen. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@174997 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6b875ef374
commit
3bc6a98c3e
46
test/lit.cfg
46
test/lit.cfg
@ -1,4 +1,4 @@
|
|||||||
# -*- Python -*-
|
# -*- Python -*- vim: set syntax=python tabstop=4 expandtab cc=80:
|
||||||
|
|
||||||
# Configuration file for the 'lit' test runner.
|
# Configuration file for the 'lit' test runner.
|
||||||
|
|
||||||
@ -10,6 +10,7 @@ import signal
|
|||||||
import subprocess
|
import subprocess
|
||||||
import errno
|
import errno
|
||||||
import time
|
import time
|
||||||
|
import shlex
|
||||||
|
|
||||||
# FIXME: For now, this is cribbed from lit.TestRunner, to avoid introducing a
|
# FIXME: For now, this is cribbed from lit.TestRunner, to avoid introducing a
|
||||||
# dependency there. What we more ideally would like to do is lift the "xfail"
|
# dependency there. What we more ideally would like to do is lift the "xfail"
|
||||||
@ -96,8 +97,8 @@ class LibcxxTestFormat(lit.formats.FileBasedTest):
|
|||||||
#
|
#
|
||||||
# FIXME: For now, this is cribbed from lit.TestRunner, to avoid
|
# FIXME: For now, this is cribbed from lit.TestRunner, to avoid
|
||||||
# introducing a dependency there. What we more ideally would like to do
|
# introducing a dependency there. What we more ideally would like to do
|
||||||
# is lift the "xfail" and "requires" handling to be a core lit framework
|
# is lift the "xfail" and "requires" handling to be a core lit
|
||||||
# feature.
|
# framework feature.
|
||||||
missing_required_features = [f for f in requires
|
missing_required_features = [f for f in requires
|
||||||
if f not in test.config.available_features]
|
if f not in test.config.available_features]
|
||||||
if missing_required_features:
|
if missing_required_features:
|
||||||
@ -178,10 +179,10 @@ class LibcxxTestFormat(lit.formats.FileBasedTest):
|
|||||||
cmd = lit_config.valgrindArgs + cmd
|
cmd = lit_config.valgrindArgs + cmd
|
||||||
out, err, exitCode = self.execute_command(cmd, source_dir)
|
out, err, exitCode = self.execute_command(cmd, source_dir)
|
||||||
if exitCode != 0:
|
if exitCode != 0:
|
||||||
report = """Compiled With: %s\n""" % ' '.join(["'%s'" % a
|
report = """Compiled With: %s\n""" % \
|
||||||
for a in compile_cmd])
|
' '.join(["'%s'" % a for a in compile_cmd])
|
||||||
report += """Command: %s\n""" % ' '.join(["'%s'" % a
|
report += """Command: %s\n""" % \
|
||||||
for a in cmd])
|
' '.join(["'%s'" % a for a in cmd])
|
||||||
report += """Exit Code: %d\n""" % exitCode
|
report += """Exit Code: %d\n""" % exitCode
|
||||||
if out:
|
if out:
|
||||||
report += """Standard Output:\n--\n%s--""" % out
|
report += """Standard Output:\n--\n%s--""" % out
|
||||||
@ -258,32 +259,47 @@ else:
|
|||||||
use_system_lib = False
|
use_system_lib = False
|
||||||
lit.note("inferred use_system_lib as: %r" % (use_system_lib,))
|
lit.note("inferred use_system_lib as: %r" % (use_system_lib,))
|
||||||
|
|
||||||
|
link_flags = []
|
||||||
|
link_flags_str = lit.params.get('link_flags', None)
|
||||||
|
if link_flags_str is None:
|
||||||
|
link_flags_str = getattr(config, 'link_flags', None)
|
||||||
|
if link_flags_str is None:
|
||||||
|
if sys.platform == 'darwin':
|
||||||
|
link_flags += ['-lSystem']
|
||||||
|
elif sys.platform == 'linux2':
|
||||||
|
link_flags += ['-lsupc++', '-lgcc_eh', '-lc', '-lm', '-lpthread',
|
||||||
|
'-lrt', '-lgcc_s']
|
||||||
|
else:
|
||||||
|
lit.fatal("unrecognized system")
|
||||||
|
lit.note("inferred link_flags as: %r" % (link_flags,))
|
||||||
|
if not link_flags_str is None:
|
||||||
|
link_flags += shlex.split(link_flags_str)
|
||||||
|
|
||||||
# Configure extra compiler flags.
|
# Configure extra compiler flags.
|
||||||
include_paths = ['-I' + libcxx_src_root + '/include', '-I' + libcxx_src_root + '/test/support']
|
include_paths = ['-I' + libcxx_src_root + '/include',
|
||||||
|
'-I' + libcxx_src_root + '/test/support']
|
||||||
library_paths = ['-L' + libcxx_obj_root + '/lib']
|
library_paths = ['-L' + libcxx_obj_root + '/lib']
|
||||||
compile_flags = []
|
compile_flags = []
|
||||||
if cxx_has_stdcxx0x_flag:
|
if cxx_has_stdcxx0x_flag:
|
||||||
compile_flags += ['-std=c++0x']
|
compile_flags += ['-std=c++0x']
|
||||||
|
|
||||||
# Configure extra libraries.
|
# Configure extra linker parameters.
|
||||||
exec_env = {}
|
exec_env = {}
|
||||||
libraries = []
|
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
libraries += ['-lSystem']
|
|
||||||
if not use_system_lib:
|
if not use_system_lib:
|
||||||
exec_env['DYLD_LIBRARY_PATH'] = os.path.join(libcxx_obj_root, 'lib')
|
exec_env['DYLD_LIBRARY_PATH'] = os.path.join(libcxx_obj_root, 'lib')
|
||||||
elif sys.platform == 'linux2':
|
elif sys.platform == 'linux2':
|
||||||
libraries += ['-lsupc++', '-lgcc_eh', '-lc', '-lm', '-lpthread', '-lrt', '-lgcc_s']
|
|
||||||
if not use_system_lib:
|
if not use_system_lib:
|
||||||
libraries += ['-Wl,-R', libcxx_obj_root + '/lib']
|
link_flags += ['-Wl,-R', libcxx_obj_root + '/lib']
|
||||||
compile_flags += ['-D__STDC_FORMAT_MACROS', '-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS']
|
compile_flags += ['-D__STDC_FORMAT_MACROS', '-D__STDC_LIMIT_MACROS',
|
||||||
|
'-D__STDC_CONSTANT_MACROS']
|
||||||
else:
|
else:
|
||||||
lit.fatal("unrecognized system")
|
lit.fatal("unrecognized system")
|
||||||
|
|
||||||
config.test_format = LibcxxTestFormat(
|
config.test_format = LibcxxTestFormat(
|
||||||
cxx_under_test,
|
cxx_under_test,
|
||||||
cpp_flags = ['-nostdinc++'] + compile_flags + include_paths,
|
cpp_flags = ['-nostdinc++'] + compile_flags + include_paths,
|
||||||
ld_flags = ['-nodefaultlibs'] + library_paths + ['-lc++'] + libraries,
|
ld_flags = ['-nodefaultlibs'] + library_paths + ['-lc++'] + link_flags,
|
||||||
exec_env = exec_env)
|
exec_env = exec_env)
|
||||||
|
|
||||||
# Get or infer the target triple.
|
# Get or infer the target triple.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user