13 from rtc_handle
import *
14 from BasicDataType_idl
import *
15 from omniORB
import any
22 env =
RtmEnv(sys.argv, [
"localhost:9898"])
25 mgr_name = socket.gethostname()+
".host_cxt/manager.mgr" 27 manager = naming.resolve(mgr_name)._narrow(RTM.Manager)
29 manager.create_component(
"PeriodicECSharedComposite?instance_name=a&exported_ports=ConsoleIn0.out,ConsoleOut0.in")
33 listo = env.name_space[
"localhost:9898"].list_obj()
34 env.name_space[
'localhost:9898'].rtc_handles.keys()
36 ns = env.name_space[
'localhost:9898']
38 a0 = ns.rtc_handles[
"a.rtc"]
39 org = a0.rtc_ref.get_owned_organizations()[0]
40 nv = SDOPackage.NameValue(
"Test", any.to_any(100))
43 (stat, output) = commands.getstatusoutput(
"ps alxww | grep \"[r]\"tcd")
44 return output.split()[7]
50 fout.write(out_data +
'\n')
58 fout.write(out_data +
'\n')
64 if rss_start != rss_end:
65 fodat =
" result: memory leak was found !!!" 67 fodat =
" result: memory leak was not found." 72 test_case =
"OrganizationSDOPackageTest" 73 fout = open(test_case +
".log",
'w')
75 fodat =
"=== " + test_case +
" start ===" 80 fodat =
"get_organization_id()" 83 for i
in range(loop_cnt):
85 id = org.get_organization_id()
88 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
89 fodat =
" %05d: %s KB start" % (1, rss0)
93 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
98 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
102 fodat =
"get_organization_property()" 105 for i
in range(loop_cnt):
107 prop = org.get_organization_property()
110 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
111 fodat =
" %05d: %s KB start" % (1, rss0)
115 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
117 rss0 = rss1 ; j0 = j1
120 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
124 fodat =
"get_owner()" 127 for i
in range(loop_cnt):
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 =
"get_organizations()" 149 for i
in range(loop_cnt):
151 a0.rtc_ref.get_organizations()
154 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
155 fodat =
" %05d: %s KB start" % (1, rss0)
159 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
161 rss0 = rss1 ; j0 = j1
164 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
168 fodat =
"add_organization_property() and get_organization_property_value() and \nremove_organization_property()" 171 for i
in range(loop_cnt):
173 org.add_organization_property(SDOPackage.OrganizationProperty([nv]))
176 org.get_organization_property_value(
"Test")
179 org.remove_organization_property(
"Test")
182 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
183 fodat =
" %05d: %s KB start" % (1, rss0)
187 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
189 rss0 = rss1 ; j0 = j1
192 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
196 fodat =
"set_organization_property_value()" 199 for i
in range(loop_cnt):
201 org.set_organization_property_value(
"Test2",any.to_any(200))
204 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
205 fodat =
" %05d: %s KB start" % (1, rss0)
209 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
211 rss0 = rss1 ; j0 = j1
214 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
218 fodat =
"set_owner()" 221 for i
in range(loop_cnt):
223 org.set_owner(a0.rtc_ref)
226 rss0 =
mem_rss() ; j0 = 0 ; rssStart = rss0
227 fodat =
" %05d: %s KB start" % (1, rss0)
231 fodat =
" %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
233 rss0 = rss1 ; j0 = j1
236 fodat =
" %05d: %s KB end" % (i+1, rssEnd)
241 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