13 from rtc_handle
import *
14 from BasicDataType_idl
import *
19 from omniORB
import any
20 from omniORB
import CORBA
23 env =
RtmEnv(sys.argv, [
"localhost:9898"])
24 list0 = env.name_space[
"localhost:9898"].list_obj()
25 env.name_space[
'localhost:9898'].rtc_handles.keys()
29 ns = env.name_space[
'localhost:9898']
31 compo0 = ns.rtc_handles[
"ConsoleIn0.rtc"]
32 compo1 = ns.rtc_handles[
"ConsoleOut0.rtc"]
38 (stat, output) = commands.getstatusoutput(
"ps alxww | grep \"[r]\"tcd")
39 return output.split()[7]
45 fout.write(out_data +
'\n')
53 fout.write(out_data +
'\n')
59 if rss_start != rss_end:
60 fodat =
" result: memory leak was found !!!" 62 fodat =
" result: memory leak was not found." 67 test_case =
"DataPortTest" 68 fout = open(test_case +
".log",
'w')
70 fodat =
"=== " + test_case +
" start ===" 73 consin_ports = compo0.rtc_ref.get_ports()
75 consout_ports = compo1.rtc_ref.get_ports()
83 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"))])
108 conprof2 = RTC.ConnectorProfile(
"connector0",
"123", [consout_ports[0], consin_ports[0]], [SDOPackage.NameValue(
"dataport.interface_type",any.to_any(
"corba_cdr")),SDOPackage.NameValue(
"dataport.dataflow_type",any.to_any(
"pull")),SDOPackage.NameValue(
"dataport.subscription_type",any.to_any(
"flush"))])
121 for i
in range(loop_cnt):
124 ret0,conprof0 = consin_ports[0].connect(conprof)
126 if ret0 != RTC.RTC_OK:
127 fodat =
" connect() error ret=" + str(ret0)
136 ior = any.from_any(conprof0.properties[4].value, keep_structs=
True)
138 inportobj = env.orb.string_to_object(ior)
139 inportcdr = inportobj._narrow(OpenRTM.InPortCdr)
140 data = RTC.TimedLong(RTC.Time(0,0),12345)
141 data0 = cdrMarshal(any.to_any(data).typecode(), data, 1)
142 ret1 = inportcdr.put(data0)
152 ret2 = consin_ports[0].disconnect(conprof.connector_id)
159 fodat =
" %05d: %s KB start" % (1, rss0)
163 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
165 rss0 = rss1 ; j0 = j1
168 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
175 for i
in range(loop_cnt):
178 ret10,conprof10 = consout_ports[0].connect(conprof2)
180 if ret10 != RTC.RTC_OK:
181 fodat =
" connect() error ret=" + str(ret10)
190 ior10 = any.from_any(conprof10.properties[4].value, keep_structs=
True)
193 outportobj = env.orb.string_to_object(ior10)
194 outportcdr = outportobj._narrow(OpenRTM.OutPortCdr)
197 ret11,data1 = outportcdr.get()
206 ret12 = consin_ports[0].disconnect(conprof2.connector_id)
212 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
213 fodat =
" %05d: %s KB start" % (1, rss0)
217 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
219 rss0 = rss1 ; j0 = j1
222 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
229 fodat =
"=== " + test_case +
" end ==="
def leak_check(rss_start, rss_end)
memory leak check
def print_file_and_cons(out_data, out_flag=0)
file and console out