PATCH: Add threaded tests

Loren James Rittle rittle@latour.rsch.comm.mot.com
Thu Jan 24 01:31:00 GMT 2002


>> Using the standard dg- keywords, I have figured out a way to let
>> us test the pthread tests on selected platforms with the correct
>> per-port flags required.  Shall I just install them? ;-)

> Yes, that sounds good.

OK, six new test cases checked in.

> Did you test the single-thread model?

Yes, I checked that a machine configured to use the single-thread
model would effectively skip the tests.  Also, since the tests
actually have to start threads, we can't use the pure abstraction
layer.  Thus, as people want threads tested on their pet ports, they
will have to update two lines (if they are POSIX; otherwise perhaps
more).  Here are the lucky targets that I knew how to handle properly:
*-*-freebsd* *-*-linux* *-*-solaris*

> Can you check in the patch for 5432 with a test?

thread/pthread3.cc covers the test case from libstdc++/5432.  However,
I just noticed that it only has a tendency to crash mainline gcc when
it is compiled with -O2 (the test case ran -O0 on my sparc machine but
this was in a rebuilt libstd++-v3 not a fresh bootstrap - and that
does make a difference, no?).

I took responsibility to wack the patch for 5432 in shape and install
it later today as I was just heading out for the night.

OK, here is the exact form of threaded tests that I just installed:

// 2002-01-23  Loren J. Rittle <rittle@labs.mot.com> <ljrittle@acm.org>
// Adapted from [where and who it came from]
//
// [Standard FSF disclaimer text.]

// { dg-do run { target *-*-freebsd* *-*-linux* *-*-solaris* } }
// { dg-options "-pthread" { target *-*-freebsd* *-*-linux* } }
// { dg-options "-pthreads" { target *-*-solaris* } }

[...standard includes for test case and additional comments...]

// Do not include <pthread.h> explicitly; if threads are properly
// configured for the port, then it is picked up free from STL headers.

#if __GTHREADS
[...the bulk of the code for the test case...]
#else
int main (void) {}
#endif

// End of threaded test case template

The only other thing of note is a conditionalized
pthread_setconcurrency() call near the start of main() in each case
since Solaris requires it to avoid deadlocking some test cases (and in
order to display a failure on a test case derived from libstdc++/5347)
and not all pthread implementations are required to support it or
honor it.

Tested with `make check' in libstdc++-v3 on i386-unknown-freebsd4.4,
MP sparc-sun-solaris2.7 and alphaev67-dec-osf5.1 (final target to
ensure new cases were skipped).

Finally, I did tune the parameters so that no one test would take more
than a minute or two (of course, near zero for targets not on the list
or without threads enabled).  But, of course, we are trying to "prove
a negative" with this type of test so no amount of time will ever be
perfect.

Regards,
Loren

	* testsuite/thread/pthread1.cc: New test.
	* testsuite/thread/pthread2.cc: New test adapted from libstdc++/5347.
	* testsuite/thread/pthread3.cc: Likewise.
	* testsuite/thread/pthread4.cc: New test adapted from
	http://gcc.gnu.org/ml/gcc-bugs/2002-01/msg00679.html
	* testsuite/thread/pthread5.cc: New test adapted from libstdc++/5464.
	* testsuite/thread/pthread6.cc: New test adapted from libstdc++/5444.

(See new files in archive.)



More information about the Gcc-patches mailing list