I've rewritten the patch against TOT. There are a couple of changes.

- Removed ability to enable warnings for now.
- Added documentation of the `libcxx_site_config` option.
- Added documentation about how `compile_flags` and `link_flags` are delimited.


http://reviews.llvm.org/D5877

Files:
  test/lit.cfg
  test/lit.site.cfg.in
  www/index.html
  www/lit_usage.html

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
Index: test/lit.cfg
===================================================================
--- test/lit.cfg
+++ test/lit.cfg
@@ -252,7 +252,6 @@
         self.configure_use_clang_verify()
         self.configure_ccache()
         self.configure_env()
-        self.configure_std_flag()
         self.configure_compile_flags()
         self.configure_link_flags()
         self.configure_sanitizer()
@@ -450,14 +449,26 @@
             self.config.available_features.add('long_tests')
 
     def configure_compile_flags(self):
-        # Configure extra compiler flags.
+        # Try and get the std version from the command line. Fall back to
+        # default given in lit.site.cfg is not present. If default is not
+        # present then force c++11.
+        std = self.get_lit_conf('std', 'c++11')
+        self.compile_flags += ['-std={0}'.format(std)]
+        self.config.available_features.add(std)
+        # Configure include paths
         self.compile_flags += ['-nostdinc++']
-        self.compile_flags += ['-I' + self.src_root + '/include',
-                               '-I' + self.src_root + '/test/support']
+        self.compile_flags += ['-I' + self.src_root + '/test/support']
+        libcxx_headers = self.get_lit_conf('libcxx_headers',
+                                           self.src_root + '/include')
+        if not os.path.isdir(libcxx_headers):
+            self.lit_config.fatal("libcxx_headers='%s' is not a directory."
+                                  % libcxx_headers)
+        self.compile_flags += ['-I' + libcxx_headers]
         if sys.platform.startswith('linux'):
             self.compile_flags += ['-D__STDC_FORMAT_MACROS',
                                    '-D__STDC_LIMIT_MACROS',
                                    '-D__STDC_CONSTANT_MACROS']
+        # Configure feature flags.
         enable_exceptions = self.get_lit_bool('enable_exceptions', True)
         if enable_exceptions:
             self.config.available_features.add('exceptions')
@@ -483,64 +494,70 @@
         elif not enable_monotonic_clock:
             self.lit_config.fatal('enable_monotonic_clock cannot be false when'
                                   ' enable_threads is true.')
+        # Use verbose output for better errors
+        self.compile_flags += ['-v']
+        # Configure extra compile flags.
+        compile_flags_str = self.get_lit_conf('compile_flags', '')
+        self.compile_flags += shlex.split(compile_flags_str)
 
 
     def configure_link_flags(self):
         self.link_flags += ['-nodefaultlibs']
-        # Configure library search paths
+        libcxx_library = self.get_lit_conf('libcxx_library')
+        # Configure libc++ library paths.
+        if libcxx_library is not None:
+            # Check that the given value for libcxx_library is valid.
+            if not os.path.isfile(libcxx_library):
+                self.lit_config.fatal(
+                    "libcxx_library='%s' is not a valid file." % libcxx_library)
+            if self.use_system_lib:
+                self.lit_config.fatal("Conflicting options: 'libcxx_library'"
+                    " cannot be used with 'use_system_lib=true'")
+            self.link_flags += ['-Wl,-rpath,' + os.path.dirname(libcxx_library)]
+        elif not self.use_system_lib:
+            self.link_flags += ['-L' + self.library_root,
+                                '-Wl,-rpath,' + self.library_root]
+        # Configure ABI library paths.
         abi_library_path = self.get_lit_conf('abi_library_path', '')
-        if not self.use_system_lib:
-            self.link_flags += ['-L' + self.library_root]
-            self.link_flags += ['-Wl,-rpath,' + self.library_root]
         if abi_library_path:
             self.link_flags += ['-L' + abi_library_path,
                                 '-Wl,-rpath,' + abi_library_path]
         # Configure libraries
