Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++] Fix tests on musl. #8287

Open
wants to merge 1 commit into
base: stable/20240123
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ int main(int, char**)
const std::error_category& e_cat1 = std::generic_category();
const std::string msg = e_cat1.message(-1);
// Exact message format varies by platform.
#if defined(_AIX)
LIBCPP_ASSERT(msg.rfind("Error -1 occurred", 0) == 0);
#elif defined(_NEWLIB_VERSION)
LIBCPP_ASSERT(msg.empty());
#else
LIBCPP_ASSERT(msg.rfind("Unknown error", 0) == 0);
#endif
LIBCPP_ASSERT(
msg.rfind("Error -1 occurred", 0) == 0 // AIX
|| msg.rfind("No error information", 0) == 0 // musl
|| msg.rfind("Unknown error", 0) == 0
|| msg.empty() // newlib
);
assert(errno == E2BIG);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@ int main(int, char**) {
const std::error_category& e_cat1 = std::system_category();
const std::string msg = e_cat1.message(-1);
// Exact message format varies by platform.
#if defined(_AIX)
LIBCPP_ASSERT(msg.rfind("Error -1 occurred", 0) == 0);
#elif defined(_NEWLIB_VERSION)
LIBCPP_ASSERT(msg.empty());
#else
LIBCPP_ASSERT(msg.rfind("Unknown error", 0) == 0);
#endif
LIBCPP_ASSERT(
msg.rfind("Error -1 occurred", 0) == 0 // AIX
|| msg.rfind("No error information", 0) == 0 // musl
|| msg.rfind("Unknown error", 0) == 0
|| msg.empty() // newlib
);
assert(errno == E2BIG);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <locale>
#include <ios>
#include <cassert>
#include <cstdio>
#include <streambuf>
#include <cmath>
#include "test_macros.h"
Expand Down Expand Up @@ -8934,11 +8935,12 @@ void test4()
char str[200];
std::locale lc = std::locale::classic();
std::locale lg(lc, new my_numpunct);
#ifdef _AIX
std::string inf = "INF";
#else
std::string inf = "inf";
#endif

std::string inf;

// This should match the underlying C library
std::sprintf(str, "%f", INFINITY);
inf = str;

const my_facet f(1);
{
Expand Down Expand Up @@ -10727,24 +10729,28 @@ void test5()
std::locale lc = std::locale::classic();
std::locale lg(lc, new my_numpunct);
const my_facet f(1);
#if defined(_AIX)
std::string nan= "NaNQ";
std::string NaN = "NaNQ";
std::string nan_padding25 = "*********************";
std::string pnan_sign = "+";
std::string pnan_padding25 = "********************";
#else
std::string nan= "nan";
std::string NaN = "NAN";
std::string nan_padding25 = "**********************";
#if defined(TEST_HAS_GLIBC) || defined(_WIN32)
std::string pnan_sign = "+";
std::string pnan_padding25 = "*********************";
#else
std::string pnan_sign = "";
std::string pnan_padding25 = "**********************";
#endif
#endif

std::string nan;
std::string NaN;
std::string pnan_sign;

// The output here depends on the underlying C library, so work out what
// that does.
std::sprintf(str, "%f", std::nan(""));
nan = str;

std::sprintf(str, "%F", std::nan(""));
NaN = str;

std::sprintf(str, "%+f", std::nan(""));
if (str[0] == '+') {
pnan_sign = "+";
}

std::string nan_padding25 = std::string(25 - nan.length(), '*');
std::string pnan_padding25 = std::string(25 - nan.length()
- pnan_sign.length(), '*');

{
long double v = std::nan("");
std::ios ios(0);
Expand Down