RE: CppUnit and multi-threading

"Tzanev, Stefan" <[email protected]> Thu, 17 Jul 2003 17:01:27 -0400
Newsgroups gmane.comp.lib.cppunit.devel
Message-ID <B6F519F39C78D511BA690008C724640A0510957D@mrms1.murry.us.respironics.com>
This is a multi-part message in MIME format.

------_=_NextPart_001_01C34CA6.96A98500
Content-Type: text/plain;
	charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

Hi Baptiste,
Thank you for the prompt response.
I was trying to do (2) - a test suite with two threads. I'm work on a
socket application which acts both as a server and as a client. For this
purpose the test harness has to have a primary thread (from which the
client calls, like connect, send, recv and disconnect are made) and a
secondary thread for the listener (for calls like bind, listen, accept,
send and recv). I was hoping that I should be able to have only one
TestRunner and that CppUnit would handle under the hood the exceptions
that were thrown (via CPPUNIT_ASSERT and the like) from the secondary
thread. As this is not the case and because I am lazy enough not to rush
into creating a special mechanism for exception propagation between the
threads I used the following workaround:
I use named registries and a separate TestRunner for each thread. It
works fine. The only disadvantage is that two sets of results are
reported. But that's not a big deal.
Thanks again.
Regards,
Stefan
=20
-----Original Message-----
From: Baptiste Lepilleur [mailto:[email protected]]=20
Sent: Thursday, July 17, 2003 4:53 PM
To: Tzanev, Stefan; [email protected]
Subject: Re: [Cppunit-devel] CppUnit and multi-threading


TestFactoryRegistry is not thread-safe, but you can easily wrap it to
make it so.
=20
CppUnit is thread-safe, which the exception of the TypeInfoHelper which
use a static variable (but it should be initialized at when registering
the test factory, so it is probably ok).
=20
What exactly are you trying to multithread ?=20
1) running multiple test case at the same time, using multiple test
result ?
2) a test case which multiple thread ?
3) ???
=20
Baptiste.

----- Original Message -----=20
From: Tzanev, Stefan <mailto:[email protected]>=20=20
To: [email protected]=20
Sent: Tuesday, July 15, 2003 9:31 PM
Subject: [Cppunit-devel] CppUnit and multi-threading

Dear Sirs,
I'm using CppUnit for a first time and I have problems testing a
multithreaded system.
Should I create a separate TestFixture (suite) for each thread or is
there a=20
different approach? That is, does CppUnit support multi-threading?
Is it possible to use TestFactoryRegistry in a multi-threaded
environment?
Thank you.
Sincerely,
=20

Stefan Tzanev

Software Engineer

Software Applications Group

Respironics, Inc.
Phone: 724-387-4860
=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
CONFIDENTIALITY NOTICE ---------------------- This message, together
with any attachments, may be legally privileged and is confidential
information intended only for the use of the individual or entity to
which it is addressed. It is exempt from disclosure under applicable law
including court orders. If you are not the intended recipient, you are
hereby notified that any use, dissemination, distribution or copy of
this message, or any attachment, is strictly prohibited. If you have
received this message in error, please notify the original sender and
delete this message, along with any attachments, from your computer.=20


=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
CONFIDENTIALITY NOTICE
----------------------
This message, together with any attachments, may be legally privileged
and is confidential information intended only for the use of the
individual or entity to which it is addressed.  It is exempt from
disclosure under applicable law including court orders.  If you are not
the intended recipient, you are hereby notified that any use,
dissemination, distribution or copy of this message, or any attachment,
is strictly prohibited.  If you have received this message in error,
please notify the original sender and delete this message, along with
any attachments, from your computer.


------_=_NextPart_001_01C34CA6.96A98500
Content-Type: text/html;
	charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns:o =3D=20
"urn:schemas-microsoft-com:office:office"><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=3Dus-ascii">
<TITLE>Message</TITLE>

