diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt --- a/libcxx/test/CMakeLists.txt +++ b/libcxx/test/CMakeLists.txt @@ -14,6 +14,14 @@ set(LIBCXX_TEST_COMPILER_FLAGS "" CACHE STRING "Additonal linker flags to pass when compiling the tests") +set(LIBCXX_TEST_AVAILABLE_LOCALES "" CACHE STRING + "Semicolon-separated list of locales supported by the system + the tests will be run on. If empty, the locales will be + inferred from the host system. + Setting this variable is useful if the tests will be run + on a remote machine. For the list of supported locales see + `add_common_locales` in utils/libcxx/test/target_info.py") + # The tests shouldn't link to any ABI library when it has been linked into # libc++ statically or via a linker script. if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY OR LIBCXX_ENABLE_ABI_LINKER_SCRIPT) diff --git a/libcxx/test/lit.site.cfg.in b/libcxx/test/lit.site.cfg.in --- a/libcxx/test/lit.site.cfg.in +++ b/libcxx/test/lit.site.cfg.in @@ -37,6 +37,8 @@ config.pstl_obj_root = "@ParallelSTL_BINARY_DIR@" if @LIBCXX_ENABLE_PARALLEL_ALGORITHMS@ else None config.libcxx_gdb = "@LIBCXX_GDB@" +config.available_locales = "@LIBCXX_TEST_AVAILABLE_LOCALES@" + # Code signing config.llvm_codesign_identity = "@LLVM_CODESIGNING_IDENTITY@" diff --git a/libcxx/utils/libcxx/test/target_info.py b/libcxx/utils/libcxx/test/target_info.py --- a/libcxx/utils/libcxx/test/target_info.py +++ b/libcxx/utils/libcxx/test/target_info.py @@ -63,7 +63,24 @@ locale.setlocale(locale.LC_ALL, default_locale) -def add_common_locales(features, lit_config, is_windows=False): +def add_common_locales(features, full_config, is_windows=False): + lit_config = full_config.lit_config + + # Prefer locales that were specified manually. + # This can be the case if tests are being run on a remote board, + # when querying the host system locale doesn't make sense. + manually_specified_locales = full_config.get_lit_conf('available_locales') + + if manually_specified_locales: + manually_specified_locales = \ + [loc.strip() for loc in manually_specified_locales.split(';')] + lit_config.note('Using manually specified locales: %s' \ + % manually_specified_locales) + def locale_is_supported(loc_name): + return loc_name in manually_specified_locales + else: + locale_is_supported = test_locale + # A list of locales needed by the test-suite. # The list uses the canonical name for the locale used in the test-suite # TODO: On Linux ISO8859 *may* needs to hyphenated. @@ -77,7 +94,7 @@ ] for loc_id, windows_loc_name in locales: loc_name = windows_loc_name if is_windows else loc_id - if test_locale(loc_name): + if locale_is_supported(loc_name): features.add('locale.{0}'.format(loc_id)) else: lit_config.warning('The locale {0} is not supported by ' @@ -136,7 +153,7 @@ return (True, name, version) def add_locale_features(self, features): - add_common_locales(features, self.full_config.lit_config) + add_common_locales(features, self.full_config) def add_cxx_compile_flags(self, flags): if self.full_config.use_deployment: @@ -182,7 +199,7 @@ super(FreeBSDLocalTI, self).__init__(full_config) def add_locale_features(self, features): - add_common_locales(features, self.full_config.lit_config) + add_common_locales(features, self.full_config) def add_cxx_link_flags(self, flags): flags += ['-lc', '-lm', '-lpthread', '-lgcc_s', '-lcxxrt'] @@ -193,7 +210,7 @@ super(NetBSDLocalTI, self).__init__(full_config) def add_locale_features(self, features): - add_common_locales(features, self.full_config.lit_config) + add_common_locales(features, self.full_config) def add_cxx_link_flags(self, flags): flags += ['-lc', '-lm', '-lpthread', '-lgcc_s', '-lc++abi', @@ -230,7 +247,7 @@ return ver # Permitted to be None. def add_locale_features(self, features): - add_common_locales(features, self.full_config.lit_config) + add_common_locales(features, self.full_config) # Some linux distributions have different locale data than others. # Insert the distributions name and name-version into the available # features to allow tests to XFAIL on them. @@ -284,7 +301,7 @@ super(WindowsLocalTI, self).__init__(full_config) def add_locale_features(self, features): - add_common_locales(features, self.full_config.lit_config, + add_common_locales(features, self.full_config, is_windows=True) def use_lit_shell_default(self):