-        self.link_flags += ['-lc++']
-        link_flags_str = self.get_lit_conf('link_flags')
-        if link_flags_str is None:
-            cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi')
-            if cxx_abi == 'libstdc++':
-                self.link_flags += ['-lstdc++']
-            elif cxx_abi == 'libsupc++':
-                self.link_flags += ['-lsupc++']
-            elif cxx_abi == 'libcxxabi':
-                self.link_flags += ['-lc++abi']
-            elif cxx_abi == 'libcxxrt':
-                self.link_flags += ['-lcxxrt']
-            elif cxx_abi == 'none':
-                pass
-            else:
-                self.lit_config.fatal(
-                    'C++ ABI setting %s unsupported for tests' % cxx_abi)
-
-            if sys.platform == 'darwin':
-                self.link_flags += ['-lSystem']
-            elif sys.platform.startswith('linux'):
-                self.link_flags += ['-lgcc_eh', '-lc', '-lm', '-lpthread',
-                                    '-lrt', '-lgcc_s']
-            elif sys.platform.startswith('freebsd'):
-                self.link_flags += ['-lc', '-lm', '-pthread', '-lgcc_s']
-            else:
-                self.lit_config.fatal("unrecognized system: %r" % sys.platform)
-
-        if link_flags_str:
-            self.link_flags += shlex.split(link_flags_str)
+        if libcxx_library:
+            self.link_flags += [libcxx_library]
+        else:
+            self.link_flags += ['-lc++']
+        cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi')
+        if cxx_abi == 'libstdc++':
+            self.link_flags += ['-lstdc++']
+        elif cxx_abi == 'libsupc++':
+            self.link_flags += ['-lsupc++']
+        elif cxx_abi == 'libcxxabi':
+            self.link_flags += ['-lc++abi']
+        elif cxx_abi == 'libcxxrt':
+            self.link_flags += ['-lcxxrt']
+        elif cxx_abi == 'none':
+            pass
+        else:
+            self.lit_config.fatal(
+                'C++ ABI setting %s unsupported for tests' % cxx_abi)
+        # Configure extra libraries.
+        if sys.platform == 'darwin':
+            self.link_flags += ['-lSystem']
+        elif sys.platform.startswith('linux'):
+            self.link_flags += ['-lgcc_eh', '-lc', '-lm', '-lpthread',
+                                '-lrt', '-lgcc_s']
+        elif sys.platform.startswith('freebsd'):
+            self.link_flags += ['-lc', '-lm', '-pthread', '-lgcc_s']
+        else:
+            self.lit_config.fatal("unrecognized system: %r" % sys.platform)
 
+        link_flags_str = self.get_lit_conf('link_flags', '')
+        self.link_flags += shlex.split(link_flags_str)
 
-    def configure_std_flag(self):
-        # Try and get the std version from the command line. Fall back to
-        # default given in lit.site.cfg is not present. If default is not
-        # present then force c++11.
-        std = self.get_lit_conf('std')
-        if std is None:
-            std = 'c++11'
-            self.lit_config.note('using default std: \'-std=c++11\'')
-        self.compile_flags += ['-std={0}'.format(std)]
-        self.config.available_features.add(std)
 
     def configure_sanitizer(self):
-        san = self.get_lit_conf('llvm_use_sanitizer', '').strip()
+        san = self.get_lit_conf('use_sanitizer', '').strip()
         if san:
             # Search for llvm-symbolizer along the compiler path first
             # and then along the PATH env variable.
@@ -606,7 +623,12 @@
 
     def configure_env(self):
         if sys.platform == 'darwin' and not self.use_system_lib:
-            self.env['DYLD_LIBRARY_PATH'] = self.library_root
+            libcxx_library = self.get_lit_conf('libcxx_library')
+            if libcxx_library:
+                library_root = os.path.dirname(libcxx_library)
+            else:
+                library_root = self.library_root
+            self.env['DYLD_LIBRARY_PATH'] = library_root
 
 # name: The name of this test suite.
 config.name = 'libc++'
Index: test/lit.site.cfg.in
===================================================================
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -11,7 +11,7 @@
 config.enable_threads           = "@LIBCXX_ENABLE_THREADS@"
 config.enable_monotonic_clock   = "@LIBCXX_ENABLE_MONOTONIC_CLOCK@"
 config.cxx_abi                  = "@LIBCXX_CXX_ABI_LIBNAME@"
-config.llvm_use_sanitizer       = "@LLVM_USE_SANITIZER@"
+config.use_sanitizer            = "@LLVM_USE_SANITIZER@"
 config.abi_library_path         = "@LIBCXX_CXX_ABI_LIBRARY_PATH@"
 
 # Let the main config do the real work.
Index: www/index.html
===================================================================
--- www/index.html
+++ www/index.html
@@ -470,6 +470,7 @@
 <li><a href="type_traits_design.html"><tt>&lt;type_traits&gt;</tt></a></li>
 <li><a href="http://cplusplusmusings.wordpress.com/2012/07/05/clang-and-standard-libraries-on-mac-os-x/";>Excellent notes by Marshall Clow</a></li>
 <li><a href="debug_mode.html">Status of debug mode</a></li>
+<li><a href="lit_usage.html">LIT usage guide</a></li>
 </ul>
 
 </div>
