Skip to content

[libcxx] Work around picolibc argv handling in tests. #127662

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

Merged
merged 6 commits into from
Feb 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions libcxx/utils/libcxx/test/dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import os
import pickle
import platform
import shlex
import shutil
import tempfile

Expand Down Expand Up @@ -274,23 +273,41 @@ def hasAnyLocale(config, locales):
%{exec} -- this means that the command may be executed on a remote host
depending on the %{exec} substitution.
"""
program = """

# Convert the locale names into C string literals. We expect all currently
# known locale names to be printable ASCII and not contain awkward
# characters like \ or ", so this should be trivial.
assert all(
0x20 <= ord(ch) <= 0x7E and ch not in {'"', "\\"}
for locale in locales
for ch in locale
)
name_string_literals = ", ".join('"' + locale + '"' for locale in locales)

program = (
"""
#include <stddef.h>
#if defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_LOCALIZATION
int main(int, char**) { return 1; }
#else
#include <locale.h>
int main(int argc, char** argv) {
for (int i = 1; i < argc; i++) {
if (::setlocale(LC_ALL, argv[i]) != NULL) {
static const char *const test_locale_names[] = {
"""
+ name_string_literals
+ """, nullptr,
};
int main() {
for (size_t i = 0; test_locale_names[i]; i++) {
if (::setlocale(LC_ALL, test_locale_names[i]) != NULL) {
return 0;
}
}
return 1;
}
#endif
"""
return programSucceeds(config, program, args=[shlex.quote(l) for l in locales])
"""
)
return programSucceeds(config, program)


@_memoizeExpensiveOperation(lambda c, flags="": (c.substitutions, c.environment, flags))
Expand Down