Add cxx_runtime_root options for testing against a different libc++ at runtime

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@266855 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/docs/TestingLibcxx.rst b/docs/TestingLibcxx.rst
index 98162d9..5aecc07 100644
--- a/docs/TestingLibcxx.rst
+++ b/docs/TestingLibcxx.rst
@@ -118,11 +118,20 @@
   Specify the libc++ headers that are tested. By default the headers in the
   source tree are used.
 
-.. option:: libcxx_library=<path/to/libc++.so>
+.. option:: cxx_library_root=<path/to/lib/>
 
-  Specify the libc++ library that is tested. By default the library in the
-  build directory is used. This option cannot be used when use_system_lib is
-  provided.
+  Specify the directory of the libc++ library to be tested. By default the
+  library folder of the build directory is used. This option cannot be used
+  when use_system_lib is provided.
+
+
+.. option:: cxx_runtime_root=<path/to/lib/>
+
+  Specify the directory of the libc++ library to use at runtime. This directory
+  is not added to the linkers search path. This can be used to compile tests
+  against one version of libc++ and run them using another. The default value
+  for this option is `cxx_library_root`. This option cannot be used
+  when use_system_lib is provided.
 
 .. option:: use_system_lib=<bool>
 
diff --git a/test/libcxx/test/config.py b/test/libcxx/test/config.py
index 3cd9114..156b424 100644
--- a/test/libcxx/test/config.py
+++ b/test/libcxx/test/config.py
@@ -61,6 +61,7 @@
         self.libcxx_src_root = None
         self.libcxx_obj_root = None
         self.cxx_library_root = None
+        self.cxx_runtime_root = None
         self.abi_library_root = None
         self.env = {}
         self.use_target = False
@@ -195,6 +196,8 @@
     def configure_cxx_library_root(self):
         self.cxx_library_root = self.get_lit_conf('cxx_library_root',
                                                   self.libcxx_obj_root)
+        self.cxx_runtime_root = self.get_lit_conf('cxx_runtime_root',
+                                                   self.cxx_library_root)
 
     def configure_use_system_cxx_lib(self):
         # This test suite supports testing against either the system library or
@@ -439,9 +442,11 @@
         self.cxx.link_flags += shlex.split(link_flags_str)
 
     def configure_link_flags_cxx_library_path(self):
-        if not self.use_system_cxx_lib and self.cxx_library_root:
-            self.cxx.link_flags += ['-L' + self.cxx_library_root,
-                                    '-Wl,-rpath,' + self.cxx_library_root]
+        if not self.use_system_cxx_lib:
+            if self.cxx_library_root:
+                self.cxx.link_flags += ['-L' + self.cxx_library_root]
+            if self.cxx_runtime_root:
+                self.cxx.link_flags += ['-Wl,-rpath,' + self.cxx_runtime_root]
 
     def configure_link_flags_abi_library_path(self):
         # Configure ABI library paths.
diff --git a/test/libcxx/test/target_info.py b/test/libcxx/test/target_info.py
index 71adbeb..a743595 100644
--- a/test/libcxx/test/target_info.py
+++ b/test/libcxx/test/target_info.py
@@ -92,8 +92,8 @@
         # Configure the library path for libc++
         if self.full_config.use_system_cxx_lib:
             pass
-        elif self.full_config.cxx_library_root:
-            library_paths += [self.full_config.cxx_library_root]
+        elif self.full_config.cxx_runtime_root:
+            library_paths += [self.full_config.cxx_runtime_root]
         # Configure the abi library path
         if self.full_config.abi_library_root:
             library_paths += [self.full_config.abi_library_root]