13 from rtc_handle
import *
14 from BasicDataType_idl
import *
18 env =
RtmEnv(sys.argv, [
"localhost:9898"])
19 list0 = env.name_space[
"localhost:9898"].list_obj()
20 env.name_space[
'localhost:9898'].rtc_handles.keys()
24 ns = env.name_space[
'localhost:9898']
26 compo1 = ns.rtc_handles[
"ConsoleIn0.rtc"]
27 compo0 = ns.rtc_handles[
"ConsoleOut0.rtc"]
30 (stat, output) = commands.getstatusoutput(
"ps alxww | grep \"[r]\"tcd")
31 return output.split()[7]
37 fout.write(out_data +
'\n')
45 fout.write(out_data +
'\n')
51 if rss_start != rss_end:
52 fodat =
" result: memory leak was found !!!" 54 fodat =
" result: memory leak was not found." 60 fout = open(test_case +
".log",
'w')
62 fodat =
"=== " + test_case +
" start ===" 65 ec = compo0.rtc_ref.get_owned_contexts()
66 ec_id = compo0.rtc_ref.get_context_handle(ec[0])
67 ec[0].activate_component(compo0.rtc_ref)
71 fodat =
"on_finalize()" 74 for i
in range(loop_cnt):
76 compo0.rtc_ref.on_finalize()
79 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
80 fodat =
" %05d: %s KB start" % (1, rss0)
84 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
89 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
93 fodat =
"on_startup()" 96 for i
in range(loop_cnt):
98 compo0.rtc_ref.on_startup(ec_id)
101 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
102 fodat =
" %05d: %s KB start" % (1, rss0)
106 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
108 rss0 = rss1 ; j0 = j1
111 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
115 fodat =
"on_shutdown()" 118 for i
in range(loop_cnt):
120 compo0.rtc_ref.on_shutdown(ec_id)
123 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
124 fodat =
" %05d: %s KB start" % (1, rss0)
128 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
130 rss0 = rss1 ; j0 = j1
133 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
137 fodat =
"on_activated()" 140 for i
in range(loop_cnt):
142 compo0.rtc_ref.on_activated(ec_id)
145 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
146 fodat =
" %05d: %s KB start" % (1, rss0)
150 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
152 rss0 = rss1 ; j0 = j1
155 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
159 fodat =
"on_deactivated()" 162 for i
in range(loop_cnt):
164 compo0.rtc_ref.on_deactivated(ec_id)
167 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
168 fodat =
" %05d: %s KB start" % (1, rss0)
172 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
174 rss0 = rss1 ; j0 = j1
177 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
181 fodat =
"on_aborting()" 184 for i
in range(loop_cnt):
186 compo0.rtc_ref.on_aborting(ec_id)
189 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
190 fodat =
" %05d: %s KB start" % (1, rss0)
194 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
196 rss0 = rss1 ; j0 = j1
199 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
206 for i
in range(loop_cnt):
208 compo0.rtc_ref.on_error(ec_id)
211 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
212 fodat =
" %05d: %s KB start" % (1, rss0)
216 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
218 rss0 = rss1 ; j0 = j1
221 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
228 for i
in range(loop_cnt):
230 compo0.rtc_ref.on_reset(ec_id)
233 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
234 fodat =
" %05d: %s KB start" % (1, rss0)
238 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
240 rss0 = rss1 ; j0 = j1
243 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
250 for i
in range(loop_cnt):
252 compo0.rtc_ref.is_alive(ec[0])
255 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
256 fodat =
" %05d: %s KB start" % (1, rss0)
260 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
262 rss0 = rss1 ; j0 = j1
265 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
269 fodat =
"get_context()" 272 for i
in range(loop_cnt):
274 compo0.rtc_ref.get_context(ec_id)
277 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
278 fodat =
" %05d: %s KB start" % (1, rss0)
282 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
284 rss0 = rss1 ; j0 = j1
287 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
291 fodat =
"get_owned_contexts()" 294 for i
in range(loop_cnt):
296 compo0.rtc_ref.get_owned_contexts()
299 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
300 fodat =
" %05d: %s KB start" % (1, rss0)
304 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
306 rss0 = rss1 ; j0 = j1
309 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
313 fodat =
"get_participating_contexts()" 316 for i
in range(loop_cnt):
318 compo0.rtc_ref.get_participating_contexts()
321 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
322 fodat =
" %05d: %s KB start" % (1, rss0)
326 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
328 rss0 = rss1 ; j0 = j1
331 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
335 fodat =
"get_context_handle()" 338 for i
in range(loop_cnt):
340 compo0.rtc_ref.get_context_handle(ec[0])
343 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
344 fodat =
" %05d: %s KB start" % (1, rss0)
348 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
350 rss0 = rss1 ; j0 = j1
353 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
357 fodat =
"is_running()" 360 for i
in range(loop_cnt):
365 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
366 fodat =
" %05d: %s KB start" % (1, rss0)
370 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
372 rss0 = rss1 ; j0 = j1
375 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
382 for i
in range(loop_cnt):
387 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
388 fodat =
" %05d: %s KB start" % (1, rss0)
392 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
394 rss0 = rss1 ; j0 = j1
397 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
404 for i
in range(loop_cnt):
409 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
410 fodat =
" %05d: %s KB start" % (1, rss0)
414 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
416 rss0 = rss1 ; j0 = j1
419 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
426 for i
in range(loop_cnt):
431 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
432 fodat =
" %05d: %s KB start" % (1, rss0)
436 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
438 rss0 = rss1 ; j0 = j1
441 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
448 for i
in range(loop_cnt):
450 ec[0].set_rate(1.23456)
453 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
454 fodat =
" %05d: %s KB start" % (1, rss0)
458 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
460 rss0 = rss1 ; j0 = j1
463 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
467 fodat =
"activate_component()" 470 for i
in range(loop_cnt):
472 ec[0].activate_component(compo0.rtc_ref)
475 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
476 fodat =
" %05d: %s KB start" % (1, rss0)
480 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
482 rss0 = rss1 ; j0 = j1
485 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
489 fodat =
"deactivate_component()" 492 for i
in range(loop_cnt):
494 ec[0].deactivate_component(compo0.rtc_ref)
497 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
498 fodat =
" %05d: %s KB start" % (1, rss0)
502 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
504 rss0 = rss1 ; j0 = j1
507 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
511 fodat =
"reset_component()" 514 for i
in range(loop_cnt):
516 ec[0].reset_component(compo0.rtc_ref)
519 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
520 fodat =
" %05d: %s KB start" % (1, rss0)
524 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
526 rss0 = rss1 ; j0 = j1
529 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
533 ec[0].activate_component(compo0.rtc_ref)
535 fodat =
"get_component_state()" 538 for i
in range(loop_cnt):
540 ec[0].get_component_state(compo0.rtc_ref)
543 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
544 fodat =
" %05d: %s KB start" % (1, rss0)
548 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
550 rss0 = rss1 ; j0 = j1
553 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
560 for i
in range(loop_cnt):
565 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
566 fodat =
" %05d: %s KB start" % (1, rss0)
570 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
572 rss0 = rss1 ; j0 = j1
575 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
579 fodat =
"on_execute()" 582 for i
in range(loop_cnt):
584 compo0.rtc_ref.on_execute(ec_id)
587 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
588 fodat =
" %05d: %s KB start" % (1, rss0)
592 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
594 rss0 = rss1 ; j0 = j1
597 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
601 fodat =
"on_state_update()" 604 for i
in range(loop_cnt):
606 compo0.rtc_ref.on_state_update(ec_id)
609 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
610 fodat =
" %05d: %s KB start" % (1, rss0)
614 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
616 rss0 = rss1 ; j0 = j1
619 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
623 fodat =
"on_rate_changed()" 626 for i
in range(loop_cnt):
628 compo0.rtc_ref.on_rate_changed(ec_id)
631 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
632 fodat =
" %05d: %s KB start" % (1, rss0)
636 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
638 rss0 = rss1 ; j0 = j1
641 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
645 fodat =
"get_profile()" 648 for i
in range(loop_cnt):
653 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
654 fodat =
" %05d: %s KB start" % (1, rss0)
658 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
660 rss0 = rss1 ; j0 = j1
663 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
667 fodat =
"get_component_profile()" 670 for i
in range(loop_cnt):
672 compo0.rtc_ref.get_component_profile()
675 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
676 fodat =
" %05d: %s KB start" % (1, rss0)
680 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
682 rss0 = rss1 ; j0 = j1
685 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
689 ec[0].deactivate_component(compo0.rtc_ref)
691 fodat =
"=== " + test_case +
" end ==="
def print_file_and_cons(out_data, out_flag=0)
file and console out
def leak_check(rss_start, rss_end)
memory leak check