As noted in the PR, some embedded targets do not support command-line
arguments, which means that the dg-require-namedlocale check always
fails. Use Sandra's suggestion of hardcoding the argument into the
executable instead of passing it as a command-line argument.

Realistically, those embedded targets probably don't support the named
locales anyway, but at least now the tests will be UNSUPPORTED for the
right reason.

libstdc++-v3/ChangeLog:

        PR libstdc++/65909
        * testsuite/lib/libstdc++.exp (check_v3_target_namedlocale):
        Hardcode the locale name instead of passing it to the
        executable. Do not hardcode buffer size for string.
---

Tested x86_64-linux.

 libstdc++-v3/testsuite/lib/libstdc++.exp | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp 
b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 5e958d159de2..fbc9f7f13e64 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -1034,7 +1034,7 @@ proc check_v3_target_namedlocale { args } {
        puts $f "using namespace std;"
        puts $f "char *transform_locale(const char *name)"
        puts $f "{"
-       puts $f "    char *result = new char\[50\];"
+       puts $f "    char *result = new char\[strlen(name)+6\];"
        puts $f "    strcpy(result, name);"
        puts $f "#if defined __FreeBSD__ || defined __DragonFly__ || defined 
__NetBSD__"
        puts $f "    /* fall-through */"
@@ -1045,14 +1045,9 @@ proc check_v3_target_namedlocale { args } {
        puts $f "#endif"
        puts $f "    return result;"
        puts $f "}"
-       puts $f "int main (int argc, char** argv)"
+       puts $f "int main ()"
        puts $f "{"
-       puts $f "  if (argc < 2)"
-       puts $f "  {"
-       puts $f "    printf(\"locale support test not supported\\n\");"
-       puts $f "    return 1;"
-       puts $f "  }"
-       puts $f "  const char *namedloc = transform_locale(*(argv + 1));"
+       puts $f "  const char *namedloc = transform_locale(\"$args\");"
        puts $f "  try"
        puts $f "  {"
        puts $f "    locale((const char*)namedloc);"
@@ -1076,7 +1071,7 @@ proc check_v3_target_namedlocale { args } {
          return 0
        }
 
-       set result [${tool}_load "./$exe" "$args" ""]
+       set result [${tool}_load "./$exe" "" ""]
        set status [lindex $result 0]
 
        verbose "check_v3_target_namedlocale <$args>: status is <$status>" 2
-- 
2.49.0

Reply via email to