Index: www/lit_usage.html
===================================================================
--- /dev/null
+++ www/lit_usage.html
@@ -0,0 +1,168 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+          "http://www.w3.org/TR/html4/strict.dtd";>
+<!-- Material used from: HTML 4.01 specs: http://www.w3.org/TR/html401/ -->
+<html>
+<head>
+  <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+  <title>Testing libc++ using LIT</title>
+  <link type="text/css" rel="stylesheet" href="menu.css">
+  <link type="text/css" rel="stylesheet" href="content.css">
+  <style>
+    .lit-option {
+      padding-top: 0.5em;
+      margin-bottom: 0.0em;
+      font-size: medium;
+      color: #2d58b7
+    }
+    .lit-option-desc {
+      display: block;
+      margin-top: 0em;
+      margin-bottom: 0em;
+      margin-left: 20px;
+      margin-right: 20px;
+    }
+  </style>
+</head>
+
+<body>
+<div id="menu">
+  <div>
+    <a href="http://llvm.org/";>LLVM Home</a>
+  </div>
+
+  <div class="submenu">
+    <label>libc++ Info</label>
+    <a href="/index.html">About</a>
+  </div>
+
+  <div class="submenu">
+    <label>Quick Links</label>
+    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev";>cfe-dev</a>
+    <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits";>cfe-commits</a>
+    <a href="http://llvm.org/bugs/";>Bug Reports</a>
+    <a href="http://llvm.org/svn/llvm-project/libcxx/trunk/";>Browse SVN</a>
+    <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/";>Browse ViewVC</a>
+  </div>
+</div>
+
+<div id="content">
+<!--*********************************************************************-->
+                     <h1>Testing libc++ using LIT</h1>
+<!--*********************************************************************-->
+<p>
+libc++ uses LIT to configure and run its tests. The primary way to run the
+libc++ tests is by using <code>make check-libcxx</code>. However since libc++
+can be used in any number of possible configurations it is important to
+customize the way LIT builds and runs the tests. This guide provides
+information on how to use LIT directly to test libc++.
+</p>
+<p>
+Documentation for LIT can be found
+<a href="http://llvm.org/docs/CommandGuide/lit.html";>here</a>.
+</p>
+
+<!--*********************************************************************-->
+                        <h2>Getting Started</h2>
+<!--*********************************************************************-->
+<p>
+After building libc++ use the following commands before you start using LIT to
+test.
+</p>
+<ul>
+  <li><code>alias lit='python path/to/llvm/utils/lit/lit.py'</code></li>
+  <li><code>export LIBCXX_SITE_CONFIG=path/to/build-libcxx/test/lit.site.cfg</code></li>
+</ul>
+<p>
+You can now run the libc++ tests by running:
+</p>
+<ul>
+  <li><code>cd path/to/libcxx</code></li>
+  <li><code>lit -sv ./test</code></li>
+</ul>
+<p>
+To only run a subsection of the tests use:
+<ul>
+  <li><code>lit -sv test/std/numerics # Run only the numeric tests</code></li>
+</ul>
+
+<!--*********************************************************************-->
+                     <h2>Customization Options</h2>
+<!--*********************************************************************-->
+<p>
+libc++'s testsuite provides multiple options to configure the way the tests
+are build and run. To use these options you pass them on the LIT command line
+as <code>--param NAME</code> or <code>--param NAME=VALUE</code>. Some options
+have default values specified during CMake's configuration. Passing the option
+on the command line will override the default.
+</p>
+
+
+<p>
+<h3 class="lit-option">libcxx_site_config=&lt;path/to/lit.site.cfg&gt;</h3>
+<blockquote class="lit-option-desc">
+Specify the site configuration to use when running the tests. This option
+overrides the enviroment variable <code>LIBCXX_SITE_CONFIG</code>
+</blockquote>
+</p>
+
+<p>
+<h3 class="lit-option">libcxx_headers=&lt;path/to/headers&gt;</h3>
+<blockquote class="lit-option-desc">
+Specify the libc++ headers that are tested. By default the headers in the source
+tree are used.
+</blockquote>
+</p>
+
+<p>
+<h3 class="lit-option">libcxx_library=&lt;path/to/libc++.so&gt;</h3>
+<blockquote class="lit-option-desc">
+Specify the libc++ library that is tested. By default the library in the build
+directory is used. This option cannot be used when <code>use_system_lib</code>
+is provided.
+</blockquote>
+</p>
+
+<p>
+<h3 class="lit-option">use_system_lib=&lt;bool&gt;</h3>
+<blockquote class="lit-option-desc">
+<b>Default: </b><code>False</code></br>
+Enable or disable testing against the installed version of libc++ library.
+Note: This does not use the installed headers.
+</blockquote>
+</p>
+
+<p>
+<h3 class="lit-option">compile_flags="&lt;list-of-args&gt;"</h3>
+<blockquote class="lit-option-desc">
+Specify additional compile flags as a space delimited string.
+Note: This options should not be used to change the standard version used.
+</blockquote>
+</p>
+
+<p>
+<h3 class="lit-option">link_flags="&lt;list-of-args&gt;"</h3>
+<blockquote class="lit-option-desc">
+Specify additional link  flags as a space delimited string.
+</blockquote>
+</p>
+
+<p>
+<h3 class="lit-option">std=&lt;standard version&gt;</h3>
+<blockquote class="lit-option-desc">
+<b>Values: </b><code>c++98, c++03, c++11, c++14, c++1z</code></br>
+Change the standard version used when building the tests.
+</blockquote>
+</p>
+
+<p>
+<h3 class="lit-option">use_sanitizer=&lt;sanitizer name&gt;</h3>
+<blockquote class="lit-option-desc">
+<b>Values: </b><code>Memory, MemoryWithOrigins, Address, Undefined</code></br>
+Run the tests using the given sanitizer. If <code>LLVM_USE_SANITIZER</code>
+was given when building libc++ then that sanitizer will be used by default.
+</blockquote>
+</p>
+
+</div>
+</body>
+</html>
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to