9 from rtc_handle
import *
10 from BasicDataType_idl
import *
18 g_test_name =
"<< component connection test >>" 22 g_interface_type1 =
"corba_cdr" 23 g_dataflow_type =
"push" 24 g_subscription_type =
"flush" 37 g_connector_id1 =
"001" 38 g_data_type1 =
"TimedFloat" 42 g_connector_id2 =
"002" 43 g_data_type2 =
"TimedFloatSeq" 47 g_connector_id3 =
"003" 48 g_interface_type3 =
"MyService" 52 g_diff_send_file =
"./original-data" 53 g_diff_recv_file =
"./received-data" 54 g_check_message = g_diff_recv_file +
" file not found." 55 g_test_result_file =
"./ResultTest.log" 60 g_test_ng_message =
" < received-data >" 76 sleep_recv_act_time = 1
105 ret,porf = g_out_ports[g_port1].connect(g_conprof1)
110 ret,porf = g_out_ports[g_port2].connect(g_conprof2)
115 ret,porf = g_out_ports[g_port3].connect(g_conprof3)
131 ret = g_in_ports[g_port3].disconnect(g_conprof3.connector_id)
134 ret = g_in_ports[g_port2].disconnect(g_conprof2.connector_id)
137 ret = g_in_ports[g_port1].disconnect(g_conprof1.connector_id)
152 ret = ec_recv[0].activate_component(g_compo_recv.rtc_ref)
156 time.sleep(sleep_recv_act_time)
158 ret = ec_send[0].activate_component(g_compo_send.rtc_ref)
173 ret = ec_send[0].deactivate_component(g_compo_send.rtc_ref)
176 ret = ec_recv[0].deactivate_component(g_compo_recv.rtc_ref)
188 global g_compo_send,g_compo_recv
189 global ec_send,ec_recv
190 global g_out_ports,g_in_ports
191 global g_conprof1,g_conprof2,g_conprof3
194 os.system(
'./AutoTestOutComp >/dev/null 2>&1 &')
195 os.system(
'./AutoTestInComp >/dev/null 2>&1 &')
200 list0 = env.name_space[
"localhost:2809"].list_obj()
201 env.name_space[
'localhost:2809'].rtc_handles.keys()
202 ns = env.name_space[
'localhost:2809']
204 g_compo_send = ns.rtc_handles[
"AutoTestOut0.rtc"]
205 g_compo_recv = ns.rtc_handles[
"AutoTestIn0.rtc"]
207 ec_send = g_compo_send.rtc_ref.get_owned_contexts()
208 ec_recv = g_compo_recv.rtc_ref.get_owned_contexts()
210 g_out_ports = g_compo_send.rtc_ref.get_ports()
211 g_in_ports = g_compo_recv.rtc_ref.get_ports()
213 g_conprof3 = RTC.ConnectorProfile(g_name3, g_connector_id3, [g_out_ports[g_port3], g_in_ports[g_port3]], [SDOPackage.NameValue(
"dataport.interface_type",any.to_any(g_interface_type3))])
224 g_compo_send.rtc_ref.exit();
225 g_compo_recv.rtc_ref.exit();
239 env =
RtmEnv(sys.argv, [
"localhost:2809"])
252 global g_conprof1, g_conprof2, g_conprof3
254 if connect_direction == 0:
256 g_conprof1 = RTC.ConnectorProfile(g_name1, g_connector_id1, [g_out_ports[g_port1], g_in_ports[g_port1]], [SDOPackage.NameValue(
"dataport.data_type",any.to_any(g_data_type1)),SDOPackage.NameValue(
"dataport.interface_type",any.to_any(g_interface_type1)),SDOPackage.NameValue(
"dataport.dataflow_type",any.to_any(g_dataflow_type)),SDOPackage.NameValue(
"dataport.subscription_type",any.to_any(subscription_type)),SDOPackage.NameValue(
"dataport.publisher.push_policy",any.to_any(push_policy)),SDOPackage.NameValue(
"dataport.publisher.push_rate",any.to_any(g_push_rate)),SDOPackage.NameValue(
"dataport.publisher.skip_count",any.to_any(g_skip_count))])
258 g_conprof2 = RTC.ConnectorProfile(g_name2, g_connector_id2, [g_out_ports[g_port2], g_in_ports[g_port2]], [SDOPackage.NameValue(
"dataport.data_type",any.to_any(g_data_type2)),SDOPackage.NameValue(
"dataport.interface_type",any.to_any(g_interface_type1)),SDOPackage.NameValue(
"dataport.dataflow_type",any.to_any(g_dataflow_type)),SDOPackage.NameValue(
"dataport.subscription_type",any.to_any(subscription_type)),SDOPackage.NameValue(
"dataport.publisher.push_policy",any.to_any(push_policy)),SDOPackage.NameValue(
"dataport.publisher.push_rate",any.to_any(g_push_rate)),SDOPackage.NameValue(
"dataport.publisher.skip_count",any.to_any(g_skip_count))])
265 g_conprof1 = RTC.ConnectorProfile(g_name1, g_connector_id1, [g_in_ports[g_port1], g_out_ports[g_port1]], [SDOPackage.NameValue(
"dataport.data_type",any.to_any(g_data_type1)),SDOPackage.NameValue(
"dataport.interface_type",any.to_any(g_interface_type1)),SDOPackage.NameValue(
"dataport.dataflow_type",any.to_any(g_dataflow_type)),SDOPackage.NameValue(
"dataport.subscription_type",any.to_any(subscription_type)),SDOPackage.NameValue(
"dataport.publisher.push_policy",any.to_any(push_policy)),SDOPackage.NameValue(
"dataport.publisher.push_rate",any.to_any(g_push_rate)),SDOPackage.NameValue(
"dataport.publisher.skip_count",any.to_any(g_skip_count))])
267 g_conprof2 = RTC.ConnectorProfile(g_name2, g_connector_id2, [g_in_ports[g_port2], g_out_ports[g_port2]], [SDOPackage.NameValue(
"dataport.data_type",any.to_any(g_data_type2)),SDOPackage.NameValue(
"dataport.interface_type",any.to_any(g_interface_type1)),SDOPackage.NameValue(
"dataport.dataflow_type",any.to_any(g_dataflow_type)),SDOPackage.NameValue(
"dataport.subscription_type",any.to_any(subscription_type)),SDOPackage.NameValue(
"dataport.publisher.push_policy",any.to_any(push_policy)),SDOPackage.NameValue(
"dataport.publisher.push_rate",any.to_any(g_push_rate)),SDOPackage.NameValue(
"dataport.publisher.skip_count",any.to_any(g_skip_count))])
283 if os.path.isfile(g_diff_recv_file) ==
True:
284 os.remove(g_diff_recv_file)
301 if os.path.isfile(g_diff_send_file) ==
False:
302 print "send_file (%s) not found." % send_file
306 if os.path.isfile(g_diff_recv_file) ==
False:
307 print "recv_file (%s) not found." % recv_file
311 f_send = open(g_diff_send_file,
'r') 312 f_recv = open(g_diff_recv_file, 'r') 315 str_send = f_send.readline() 316 str_recv = f_recv.readline() 317 if len(str_send) == 0:
326 str_send2 = str_send.rstrip(
'\n')
327 str_send2 = str_send2.rstrip(
'\r')
328 str_recv2 = str_recv.rstrip(
'\n')
329 str_recv2 = str_recv2.rstrip(
'\r')
335 list_send = str_send2.split(
" ")
336 list_recv = str_recv2.split(
" ")
337 for ic
in range(len(list_send)):
339 float_send = float(list_send[ic]);
340 float_recv = float(list_recv[ic]);
341 if float_send != float_recv:
345 if str_send2 != str_recv2:
370 for i
in range(loop_count):
380 time.sleep(sleep_connect_time)
388 fout = open(g_test_result_file,
'a')
398 time.sleep(sleep_for_time)
428 for i
in range(loop_count):
438 time.sleep(sleep_act_time)
446 if os.path.isfile(g_diff_recv_file) ==
False:
448 fout = open(g_test_result_file,
'a')
455 time.sleep(sleep_for_time)
459 time.sleep(sleep_act_time)
460 fout = open(g_test_result_file,
'a')
461 fsize=os.path.getsize(g_diff_recv_file)
477 time.sleep(sleep_for_time)
506 for i
in range(loop_count):
516 time.sleep(sleep_act_time)
524 if os.path.isfile(g_diff_recv_file) ==
False:
526 fout = open(g_test_result_file,
'a')
533 time.sleep(sleep_for_time)
537 time.sleep(sleep_act_time)
541 fout = open(g_test_result_file,
'a')
548 fout.write(message +
'\n')
555 fout.write(message +
'\n')
557 fin2 = open(g_diff_recv_file,
'r') 566 time.sleep(sleep_for_time)
589 for i
in range(loop_count):
599 time.sleep(sleep_act_time)
607 fout = open(g_test_result_file,
'a')
617 time.sleep(sleep_for_time)
639 for i
in range(loop_count):
657 time.sleep(sleep_act_time)
670 if os.path.isfile(g_diff_recv_file) ==
False:
672 fout = open(g_test_result_file,
'a')
674 fout.write(message +
'\n')
678 time.sleep(sleep_for_time)
682 time.sleep(sleep_act_time)
683 fout = open(g_test_result_file,
'a')
684 fsize=os.path.getsize(g_diff_recv_file)
700 time.sleep(sleep_for_time)
716 for i
in range(loop_count):
734 time.sleep(sleep_act_time)
748 if os.path.isfile(g_diff_recv_file) ==
False:
750 fout = open(g_test_result_file,
'a')
752 fout.write(message +
'\n')
756 time.sleep(sleep_for_time)
760 time.sleep(sleep_act_time)
764 fout = open(g_test_result_file,
'a')
771 fout.write(message +
'\n')
778 fout.write(message +
'\n')
780 fin2 = open(g_diff_recv_file,
'r') 789 time.sleep(sleep_for_time)
808 for i
in range(loop_count):
826 time.sleep(sleep_act_time)
839 if os.path.isfile(g_diff_recv_file) ==
False:
841 fout = open(g_test_result_file,
'a')
843 fout.write(message +
'\n')
847 time.sleep(sleep_for_time)
851 time.sleep(sleep_act_time)
855 fout = open(g_test_result_file,
'a')
862 fout.write(message +
'\n')
869 fout.write(message +
'\n')
871 fin2 = open(g_diff_recv_file,
'r') 880 time.sleep(sleep_for_time)
903 for i
in range(loop_count):
921 time.sleep(sleep_act_time)
934 if os.path.isfile(g_diff_recv_file) ==
False:
936 fout = open(g_test_result_file,
'a')
938 fout.write(message +
'\n')
942 time.sleep(sleep_for_time)
946 time.sleep(sleep_act_time)
947 fout = open(g_test_result_file,
'a')
948 fsize=os.path.getsize(g_diff_recv_file)
964 time.sleep(sleep_for_time)
986 for i
in range(loop_count):
1004 time.sleep(sleep_act_time)
1017 if os.path.isfile(g_diff_recv_file) ==
False:
1019 fout = open(g_test_result_file,
'a')
1021 fout.write(message +
'\n')
1025 time.sleep(sleep_for_time)
1029 time.sleep(sleep_act_time)
1030 fout = open(g_test_result_file,
'a')
1031 fsize=os.path.getsize(g_diff_recv_file)
1047 time.sleep(sleep_for_time)
1058 [ test_connect_disconnect,
1059 "Connect(out->in, flush) -> Disconnect",
1061 [ test_connect_disconnect,
1062 "Connect(in->out, flush) -> Disconnect",
1064 [ test_activate_deactivate,
1065 "Connecting(out->in, flush), Activate -> send/recv -> Deactivate",
1067 [ test_activate_deactivate,
1068 "Connecting(in->out, flush), Activate -> send/recv -> Deactivate",
1070 [ test_activate_deactivate_2,
1071 "Not Connect(out->in, flush), Activate -> Deactivate",
1074 "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect",
1077 "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect",
1079 [ test_connection_2,
1080 "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate",
1082 [ test_connection_2,
1083 "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate",
1085 [ test_connection_3,
1086 "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect",
1088 [ test_connection_3,
1089 "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect",
1091 [ test_connection_4,
1092 "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate",
1094 [ test_connection_4,
1095 "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate",
1097 [ test_connect_disconnect,
1098 "Connect(out->in, new,ALL) -> Disconnect",
1100 [ test_connect_disconnect,
1101 "Connect(out->in, new,FIFO) -> Disconnect",
1103 [ test_connect_disconnect,
1104 "Connect(out->in, new,NEW) -> Disconnect",
1106 [ test_connect_disconnect,
1107 "Connect(out->in, new,SKIP) -> Disconnect",
1109 [ test_connect_disconnect,
1110 "Connect(in->out, new,ALL) -> Disconnect",
1112 [ test_connect_disconnect,
1113 "Connect(in->out, new,FIFO) -> Disconnect",
1115 [ test_connect_disconnect,
1116 "Connect(in->out, new,NEW) -> Disconnect",
1118 [ test_connect_disconnect,
1119 "Connect(in->out, new,SKIP) -> Disconnect",
1121 [ test_activate_deactivate,
1122 "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate",
1124 [ test_activate_deactivate,
1125 "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate",
1127 [ test_activate_deactivate,
1128 "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate",
1130 [ test_activate_deactivate_2,
1131 "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate",
1133 [ test_activate_deactivate,
1134 "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate",
1136 [ test_activate_deactivate,
1137 "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate",
1139 [ test_activate_deactivate_2,
1140 "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate",
1142 [ test_activate_deactivate_2,
1143 "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate",
1146 "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect",
1149 "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect",
1151 [ test_connection_5,
1152 "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect",
1154 [ test_connection_5,
1155 "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect",
1158 "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect",
1161 "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect",
1163 [ test_connection_5,
1164 "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect",
1166 [ test_connection_5,
1167 "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect",
1169 [ test_connect_disconnect,
1170 "Connect(out->in, periodic,ALL) -> Disconnect",
1171 "periodic",
"ALL", 0 ],
1172 [ test_connect_disconnect,
1173 "Connect(out->in, periodic,FIFO) -> Disconnect",
1174 "periodic",
"FIFO", 0 ],
1175 [ test_connect_disconnect,
1176 "Connect(out->in, periodic,NEW) -> Disconnect",
1177 "periodic",
"NEW", 0 ],
1178 [ test_connect_disconnect,
1179 "Connect(out->in, periodic,SKIP) -> Disconnect",
1180 "periodic",
"SKIP", 0 ],
1181 [ test_connect_disconnect,
1182 "Connect(in->out, periodic,ALL) -> Disconnect",
1183 "periodic",
"ALL", 1 ],
1184 [ test_connect_disconnect,
1185 "Connect(in->out, periodic,FIFO) -> Disconnect",
1186 "periodic",
"FIFO", 1 ],
1187 [ test_connect_disconnect,
1188 "Connect(in->out, periodic,NEW) -> Disconnect",
1189 "periodic",
"NEW", 1 ],
1190 [ test_connect_disconnect,
1191 "Connect(in->out, periodic,SKIP) -> Disconnect",
1192 "periodic",
"SKIP", 1 ],
1193 [ test_activate_deactivate,
1194 "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate",
1195 "periodic",
"ALL", 0 ],
1196 [ test_activate_deactivate,
1197 "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate",
1198 "periodic",
"FIFO", 0 ],
1199 [ test_activate_deactivate_2,
1200 "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate",
1201 "periodic",
"NEW", 0 ],
1202 [ test_activate_deactivate_2,
1203 "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate",
1204 "periodic",
"SKIP", 0 ],
1205 [ test_activate_deactivate,
1206 "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate",
1207 "periodic",
"ALL", 1 ],
1208 [ test_activate_deactivate,
1209 "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate",
1210 "periodic",
"FIFO", 1 ],
1211 [ test_activate_deactivate_2,
1212 "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate",
1213 "periodic",
"NEW", 1 ],
1214 [ test_activate_deactivate_2,
1215 "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate",
1216 "periodic",
"SKIP", 1 ],
1218 "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect",
1219 "periodic",
"ALL", 0 ],
1221 "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect",
1222 "periodic",
"FIFO", 0 ],
1223 [ test_connection_5,
1224 "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect",
1225 "periodic",
"NEW", 0 ],
1226 [ test_connection_5,
1227 "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect",
1228 "periodic",
"SKIP", 0 ],
1230 "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect",
1231 "periodic",
"ALL", 1 ],
1233 "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect",
1234 "periodic",
"FIFO", 1 ],
1235 [ test_connection_5,
1236 "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect",
1237 "periodic",
"NEW", 1 ],
1238 [ test_connection_5,
1239 "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect",
1240 "periodic",
"SKIP", 1 ],
1257 for element
in test_table:
1260 message = g_mess_header + g_test_case
1261 message = message + element[1]
1262 message = message + g_mess_footer
1263 fout = open(g_test_result_file,
'a')
1264 fout.write(
'\n' + message)
1268 ret = element[0](message,element[2],element[3],element[4])
1271 ng_counter = ng_counter + 1
1273 result_message =
"!!!FAILURES!!!" 1276 ok_counter = ok_counter + 1
1280 print result_message
1281 print "Test Results: " 1282 print "Run:",ok_counter+ng_counter,
" Failures:", ng_counter
1284 if __name__ ==
"__main__":
def test_connection_5(message, arg0, arg1, arg2)
The connection, activate, deactivate, and cutting are repeated.
def test_activate_deactivate_2(message, arg0, arg1, arg2)
Only activation and deactivation are repeated.
def test_connect_disconnect(message, arg0, arg1, arg2)
Only the connection and cutting are repeated.
def disconnect_ports()
Disconnects ports.
def components_exit()
AutoTestOut and AutoTestIn are ended.
def initGlobal()
Initialization of global variable.
def test_connection_2(message, arg0, arg1, arg2)
def test_connection_3(message, arg0, arg1, arg2)
def components_entry()
AutoTestOut and AutoTestIn are started.
def delete_recv_file()
内部関数:受信ファイル削除
def connect_ports()
ネームサーバー定義 env = RtmEnv(sys.argv, ["localhost:2809"]) list0 = env.name_space["localhost:2809"].list_obj() env.name_space['localhost:2809'].rtc_handles.keys() ns = env.name_space['localhost:2809']
def deactivate_components()
Deactivate components.
def activate_components(sleep_recv_act_time)
Activate components.
def make_connecter_profile(subscription_type, push_policy, connect_direction)
内部関数:コネクタープロファイル設定(データポート)
def test_activate_deactivate(message, arg0, arg1, arg2)
Only activation and deactivation are repeated.
def diff_file()
内部関数:送受信ファイルのデータ比較
def test_connection_4(message, arg0, arg1, arg2)
def test_connection(message, arg0, arg1, arg2)
The connection, activate, deactivate, and cutting are repeated.