Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 from rtc_handle import *
00014 from BasicDataType_idl import *
00015 from omniORB import any
00016 import time
00017 import commands
00018 import SDOPackage
00019 import socket
00020 import RTM
00021
00022 env = RtmEnv(sys.argv, ["localhost:9898"])
00023
00024
00025 mgr_name = socket.gethostname()+".host_cxt/manager.mgr"
00026 naming = CorbaNaming(env.orb, "localhost:9898")
00027 manager = naming.resolve(mgr_name)._narrow(RTM.Manager)
00028
00029 manager.create_component("PeriodicECSharedComposite?instance_name=a&exported_ports=ConsoleIn0.out,ConsoleOut0.in")
00030
00031 time.sleep(2)
00032
00033 listo = env.name_space["localhost:9898"].list_obj()
00034 env.name_space['localhost:9898'].rtc_handles.keys()
00035
00036
00037 ns = env.name_space['localhost:9898']
00038
00039 consin0 = ns.rtc_handles["ConsoleIn0.rtc"]
00040 consout0 = ns.rtc_handles["ConsoleOut0.rtc"]
00041 seqin0 = ns.rtc_handles["SequenceInComponent0.rtc"]
00042 a0 = ns.rtc_handles["a.rtc"]
00043 org = a0.rtc_ref.get_owned_organizations()[0]
00044
00045 def mem_rss():
00046 (stat, output) = commands.getstatusoutput("ps alxww | grep \"[r]\"tcd")
00047 return output.split()[7]
00048
00049
00050 def print_file_and_cons(out_data, out_flag=0):
00051
00052 if out_flag == 1:
00053 fout.write(out_data + '\n')
00054 fout.flush()
00055
00056 elif out_flag == 2:
00057 print out_data
00058
00059 else:
00060 print out_data
00061 fout.write(out_data + '\n')
00062 fout.flush()
00063 return
00064
00065
00066 def leak_check(rss_start, rss_end):
00067 if rss_start != rss_end:
00068 fodat = " result: memory leak was found !!!"
00069 else:
00070 fodat = " result: memory leak was not found."
00071 print_file_and_cons(fodat)
00072 return
00073
00074
00075 test_case = "SetMemberSDOPackageTest"
00076 fout = open(test_case + ".log", 'w')
00077
00078 fodat = "=== " + test_case + " start ==="
00079 print_file_and_cons(fodat)
00080
00081 loop_cnt = 1000
00082
00083 fodat = "set_members()"
00084 print_file_and_cons(fodat)
00085
00086 for i in range(loop_cnt):
00087
00088
00089 org.set_members ([consin0.rtc_ref])
00090
00091 if i == 0:
00092 rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
00093 fodat = " %05d: %s KB start" % (1, rss0)
00094 print_file_and_cons(fodat,1)
00095 rss1 = mem_rss() ; j1 = i
00096 if rss0 != rss1:
00097 fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
00098 print_file_and_cons(fodat,1)
00099 rss0 = rss1 ; j0 = j1
00100
00101 rssEnd = mem_rss()
00102 fodat = " %05d: %s KB end" % (i+1, rssEnd)
00103 print_file_and_cons(fodat,1)
00104 leak_check(rssStart, rssEnd)
00105
00106 fodat = "get_members()"
00107 print_file_and_cons(fodat)
00108
00109 for i in range(loop_cnt):
00110
00111 org.get_members ()
00112
00113 if i == 0:
00114 rss0 = mem_rss() ; j0 = 0 ; rssStart = rss0
00115 fodat = " %05d: %s KB start" % (1, rss0)
00116 print_file_and_cons(fodat,1)
00117 rss1 = mem_rss() ; j1 = i
00118 if rss0 != rss1:
00119 fodat = " %05d: %s KB -> %d KB. count diff -> %d" % (i+1, rss1,int(rss1)-int(rss0),int(j1)-int(j0) )
00120 print_file_and_cons(fodat,1)
00121 rss0 = rss1 ; j0 = j1
00122
00123 rssEnd = mem_rss()
00124 fodat = " %05d: %s KB end" % (i+1, rssEnd)
00125 print_file_and_cons(fodat,1)
00126 leak_check(rssStart, rssEnd)
00127
00128
00129 fodat = "=== " + test_case + " end ==="
00130 print_file_and_cons(fodat)
00131 fout.close()