• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# -*- Python -*-
2
3import os
4
5def get_required_attr(config, attr_name):
6  attr_value = getattr(config, attr_name, None)
7  if not attr_value:
8    lit.fatal("No attribute %r in test configuration! You may need to run "
9              "tests from your build directory or add this attribute "
10              "to lit.site.cfg " % attr_name)
11  return attr_value
12
13# Setup config name.
14config.name = 'ThreadSanitizer-Unit'
15
16# Setup test source and exec root. For unit tests, we define
17# it as build directory with TSan unit tests.
18llvm_obj_root = get_required_attr(config, "llvm_obj_root")
19config.test_exec_root = os.path.join(llvm_obj_root, "projects",
20                                     "compiler-rt", "lib",
21                                     "tsan", "tests")
22config.test_source_root = config.test_exec_root
23
24# Get path to external LLVM symbolizer to run ThreadSanitizer unit tests.
25llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
26if llvm_tools_dir:
27  llvm_symbolizer_path = os.path.join(llvm_tools_dir, "llvm-symbolizer")
28  config.environment['TSAN_OPTIONS'] = ("external_symbolizer_path=" +
29                                        llvm_symbolizer_path)
30
31