summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorharris_s <harris_s@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-11-04 23:11:00 +0000
committerharris_s <harris_s@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2004-11-04 23:11:00 +0000
commit8cf6309c1ddb0ea3121b2eff75e72ead56d5ade0 (patch)
tree9fc9b6460b5860e760617707506ba58df0ba0eaf /tests
parent75045a05a6fb17bd701e7f8c86961d175945f3c0 (diff)
downloadATCD-8cf6309c1ddb0ea3121b2eff75e72ead56d5ade0.tar.gz
Thu Nov 4 17:06:08 CST 2004 Scott Harris <harris_s@ociweb.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Log_Msg_Test.cpp3
-rw-r--r--tests/Test_Output.cpp24
2 files changed, 21 insertions, 6 deletions
diff --git a/tests/Log_Msg_Test.cpp b/tests/Log_Msg_Test.cpp
index daff113d3b4..293e0354589 100644
--- a/tests/Log_Msg_Test.cpp
+++ b/tests/Log_Msg_Test.cpp
@@ -353,6 +353,7 @@ test_ostream (void)
if (myostream.bad ())
return -1;
+ OFSTREAM *old_stream = ace_file_stream::instance ()->output_file ();
// Set the ostream.
ACE_LOG_MSG->msg_ostream (&myostream);
@@ -360,7 +361,7 @@ test_ostream (void)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("fourth message\n")));
// Set the ostream back to the test's log file.
- ACE_LOG_MSG->msg_ostream (ace_file_stream::instance ()->output_file ());
+ ACE_LOG_MSG->msg_ostream (old_stream);
// Now close the ostream file and check its contents.
myostream.close ();
diff --git a/tests/Test_Output.cpp b/tests/Test_Output.cpp
index adb9e9e8e46..ed0e180faa8 100644
--- a/tests/Test_Output.cpp
+++ b/tests/Test_Output.cpp
@@ -48,6 +48,8 @@ ACE_Test_Output::ACE_Test_Output (void)
ACE_Test_Output::~ACE_Test_Output (void)
{
#if !defined (ACE_LACKS_IOSTREAM_TOTALLY) && !defined (ACE_PSOS)
+ ACE_OSTREAM_TYPE *log_msg_stream = ACE_LOG_MSG->msg_ostream ();
+
ACE_LOG_MSG->msg_ostream (&cerr);
#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY && ! ACE_PSOS */
@@ -55,14 +57,21 @@ ACE_Test_Output::~ACE_Test_Output (void)
ACE_LOG_MSG->set_flags (ACE_Log_Msg::STDERR);
#if !defined (ACE_LACKS_IOSTREAM_TOTALLY) && !defined (ACE_HAS_PHARLAP)
- delete this->output_file_;
+ if (this->output_file_ == log_msg_stream)
+ delete this->output_file_;
+ // else something else changed the stream and hence should
+ // have closed and deleted the output_file_
#endif /* ! ACE_LACKS_IOSTREAM_TOTALLY */
}
OFSTREAM *
ACE_Test_Output::output_file (void)
{
- return this->output_file_;
+ // the output_file_ is given to ACE_LOG_MSG
+ // and something else might destroy and/or change the stream
+ // so return what ACE_LOG_MSG is using.
+ return dynamic_cast<OFSTREAM*>( ACE_LOG_MSG->msg_ostream () );
+ //return this->output_file_;
}
int
@@ -146,7 +155,7 @@ ACE_Test_Output::set_output (const ACE_TCHAR *filename, int append)
this->output_file_ = ACE_OS::fopen (temp, fmode);
# endif /* ACE_LACKS_IOSTREAM_TOTALLY */
- ACE_LOG_MSG->msg_ostream (this->output_file ());
+ ACE_LOG_MSG->msg_ostream (this->output_file_);
#endif /* ACE_HAS_PHARLAP */
ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR | ACE_Log_Msg::LOGGER );
@@ -159,8 +168,13 @@ void
ACE_Test_Output::close (void)
{
#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
- this->output_file_->flush ();
- this->output_file_->close ();
+ if (this->output_file_ == ACE_LOG_MSG->msg_ostream () )
+ {
+ this->output_file_->flush ();
+ this->output_file_->close ();
+ }
+ // else something else changed the stream and hence should
+ // have closed and deleted the output_file_
#else
ACE_OS::fflush (this->output_file_);
ACE_OS::fclose (this->output_file_);