<META content=3D"MSHTML 6.00.2800.1170" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><SPAN class=3D500165220-17072003><FONT face=3D"Courier New" color=3D#0=
000ff=20
size=3D2>Hi Baptiste,</FONT></SPAN></DIV>
<DIV><SPAN class=3D500165220-17072003><FONT face=3D"Courier New" color=3D#0=
000ff=20
size=3D2>Thank you for the prompt response.</FONT></SPAN></DIV>
<DIV><SPAN class=3D500165220-17072003><FONT face=3D"Courier New" color=3D#0=
000ff=20
size=3D2>I was trying to&nbsp;do (2) - a test suite with two threads. I'm w=
ork on=20
a socket application which acts both as a server and as a client. For this=
=20
purpose the test harness has to have a primary thread (from which the clien=
t=20
calls, like connect, send, recv and disconnect are made) and a secondary th=
read=20
for the listener (for calls like bind, listen, accept, send and recv). I wa=
s=20
hoping that I should be able to have only one TestRunner and that CppUnit w=
ould=20
handle under the hood the exceptions that were thrown (via CPPUNIT_ASSERT a=
nd=20
the like) from the secondary thread. As this is not the case and because I =
am=20
lazy enough not to rush into creating a special mechanism for exception=20
propagation between the threads I used the following=20
workaround:</FONT></SPAN></DIV>
<DIV><SPAN class=3D500165220-17072003><FONT face=3D"Courier New" color=3D#0=
000ff=20
size=3D2>I use named registries and a separate TestRunner for each thread. =
It=20
works fine. The only disadvantage is that two sets of results are reported.=
 But=20
that's not a big deal.</FONT></SPAN></DIV>
<DIV><SPAN class=3D500165220-17072003><FONT face=3D"Courier New" color=3D#0=
000ff=20
size=3D2>Thanks again.</FONT></SPAN></DIV>
<DIV><SPAN class=3D500165220-17072003><FONT face=3D"Courier New" color=3D#0=
000ff=20
size=3D2>Regards,</FONT></SPAN></DIV>
<DIV><SPAN class=3D500165220-17072003><FONT face=3D"Courier New" color=3D#0=
000ff=20
size=3D2>Stefan</FONT></SPAN></DIV>
<DIV><SPAN class=3D500165220-17072003><FONT face=3D"Courier New" color=3D#0=
000ff=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV></DIV>
<DIV class=3DOutlookMessageHeader lang=3Den-us dir=3Dltr align=3Dleft><FONT=
 face=3DTahoma=20
size=3D2>-----Original Message-----<BR><B>From:</B> Baptiste Lepilleur=20
[mailto:[email protected]] <BR><B>Sent:</B> Thursday, July 17, 2003 4:53=20
PM<BR><B>To:</B> Tzanev, Stefan;=20
[email protected]<BR><B>Subject:</B> Re: [Cppunit-devel]=
=20
CppUnit and multi-threading<BR><BR></FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>TestFactoryRegistry is not thread-=
safe, but=20
you can easily wrap it to make it so.</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>CppUnit is thread-safe, which the =
exception=20
of the TypeInfoHelper which use a static variable (but it should be initial=
ized=20
at when&nbsp;registering the test factory, so it is probably ok).</FONT></D=
IV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>What exactly are you trying to mul=
tithread=20
? </FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>1) running multiple test case at t=
he same=20
time, using multiple test result ?</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>2) a test case which multiple thre=
ad=20
?</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>3) ???</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Baptiste.</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LE=
FT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>Fro=
m:</B>=20
  <A [email protected]=20
  href=3D"mailto:[email protected]">Tzanev, Stefan</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A=20
  title=3Dcppunit-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org=20
  href=3D"mailto:[email protected]">[email protected]=
ourceforge.net</A>=20
  </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Tuesday, July 15, 2003 9:31=
=20
PM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> [Cppunit-devel] CppUnit a=
nd=20
  multi-threading</DIV>
  <DIV><BR></DIV>
  <DIV><FONT face=3D"Courier New" size=3D2><SPAN class=3D571352116-15072003=
