summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2019-01-28 20:39:50 +0000
committerPetr Hosek <phosek@chromium.org>2019-01-28 20:39:50 +0000
commit4155e789120b764911d7da5ec1ac7dc37069889b (patch)
treee89857f2ce711d2c1bbb2922f7ba5247b46aeef0 /libcxx/test/std
parent89654116199b56e30767848beebaeee5d2dc5c78 (diff)
downloadbcm5719-llvm-4155e789120b764911d7da5ec1ac7dc37069889b.tar.gz
bcm5719-llvm-4155e789120b764911d7da5ec1ac7dc37069889b.zip
[libc++] Use runtime rather then compile-time glibc version check
glibc supports versioning, so it's possible to build against older version and run against newer version. This is sometimes relied on in practice, e.g. in Fuchsia build we build against older sysroot (equivalent to Ubuntu Trusty) to cover the broadest possible range of host systems, but that doesn't necessarily match the system that binary is going to run on which may have newer version, in which case the compile test used in curr_symbol is going to fail. Using runtime check is more reliable. Differential Revision: https://reviews.llvm.org/D56702 llvm-svn: 352425
Diffstat (limited to 'libcxx/test/std')
-rw-r--r--libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
index f66d2c6330d..f04ff4fb614 100644
--- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
@@ -61,6 +61,20 @@ public:
: std::moneypunct_byname<wchar_t, true>(nm, refs) {}
};
+#if defined(_CS_GNU_LIBC_VERSION)
+static bool glibc_version_less_than(char const* version) {
+ std::string test_version = std::string("glibc ") + version;
+
+ size_t n = confstr(_CS_GNU_LIBC_VERSION, nullptr, (size_t)0);
+ char *current_version = new char[n];
+ confstr(_CS_GNU_LIBC_VERSION, current_version, n);
+
+ bool result = strverscmp(current_version, test_version.c_str()) < 0;
+ delete[] current_version;
+ return result;
+}
+#endif
+
int main()
{
{
@@ -116,17 +130,14 @@ int main()
{
Fnf f(LOCALE_ru_RU_UTF_8, 1);
+#if defined(_CS_GNU_LIBC_VERSION)
// GLIBC <= 2.23 uses currency_symbol="<U0440><U0443><U0431>"
// GLIBC >= 2.24 uses currency_symbol="<U20BD>"
// See also: http://www.fileformat.info/info/unicode/char/20bd/index.htm
-#if defined(TEST_GLIBC_PREREQ)
- #if TEST_GLIBC_PREREQ(2, 24)
- #define TEST_GLIBC_2_24_CURRENCY_SYMBOL
- #endif
-#endif
-
-#if defined(TEST_GLIBC_2_24_CURRENCY_SYMBOL)
- assert(f.curr_symbol() == " \u20BD");
+ if (!glibc_version_less_than("2.24"))
+ assert(f.curr_symbol() == " \u20BD");
+ else
+ assert(f.curr_symbol() == " \xD1\x80\xD1\x83\xD0\xB1");
#else
assert(f.curr_symbol() == " \xD1\x80\xD1\x83\xD0\xB1");
#endif
@@ -137,8 +148,11 @@ int main()
}
{
Fwf f(LOCALE_ru_RU_UTF_8, 1);
-#if defined(TEST_GLIBC_2_24_CURRENCY_SYMBOL)
- assert(f.curr_symbol() == L" \u20BD");
+#if defined(_CS_GNU_LIBC_VERSION)
+ if (!glibc_version_less_than("2.24"))
+ assert(f.curr_symbol() == L" \u20BD");
+ else
+ assert(f.curr_symbol() == L" \x440\x443\x431");
#else
assert(f.curr_symbol() == L" \x440\x443\x431");
#endif
OpenPOWER on IntegriCloud