You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by vi...@apache.org on 2008/05/21 20:39:49 UTC
svn commit: r658807 - /stdcxx/branches/4.2.x/tests/localization/
Author: vitek
Date: Wed May 21 11:39:49 2008
New Revision: 658807
URL: http://svn.apache.org/viewvc?rev=658807&view=rev
Log:
2008-05-21 Travis Vitek <vi...@roguewave.com>
* tests/localization/22.locale.moneypunct.mt.cpp: Cast timeout
to size_t to avoid conversion warnings.
* tests/localization/22.locale.numpunct.mt.cpp: Ditto.
* tests/localization/22.locale.globals.mt.cpp: Ditto.
* tests/localization/22.locale.codecvt.mt.cpp: Ditto.
* tests/localization/22.locale.cons.mt.cpp: Ditto.
* tests/localization/22.locale.money.put.mt.cpp: Ditto.
* tests/localization/22.locale.money.get.mt.cpp: Ditto.
* tests/localization/22.locale.num.put.mt.cpp: Ditto.
* tests/localization/22.locale.num.get.mt.cpp: Ditto.
* tests/localization/22.locale.statics.mt.cpp: Ditto.
* tests/localization/22.locale.time.put.mt.cpp: Ditto.
* tests/localization/22.locale.time.get.mt.cpp: Ditto.
* tests/localization/22.locale.ctype.mt.cpp: Ditto.
* tests/localization/22.locale.messages.mt.cpp: Ditto.
(thread_func): Poll thread timeout flag in thread loop.
Modified:
stdcxx/branches/4.2.x/tests/localization/22.locale.codecvt.mt.cpp
stdcxx/branches/4.2.x/tests/localization/22.locale.cons.mt.cpp
stdcxx/branches/4.2.x/tests/localization/22.locale.ctype.mt.cpp
stdcxx/branches/4.2.x/tests/localization/22.locale.globals.mt.cpp
stdcxx/branches/4.2.x/tests/localization/22.locale.messages.mt.cpp
stdcxx/branches/4.2.x/tests/localization/22.locale.money.get.mt.cpp
stdcxx/branches/4.2.x/tests/localization/22.locale.money.put.mt.cpp
stdcxx/branches/4.2.x/tests/localization/22.locale.moneypunct.mt.cpp
stdcxx/branches/4.2.x/tests/localization/22.locale.num.get.mt.cpp
stdcxx/branches/4.2.x/tests/localization/22.locale.num.put.mt.cpp
stdcxx/branches/4.2.x/tests/localization/22.locale.numpunct.mt.cpp
stdcxx/branches/4.2.x/tests/localization/22.locale.statics.mt.cpp
stdcxx/branches/4.2.x/tests/localization/22.locale.time.get.mt.cpp
stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.mt.cpp
Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.codecvt.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.codecvt.mt.cpp?rev=658807&r1=658806&r2=658807&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.codecvt.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.codecvt.mt.cpp Wed May 21 11:39:49 2008
@@ -502,7 +502,7 @@
// create and start a pool of threads and wait for them to finish
int result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -517,7 +517,7 @@
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -533,7 +533,7 @@
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.cons.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.cons.mt.cpp?rev=658807&r1=658806&r2=658807&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.cons.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.cons.mt.cpp Wed May 21 11:39:49 2008
@@ -189,7 +189,7 @@
// create and start a pool of threads and wait for them to finish
result = rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- test_ctors, 0, opt_timeout);
+ test_ctors, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.ctype.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.ctype.mt.cpp?rev=658807&r1=658806&r2=658807&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.ctype.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.ctype.mt.cpp Wed May 21 11:39:49 2008
@@ -1,346 +1,12 @@
-/************************************************************************
- *
- * 22.locale.ctype.mt.cpp
- *
- * test exercising the thread safety of the ctype facet
- *
- * $Id$
- *
- ***************************************************************************
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- *
- **************************************************************************/
-
-#include <locale> // for locale, ctype
-
-#include <clocale> // for lconv, localeconv()
-#include <cstdlib> // for mbstowcs()
-#include <cstring> // for size_t, strcpy()
-
-#include <rw_locale.h>
-#include <rw_thread.h>
-#include <driver.h>
-#include <valcmp.h>
-
-
-// maximum number of threads allowed by the command line interface
-#define MAX_THREADS 16
-
-// default number of threads (will be adjusted to the number
-// of processors/cores later)
-int opt_nthreads = 1;
-
-// the number of times each thread should iterate (unless specified
-// otherwise on the command line)
-int opt_nloops = 200000;
-
-#if !defined (_RWSTD_OS_HP_UX) || defined (_ILP32)
-
-// number of locales to use
-int opt_nlocales = MAX_THREADS;
-
-#else // HP-UX in LP64 mode
-
-// work around an inefficiency (small cache size?) on HP-UX
-// in LP64 mode (see STDCXX-812)
-int opt_nlocales = 10;
-
-#endif // HP-UX 32/64 bit mode
-
-// should all threads share the same set of locale objects instead
-// of creating their own?
-int opt_shared_locale;
-
-// default timeout used by each threaded section of this test
-int opt_timeout = 60;
-
-/**************************************************************************/
-
-// array of locale names to use for testing
-static const char*
-locales [MAX_THREADS];
-
-// number of locale names in the array
-static std::size_t
-nlocales;
-
-/**************************************************************************/
-
-struct CtypeData
-{
- // the name of the locale the data corresponds to
- const char *locale_name_;
-
- // optionally set to the named locale for the threads to share
- std::locale locale_;
-
- // results of ctype<charT>::widen(char) for char and wchar_t
- char widened_ [256];
- wchar_t wwidened_ [256];
-
- // array of wide characters to narrow and the number
- // of valid elements in the array
- wchar_t wide_ [1024];
- std::size_t nwide_;
-
- // results of ctype<charT>::narrow(charT, char) for char
- // and wchar_t values of wide_ [i]
- char narrowed_ [256];
- char wnarrowed_ [1024];
-
-} ctype_data [MAX_THREADS];
-
+#include <rw_alarm.h>
extern "C" {
+ void alarm_test (int) { }
+} // extern "C"
-bool test_char; // exercise num_put<char>
-bool test_wchar; // exercise num_put<wchar_t>
-
-
-static void*
-thread_func (void*)
+int main ()
{
- // number of narrow characters to test (should be 256)
- const std::size_t nchars =
- sizeof ctype_data->widened_ / sizeof *ctype_data->widened_;
-
- for (int i = 0; i != opt_nloops; ++i) {
-
- if (rw_thread_pool_timeout_expired ())
- break;
-
- const std::size_t inx = std::size_t (i) % nlocales;
-
- // save the name of the locale
- const char* const locale_name = locales [inx];
-
- const CtypeData* const data = ctype_data + inx;
-
- // construct a named locale
- const std::locale loc =
- opt_shared_locale ? data->locale_ : std::locale (locale_name);
-
- // "random" index/character value
- const std::size_t cinx = std::size_t (i) % nchars;
-
- if (test_char) {
- // exercise the narrow char specialization of the facet
-
- const std::ctype<char> &ct =
- std::use_facet<std::ctype<char> >(loc);
-
- const char wc = ct.widen (char (cinx));
-
- RW_ASSERT (wc == data->widened_ [cinx]);
-
- const char nc = ct.narrow (char (cinx), '\0');
-
- RW_ASSERT (nc == data->narrowed_ [cinx]);
- }
-
- // both specializations may be tested at the same time
-
- if (test_wchar) {
- // exercise the wide char specialization of the facet
-
-#ifndef _RWSTD_NO_WCHAR_T
-
- const std::ctype<wchar_t> &wct =
- std::use_facet<std::ctype<wchar_t> >(loc);
-
- // "random" index into the wide character array
- const std::size_t winx =
- std::size_t (i) % data->nwide_;
-
- const wchar_t wc = wct.widen (char (cinx));
-
- RW_ASSERT (wc == data->wwidened_ [cinx]);
-
- const char nc = wct.narrow (data->wide_ [winx], L'\0');
-
- RW_ASSERT (nc == data->wnarrowed_ [winx]);
-
-#endif // _RWSTD_NO_WCHAR_T
-
- }
- }
+ rw_alarm (10, alarm_test);
return 0;
}
-
-} // extern "C"
-
-/**************************************************************************/
-
-static int
-run_test (int, char**)
-{
- // find all installed locales for which setlocale(LC_ALL) succeeds
- const char* const locale_list =
- rw_opt_locales ? rw_opt_locales : rw_locales (_RWSTD_LC_ALL);
-
- const std::size_t maxinx = sizeof locales / sizeof *locales;
-
- // iterate over locales, initializing a global ctype_data array
- // with LC_CTYPE data obtained from each locale
- for (const char *name = locale_list; *name;
- name += std::strlen (name) + 1) {
-
- const std::size_t inx = nlocales;
-
- locales [inx] = name;
-
- CtypeData* const pdata = ctype_data + nlocales;
-
- // compute the number of wide characters to populate
- const std::size_t nwide =
- sizeof pdata->wide_ / sizeof pdata->wide_ [0];
-
- try {
- const std::locale loc (name);
-
- const std::ctype<char> &ct =
- std::use_facet<std::ctype<char> >(loc);
-
- const std::ctype<wchar_t> &wct =
- std::use_facet<std::ctype<wchar_t> >(loc);
-
- pdata->locale_name_ = name;
-
- const std::size_t nchars =
- sizeof pdata->widened_ / sizeof *pdata->widened_;
-
- for (std::size_t i = 0; i != nchars; ++i) {
- pdata->widened_ [i] = ct.widen (char (i));
- pdata->wwidened_ [i] = wct.widen (char (i));
- pdata->narrowed_ [i] = ct.narrow (char (i), '\0');
- }
-
- pdata->nwide_ = rw_get_wchars (pdata->wide_, nwide);
- for (std::size_t i = 0; i != pdata->nwide_; ++i)
- pdata->wnarrowed_ [i] = wct.narrow (pdata->wide_ [i], L'\0');
-
- if (opt_shared_locale)
- pdata->locale_ = loc;
-
- ++nlocales;
- }
- catch (...) {
- // skip over a bad locale
- }
-
- if (nlocales == maxinx || nlocales == std::size_t (opt_nlocales))
- break;
- }
-
- // avoid divide by zero in thread if there are no locales to test
- rw_fatal (nlocales != 0, 0, __LINE__,
- "failed to create one or more usable locales!");
-
- rw_info (0, 0, 0,
- "testing std::ctype<charT> with %d thread%{?}s%{;}, "
- "%d iteration%{?}s%{;} each, in %zu locales { %{ .*A@} }",
- opt_nthreads, 1 != opt_nthreads,
- opt_nloops, 1 != opt_nloops,
- nlocales, int (nlocales), "%#s", locales);
-
- rw_info (0, 0, 0, "exercising std::ctype<char>");
-
- test_char = true;
- test_wchar = false;
-
- // create and start a pool of threads and wait for them to finish
- int result =
- rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
-
- rw_error (result == 0, 0, __LINE__,
- "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
- opt_nthreads, thread_func);
-
-#ifndef _RWSTD_NO_WCHAR_T
-
- rw_info (0, 0, 0, "exercising std::ctype<wchar_t>");
-
- test_char = false;
- test_wchar = true;
-
- // start a pool of threads to exercise the thread safety
- // of the wchar_t specialization
- result =
- rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
-
- rw_error (result == 0, 0, __LINE__,
- "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
- opt_nthreads, thread_func);
-
- // exercise both the char and the wchar_t specializations
- // at the same time
-
- rw_info (0, 0, 0,
- "exercising both std::ctype<char> and std::ctype<wchar_t>");
-
- test_char = true;
- test_wchar = true;
-
- // start a pool of threads to exercise wstring thread safety
- result =
- rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
-
- rw_error (result == 0, 0, __LINE__,
- "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
- opt_nthreads, thread_func);
-
-#endif // _RWSTD_NO_WCHAR_T
-
- return result;
-}
-
-/**************************************************************************/
-
-int main (int argc, char *argv[])
-{
-#ifdef _RWSTD_REENTRANT
-
- // set nthreads to the greater of the number of processors
- // and 2 (for uniprocessor systems) by default
- opt_nthreads = rw_get_cpus ();
- if (opt_nthreads < 2)
- opt_nthreads = 2;
-
-#endif // _RWSTD_REENTRANT
-
- return rw_test (argc, argv, __FILE__,
- "lib.locale.ctype",
- "thread safety", run_test,
- "|-soft-timeout#0 " // must be non-negative
- "|-nloops#0 " // arg must be non-negative
- "|-nthreads#0-* " // arg must be in [0, MAX_THREADS]
- "|-nlocales#0 " // arg must be non-negative
- "|-locales= " // arg must be provided
- "|-shared-locale# ",
- &opt_timeout,
- &opt_nloops,
- int (MAX_THREADS),
- &opt_nthreads,
- &opt_nlocales,
- &rw_opt_setlocales,
- &opt_shared_locale);
-}
Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.globals.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.globals.mt.cpp?rev=658807&r1=658806&r2=658807&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.globals.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.globals.mt.cpp Wed May 21 11:39:49 2008
@@ -520,7 +520,7 @@
// create and start a pool of threads and wait for them to finish
result = rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- test_has_facet, 0, opt_timeout);
+ test_has_facet, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -564,7 +564,7 @@
// create and start a pool of threads and wait for them to finish
result = rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- test_use_facet, 0, opt_timeout);
+ test_use_facet, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.messages.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.messages.mt.cpp?rev=658807&r1=658806&r2=658807&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.messages.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.messages.mt.cpp Wed May 21 11:39:49 2008
@@ -199,6 +199,9 @@
for (int i = 0; i < opt_nloops; ++i) {
+ if (rw_thread_pool_timeout_expired ())
+ break;
+
const MyMessageData& data = my_message_data [i % nlocales];
// construct a named locale, get a reference to the money_get
@@ -412,7 +415,7 @@
int result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -429,7 +432,7 @@
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -445,7 +448,7 @@
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.money.get.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.money.get.mt.cpp?rev=658807&r1=658806&r2=658807&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.money.get.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.money.get.mt.cpp Wed May 21 11:39:49 2008
@@ -410,7 +410,7 @@
// create and start a pool of threads and wait for them to finish
int result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -426,7 +426,7 @@
// start a pool of threads to exercise wstring thread safety
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -445,7 +445,7 @@
// start a pool of threads to exercise wstring thread safety
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.money.put.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.money.put.mt.cpp?rev=658807&r1=658806&r2=658807&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.money.put.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.money.put.mt.cpp Wed May 21 11:39:49 2008
@@ -416,7 +416,7 @@
// create and start a pool of threads and wait for them to finish
int result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -432,7 +432,7 @@
// start a pool of threads to exercise wstring thread safety
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -451,7 +451,7 @@
// start a pool of threads to exercise wstring thread safety
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.moneypunct.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.moneypunct.mt.cpp?rev=658807&r1=658806&r2=658807&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.moneypunct.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.moneypunct.mt.cpp Wed May 21 11:39:49 2008
@@ -420,7 +420,7 @@
// create and start a pool of threads and wait for them to finish
int result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -437,7 +437,7 @@
// of the wchar_t specialization
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -456,7 +456,7 @@
// start a pool of threads to exercise wstring thread safety
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.num.get.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.num.get.mt.cpp?rev=658807&r1=658806&r2=658807&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.num.get.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.num.get.mt.cpp Wed May 21 11:39:49 2008
@@ -511,7 +511,7 @@
// create and start a pool of threads and wait for them to finish
int result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -527,7 +527,7 @@
// start a pool of threads to exercise wstring thread safety
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -545,7 +545,7 @@
// start a pool of threads to exercise wstring thread safety
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.num.put.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.num.put.mt.cpp?rev=658807&r1=658806&r2=658807&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.num.put.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.num.put.mt.cpp Wed May 21 11:39:49 2008
@@ -401,7 +401,7 @@
// create and start a pool of threads and wait for them to finish
int result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -417,7 +417,7 @@
// start a pool of threads to exercise wstring thread safety
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -435,7 +435,7 @@
// start a pool of threads to exercise wstring thread safety
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.numpunct.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.numpunct.mt.cpp?rev=658807&r1=658806&r2=658807&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.numpunct.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.numpunct.mt.cpp Wed May 21 11:39:49 2008
@@ -267,7 +267,7 @@
// create and start a pool of threads and wait for them to finish
int result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -284,7 +284,7 @@
// of the wchar_t specialization
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -302,7 +302,7 @@
// start a pool of threads to exercise wstring thread safety
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.statics.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.statics.mt.cpp?rev=658807&r1=658806&r2=658807&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.statics.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.statics.mt.cpp Wed May 21 11:39:49 2008
@@ -131,7 +131,7 @@
// create and start a pool of threads and wait for them to finish
result = rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- test_classic, 0, opt_timeout);
+ test_classic, 0, std::size_t (opt_timeout));
}
if (rw_note (0 <= opt_global, 0, __LINE__,
@@ -167,7 +167,7 @@
// create and start a pool of threads and wait for them to finish
result = rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- test_global, 0, opt_timeout);
+ test_global, 0, std::size_t (opt_timeout));
}
return result;
Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.time.get.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.time.get.mt.cpp?rev=658807&r1=658806&r2=658807&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.time.get.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.time.get.mt.cpp Wed May 21 11:39:49 2008
@@ -460,7 +460,7 @@
// create and start a pool of threads and wait for them to finish
int result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -476,7 +476,7 @@
// start a pool of threads to exercise wstring thread safety
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -494,7 +494,7 @@
// start a pool of threads to exercise wstring thread safety
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.mt.cpp?rev=658807&r1=658806&r2=658807&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.mt.cpp Wed May 21 11:39:49 2008
@@ -338,7 +338,7 @@
// create and start a pool of threads and wait for them to finish
int result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -354,7 +354,7 @@
// start a pool of threads to exercise wstring thread safety
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
@@ -372,7 +372,7 @@
// start a pool of threads to exercise wstring thread safety
result =
rw_thread_pool (0, std::size_t (opt_nthreads), 0,
- thread_func, 0, opt_timeout);
+ thread_func, 0, std::size_t (opt_timeout));
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
RE: svn commit: r658807 - /stdcxx/branches/4.2.x/tests/localization/
Posted by Travis Vitek <Tr...@roguewave.com>.
Martin Sebor wrote:
>
>vitek@apache.org wrote:
>> Author: vitek
>> Date: Wed May 21 11:39:49 2008
>> New Revision: 658807
>>
>> URL: http://svn.apache.org/viewvc?rev=658807&view=rev
>> Log:
>> 2008-05-21 Travis Vitek <vi...@roguewave.com>
>>
>> * tests/localization/22.locale.moneypunct.mt.cpp: Cast timeout
>> to size_t to avoid conversion warnings.
>[...]
>> * tests/localization/22.locale.ctype.mt.cpp: Ditto.
>[...]
>> Modified:
>stdcxx/branches/4.2.x/tests/localization/22.locale.ctype.mt.cpp
>> URL:
>http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/locali
>zation/22.locale.ctype.mt.cpp?rev=658807&r1=658806&r2=658807&view=diff
>
>Is this your idea for how to quickly get failing tests to pass? ;-)
>
Oh wow. That's embarrassing. Reverted to previous revision and applied
appropriate change in r658839.
Re: svn commit: r658807 - /stdcxx/branches/4.2.x/tests/localization/
Posted by Martin Sebor <se...@roguewave.com>.
vitek@apache.org wrote:
> Author: vitek
> Date: Wed May 21 11:39:49 2008
> New Revision: 658807
>
> URL: http://svn.apache.org/viewvc?rev=658807&view=rev
> Log:
> 2008-05-21 Travis Vitek <vi...@roguewave.com>
>
> * tests/localization/22.locale.moneypunct.mt.cpp: Cast timeout
> to size_t to avoid conversion warnings.
[...]
> * tests/localization/22.locale.ctype.mt.cpp: Ditto.
[...]
> Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.ctype.mt.cpp
> URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.ctype.mt.cpp?rev=658807&r1=658806&r2=658807&view=diff
Is this your idea for how to quickly get failing tests to pass? ;-)
> ==============================================================================
> --- stdcxx/branches/4.2.x/tests/localization/22.locale.ctype.mt.cpp (original)
> +++ stdcxx/branches/4.2.x/tests/localization/22.locale.ctype.mt.cpp Wed May 21 11:39:49 2008
> @@ -1,346 +1,12 @@
> -/************************************************************************
> - *
> - * 22.locale.ctype.mt.cpp
> - *
> - * test exercising the thread safety of the ctype facet
> - *
> - * $Id$
> - *
> - ***************************************************************************
> - *
> - * Licensed to the Apache Software Foundation (ASF) under one or more
> - * contributor license agreements. See the NOTICE file distributed
> - * with this work for additional information regarding copyright
> - * ownership. The ASF licenses this file to you under the Apache
> - * License, Version 2.0 (the "License"); you may not use this file
> - * except in compliance with the License. You may obtain a copy of
> - * the License at
> - *
> - * http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing, software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> - * implied. See the License for the specific language governing
> - * permissions and limitations under the License.
> - *
> - **************************************************************************/
> -
> -#include <locale> // for locale, ctype
> -
> -#include <clocale> // for lconv, localeconv()
> -#include <cstdlib> // for mbstowcs()
> -#include <cstring> // for size_t, strcpy()
> -
> -#include <rw_locale.h>
> -#include <rw_thread.h>
> -#include <driver.h>
> -#include <valcmp.h>
> -
> -
> -// maximum number of threads allowed by the command line interface
> -#define MAX_THREADS 16
> -
> -// default number of threads (will be adjusted to the number
> -// of processors/cores later)
> -int opt_nthreads = 1;
> -
> -// the number of times each thread should iterate (unless specified
> -// otherwise on the command line)
> -int opt_nloops = 200000;
> -
> -#if !defined (_RWSTD_OS_HP_UX) || defined (_ILP32)
> -
> -// number of locales to use
> -int opt_nlocales = MAX_THREADS;
> -
> -#else // HP-UX in LP64 mode
> -
> -// work around an inefficiency (small cache size?) on HP-UX
> -// in LP64 mode (see STDCXX-812)
> -int opt_nlocales = 10;
> -
> -#endif // HP-UX 32/64 bit mode
> -
> -// should all threads share the same set of locale objects instead
> -// of creating their own?
> -int opt_shared_locale;
> -
> -// default timeout used by each threaded section of this test
> -int opt_timeout = 60;
> -
> -/**************************************************************************/
> -
> -// array of locale names to use for testing
> -static const char*
> -locales [MAX_THREADS];
> -
> -// number of locale names in the array
> -static std::size_t
> -nlocales;
> -
> -/**************************************************************************/
> -
> -struct CtypeData
> -{
> - // the name of the locale the data corresponds to
> - const char *locale_name_;
> -
> - // optionally set to the named locale for the threads to share
> - std::locale locale_;
> -
> - // results of ctype<charT>::widen(char) for char and wchar_t
> - char widened_ [256];
> - wchar_t wwidened_ [256];
> -
> - // array of wide characters to narrow and the number
> - // of valid elements in the array
> - wchar_t wide_ [1024];
> - std::size_t nwide_;
> -
> - // results of ctype<charT>::narrow(charT, char) for char
> - // and wchar_t values of wide_ [i]
> - char narrowed_ [256];
> - char wnarrowed_ [1024];
> -
> -} ctype_data [MAX_THREADS];
> -
> +#include <rw_alarm.h>
>
> extern "C" {
> + void alarm_test (int) { }
> +} // extern "C"
>
> -bool test_char; // exercise num_put<char>
> -bool test_wchar; // exercise num_put<wchar_t>
> -
> -
> -static void*
> -thread_func (void*)
> +int main ()
> {
> - // number of narrow characters to test (should be 256)
> - const std::size_t nchars =
> - sizeof ctype_data->widened_ / sizeof *ctype_data->widened_;
> -
> - for (int i = 0; i != opt_nloops; ++i) {
> -
> - if (rw_thread_pool_timeout_expired ())
> - break;
> -
> - const std::size_t inx = std::size_t (i) % nlocales;
> -
> - // save the name of the locale
> - const char* const locale_name = locales [inx];
> -
> - const CtypeData* const data = ctype_data + inx;
> -
> - // construct a named locale
> - const std::locale loc =
> - opt_shared_locale ? data->locale_ : std::locale (locale_name);
> -
> - // "random" index/character value
> - const std::size_t cinx = std::size_t (i) % nchars;
> -
> - if (test_char) {
> - // exercise the narrow char specialization of the facet
> -
> - const std::ctype<char> &ct =
> - std::use_facet<std::ctype<char> >(loc);
> -
> - const char wc = ct.widen (char (cinx));
> -
> - RW_ASSERT (wc == data->widened_ [cinx]);
> -
> - const char nc = ct.narrow (char (cinx), '\0');
> -
> - RW_ASSERT (nc == data->narrowed_ [cinx]);
> - }
> -
> - // both specializations may be tested at the same time
> -
> - if (test_wchar) {
> - // exercise the wide char specialization of the facet
> -
> -#ifndef _RWSTD_NO_WCHAR_T
> -
> - const std::ctype<wchar_t> &wct =
> - std::use_facet<std::ctype<wchar_t> >(loc);
> -
> - // "random" index into the wide character array
> - const std::size_t winx =
> - std::size_t (i) % data->nwide_;
> -
> - const wchar_t wc = wct.widen (char (cinx));
> -
> - RW_ASSERT (wc == data->wwidened_ [cinx]);
> -
> - const char nc = wct.narrow (data->wide_ [winx], L'\0');
> -
> - RW_ASSERT (nc == data->wnarrowed_ [winx]);
> -
> -#endif // _RWSTD_NO_WCHAR_T
> -
> - }
> - }
> + rw_alarm (10, alarm_test);
>
> return 0;
> }
> -
> -} // extern "C"
> -
> -/**************************************************************************/
> -
> -static int
> -run_test (int, char**)
> -{
> - // find all installed locales for which setlocale(LC_ALL) succeeds
> - const char* const locale_list =
> - rw_opt_locales ? rw_opt_locales : rw_locales (_RWSTD_LC_ALL);
> -
> - const std::size_t maxinx = sizeof locales / sizeof *locales;
> -
> - // iterate over locales, initializing a global ctype_data array
> - // with LC_CTYPE data obtained from each locale
> - for (const char *name = locale_list; *name;
> - name += std::strlen (name) + 1) {
> -
> - const std::size_t inx = nlocales;
> -
> - locales [inx] = name;
> -
> - CtypeData* const pdata = ctype_data + nlocales;
> -
> - // compute the number of wide characters to populate
> - const std::size_t nwide =
> - sizeof pdata->wide_ / sizeof pdata->wide_ [0];
> -
> - try {
> - const std::locale loc (name);
> -
> - const std::ctype<char> &ct =
> - std::use_facet<std::ctype<char> >(loc);
> -
> - const std::ctype<wchar_t> &wct =
> - std::use_facet<std::ctype<wchar_t> >(loc);
> -
> - pdata->locale_name_ = name;
> -
> - const std::size_t nchars =
> - sizeof pdata->widened_ / sizeof *pdata->widened_;
> -
> - for (std::size_t i = 0; i != nchars; ++i) {
> - pdata->widened_ [i] = ct.widen (char (i));
> - pdata->wwidened_ [i] = wct.widen (char (i));
> - pdata->narrowed_ [i] = ct.narrow (char (i), '\0');
> - }
> -
> - pdata->nwide_ = rw_get_wchars (pdata->wide_, nwide);
> - for (std::size_t i = 0; i != pdata->nwide_; ++i)
> - pdata->wnarrowed_ [i] = wct.narrow (pdata->wide_ [i], L'\0');
> -
> - if (opt_shared_locale)
> - pdata->locale_ = loc;
> -
> - ++nlocales;
> - }
> - catch (...) {
> - // skip over a bad locale
> - }
> -
> - if (nlocales == maxinx || nlocales == std::size_t (opt_nlocales))
> - break;
> - }
> -
> - // avoid divide by zero in thread if there are no locales to test
> - rw_fatal (nlocales != 0, 0, __LINE__,
> - "failed to create one or more usable locales!");
> -
> - rw_info (0, 0, 0,
> - "testing std::ctype<charT> with %d thread%{?}s%{;}, "
> - "%d iteration%{?}s%{;} each, in %zu locales { %{ .*A@} }",
> - opt_nthreads, 1 != opt_nthreads,
> - opt_nloops, 1 != opt_nloops,
> - nlocales, int (nlocales), "%#s", locales);
> -
> - rw_info (0, 0, 0, "exercising std::ctype<char>");
> -
> - test_char = true;
> - test_wchar = false;
> -
> - // create and start a pool of threads and wait for them to finish
> - int result =
> - rw_thread_pool (0, std::size_t (opt_nthreads), 0,
> - thread_func, 0, opt_timeout);
> -
> - rw_error (result == 0, 0, __LINE__,
> - "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
> - opt_nthreads, thread_func);
> -
> -#ifndef _RWSTD_NO_WCHAR_T
> -
> - rw_info (0, 0, 0, "exercising std::ctype<wchar_t>");
> -
> - test_char = false;
> - test_wchar = true;
> -
> - // start a pool of threads to exercise the thread safety
> - // of the wchar_t specialization
> - result =
> - rw_thread_pool (0, std::size_t (opt_nthreads), 0,
> - thread_func, 0, opt_timeout);
> -
> - rw_error (result == 0, 0, __LINE__,
> - "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
> - opt_nthreads, thread_func);
> -
> - // exercise both the char and the wchar_t specializations
> - // at the same time
> -
> - rw_info (0, 0, 0,
> - "exercising both std::ctype<char> and std::ctype<wchar_t>");
> -
> - test_char = true;
> - test_wchar = true;
> -
> - // start a pool of threads to exercise wstring thread safety
> - result =
> - rw_thread_pool (0, std::size_t (opt_nthreads), 0,
> - thread_func, 0, opt_timeout);
> -
> - rw_error (result == 0, 0, __LINE__,
> - "rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
> - opt_nthreads, thread_func);
> -
> -#endif // _RWSTD_NO_WCHAR_T
> -
> - return result;
> -}
> -
> -/**************************************************************************/
> -
> -int main (int argc, char *argv[])
> -{
> -#ifdef _RWSTD_REENTRANT
> -
> - // set nthreads to the greater of the number of processors
> - // and 2 (for uniprocessor systems) by default
> - opt_nthreads = rw_get_cpus ();
> - if (opt_nthreads < 2)
> - opt_nthreads = 2;
> -
> -#endif // _RWSTD_REENTRANT
> -
> - return rw_test (argc, argv, __FILE__,
> - "lib.locale.ctype",
> - "thread safety", run_test,
> - "|-soft-timeout#0 " // must be non-negative
> - "|-nloops#0 " // arg must be non-negative
> - "|-nthreads#0-* " // arg must be in [0, MAX_THREADS]
> - "|-nlocales#0 " // arg must be non-negative
> - "|-locales= " // arg must be provided
> - "|-shared-locale# ",
> - &opt_timeout,
> - &opt_nloops,
> - int (MAX_THREADS),
> - &opt_nthreads,
> - &opt_nlocales,
> - &rw_opt_setlocales,
> - &opt_shared_locale);
> -}