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') f_recv = open(g_diff_recv_file, 'r') 314 str_send = f_send.readline() 315 str_recv = f_recv.readline() 316 if len(str_send) == 0:
325 str_send2 = str_send.rstrip(
'\n')
326 str_send2 = str_send2.rstrip(
'\r')
327 str_recv2 = str_recv.rstrip(
'\n')
328 str_recv2 = str_recv2.rstrip(
'\r')
334 list_send = str_send2.split(
" ")
335 list_recv = str_recv2.split(
" ")
336 for ic
in range(len(list_send)):
338 float_send = float(list_send[ic]);
339 float_recv = float(list_recv[ic]);
340 if float_send != float_recv:
344 if str_send2 != str_recv2:
369 for i
in range(loop_count):
379 time.sleep(sleep_connect_time)
387 fout = open(g_test_result_file,
'a')
397 time.sleep(sleep_for_time)
427 for i
in range(loop_count):
437 time.sleep(sleep_act_time)
445 if os.path.isfile(g_diff_recv_file) ==
False:
447 fout = open(g_test_result_file,
'a')
454 time.sleep(sleep_for_time)
458 time.sleep(sleep_act_time)
459 fout = open(g_test_result_file,
'a')
460 fsize=os.path.getsize(g_diff_recv_file)
476 time.sleep(sleep_for_time)
505 for i
in range(loop_count):
515 time.sleep(sleep_act_time)
523 if os.path.isfile(g_diff_recv_file) ==
False:
525 fout = open(g_test_result_file,
'a')
532 time.sleep(sleep_for_time)
536 time.sleep(sleep_act_time)
540 fout = open(g_test_result_file,
'a')
547 fout.write(message +
'\n')
554 fout.write(message +
'\n')
556 fin2 = open(g_diff_recv_file,
'r') while(1): 564 time.sleep(sleep_for_time)
587 for i
in range(loop_count):
597 time.sleep(sleep_act_time)
605 fout = open(g_test_result_file,
'a')
615 time.sleep(sleep_for_time)
637 for i
in range(loop_count):
655 time.sleep(sleep_act_time)
668 if os.path.isfile(g_diff_recv_file) ==
False:
670 fout = open(g_test_result_file,
'a')
672 fout.write(message +
'\n')
676 time.sleep(sleep_for_time)
680 time.sleep(sleep_act_time)
681 fout = open(g_test_result_file,
'a')
682 fsize=os.path.getsize(g_diff_recv_file)
698 time.sleep(sleep_for_time)
714 for i
in range(loop_count):
732 time.sleep(sleep_act_time)
746 if os.path.isfile(g_diff_recv_file) ==
False:
748 fout = open(g_test_result_file,
'a')
750 fout.write(message +
'\n')
754 time.sleep(sleep_for_time)
758 time.sleep(sleep_act_time)
762 fout = open(g_test_result_file,
'a')
769 fout.write(message +
'\n')
776 fout.write(message +
'\n')
778 fin2 = open(g_diff_recv_file,
'r') while(1): 786 time.sleep(sleep_for_time)
805 for i
in range(loop_count):
823 time.sleep(sleep_act_time)
836 if os.path.isfile(g_diff_recv_file) ==
False:
838 fout = open(g_test_result_file,
'a')
840 fout.write(message +
'\n')
844 time.sleep(sleep_for_time)
848 time.sleep(sleep_act_time)
852 fout = open(g_test_result_file,
'a')
859 fout.write(message +
'\n')
866 fout.write(message +
'\n')
868 fin2 = open(g_diff_recv_file,
'r') while(1): 876 time.sleep(sleep_for_time)
899 for i
in range(loop_count):
917 time.sleep(sleep_act_time)
930 if os.path.isfile(g_diff_recv_file) ==
False:
932 fout = open(g_test_result_file,
'a')
934 fout.write(message +
'\n')
938 time.sleep(sleep_for_time)
942 time.sleep(sleep_act_time)
943 fout = open(g_test_result_file,
'a')
944 fsize=os.path.getsize(g_diff_recv_file)
960 time.sleep(sleep_for_time)
982 for i
in range(loop_count):
1000 time.sleep(sleep_act_time)
1013 if os.path.isfile(g_diff_recv_file) ==
False:
1015 fout = open(g_test_result_file,
'a')
1017 fout.write(message +
'\n')
1021 time.sleep(sleep_for_time)
1025 time.sleep(sleep_act_time)
1026 fout = open(g_test_result_file,
'a')
1027 fsize=os.path.getsize(g_diff_recv_file)
1043 time.sleep(sleep_for_time)
1054 [ test_connect_disconnect,
1055 "Connect(out->in, flush) -> Disconnect",
1057 [ test_connect_disconnect,
1058 "Connect(in->out, flush) -> Disconnect",
1060 [ test_activate_deactivate,
1061 "Connecting(out->in, flush), Activate -> send/recv -> Deactivate",
1063 [ test_activate_deactivate,
1064 "Connecting(in->out, flush), Activate -> send/recv -> Deactivate",
1066 [ test_activate_deactivate_2,
1067 "Not Connect(out->in, flush), Activate -> Deactivate",
1070 "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect",
1073 "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect",
1075 [ test_connection_2,
1076 "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate",
1078 [ test_connection_2,
1079 "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate",
1081 [ test_connection_3,
1082 "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect",
1084 [ test_connection_3,
1085 "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect",
1087 [ test_connection_4,
1088 "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate",
1090 [ test_connection_4,
1091 "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate",
1093 [ test_connect_disconnect,
1094 "Connect(out->in, new,ALL) -> Disconnect",
1096 [ test_connect_disconnect,
1097 "Connect(out->in, new,FIFO) -> Disconnect",
1099 [ test_connect_disconnect,
1100 "Connect(out->in, new,NEW) -> Disconnect",
1102 [ test_connect_disconnect,
1103 "Connect(out->in, new,SKIP) -> Disconnect",
1105 [ test_connect_disconnect,
1106 "Connect(in->out, new,ALL) -> Disconnect",
1108 [ test_connect_disconnect,
1109 "Connect(in->out, new,FIFO) -> Disconnect",
1111 [ test_connect_disconnect,
1112 "Connect(in->out, new,NEW) -> Disconnect",
1114 [ test_connect_disconnect,
1115 "Connect(in->out, new,SKIP) -> Disconnect",
1117 [ test_activate_deactivate,
1118 "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate",
1120 [ test_activate_deactivate,
1121 "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate",
1123 [ test_activate_deactivate,
1124 "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate",
1126 [ test_activate_deactivate_2,
1127 "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate",
1129 [ test_activate_deactivate,
1130 "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate",
1132 [ test_activate_deactivate,
1133 "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate",
1135 [ test_activate_deactivate_2,
1136 "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate",
1138 [ test_activate_deactivate_2,
1139 "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate",
1142 "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect",
1145 "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect",
1147 [ test_connection_5,
1148 "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect",
1150 [ test_connection_5,
1151 "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect",
1154 "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect",
1157 "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect",
1159 [ test_connection_5,
1160 "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect",
1162 [ test_connection_5,
1163 "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect",
1165 [ test_connect_disconnect,
1166 "Connect(out->in, periodic,ALL) -> Disconnect",
1167 "periodic",
"ALL", 0 ],
1168 [ test_connect_disconnect,
1169 "Connect(out->in, periodic,FIFO) -> Disconnect",
1170 "periodic",
"FIFO", 0 ],
1171 [ test_connect_disconnect,
1172 "Connect(out->in, periodic,NEW) -> Disconnect",
1173 "periodic",
"NEW", 0 ],
1174 [ test_connect_disconnect,
1175 "Connect(out->in, periodic,SKIP) -> Disconnect",
1176 "periodic",
"SKIP", 0 ],
1177 [ test_connect_disconnect,
1178 "Connect(in->out, periodic,ALL) -> Disconnect",
1179 "periodic",
"ALL", 1 ],
1180 [ test_connect_disconnect,
1181 "Connect(in->out, periodic,FIFO) -> Disconnect",
1182 "periodic",
"FIFO", 1 ],
1183 [ test_connect_disconnect,
1184 "Connect(in->out, periodic,NEW) -> Disconnect",
1185 "periodic",
"NEW", 1 ],
1186 [ test_connect_disconnect,
1187 "Connect(in->out, periodic,SKIP) -> Disconnect",
1188 "periodic",
"SKIP", 1 ],
1189 [ test_activate_deactivate,
1190 "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate",
1191 "periodic",
"ALL", 0 ],
1192 [ test_activate_deactivate,
1193 "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate",
1194 "periodic",
"FIFO", 0 ],
1195 [ test_activate_deactivate_2,
1196 "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate",
1197 "periodic",
"NEW", 0 ],
1198 [ test_activate_deactivate_2,
1199 "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate",
1200 "periodic",
"SKIP", 0 ],
1201 [ test_activate_deactivate,
1202 "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate",
1203 "periodic",
"ALL", 1 ],
1204 [ test_activate_deactivate,
1205 "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate",
1206 "periodic",
"FIFO", 1 ],
1207 [ test_activate_deactivate_2,
1208 "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate",
1209 "periodic",
"NEW", 1 ],
1210 [ test_activate_deactivate_2,
1211 "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate",
1212 "periodic",
"SKIP", 1 ],
1214 "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect",
1215 "periodic",
"ALL", 0 ],
1217 "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect",
1218 "periodic",
"FIFO", 0 ],
1219 [ test_connection_5,
1220 "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect",
1221 "periodic",
"NEW", 0 ],
1222 [ test_connection_5,
1223 "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect",
1224 "periodic",
"SKIP", 0 ],
1226 "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect",
1227 "periodic",
"ALL", 1 ],
1229 "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect",
1230 "periodic",
"FIFO", 1 ],
1231 [ test_connection_5,
1232 "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect",
1233 "periodic",
"NEW", 1 ],
1234 [ test_connection_5,
1235 "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect",
1236 "periodic",
"SKIP", 1 ],
1253 for element
in test_table:
1256 message = g_mess_header + g_test_case
1257 message = message + element[1]
1258 message = message + g_mess_footer
1259 fout = open(g_test_result_file,
'a')
1260 fout.write(
'\n' + message)
1264 ret = element[0](message,element[2],element[3],element[4])
1267 ng_counter = ng_counter + 1
1269 result_message =
"!!!FAILURES!!!" 1272 ok_counter = ok_counter + 1
1276 print result_message
1277 print "Test Results: " 1278 print "Run:",ok_counter+ng_counter,
" Failures:", ng_counter
1280 if __name__ ==
"__main__":
1282 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.