AddRemoveOrganizationSDOPackageTest.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: euc-jp -*-
3 #
4 ## AddRemoveOrganizationSDOPackageTest.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 ns = env.name_space['localhost:9898']
37 
38 a0 = ns.rtc_handles["a.rtc"]
39 org = a0.rtc_ref.get_owned_organizations()[0]
40 config = a0.rtc_ref.get_configuration()
41 
42 
43 def mem_rss():
44  (stat, output) = commands.getstatusoutput("ps alxww | grep \"[r]\"tcd")
45  return output.split()[7]
46 
47 ## file and console out
48 def print_file_and_cons(out_data, out_flag=0):
49  ## out_flag:1 is file out only
50  if out_flag == 1:
51  fout.write(out_data + '\n')
52  fout.flush()
53  ## out_flag:2 is console out only
54  elif out_flag == 2:
55  print out_data
56  ## out_flag:0 is console and file out (default)
57  else:
58  print out_data
59  fout.write(out_data + '\n')
60  fout.flush()
61  return
62 
63 ## memory leak check
64 def leak_check(rss_start, rss_end):
65  if rss_start != rss_end:
66  fodat = " result: memory leak was found !!!"
67  else:
68  fodat = " result: memory leak was not found."
69  print_file_and_cons(fodat)
70  return
71 
72 ## file out setting
73 test_case = "AddRemoveOrganizationSDOPackageTest"
74 fout = open(test_case + ".log", 'w')
75 
76 fodat = "=== " + test_case + " start ==="
78 
79 loop_cnt = 1000
80 ## -----------------------------------------------------------------------------
81 fodat = "add_organization() and remove_organization()"
83 
84 for i in range(loop_cnt):
85  id = org.get_organization_id()
86 
87  ## Configuration::add_organization (in Organization organization_object);
88  config.add_organization (org) ### [add/remove]_organization set
89 
90  ## Configuration::remove_organization (in UniqueIdentifier organization_id);
91  config.remove_organization (id) ###
92 
93  if i == 0:
94  rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
95  fodat = " %05d: %s KB start" % (1, rss0)
96  print_file_and_cons(fodat,1)
97  rss1 = mem_rss() ; j1 = i
98  if rss0 != rss1:
99  fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
100  print_file_and_cons(fodat,1)
101  rss0 = rss1 ; j0 = j1
102 
103 rssEnd = mem_rss()
104 fodat = " %05d: %s KB end" % (i+1, rssEnd)
105 print_file_and_cons(fodat,1)
106 leak_check(rssStart, rssEnd)
107 ## -----------------------------------------------------------------------------
108 
109 fodat = "=== " + test_case + " end ==="
110 print_file_and_cons(fodat)
111 fout.close()
def leak_check(rss_start, rss_end)
memory leak check
def print_file_and_cons(out_data, out_flag=0)
file and console out


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:25:56