diff --git a/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp b/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp --- a/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp +++ b/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp @@ -10732,7 +10732,8 @@ std::string nan= "nan"; std::string NaN = "NAN"; std::string nan_padding25 = "**********************"; -#if defined(TEST_HAS_GLIBC) || defined(_WIN32) +#if defined(TEST_HAS_GLIBC) || defined(_WIN32) || \ + (defined(__BIONIC__) && !defined(_LIBCPP_TESTING_ANDROID_PRINTF_NAN_NO_SIGN)) std::string pnan_sign = "+"; std::string pnan_padding25 = "*********************"; #else diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py --- a/libcxx/utils/libcxx/test/features.py +++ b/libcxx/utils/libcxx/test/features.py @@ -142,6 +142,24 @@ } """)), + # Check for an Android NAN printf change. Considering NAN and -NAN: + # - Android L (API 21): "%f" and "%+f" print "nan". + # - Android M (API 23) and up: "%f" prints "nan" or "-nan", "%+f" prints + # "+nan" or "-nan". + # Set this feature for L, where the sign is never printed. Otherwise, "%+f" + # for non-negative NAN prints the '+' sign. + Feature(name='android-printf-nan-no-sign', + when=lambda cfg: '__ANDROID__' in compilerMacros(cfg) and not programSucceeds(cfg, """ + #include + #include + int main(int, char**) { + char buf[100]; + snprintf(buf, sizeof(buf), "%+f", NAN); + return buf[0] != '+'; + } + """), + actions=[AddCompileFlag('-D_LIBCPP_TESTING_ANDROID_PRINTF_NAN_NO_SIGN')]), + # Whether Bash can run on the executor. # This is not always the case, for example when running on embedded systems. #