>Dear=20
  Sirs,</SPAN></FONT></DIV>
  <DIV><FONT face=3D"Courier New" size=3D2><SPAN class=3D571352116-15072003=
>I'm using=20
  CppUnit for a first time and I have problems testing a multithreaded=20
  system.</SPAN></FONT></DIV>
  <DIV><FONT face=3D"Courier New" size=3D2><SPAN class=3D571352116-15072003=
>Should I=20
  create a separate TestFixture (suite) for each thread or is there a=20
  </SPAN></FONT></DIV>
  <DIV><FONT face=3D"Courier New" size=3D2><SPAN class=3D571352116-15072003=
>different=20
  approach? That is, does CppUnit support multi-threading?</SPAN></FONT></D=
IV>
  <DIV><FONT face=3D"Courier New" size=3D2><SPAN class=3D571352116-15072003=
>Is it=20
  possible to use TestFactoryRegistry in a multi-threaded=20
  environment?</SPAN></FONT></DIV>
  <DIV><FONT face=3D"Courier New" size=3D2><SPAN class=3D571352116-15072003=
>Thank=20
  you.</SPAN></FONT></DIV>
  <DIV><SPAN class=3D571352116-15072003><FONT face=3D"Courier New"=20
  size=3D2>Sincerely,</FONT></SPAN></DIV>
  <DIV><SPAN class=3D571352116-15072003><FONT face=3D"Courier New"=20
  size=3D2></FONT></SPAN>&nbsp;</DIV>
  <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt" align=3Dleft><B=20
  style=3D"mso-bidi-font-weight: normal"><I=20
  style=3D"mso-bidi-font-style: normal"><SPAN=20
  style=3D"FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no=
-proof: yes">Stefan=20
  Tzanev<o:p></o:p></SPAN></I></B></P>
  <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt" align=3Dleft><I=20
  style=3D"mso-bidi-font-style: normal"><SPAN=20
  style=3D"FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no=
-proof: yes">Software=20
  Engineer<o:p></o:p></SPAN></I></P>
  <P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt" align=3Dleft><I=20
  style=3D"mso-bidi-font-style: normal"><SPAN=20
  style=3D"FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no=
-proof: yes">Software=20
  Applications Group<o:p></o:p></SPAN></I></P>
  <DIV align=3Dleft><I style=3D"mso-bidi-font-style: normal"><SPAN=20
  style=3D"FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no=
-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language:=
 EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">Respironics,=
=20
  Inc.</SPAN></I></DIV>
  <DIV align=3Dleft><I style=3D"mso-bidi-font-style: normal"><SPAN=20
  style=3D"FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no=
-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-ansi-language:=
 EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">Phone:=20
  724-387-4860</SPAN></I></DIV>
  <DIV>&nbsp;</DIV>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=20
  CONFIDENTIALITY NOTICE ---------------------- This message, together with=
 any=20
  attachments, may be legally privileged and is confidential information=20
  intended only for the use of the individual or entity to which it is=20
  addressed. It is exempt from disclosure under applicable law including co=
urt=20
  orders. If you are not the intended recipient, you are hereby notified th=
at=20
  any use, dissemination, distribution or copy of this message, or any=20
  attachment, is strictly prohibited. If you have received this message in=
=20
  error, please notify the original sender and delete this message, along w=
ith=20
  any attachments, from your computer. </BLOCKQUOTE></BODY></HTML>

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
CONFIDENTIALITY NOTICE
----------------------
This message, together with any attachments, may be legally privileged
and is confidential information intended only for the use of the
individual or entity to which it is addressed.  It is exempt from
disclosure under applicable law including court orders.  If you are not
the intended recipient, you are hereby notified that any use,
dissemination, distribution or copy of this message, or any attachment,
is strictly prohibited.  If you have received this message in error,
please notify the original sender and delete this message, along with
any attachments, from your computer.


------_=_NextPart_001_01C34CA6.96A98500--


-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0