SignalTests.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
12 /*
13  * $Log$
14  *
15  */
16 
17 #ifndef Signal_cpp
18 #define Signal_cpp
19 
20 #include <cppunit/ui/text/TestRunner.h>
21 #include <cppunit/TextOutputter.h>
22 #include <cppunit/extensions/TestFactoryRegistry.h>
23 #include <cppunit/extensions/HelperMacros.h>
24 #include <cppunit/TestAssert.h>
25 
26 #include <coil/Signal.h>
27 
32 namespace Signal
33 {
34 static int Signum;
35 
37  : public CppUnit::TestFixture
38  {
44 
45  private:
46 
47  public:
48 
53  {
54  }
55 
60  {
61  }
62 
66  virtual void setUp()
67  {
68  }
69 
73  virtual void tearDown()
74  {
75  }
76 
77  /* test case */
82  {
84  delete sa;
85  }
86 
91  {
93  int signum(SIGINT);
94  coil::SignalAction * sa = new coil::SignalAction(handle, signum);
95 
96  delete sa;
97  }
98 
103 // void test_SignalAction_constructor_3()
104 // {
105 // coil::SignalHandler handle(0);
106 // int signum(0);
107 // sigset_t *mask(0);
108 // coil::SignalAction * sa = new coil::SignalAction(handle, signum, mask);
109 
110 // delete sa;
111 // }
112 
117  {
119  }
120 
125  {
126  coil::SignalAction * signalAction;
128 // int sn[] = {
129 // SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV, SIGPIPE, SIGALRM,
130 // SIGTERM,SIGUSR1, SIGUSR2, SIGCHLD, SIGCONT, SIGTSTP, SIGTTIN, SIGTTOU,
131 // 0
132 // };
133  int sn[] = { // posix, win common.
134  SIGINT, SIGILL, SIGABRT, SIGFPE, SIGSEGV,
135  0
136  };
137  int index;
138 
139  for (index = 0; sn[index]; index++) {
140  Signum = sn[index];
141 // signalAction = new coil::SignalAction(handle, Signum, mask);
142  signalAction = new coil::SignalAction(handle, Signum);
143  raise(Signum);
144  delete signalAction;
145  }
146  }
147 
148  /* Signal Handler */
152  static void signalHandler(int aSignum)
153  {
154 // std::cout << "Signum : " << Signum << std::endl << std::flush ;
155  CPPUNIT_ASSERT_EQUAL(Signum, aSignum);
156  }
157  };
158 }; // namespace Signal
159 
160 /*
161  * Register test suite
162  */
164 
165 #ifdef LOCAL_MAIN
166 int main(int argc, char* argv[])
167 {
168  CppUnit::TextUi::TestRunner runner;
169  runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
170  CppUnit::Outputter* outputter =
171  new CppUnit::TextOutputter(&runner.result(), std::cout);
172  runner.setOutputter(outputter);
173  bool retcode = runner.run();
174  return !retcode;
175 }
176 #endif // MAIN
177 
178 #if 0
179 __sighandler_t signal(int __sig, __sighandler_t __handler)
180 {
181  __sighandler_t st;
182  std::cout << "Hello, Signal" << std::endl;
183  return st;
184 }
185 #endif
186 
187 #endif // Signal_cpp
int main(int argc, char **argv)
void test_SignalAction_test()
Constractor with 3 paramater.
CPPUNIT_TEST(test_SignalAction_constructor_1)
void checkSignalAction()
Set SignalAction for Linux.
static void signalHandler(int aSignum)
OSから渡されたシグナル番号と、予定されていたシグナル番号を比較検証する。
void(* SignalHandler)(int)
static int Signum
Definition: SignalTests.cpp:34
list index
Definition: rtimages.py:10
virtual void tearDown()
Test finalization.
Definition: SignalTests.cpp:73
CPPUNIT_TEST_SUITE(SignalTests)
ACE_Sig_Action SignalAction
void test_SignalAction_constructor_2()
Constractor with 2 paramater.
Definition: SignalTests.cpp:90
virtual void setUp()
Test initialization.
Definition: SignalTests.cpp:66
SignalTests()
Constructor.
Definition: SignalTests.cpp:52
SignalAction class.
void test_SignalAction_constructor_1()
Constractor with no paramater.
Definition: SignalTests.cpp:81
~SignalTests()
Destructor.
Definition: SignalTests.cpp:59
CPPUNIT_TEST_SUITE_REGISTRATION(Signal::SignalTests)


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Jun 10 2019 14:07:56