gcc/libstdc++-v3/testsuite
Paolo Carlini aa53f832ac localefwd.h (class locale): Add static member _S_num_extra_categories...
2002-10-08  Paolo Carlini  <pcarlini@unitus.it>
	    Benjamin Kosnik  <bkoz@redhat.com>

	* include/bits/localefwd.h (class locale): Add static member
	_S_num_extra_categories, encoding the number of additional
	categories.
	Change _S_num_categories to _S_categories_size.
	(class locale::_Impl): Add _M_c_cats.
	(class locale::_Impl::_M_names): Change to array of chars.
	(class locale::_Impl::_M_check_same_name): Use
	_S_extra_categories_size, tweak.
	(locale::locale(const locale&, _Facet*)): Ditto.
    	* src/locale.cc (locale::locale(const char* )): Rewrite to deal
	with the environment in a POSIX-compliant way while being thread
	safe.
	(locale::name()): Update to output POSIX environment strings.
	* src/localename.cc
	(locale::_Impl::_Impl(const _Impl&, size_t): Use
	_S_categories_size_*, tweak.
	(locale::_Impl::_Impl(facet**, size_t, bool)): Ditto.
	(locale::_Impl::_Impl(const char*, size_t)): Name each category
	individually.
	(locale::_Impl::_M_replace_categories): Use strcpy.

	* include/bits/locale_facets.h (numpunct::_M_initialize_numpunct):
	Change default argument to NULL from _S_c_locale.
	(timepunct::_M_initialize_timepunct): Same.
	_S_c_locale cleanups.
	* src/codecvt.c: _S_c_locale simplification.
	* src/ctype.c: Same.
	* src/globals.cc: Add fake_name.
	* src/locale-inst.cc: Remove extra includes.
	* src/locale.cc: Remove extra includes.
	Add _S_extra_categories_size definition.
	Correct "C" initialization.
	(locale::facet::facet): Don't initialize _S_c_locale.
	(locale::facet::_M_remove_reference): Adjust.
	* src/localename: Use facet_vec, facet_name.
	(locale::_Impl::_Impl(facet** __f, size_t __refs, bool)): Set
	facet ref counts to one. Initialize _S_c_locale.
	(locale::_Impl::_M_install_facet(id*, facet*)): Adjust facet ref
	counts when installing unilaterally.

	* config/locale/generic/c_locale.cc: Add _S_categories definition.
	* config/locale/generic/c_locale.h: Add _GLIBCPP_NUM_CATEGORIES macro.
	* config/locale/generic/time_members.cc: _S_c_locale cleanup.

	* config/locale/gnu/c_locale.cc: Add _S_categories definition.
	(_S_destroy_c_locale): Move checks against _S_c_locale here.
	* config/locale/gnu/c_locale.h: Add _GLIBCPP_NUM_CATEGORIES macro.
	* config/locale/gnu/ctype_members.cc: Simplify _S_destroy_c_locale
	calls, _S_c_locale usage.
	* config/locale/gnu/monetary_members.cc: Same, tweaks.
	* config/locale/gnu/monetary_members.cc: Same.
	* config/locale/gnu/time_members.cc: Same.
	* config/os/gnu-linux/ctype_noninline.h: Use locale::classic().

	* docs/html/22_locale/locale.html: Add bits about global locales
	and "C" setlocale.

	* testsuite/22_locale/facet.cc (test02): Add.
	* testsuite/22_locale/static_members.cc (test02): Add.
	* testsuite/22_locale/ctor_copy_dtor.cc (test04): Add.

Co-Authored-By: Benjamin Kosnik <bkoz@redhat.com>

From-SVN: r57964
2002-10-08 23:32:23 +00:00
..
17_intro c_compatibility: New. 2002-06-21 20:21:03 +00:00
18_support numeric_limits.cc: Check the maximum and minimum values of the wchar_t type. 2002-09-25 19:37:04 +00:00
19_diagnostics Revert PR libstdc++/6594 2002-08-02 16:04:16 +00:00
20_util std_memory.h: Fix formatting. 2002-07-04 07:25:19 +00:00
21_strings char_traits.h: Remove generic definitions. 2002-07-31 02:47:36 +00:00
22_locale localefwd.h (class locale): Add static member _S_num_extra_categories... 2002-10-08 23:32:23 +00:00
23_containers re PR libstdc++/7186 (DR179 for std::deque::iterator and const_iterator) 2002-07-07 10:15:06 +00:00
24_iterators re PR libstdc++/6642 (Constness prevents substraction of iterators) 2002-07-02 18:42:58 +00:00
25_algorithms acinclude.m4 (GLIBCPP_CONFIGURE_TESTSUITE): New macro, calls... 2001-08-07 03:38:33 +00:00
26_numerics valarray_name_lookup.cc: Rename from testsuite/26_numerics/valarray_name_lookup.C 2002-08-03 19:56:17 +00:00
27_io istream.tcc (basic_istream::ignore): Use sbumpc, not snextc. 2002-08-09 06:00:46 +00:00
backward Revert PR libstdc++/6594 2002-08-02 16:04:16 +00:00
config *.cc: Remove spaces, make sure testcases return zero. 2001-05-12 16:53:08 +00:00
ext re PR libstdc++/7057 (Operator== on hashtables doesn't appear to work correctly (patch included)) 2002-07-04 00:28:03 +00:00
lib libstdc++-v3-dg.exp (libstdc++-v3_target_compile): Search correct multilib testsuite dir for libv3test. 2002-06-04 18:44:35 +00:00
libstdc++-v3.dg libstdc++-v3-dg.exp (libstdc++-v3-list-sourcefiles): New function. 2002-03-11 21:11:07 +00:00
thread reported by Peter Schmid <schmid@snake.iap.physik.tu-darmstadt.de> 2002-03-13 02:53:27 +00:00
abi_check.cc abi_check.cc: Pull shell fragments out into... 2002-09-16 18:58:48 +00:00
Makefile.am Makefile.am: Use LD_RUN_PATH when linking abi_check. 2002-09-01 18:09:18 +00:00
Makefile.in Makefile.am (target_headers): Remove cpu_limits.h. 2002-09-26 05:25:14 +00:00
printnow.c
README std_memory.h: Fix formatting. 2002-07-04 07:25:19 +00:00
testsuite_hooks.cc acinclude.m4 (GLIBCPP_CHECK_SETRLIMIT_ancilliary): Reorder and include all required headers for test against older POSIX standard. 2002-06-10 20:52:12 +00:00
testsuite_hooks.h Revert PR libstdc++/6594 2002-08-02 16:04:16 +00:00

We're in the process of converting the existing testsuite machinery to
use the new style DejaGnu framework.  Eventually, we'll abandon
../mkcheck.in in favor of this new testsuite framework.

// 1: Thoughts on naming test cases, and structuring them.
The testsuite directory has been divided into 11 directories, directly
correlated to the relevant chapters in the standard. For example, the
directory testsuite/21_strings contains tests related to "Chapter 21,
Strings library" in the C++ standard.

So, the first step in making a new test case is to choose the correct
directory. The second item is seeing if a test file exists that tests
the item in question. Generally, within chapters test files are named
after the section headings in ISO 14882, the C++ standard. For instance, 

21.3.7.9 Inserters and Extractors

Has a related test case:
21_strings/inserters_extractors.cc

Not so hard. Some time, the words "ctor" and "dtor" are used instead
of "construct", "constructor", "cons", "destructor", etc. Other than
that, the naming seems mostly consistent. If the file exists, add a
test to it. If it does not, then create a new file. All files are
copyright the FSF, and GPL'd: this is very important. 

In addition, some of the locale and io code tests different
instantiating types: thus, 'char' or 'wchar_t' is appended to the name
as constructed above.

Also, some test files are negative tests. That is, they are supposed
to fail (usually this involves making sure some kind of construct gets
an error when it's compiled.) These test files have 'neg' appended to
the name as constructed above.

Inside a test file, the plan is to test the relevant parts of the
standard, and then add specific regressions as additional test
functions, ie test04() can represent a specific regression noted in
GNATS. Once test files get unwieldy or too big, then they should be
broken up into multiple sub-categories, hopefully intelligently named
after the relevant (and more specific) part of the standard.


// 2: How to write a test case, from a dejagnu perspective
As per the dejagnu instructions, always return 0 from main to indicate
success.

Basically, a test case contains dg-keywords (see dg.exp) indicating
what to do and what kinds of behaviour are to be expected.  New
testcases should be written with the new style DejaGnu framework in
mind.

To ease transition, here is the list of dg-keyword documentation
lifted from dg.exp -- eventually we should improve DejaGnu
documentation, but getting checkin account currently demands Pyrrhic
effort. 

# The currently supported options are:
#
# dg-prms-id N
#	set prms_id to N
#
# dg-options "options ..." [{ target selector }]
#	specify special options to pass to the tool (eg: compiler)
#
# dg-do do-what-keyword [{ target/xfail selector }]
#	`do-what-keyword' is tool specific and is passed unchanged to
#	${tool}-dg-test.  An example is gcc where `keyword' can be any of:
#	preprocess|compile|assemble|link|run
#	and will do one of: produce a .i, produce a .s, produce a .o,
#	produce an a.out, or produce an a.out and run it (the default is
#	compile).
#
# dg-error regexp comment [{ target/xfail selector } [{.|0|linenum}]]
#	indicate an error message <regexp> is expected on this line
#	(the test fails if it doesn't occur)
#	Linenum=0 for general tool messages (eg: -V arg missing).
#	"." means the current line.
#
# dg-warning regexp comment [{ target/xfail selector } [{.|0|linenum}]]
#	indicate a warning message <regexp> is expected on this line
#	(the test fails if it doesn't occur)
#
# dg-bogus regexp comment [{ target/xfail selector } [{.|0|linenum}]]
#	indicate a bogus error message <regexp> use to occur here
#	(the test fails if it does occur)
#
# dg-build regexp comment [{ target/xfail selector }]
#	indicate the build use to fail for some reason
#	(errors covered here include bad assembler generated, tool crashes,
#	and link failures)
#	(the test fails if it does occur)
#
# dg-excess-errors comment [{ target/xfail selector }]
#	indicate excess errors are expected (any line)
#	(this should only be used sparingly and temporarily)
#
# dg-output regexp [{ target selector }]
#	indicate the expected output of the program is <regexp>
#	(there may be multiple occurrences of this, they are concatenated)
#
# dg-final { tcl code }
#	add some tcl code to be run at the end
#	(there may be multiple occurrences of this, they are concatenated)
#	(unbalanced braces must be \-escaped)
#
# "{ target selector }" is a list of expressions that determine whether the
# test succeeds or fails for a particular target, or in some cases whether the
# option applies for a particular target.  If the case of `dg-do' it specifies
# whether the testcase is even attempted on the specified target.
#
# The target selector is always optional.  The format is one of:
#
# { xfail *-*-* ... } - the test is expected to fail for the given targets
# { target *-*-* ... } - the option only applies to the given targets
#
# At least one target must be specified, use *-*-* for "all targets".
# At present it is not possible to specify both `xfail' and `target'.
# "native" may be used in place of "*-*-*".

Example 1: Testing compilation only
(to just have a testcase do compile testing, without linking and executing)
// { dg-do compile }

Example 2: Testing for expected warings on line 36
// { dg-warning "string literals" "" { xfail *-*-* } 36

Example 3: Testing for compilation errors on line 41
// { dg-do compile }
// { dg-error "no match for" "" { xfail *-*-* } 41 }

More examples can be found in the libstdc++-v3/testsuite/*/*.cc files.


// 3: Test harness notes, invocation, and debugging.
Configuring the dejagnu harness to work with libstdc++-v3 in a cross
compilation environment has been maddening. However, it does work now,
and on a variety of platforms. Including solaris, linux, and cygwin.

To debug the test harness during runs, try invoking with

make check-target-libstdc++-v3 RUNTESTFLAGS="-v"
or
make check-target-libstdc++-v3 RUNTESTFLAGS="-v -v"

There are two ways to run on a simulator: set up DEJAGNU to point to a
specially crafted site.exp, or pass down --target_board flags.

Example flags to pass down for various embedded builds are as follows:

--target=powerpc-eabism (libgloss/sim)
make check-target-libstdc++-v3 RUNTESTFLAGS="--target_board=powerpc-sim"

--target=calmrisc32 (libgloss/sid)
make check-target-libstdc++-v3 RUNTESTFLAGS="--target_board=calmrisc32-sid"

--target=xscale-elf (newlib/sim)
make check-target-libstdc++-v3 RUNTESTFLAGS="--target_board=arm-sim"


// 4: Future plans, to be done
Shared runs need to be implemented, for targets that support shared libraries.

Diffing of expected output to standard streams needs to be finished off.

The V3 testing framework supports, or will eventually support,
additional keywords for the purpose of easing the job of writing
testcases.  All V3-keywords are of the form @xxx@.  Currently plans
for supported keywords include:

  @require@ <files>
      The existence of <files> is essential for the test to complete
      successfully.  For example, a testcase foo.C using bar.baz as
      input file could say
	    // @require@ bar.baz
      The special variable % stands for the rootname, e.g. the
      file-name without its `.C' extension.  Example of use (taken
      verbatim from 27_io/filebuf.cc)
	   // @require@ %-*.tst %-*.txt

  @diff@ <first-list> <second-list>
      After the testcase compiles and ran successfully, diff
      <first-list> against <second-list>, these lists should have the
      same length.  The test fails if diff returns non-zero a pair of
      files.

Current testing problems with cygwin-hosted tools:

There are two known problems which I have not addressed.  The first is
that when testing cygwin hosted tools from the unix build dir, it does
the wrong thing building the wrapper program (testglue.c) because host
and target are the same in site.exp (host and target are the same from
the perspective of the target libraries)

Problem number two is a little more annoying.  In order for me to make
v3 testing work on Windows, I had to tell dejagnu to copy over the
debug_assert.h file to the remote host and then set the includes to
-I./.  This is how all the other tests like this are done so I didn't
think much of it.  However, this had some unfortunate results due to
gcc having a testcase called "limits" and C++ having an include file
called "limits".  The gcc "limits" binary was in the temporary dir
when the v3 tests were being built.  As a result, the gcc "limits"
binary was being #included rather than the intended one.  The only way
to fix this is to go through the testsuites and make sure binaries are
deleted on the remote host when testing is done with them.  That is a
lot more work than I want to do so I worked around it by cleaning out
D:\kermit on compsognathus and rerunning tests.