FOO.fail.cpp - Negative test case which is expected to fail compilation.
"""
- def __init__(self, cxx_under_test, cpp_flags, ld_flags):
+ def __init__(self, cxx_under_test, cpp_flags, ld_flags, exec_env):
self.cxx_under_test = cxx_under_test
self.cpp_flags = list(cpp_flags)
self.ld_flags = list(ld_flags)
+ self.exec_env = dict(exec_env)
def execute_command(self, command, in_dir=None):
kwargs = {
report += "\n\nCompilation failed unexpectedly!"
return lit.Test.FAIL, report
- cmd = [exec_path]
+ cmd = []
+ if self.exec_env:
+ cmd.append('env')
+ cmd.extend('%s=%s' % (name, value)
+ for name,value in self.exec_env.items())
+ cmd.append(exec_path)
if lit_config.useValgrind:
cmd = lit_config.valgrindArgs + cmd
out, err, exitCode = self.execute_command(cmd, source_dir)
cxx_has_stdcxx0x_flag_str = lit.params.get('cxx_has_stdcxx0x_flag', None)
if cxx_has_stdcxx0x_flag_str is not None:
- if cxx_has_stdcxx0x_flag_str in ('1', 'True'):
+ if cxx_has_stdcxx0x_flag_str.lower() in ('1', 'true'):
cxx_has_stdcxx0x_flag = True
- elif cxx_has_stdcxx0x_flag_str in ('', '0', 'False'):
+ elif cxx_has_stdcxx0x_flag_str.lower() in ('', '0', 'false'):
cxx_has_stdcxx0x_flag = False
else:
lit.fatal('user parameter cxx_has_stdcxx0x_flag_str should be 0 or 1')
else:
cxx_has_stdcxx0x_flag = getattr(config, 'cxx_has_stdcxx0x_flag', True)
+# This test suite supports testing against either the system library or the
+# locally built one; the former mode is useful for testing ABI compatibility
+# between the current headers and a shipping dynamic library. We require the
+# user to explicitly pick one of the two modes.
+use_system_lib_str = lit.params.get('use_system_lib', None)
+if use_system_lib_str is not None:
+ if use_system_lib_str.lower() in ('1', 'true'):
+ use_system_lib = True
+ elif use_system_lib_str.lower() in ('', '0', 'false'):
+ use_system_lib = False
+ else:
+ lit.fatal('user parameter use_system_lib should be 0 or 1')
+else:
+ use_system_lib = True
+
# Configure extra compiler flags.
include_paths = ['-I' + libcxx_src_root + '/include', '-I' + libcxx_src_root + '/test/support']
library_paths = ['-L' + libcxx_obj_root + '/lib']
compile_flags = []
if cxx_has_stdcxx0x_flag:
- compile_flags += ['-std=c++0x']
+ compile_flags += ['-std=c++0x']
# Configure extra libraries.
+exec_env = {}
libraries = []
if sys.platform == 'darwin':
- libraries += ['-lSystem']
-if sys.platform == 'linux2':
- libraries += ['-lsupc++', '-lgcc_eh', '-lc', '-lm', '-lpthread', '-lrt', '-lgcc_s']
- libraries += ['-Wl,-R', libcxx_obj_root + '/lib']
- compile_flags += ['-D__STDC_FORMAT_MACROS', '-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS']
+ libraries += ['-lSystem']
+ if not use_system_lib:
+ exec_env['DYLD_LIBRARY_PATH'] = os.path.join(libcxx_obj_root, 'lib')
+elif sys.platform == 'linux2':
+ libraries += ['-lsupc++', '-lgcc_eh', '-lc', '-lm', '-lpthread', '-lrt', '-lgcc_s']
+ libraries += ['-Wl,-R', libcxx_obj_root + '/lib']
+else:
+ lit.fatal("unrecognized system")
config.test_format = LibcxxTestFormat(
cxx_under_test,
cpp_flags = ['-nostdinc++'] + compile_flags + include_paths,
- ld_flags = ['-nodefaultlibs'] + library_paths + ['-lc++'] + libraries)
+ ld_flags = ['-nodefaultlibs'] + library_paths + ['-lc++'] + libraries,
+ exec_env = exec_env)
config.target_triple = None