Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Crashed_Callback / Service.cpp
blob697eddf636eb1cda31d2812e5a23b80576525435
1 #include "Service.h"
3 Service::Service (void)
4 : orb_ (CORBA::ORB::_nil ()),
5 test_count_ (0)
9 void
10 Service::dump_results (void)
12 if (this->test_count_ == 0)
14 ACE_DEBUG ((LM_DEBUG,
15 "ERROR: no tests were completed!\n"));
19 void
20 Service::run_test (Test::Crashed_Callback_ptr callback)
22 int pre_crash_exceptions =
23 this->call_are_you_there (callback);
25 pre_crash_exceptions +=
26 this->call_test_oneway (callback);
28 try
30 ACE_DEBUG ((LM_DEBUG,
31 "(%P|%t) - Service, calling crash_now_please\n"));
32 callback->crash_now_please ();
34 catch (const CORBA::Exception&){}
36 int pos_crash_exceptions =
37 this->call_test_oneway (callback);
39 if (pre_crash_exceptions != 0)
41 ACE_ERROR ((LM_ERROR,
42 "ERROR: There were %d exceptions before crash\n"));
45 if (pos_crash_exceptions == 0)
47 ACE_ERROR ((LM_ERROR,
48 "ERROR: There were no exceptions after crash\n"));
50 else
52 ACE_DEBUG ((LM_DEBUG,
53 "Good!! %d exceptions raised after crash\n",
54 pos_crash_exceptions));
55 orb_->shutdown (false);
58 /// Increment the number of tests completed
59 this->test_count_++;
62 int
63 Service::call_are_you_there (Test::Crashed_Callback_ptr callback)
65 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Service, calling are_you_there\n"));
66 const int iterations = 50;
68 int exception_count = 0;
69 for (int i = 0; i != iterations; ++i)
71 try
73 (void) callback->are_you_there ();
75 catch (const CORBA::Exception&)
77 exception_count++;
80 return exception_count;
83 int
84 Service::call_test_oneway (Test::Crashed_Callback_ptr callback)
86 ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Service, calling test_oneway\n"));
87 const int iterations = 50;
89 int exception_count = 0;
90 for (int i = 0; i != iterations; ++i)
92 try
94 (void) callback->test_oneway ();
96 catch (const CORBA::Exception&)
98 exception_count++;
101 return exception_count;