19 sys.path.insert(1,
"../")
24 from PeriodicTask
import *
25 from TimeMeasure
import *
38 for i
in range(len(self.
m_log)):
39 if self.
m_log[i] == msg:
90 self.assert_(self.
_pt.setTask(self.
_my.mysvc2))
91 self.assertEqual(0, self.
_logger.countLog(
"mysvc2"))
96 self.assert_(1 < self.
_logger.countLog(
"mysvc2"))
106 self.
_pt.setTask(self.
_my.mysvc2)
107 self.
_pt.setPeriod(0.05)
108 self.assertEqual(0, self.
_logger.countLog(
"mysvc2"))
114 self.assert_(4 > self.
_logger.countLog(
"mysvc2"))
115 self.assert_(0 < self.
_logger.countLog(
"mysvc2"))
118 self.
_pt.setPeriod(0.01)
119 self.assertEqual(0, self.
_logger.countLog(
"mysvc2"))
125 self.assert_(12 > self.
_logger.countLog(
"mysvc2"))
126 self.assert_( 8 < self.
_logger.countLog(
"mysvc2"))
129 self.
_pt.setPeriod(0.05)
130 self.assertEqual(0, self.
_logger.countLog(
"mysvc2"))
136 self.assert_(4 > self.
_logger.countLog(
"mysvc2"))
137 self.assert_(0 < self.
_logger.countLog(
"mysvc2"))
147 self.
_pt.setTask(self.
_my.mysvc2)
148 self.
_pt.setPeriod(0.05)
149 self.assertEqual(0, self.
_logger.countLog(
"mysvc2"))
154 count = self.
_logger.countLog(
"mysvc2")
157 self.assertEqual(count, self.
_logger.countLog(
"mysvc2"))
161 self.assertEqual(count+1, self.
_logger.countLog(
"mysvc2"))
165 self.assertEqual(count+2, self.
_logger.countLog(
"mysvc2"))
172 self.assert_(6 > self.
_logger.countLog(
"mysvc2"))
173 self.assert_(2 < self.
_logger.countLog(
"mysvc2"))
187 self.
_pt.setTask(self.
_my.mysvc3)
188 self.
_pt.setPeriod(0.05)
189 self.
_pt.executionMeasure(
True)
196 estat = self.
_pt.getExecStat()
198 ss = ss +
"wait: " + str(wait) +
"\n" 199 ss = ss +
"estat max: " + str(estat._max_interval) +
"\n" 200 ss = ss +
"estat min: " + str(estat._min_interval) +
"\n" 201 ss = ss +
"estat mean: " + str(estat._mean_interval) +
"\n" 202 ss = ss +
"estat sdev: " + str(estat._std_deviation) +
"\n" 203 self.assert_(estat._max_interval < (wait + 0.030), ss)
204 self.assert_(estat._min_interval > (wait - 0.03), ss)
205 self.assert_(abs(estat._mean_interval - wait) < 0.03, ss)
206 self.assert_(estat._std_deviation < (wait / 5.0), ss)
209 self.
_pt.executionMeasureCount(5)
214 estat = self.
_pt.getExecStat()
216 ss = ss +
"wait: " + str(wait) +
"\n" 217 ss = ss +
"estat max: " + str(estat._max_interval) +
"\n" 218 ss = ss +
"estat min: " + str(estat._min_interval) +
"\n" 219 ss = ss +
"estat mean: " + str(estat._mean_interval) +
"\n" 220 ss = ss +
"estat sdev: " + str(estat._std_deviation) +
"\n" 221 self.assert_(estat._max_interval < (wait + 0.030), ss)
222 self.assert_(estat._min_interval > (wait - 0.03), ss)
223 self.assert_(abs(estat._mean_interval - wait) < 0.03, ss)
224 self.assert_(estat._std_deviation < (wait / 5.0), ss)
227 self.
_pt.executionMeasureCount(10)
233 estat2 = self.
_pt.getExecStat()
236 self.assert_(estat._max_interval == estat2._max_interval)
237 self.assert_(estat._min_interval == estat2._min_interval)
238 self.assert_(estat._mean_interval == estat2._mean_interval)
239 self.assert_(estat._std_deviation == estat2._std_deviation)
250 self.
_pt.setTask(self.
_my.mysvc3)
251 self.
_pt.setPeriod(0.05)
252 self.
_pt.periodicMeasure(
True)
259 pstat = self.
_pt.getPeriodStat()
260 self.assert_(pstat._max_interval < (wait + 0.030))
261 self.assert_(pstat._min_interval > (wait - 0.050))
262 self.assert_(abs(pstat._mean_interval - wait) < 0.03)
263 self.assert_(pstat._std_deviation < (wait / 1.0))
266 self.
_pt.periodicMeasureCount(5)
271 pstat = self.
_pt.getPeriodStat()
272 self.assert_(pstat._max_interval < (wait + 0.030))
273 self.assert_(pstat._min_interval > (wait - 0.010))
274 self.assert_(abs(pstat._mean_interval - wait) < 0.03)
275 self.assert_(pstat._std_deviation < (wait / 5.0))
278 self.
_pt.periodicMeasureCount(10)
284 pstat2 = self.
_pt.getPeriodStat()
296 if __name__ ==
'__main__':
def setLogger(self, logger)
def test_periodicMeasure(self)
def test_executionMeasure(self)
def test_setPeriodic(self)
def setLogger(self, logger)