AddRemoveMemberSDOPackageTest.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: euc-jp -*-
3 #
4 ## AddRemoveMemberSDOPackageTest.py
5 
12 
13 
14 from rtc_handle import *
15 from BasicDataType_idl import *
16 from omniORB import any
17 import time
18 import commands
19 import SDOPackage
20 import socket
21 import RTM
22 
23 env = RtmEnv(sys.argv, ["localhost:9898"])
24 
25 ## Get Manager object reference
26 mgr_name = socket.gethostname()+".host_cxt/manager.mgr"
27 naming = CorbaNaming(env.orb, "localhost:9898")
28 manager = naming.resolve(mgr_name)._narrow(RTM.Manager)
29 ## Create Composite RTC.
30 manager.create_component("PeriodicECSharedComposite?instance_name=a&exported_ports=ConsoleIn0.out,ConsoleOut0.in")
31 
32 time.sleep(2)
33 
34 listo = env.name_space["localhost:9898"].list_obj()
35 env.name_space['localhost:9898'].rtc_handles.keys()
36 
37 ns = env.name_space['localhost:9898']
38 
39 seqin0 = ns.rtc_handles["SequenceInComponent0.rtc"]
40 a0 = ns.rtc_handles["a.rtc"]
41 org = a0.rtc_ref.get_owned_organizations()[0]
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 = "AddRemoveMemberSDOPackageTest"
74 fout = open(test_case + ".log", 'w')
75 
76 fodat = "=== " + test_case + " start ==="
78 
79 loop_cnt = 1000
80 ## -----------------------------------------------------------------------------
81 fodat = "add_members() and remove_member()"
83 
84 for i in range(loop_cnt):
85  ## Organization::add_members ( in SDOList sdo_list);
86  org.add_members ([seqin0.rtc_ref]) ### [add/remove]_member set
87 
88  ## Organization::remove_member (in UniqueIdentifier id);
89  org.remove_member (seqin0.rtc_ref.get_sdo_id()) ### Segmentation fault.
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 
107 fodat = "=== " + test_case + " end ==="
108 print_file_and_cons(fodat)
109 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 Thu Jun 6 2019 19:25:56