13 from rtc_handle
import *
14 from BasicDataType_idl
import *
19 env =
RtmEnv(sys.argv, [
"localhost:9898"])
20 list0 = env.name_space[
"localhost:9898"].list_obj()
21 env.name_space[
'localhost:9898'].rtc_handles.keys()
25 ns = env.name_space[
'localhost:9898']
27 compo0 = ns.rtc_handles[
"ConsoleIn0.rtc"]
28 compo1 = ns.rtc_handles[
"ConsoleOut0.rtc"]
31 (stat, output) = commands.getstatusoutput(
"ps alxww | grep \"[r]\"tcd")
32 return output.split()[7]
38 fout.write(out_data +
'\n')
46 fout.write(out_data +
'\n')
52 if rss_start != rss_end:
53 fodat =
" result: memory leak was found !!!" 55 fodat =
" result: memory leak was not found." 60 test_case =
"ConnectRTCTest" 61 fout = open(test_case +
".log",
'w')
63 fodat =
"=== " + test_case +
" start ===" 68 consin_ports = compo0.rtc_ref.get_ports()
70 consout_ports = compo1.rtc_ref.get_ports()
75 conprof = RTC.ConnectorProfile(
"connector0",
"123", [consin_ports[0],consout_ports[0]], [SDOPackage.NameValue(
"dataport.interface_type",any.to_any(
"corba_cdr")),SDOPackage.NameValue(
"dataport.dataflow_type",any.to_any(
"push")),SDOPackage.NameValue(
"dataport.subscription_type",any.to_any(
"flush"))])
101 for i
in range(loop_cnt):
104 compo1.rtc_ref.get_ports()
109 fodat =
" %05d: %s KB start" % (1, rss0)
113 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
115 rss0 = rss1 ; j0 = j1
118 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
122 fodat =
"get_port_profile()" 125 for i
in range(loop_cnt):
128 consin_ports[0].get_port_profile()
132 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
133 fodat =
" %05d: %s KB start" % (1, rss0)
137 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
139 rss0 = rss1 ; j0 = j1
142 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
146 fodat =
"notify_connect() and notify_disconnect()" 149 for i
in range(loop_cnt):
151 ret0 = consin_ports[0].notify_connect(conprof)
154 ret1 = consin_ports[0].notify_disconnect(conprof.connector_id)
159 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
160 fodat =
" %05d: %s KB start" % (1, rss0)
164 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
166 rss0 = rss1 ; j0 = j1
169 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
173 fodat =
"get_connector_profiles()" 176 for i
in range(loop_cnt):
178 consin_ports[0].connect(conprof)
179 consin_ports[0].get_connector_profiles()
180 consin_ports[0].disconnect(conprof.connector_id)
183 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
184 fodat =
" %05d: %s KB start" % (1, rss0)
188 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
190 rss0 = rss1 ; j0 = j1
193 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
197 fodat =
"get_connector_profile()" 200 for i
in range(loop_cnt):
202 consin_ports[0].connect(conprof)
203 consin_ports[0].get_connector_profile(conprof.connector_id)
204 consin_ports[0].disconnect(conprof.connector_id)
207 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
208 fodat =
" %05d: %s KB start" % (1, rss0)
212 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
214 rss0 = rss1 ; j0 = j1
217 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
221 fodat =
"connect() and disconnect()" 224 for i
in range(loop_cnt):
226 ret0 = consin_ports[0].connect(conprof)
228 ret1 = consin_ports[0].disconnect(conprof.connector_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)
247 fodat =
"connect() and disconnect_all()" 250 for i
in range(loop_cnt):
252 ret0 = consin_ports[0].connect(conprof)
255 consin_ports[0].disconnect_all()
258 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
259 fodat =
" %05d: %s KB start" % (1, rss0)
263 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
265 rss0 = rss1 ; j0 = j1
268 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
273 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