SetMemberSDOPackageTest.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: euc-jp -*-
3 #
4 ## SetMemberSDOPackageTest.py
5 
12 
13 from rtc_handle import *
14 from BasicDataType_idl import *
15 from omniORB import any
16 import time
17 import commands
18 import SDOPackage
19 import socket
20 import RTM
21 
22 env = RtmEnv(sys.argv, ["localhost:9898"])
23 
24 ## Get Manager object reference
25 mgr_name = socket.gethostname()+".host_cxt/manager.mgr"
26 naming = CorbaNaming(env.orb, "localhost:9898")
27 manager = naming.resolve(mgr_name)._narrow(RTM.Manager)
28 ## Create Composite RTC
29 manager.create_component("PeriodicECSharedComposite?instance_name=a&exported_ports=ConsoleIn0.out,ConsoleOut0.in")
30 
31 time.sleep(2)
32 
33 listo = env.name_space["localhost:9898"].list_obj()
34 env.name_space['localhost:9898'].rtc_handles.keys()
35 
36 
37 ns = env.name_space['localhost:9898']
38 
39 consin0 = ns.rtc_handles["ConsoleIn0.rtc"]
40 consout0 = ns.rtc_handles["ConsoleOut0.rtc"]
41 seqin0 = ns.rtc_handles["SequenceInComponent0.rtc"]
42 a0 = ns.rtc_handles["a.rtc"]
43 org = a0.rtc_ref.get_owned_organizations()[0]
44 
45 def mem_rss():
46  (stat, output) = commands.getstatusoutput("ps alxww | grep \"[r]\"tcd")
47  return output.split()[7]
48 
49 ## file and console out
50 def print_file_and_cons(out_data, out_flag=0):
51  ## out_flag:1 is file out only
52  if out_flag == 1:
53  fout.write(out_data + '\n')
54  fout.flush()
55  ## out_flag:2 is console out only
56  elif out_flag == 2:
57  print out_data
58  ## out_flag:0 is console and file out (default)
59  else:
60  print out_data
61  fout.write(out_data + '\n')
62  fout.flush()
63  return
64 
65 ## memory leak check
66 def leak_check(rss_start, rss_end):
67  if rss_start != rss_end:
68  fodat = " result: memory leak was found !!!"
69  else:
70  fodat = " result: memory leak was not found."
71  print_file_and_cons(fodat)
72  return
73 
74 ## file out setting
75 test_case = "SetMemberSDOPackageTest"
76 fout = open(test_case + ".log", 'w')
77 
78 fodat = "=== " + test_case + " start ==="
80 
81 loop_cnt = 1000
82 ## -----------------------------------------------------------------------------
83 fodat = "set_members()"
85 
86 for i in range(loop_cnt):
87  ## Organization::set_members (in SDOList sdos);
88  #org.set_members ([consin0.rtc_ref,consout0.rtc_ref])
89  org.set_members ([consin0.rtc_ref])
90 
91  if i == 0:
92  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
93  fodat = " %05d: %s KB start" % (1, rss0)
94  print_file_and_cons(fodat,1)
95  rss1 = mem_rss() ; j1 = i
96  if rss0 != rss1:
97  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
98  print_file_and_cons(fodat,1)
99  rss0 = rss1 ; j0 = j1
100 
101 rssEnd = mem_rss()
102 fodat = " %05d: %s KB end" % (i+1, rssEnd)
103 print_file_and_cons(fodat,1)
104 leak_check(rssStart, rssEnd)
105 ## -----------------------------------------------------------------------------
106 fodat = "get_members()"
107 print_file_and_cons(fodat)
108 
109 for i in range(loop_cnt):
110  ## Organization::get_members ();
111  org.get_members ()
112 
113  if i == 0:
114  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
115  fodat = " %05d: %s KB start" % (1, rss0)
116  print_file_and_cons(fodat,1)
117  rss1 = mem_rss() ; j1 = i
118  if rss0 != rss1:
119  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
120  print_file_and_cons(fodat,1)
121  rss0 = rss1 ; j0 = j1
122 
123 rssEnd = mem_rss()
124 fodat = " %05d: %s KB end" % (i+1, rssEnd)
125 print_file_and_cons(fodat,1)
126 leak_check(rssStart, rssEnd)
127 ## -----------------------------------------------------------------------------
128 
129 fodat = "=== " + test_case + " end ==="
130 print_file_and_cons(fodat)
131 fout.close()
def print_file_and_cons(out_data, out_flag=0)
file and console out
def leak_check(rss_start, rss_end)
memory leak check


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