forked from OSchip/llvm-project
84 lines
3.1 KiB
INI
84 lines
3.1 KiB
INI
import lit.formats
|
|
import sys
|
|
|
|
config.name = "LLVMFuzzer"
|
|
config.test_format = lit.formats.ShTest(True)
|
|
config.suffixes = ['.test']
|
|
config.test_source_root = os.path.dirname(__file__)
|
|
|
|
# Choose between lit's internal shell pipeline runner and a real shell. If
|
|
# LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override.
|
|
use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
|
|
if use_lit_shell:
|
|
# 0 is external, "" is default, and everything else is internal.
|
|
execute_external = (use_lit_shell == "0")
|
|
else:
|
|
# Otherwise we default to internal on Windows and external elsewhere, as
|
|
# bash on Windows is usually very slow.
|
|
execute_external = (not sys.platform in ['win32'])
|
|
|
|
# testFormat: The test format to use to interpret tests.
|
|
#
|
|
# For now we require '&&' between commands, until they get globally killed and
|
|
# the test runner updated.
|
|
config.test_format = lit.formats.ShTest(execute_external)
|
|
|
|
# Tweak PATH to include llvm tools dir and current exec dir.
|
|
llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
|
|
if (not llvm_tools_dir) or (not os.path.exists(llvm_tools_dir)):
|
|
lit_config.fatal("Invalid llvm_tools_dir config attribute: %r" % llvm_tools_dir)
|
|
path = os.path.pathsep.join((llvm_tools_dir, config.test_exec_root,
|
|
config.environment['PATH']))
|
|
config.environment['PATH'] = path
|
|
|
|
if config.has_lsan:
|
|
lit_config.note('lsan feature available')
|
|
config.available_features.add('lsan')
|
|
else:
|
|
lit_config.note('lsan feature unavailable')
|
|
|
|
if sys.platform.startswith('win') or sys.platform.startswith('cygwin'):
|
|
config.available_features.add('windows')
|
|
|
|
if sys.platform.startswith('darwin'):
|
|
config.available_features.add('darwin')
|
|
|
|
if sys.platform.startswith('linux'):
|
|
# Note the value of ``sys.platform`` is not consistent
|
|
# between python 2 and 3, hence the use of ``.startswith()``.
|
|
lit_config.note('linux feature available')
|
|
config.available_features.add('linux')
|
|
else:
|
|
lit_config.note('linux feature unavailable')
|
|
|
|
config.substitutions.append(('%build_dir', config.cmake_binary_dir))
|
|
|
|
def generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True):
|
|
compiler_cmd = config.cpp_compiler if is_cpp else config.c_compiler
|
|
std_cmd = '-std=c++11' if is_cpp else ''
|
|
sanitizers = ['address']
|
|
if fuzzer_enabled:
|
|
sanitizers.append('fuzzer')
|
|
sanitizers_cmd = ('-fsanitize=%s' % ','.join(sanitizers))
|
|
isysroot_cmd = ('-isysroot %s' % config.osx_sysroot
|
|
) if 'darwin' in config.target_triple else ''
|
|
include_cmd = '-I%s/../.' % config.test_source_root
|
|
return '%s %s -gline-tables-only %s %s %s' % (
|
|
compiler_cmd, std_cmd, isysroot_cmd, sanitizers_cmd, include_cmd)
|
|
|
|
config.substitutions.append(('%cpp_compiler',
|
|
generate_compiler_cmd(is_cpp=True, fuzzer_enabled=True)
|
|
))
|
|
|
|
config.substitutions.append(('%c_compiler',
|
|
generate_compiler_cmd(is_cpp=False, fuzzer_enabled=True)
|
|
))
|
|
|
|
config.substitutions.append(('%no_fuzzer_cpp_compiler',
|
|
generate_compiler_cmd(is_cpp=True, fuzzer_enabled=False)
|
|
))
|
|
|
|
config.substitutions.append(('%no_fuzzer_c_compiler',
|
|
generate_compiler_cmd(is_cpp=False, fuzzer_enabled=False)
|
|
))
|