TestsConnection.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: euc-jp -*-
3 #
4 ## ConnectTest.py
5 
8 
9 from rtc_handle import *
10 from BasicDataType_idl import *
11 import time
12 import commands
13 import SDOPackage
14 import os
15 import sys
16 
17 ##--------------------------------------------------------------------
18 g_test_name = "<< component connection test >>"
19 
20 ##--------------------------------------------------------------------
21 ## コネクタープロファイルデフォルト定義g_interface_type1 = "corba_cdr" g_dataflow_type = "push" g_subscription_type = "flush" g_push_policy = "NEW" g_push_rate = "2000" g_skip_count = "4" #g_skip_count = "0" ## ポート番号指定 ( get_ports()より ) g_port1 = 0 g_port2 = 1 g_port3 = 2 ## データポート TimedFloat g_name1 = "out" g_connector_id1 = "001" g_data_type1 = "TimedFloat" ## データポート TimedFloatSeq g_name2 = "seqout" g_connector_id2 = "002" g_data_type2 = "TimedFloatSeq" ## サービスポート g_name3 = "MyService" g_connector_id3 = "003" g_interface_type3 = "MyService" ##-------------------------------------------------------------------- ## 送受信結果判定関連 g_diff_send_file = "./original-data" g_diff_recv_file = "./received-data" g_check_message = g_diff_recv_file + " file not found." g_test_result_file = "./ResultTest.log" g_test_case = "" g_test_cnt = "count" g_test_ok = "." g_test_ng = "F" g_test_ng_message = " < received-data >" g_mess_header = "< " g_mess_footer = " > " # テスト結果内容 # 例)ケース1、1回目 -> "<<< case1 count1 >>> OK." # 例)ケース1、2回目 -> "<<< case1 count2 >>> NG detected." ##-------------------------------------------------------------------- ## テストケース番号の初期値設定 ## 上から連番を振っている case_no = 0 ## ケース毎のテスト回数 loop_count = 1 ## 受信側activate_componentから送信側activate_componentまでのスリープ時間(秒数) sleep_recv_act_time = 1 ## activate_componentからdeactivate_componentまでのスリープ時間(秒数) sleep_act_time = 2 ## forループのスリープ時間(秒数) sleep_for_time = 1 ## connectからdisconnectまでのスリープ時間(秒数) sleep_connect_time =1 ## ネームサーバー定義 #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'] ## # @if jp # @brief ポートを接続する。 # @else # @brief Connects ports. # @endif def connect_ports(): errorFlag = True # データポート1 TimedFloat ret,porf = g_out_ports[g_port1].connect(g_conprof1) if ret!=RTC.RTC_OK: errorFlag = False # データポート2 TimedFloatSeq ret,porf = g_out_ports[g_port2].connect(g_conprof2) if ret!=RTC.RTC_OK: errorFlag = False # サービスポート MyService ret,porf = g_out_ports[g_port3].connect(g_conprof3) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief ポートを切断する。 # @else # @brief Disconnects ports. # @endif def disconnect_ports(): errorFlag = True ret = g_in_ports[g_port3].disconnect(g_conprof3.connector_id) if ret!=RTC.RTC_OK: errorFlag = False ret = g_in_ports[g_port2].disconnect(g_conprof2.connector_id) if ret!=RTC.RTC_OK: errorFlag = False ret = g_in_ports[g_port1].disconnect(g_conprof1.connector_id) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief ポートを活性化する。 # @else # @brief Activate components. # @endif def activate_components(sleep_recv_act_time): errorFlag = True ret = ec_recv[0].activate_component(g_compo_recv.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False time.sleep(sleep_recv_act_time) ret = ec_send[0].activate_component(g_compo_send.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief ポートを非活性化する。 # @else # @brief Deactivate components. # @endif def deactivate_components(): errorFlag = True ret = ec_send[0].deactivate_component(g_compo_send.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False ret = ec_recv[0].deactivate_component(g_compo_recv.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief AutoTestOut と AutoTestIn を起動させる。 # @else # @brief AutoTestOut and AutoTestIn are started. # @endif def components_entry(): global g_compo_send,g_compo_recv global ec_send,ec_recv global g_out_ports,g_in_ports global g_conprof1,g_conprof2,g_conprof3 global env os.system('./AutoTestOutComp >/dev/null 2>&1 &') os.system('./AutoTestInComp >/dev/null 2>&1 &') time.sleep(2) #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'] g_compo_send = ns.rtc_handles["AutoTestOut0.rtc"] g_compo_recv = ns.rtc_handles["AutoTestIn0.rtc"] ec_send = g_compo_send.rtc_ref.get_owned_contexts() ec_recv = g_compo_recv.rtc_ref.get_owned_contexts() g_out_ports = g_compo_send.rtc_ref.get_ports() g_in_ports = g_compo_recv.rtc_ref.get_ports() 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))]) return ## # @if jp # @brief AutoTestOut と AutoTestIn を終了させる。 # @else # @brief AutoTestOut and AutoTestIn are ended. # @endif def components_exit(): g_compo_send.rtc_ref.exit(); g_compo_recv.rtc_ref.exit(); time.sleep(1) return ## # @if jp # @brief グローバル変数の初期化 # @else # @brief Initialization of global variable # @endif def initGlobal(): global env env = RtmEnv(sys.argv, ["localhost:2809"]) return ##-------------------------------------------------------------------- ## 内部関数:コネクタープロファイル設定(データポート) ## ## (引数) ## subscription_type : "flush", "new", "periodic" ## push_policy : "ALL", "FIFO", "SKIP", "NEW", "" ## connect_direction : 0:outport -> inport, 1:inport -> outport ##-------------------------------------------------------------------- def make_connecter_profile(subscription_type, push_policy, connect_direction): global g_conprof1, g_conprof2, g_conprof3 if connect_direction == 0: ## outport -> inport Set 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))]) 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))]) #print "outport -> inport set >>>" #print "g_conprof1=",g_conprof1 #print "g_conprof2=",g_conprof2 else: ## inport -> outport Set 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))]) 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))]) #print "inport -> outport set >>>" #print "g_conprof1=",g_conprof1 #print "g_conprof2=",g_conprof2 return ##-------------------------------------------------------------------- ## 内部関数:受信ファイル削除 ## ## (引数) ## なし ##-------------------------------------------------------------------- def delete_recv_file(): ## ファイルが存在する場合 if os.path.isfile(g_diff_recv_file) == True: os.remove(g_diff_recv_file) return ##-------------------------------------------------------------------- ## 内部関数:送受信ファイルのデータ比較 ## ## (引数) ## なし ## (戻り値) True : 一致、 False : 不一致 ##-------------------------------------------------------------------- def diff_file(): bret = True ## if connect_direction == 0: ## else: ## 送信ファイル有無判定 if os.path.isfile(g_diff_send_file) == False: print "send_file (%s) not found." % send_file return False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: print "recv_file (%s) not found." % recv_file return False ## 送受信データ差分判定 f_send = open(g_diff_send_file, 'r') f_recv = open(g_diff_recv_file, 'r') while(1): str_send = f_send.readline() str_recv = f_recv.readline() if len(str_send) == 0: break #print "original send date=(%s)" % str_send #print ''.join(['%x ' % ord(s) for s in str_send]) #print "original recv date=(%s)" % str_recv #print ''.join(['%x ' % ord(s) for s in str_recv]) ## 末尾の改行、復帰コード削除 str_send2 = str_send.rstrip('\n') str_send2 = str_send2.rstrip('\r') str_recv2 = str_recv.rstrip('\n') str_recv2 = str_recv2.rstrip('\r') #print "rstrip after send date=(%s)" % str_send2 #print "rstrip after recv date=(%s)" % str_recv2 ## データ比較 list_send = str_send2.split(" ") list_recv = str_recv2.split(" ") for ic in range(len(list_send)): try: float_send = float(list_send[ic]); float_recv = float(list_recv[ic]); if float_send != float_recv: bret = False break; except: if str_send2 != str_recv2: bret = False break; f_recv.close() f_send.close() return bret ## # @if jp # @brief 接続と切断だけを繰り返す。 # # # # @else # @brief Only the connection and cutting are repeated. # # # # @endif def test_connect_disconnect(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_connect_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # データのチェックは行われない。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # Data is not checked. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
22 g_interface_type1 = "corba_cdr"
23 g_dataflow_type = "push"
24 g_subscription_type = "flush"
25 g_push_policy = "NEW"
26 g_push_rate = "2000"
27 g_skip_count = "4"
28 #g_skip_count = "0"
29 
30 ## ポート番号指定 ( get_ports()より )
31 g_port1 = 0
32 g_port2 = 1
33 g_port3 = 2
34 
35 ## データポート TimedFloat
36 g_name1 = "out"
37 g_connector_id1 = "001"
38 g_data_type1 = "TimedFloat"
39 
40 ## データポート TimedFloatSeq
41 g_name2 = "seqout"
42 g_connector_id2 = "002"
43 g_data_type2 = "TimedFloatSeq"
44 
45 ## サービスポート
46 g_name3 = "MyService"
47 g_connector_id3 = "003"
48 g_interface_type3 = "MyService"
49 
50 ##--------------------------------------------------------------------
51 ## 送受信結果判定関連
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"
56 g_test_case = ""
57 g_test_cnt = "count"
58 g_test_ok = "."
59 g_test_ng = "F"
60 g_test_ng_message = " < received-data >"
61 g_mess_header = "< "
62 g_mess_footer = " > "
63 # テスト結果内容# 例)ケース1、1回目 -> "<<< case1 count1 >>> OK." # 例)ケース1、2回目 -> "<<< case1 count2 >>> NG detected." ##-------------------------------------------------------------------- ## テストケース番号の初期値設定 ## 上から連番を振っている case_no = 0 ## ケース毎のテスト回数 loop_count = 1 ## 受信側activate_componentから送信側activate_componentまでのスリープ時間(秒数) sleep_recv_act_time = 1 ## activate_componentからdeactivate_componentまでのスリープ時間(秒数) sleep_act_time = 2 ## forループのスリープ時間(秒数) sleep_for_time = 1 ## connectからdisconnectまでのスリープ時間(秒数) sleep_connect_time =1 ## ネームサーバー定義 #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'] ## # @if jp # @brief ポートを接続する。 # @else # @brief Connects ports. # @endif def connect_ports(): errorFlag = True # データポート1 TimedFloat ret,porf = g_out_ports[g_port1].connect(g_conprof1) if ret!=RTC.RTC_OK: errorFlag = False # データポート2 TimedFloatSeq ret,porf = g_out_ports[g_port2].connect(g_conprof2) if ret!=RTC.RTC_OK: errorFlag = False # サービスポート MyService ret,porf = g_out_ports[g_port3].connect(g_conprof3) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief ポートを切断する。 # @else # @brief Disconnects ports. # @endif def disconnect_ports(): errorFlag = True ret = g_in_ports[g_port3].disconnect(g_conprof3.connector_id) if ret!=RTC.RTC_OK: errorFlag = False ret = g_in_ports[g_port2].disconnect(g_conprof2.connector_id) if ret!=RTC.RTC_OK: errorFlag = False ret = g_in_ports[g_port1].disconnect(g_conprof1.connector_id) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief ポートを活性化する。 # @else # @brief Activate components. # @endif def activate_components(sleep_recv_act_time): errorFlag = True ret = ec_recv[0].activate_component(g_compo_recv.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False time.sleep(sleep_recv_act_time) ret = ec_send[0].activate_component(g_compo_send.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief ポートを非活性化する。 # @else # @brief Deactivate components. # @endif def deactivate_components(): errorFlag = True ret = ec_send[0].deactivate_component(g_compo_send.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False ret = ec_recv[0].deactivate_component(g_compo_recv.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief AutoTestOut と AutoTestIn を起動させる。 # @else # @brief AutoTestOut and AutoTestIn are started. # @endif def components_entry(): global g_compo_send,g_compo_recv global ec_send,ec_recv global g_out_ports,g_in_ports global g_conprof1,g_conprof2,g_conprof3 global env os.system('./AutoTestOutComp >/dev/null 2>&1 &') os.system('./AutoTestInComp >/dev/null 2>&1 &') time.sleep(2) #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'] g_compo_send = ns.rtc_handles["AutoTestOut0.rtc"] g_compo_recv = ns.rtc_handles["AutoTestIn0.rtc"] ec_send = g_compo_send.rtc_ref.get_owned_contexts() ec_recv = g_compo_recv.rtc_ref.get_owned_contexts() g_out_ports = g_compo_send.rtc_ref.get_ports() g_in_ports = g_compo_recv.rtc_ref.get_ports() 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))]) return ## # @if jp # @brief AutoTestOut と AutoTestIn を終了させる。 # @else # @brief AutoTestOut and AutoTestIn are ended. # @endif def components_exit(): g_compo_send.rtc_ref.exit(); g_compo_recv.rtc_ref.exit(); time.sleep(1) return ## # @if jp # @brief グローバル変数の初期化 # @else # @brief Initialization of global variable # @endif def initGlobal(): global env env = RtmEnv(sys.argv, ["localhost:2809"]) return ##-------------------------------------------------------------------- ## 内部関数:コネクタープロファイル設定(データポート) ## ## (引数) ## subscription_type : "flush", "new", "periodic" ## push_policy : "ALL", "FIFO", "SKIP", "NEW", "" ## connect_direction : 0:outport -> inport, 1:inport -> outport ##-------------------------------------------------------------------- def make_connecter_profile(subscription_type, push_policy, connect_direction): global g_conprof1, g_conprof2, g_conprof3 if connect_direction == 0: ## outport -> inport Set 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))]) 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))]) #print "outport -> inport set >>>" #print "g_conprof1=",g_conprof1 #print "g_conprof2=",g_conprof2 else: ## inport -> outport Set 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))]) 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))]) #print "inport -> outport set >>>" #print "g_conprof1=",g_conprof1 #print "g_conprof2=",g_conprof2 return ##-------------------------------------------------------------------- ## 内部関数:受信ファイル削除 ## ## (引数) ## なし ##-------------------------------------------------------------------- def delete_recv_file(): ## ファイルが存在する場合 if os.path.isfile(g_diff_recv_file) == True: os.remove(g_diff_recv_file) return ##-------------------------------------------------------------------- ## 内部関数:送受信ファイルのデータ比較 ## ## (引数) ## なし ## (戻り値) True : 一致、 False : 不一致 ##-------------------------------------------------------------------- def diff_file(): bret = True ## if connect_direction == 0: ## else: ## 送信ファイル有無判定 if os.path.isfile(g_diff_send_file) == False: print "send_file (%s) not found." % send_file return False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: print "recv_file (%s) not found." % recv_file return False ## 送受信データ差分判定 f_send = open(g_diff_send_file, 'r') f_recv = open(g_diff_recv_file, 'r') while(1): str_send = f_send.readline() str_recv = f_recv.readline() if len(str_send) == 0: break #print "original send date=(%s)" % str_send #print ''.join(['%x ' % ord(s) for s in str_send]) #print "original recv date=(%s)" % str_recv #print ''.join(['%x ' % ord(s) for s in str_recv]) ## 末尾の改行、復帰コード削除 str_send2 = str_send.rstrip('\n') str_send2 = str_send2.rstrip('\r') str_recv2 = str_recv.rstrip('\n') str_recv2 = str_recv2.rstrip('\r') #print "rstrip after send date=(%s)" % str_send2 #print "rstrip after recv date=(%s)" % str_recv2 ## データ比較 list_send = str_send2.split(" ") list_recv = str_recv2.split(" ") for ic in range(len(list_send)): try: float_send = float(list_send[ic]); float_recv = float(list_recv[ic]); if float_send != float_recv: bret = False break; except: if str_send2 != str_recv2: bret = False break; f_recv.close() f_send.close() return bret ## # @if jp # @brief 接続と切断だけを繰り返す。 # # # # @else # @brief Only the connection and cutting are repeated. # # # # @endif def test_connect_disconnect(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_connect_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # データのチェックは行われない。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # Data is not checked. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
64 # 例)ケース1、1回目 -> "<<< case1 count1 >>> OK."
65 # 例)ケース1、2回目 -> "<<< case1 count2 >>> NG detected."
66 
67 ##--------------------------------------------------------------------
68 ## テストケース番号の初期値設定## 上から連番を振っている case_no = 0 ## ケース毎のテスト回数 loop_count = 1 ## 受信側activate_componentから送信側activate_componentまでのスリープ時間(秒数) sleep_recv_act_time = 1 ## activate_componentからdeactivate_componentまでのスリープ時間(秒数) sleep_act_time = 2 ## forループのスリープ時間(秒数) sleep_for_time = 1 ## connectからdisconnectまでのスリープ時間(秒数) sleep_connect_time =1 ## ネームサーバー定義 #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'] ## # @if jp # @brief ポートを接続する。 # @else # @brief Connects ports. # @endif def connect_ports(): errorFlag = True # データポート1 TimedFloat ret,porf = g_out_ports[g_port1].connect(g_conprof1) if ret!=RTC.RTC_OK: errorFlag = False # データポート2 TimedFloatSeq ret,porf = g_out_ports[g_port2].connect(g_conprof2) if ret!=RTC.RTC_OK: errorFlag = False # サービスポート MyService ret,porf = g_out_ports[g_port3].connect(g_conprof3) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief ポートを切断する。 # @else # @brief Disconnects ports. # @endif def disconnect_ports(): errorFlag = True ret = g_in_ports[g_port3].disconnect(g_conprof3.connector_id) if ret!=RTC.RTC_OK: errorFlag = False ret = g_in_ports[g_port2].disconnect(g_conprof2.connector_id) if ret!=RTC.RTC_OK: errorFlag = False ret = g_in_ports[g_port1].disconnect(g_conprof1.connector_id) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief ポートを活性化する。 # @else # @brief Activate components. # @endif def activate_components(sleep_recv_act_time): errorFlag = True ret = ec_recv[0].activate_component(g_compo_recv.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False time.sleep(sleep_recv_act_time) ret = ec_send[0].activate_component(g_compo_send.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief ポートを非活性化する。 # @else # @brief Deactivate components. # @endif def deactivate_components(): errorFlag = True ret = ec_send[0].deactivate_component(g_compo_send.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False ret = ec_recv[0].deactivate_component(g_compo_recv.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief AutoTestOut と AutoTestIn を起動させる。 # @else # @brief AutoTestOut and AutoTestIn are started. # @endif def components_entry(): global g_compo_send,g_compo_recv global ec_send,ec_recv global g_out_ports,g_in_ports global g_conprof1,g_conprof2,g_conprof3 global env os.system('./AutoTestOutComp >/dev/null 2>&1 &') os.system('./AutoTestInComp >/dev/null 2>&1 &') time.sleep(2) #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'] g_compo_send = ns.rtc_handles["AutoTestOut0.rtc"] g_compo_recv = ns.rtc_handles["AutoTestIn0.rtc"] ec_send = g_compo_send.rtc_ref.get_owned_contexts() ec_recv = g_compo_recv.rtc_ref.get_owned_contexts() g_out_ports = g_compo_send.rtc_ref.get_ports() g_in_ports = g_compo_recv.rtc_ref.get_ports() 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))]) return ## # @if jp # @brief AutoTestOut と AutoTestIn を終了させる。 # @else # @brief AutoTestOut and AutoTestIn are ended. # @endif def components_exit(): g_compo_send.rtc_ref.exit(); g_compo_recv.rtc_ref.exit(); time.sleep(1) return ## # @if jp # @brief グローバル変数の初期化 # @else # @brief Initialization of global variable # @endif def initGlobal(): global env env = RtmEnv(sys.argv, ["localhost:2809"]) return ##-------------------------------------------------------------------- ## 内部関数:コネクタープロファイル設定(データポート) ## ## (引数) ## subscription_type : "flush", "new", "periodic" ## push_policy : "ALL", "FIFO", "SKIP", "NEW", "" ## connect_direction : 0:outport -> inport, 1:inport -> outport ##-------------------------------------------------------------------- def make_connecter_profile(subscription_type, push_policy, connect_direction): global g_conprof1, g_conprof2, g_conprof3 if connect_direction == 0: ## outport -> inport Set 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))]) 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))]) #print "outport -> inport set >>>" #print "g_conprof1=",g_conprof1 #print "g_conprof2=",g_conprof2 else: ## inport -> outport Set 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))]) 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))]) #print "inport -> outport set >>>" #print "g_conprof1=",g_conprof1 #print "g_conprof2=",g_conprof2 return ##-------------------------------------------------------------------- ## 内部関数:受信ファイル削除 ## ## (引数) ## なし ##-------------------------------------------------------------------- def delete_recv_file(): ## ファイルが存在する場合 if os.path.isfile(g_diff_recv_file) == True: os.remove(g_diff_recv_file) return ##-------------------------------------------------------------------- ## 内部関数:送受信ファイルのデータ比較 ## ## (引数) ## なし ## (戻り値) True : 一致、 False : 不一致 ##-------------------------------------------------------------------- def diff_file(): bret = True ## if connect_direction == 0: ## else: ## 送信ファイル有無判定 if os.path.isfile(g_diff_send_file) == False: print "send_file (%s) not found." % send_file return False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: print "recv_file (%s) not found." % recv_file return False ## 送受信データ差分判定 f_send = open(g_diff_send_file, 'r') f_recv = open(g_diff_recv_file, 'r') while(1): str_send = f_send.readline() str_recv = f_recv.readline() if len(str_send) == 0: break #print "original send date=(%s)" % str_send #print ''.join(['%x ' % ord(s) for s in str_send]) #print "original recv date=(%s)" % str_recv #print ''.join(['%x ' % ord(s) for s in str_recv]) ## 末尾の改行、復帰コード削除 str_send2 = str_send.rstrip('\n') str_send2 = str_send2.rstrip('\r') str_recv2 = str_recv.rstrip('\n') str_recv2 = str_recv2.rstrip('\r') #print "rstrip after send date=(%s)" % str_send2 #print "rstrip after recv date=(%s)" % str_recv2 ## データ比較 list_send = str_send2.split(" ") list_recv = str_recv2.split(" ") for ic in range(len(list_send)): try: float_send = float(list_send[ic]); float_recv = float(list_recv[ic]); if float_send != float_recv: bret = False break; except: if str_send2 != str_recv2: bret = False break; f_recv.close() f_send.close() return bret ## # @if jp # @brief 接続と切断だけを繰り返す。 # # # # @else # @brief Only the connection and cutting are repeated. # # # # @endif def test_connect_disconnect(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_connect_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # データのチェックは行われない。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # Data is not checked. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
69 ## 上から連番を振っているcase_no = 0 ## ケース毎のテスト回数 loop_count = 1 ## 受信側activate_componentから送信側activate_componentまでのスリープ時間(秒数) sleep_recv_act_time = 1 ## activate_componentからdeactivate_componentまでのスリープ時間(秒数) sleep_act_time = 2 ## forループのスリープ時間(秒数) sleep_for_time = 1 ## connectからdisconnectまでのスリープ時間(秒数) sleep_connect_time =1 ## ネームサーバー定義 #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'] ## # @if jp # @brief ポートを接続する。 # @else # @brief Connects ports. # @endif def connect_ports(): errorFlag = True # データポート1 TimedFloat ret,porf = g_out_ports[g_port1].connect(g_conprof1) if ret!=RTC.RTC_OK: errorFlag = False # データポート2 TimedFloatSeq ret,porf = g_out_ports[g_port2].connect(g_conprof2) if ret!=RTC.RTC_OK: errorFlag = False # サービスポート MyService ret,porf = g_out_ports[g_port3].connect(g_conprof3) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief ポートを切断する。 # @else # @brief Disconnects ports. # @endif def disconnect_ports(): errorFlag = True ret = g_in_ports[g_port3].disconnect(g_conprof3.connector_id) if ret!=RTC.RTC_OK: errorFlag = False ret = g_in_ports[g_port2].disconnect(g_conprof2.connector_id) if ret!=RTC.RTC_OK: errorFlag = False ret = g_in_ports[g_port1].disconnect(g_conprof1.connector_id) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief ポートを活性化する。 # @else # @brief Activate components. # @endif def activate_components(sleep_recv_act_time): errorFlag = True ret = ec_recv[0].activate_component(g_compo_recv.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False time.sleep(sleep_recv_act_time) ret = ec_send[0].activate_component(g_compo_send.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief ポートを非活性化する。 # @else # @brief Deactivate components. # @endif def deactivate_components(): errorFlag = True ret = ec_send[0].deactivate_component(g_compo_send.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False ret = ec_recv[0].deactivate_component(g_compo_recv.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief AutoTestOut と AutoTestIn を起動させる。 # @else # @brief AutoTestOut and AutoTestIn are started. # @endif def components_entry(): global g_compo_send,g_compo_recv global ec_send,ec_recv global g_out_ports,g_in_ports global g_conprof1,g_conprof2,g_conprof3 global env os.system('./AutoTestOutComp >/dev/null 2>&1 &') os.system('./AutoTestInComp >/dev/null 2>&1 &') time.sleep(2) #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'] g_compo_send = ns.rtc_handles["AutoTestOut0.rtc"] g_compo_recv = ns.rtc_handles["AutoTestIn0.rtc"] ec_send = g_compo_send.rtc_ref.get_owned_contexts() ec_recv = g_compo_recv.rtc_ref.get_owned_contexts() g_out_ports = g_compo_send.rtc_ref.get_ports() g_in_ports = g_compo_recv.rtc_ref.get_ports() 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))]) return ## # @if jp # @brief AutoTestOut と AutoTestIn を終了させる。 # @else # @brief AutoTestOut and AutoTestIn are ended. # @endif def components_exit(): g_compo_send.rtc_ref.exit(); g_compo_recv.rtc_ref.exit(); time.sleep(1) return ## # @if jp # @brief グローバル変数の初期化 # @else # @brief Initialization of global variable # @endif def initGlobal(): global env env = RtmEnv(sys.argv, ["localhost:2809"]) return ##-------------------------------------------------------------------- ## 内部関数:コネクタープロファイル設定(データポート) ## ## (引数) ## subscription_type : "flush", "new", "periodic" ## push_policy : "ALL", "FIFO", "SKIP", "NEW", "" ## connect_direction : 0:outport -> inport, 1:inport -> outport ##-------------------------------------------------------------------- def make_connecter_profile(subscription_type, push_policy, connect_direction): global g_conprof1, g_conprof2, g_conprof3 if connect_direction == 0: ## outport -> inport Set 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))]) 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))]) #print "outport -> inport set >>>" #print "g_conprof1=",g_conprof1 #print "g_conprof2=",g_conprof2 else: ## inport -> outport Set 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))]) 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))]) #print "inport -> outport set >>>" #print "g_conprof1=",g_conprof1 #print "g_conprof2=",g_conprof2 return ##-------------------------------------------------------------------- ## 内部関数:受信ファイル削除 ## ## (引数) ## なし ##-------------------------------------------------------------------- def delete_recv_file(): ## ファイルが存在する場合 if os.path.isfile(g_diff_recv_file) == True: os.remove(g_diff_recv_file) return ##-------------------------------------------------------------------- ## 内部関数:送受信ファイルのデータ比較 ## ## (引数) ## なし ## (戻り値) True : 一致、 False : 不一致 ##-------------------------------------------------------------------- def diff_file(): bret = True ## if connect_direction == 0: ## else: ## 送信ファイル有無判定 if os.path.isfile(g_diff_send_file) == False: print "send_file (%s) not found." % send_file return False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: print "recv_file (%s) not found." % recv_file return False ## 送受信データ差分判定 f_send = open(g_diff_send_file, 'r') f_recv = open(g_diff_recv_file, 'r') while(1): str_send = f_send.readline() str_recv = f_recv.readline() if len(str_send) == 0: break #print "original send date=(%s)" % str_send #print ''.join(['%x ' % ord(s) for s in str_send]) #print "original recv date=(%s)" % str_recv #print ''.join(['%x ' % ord(s) for s in str_recv]) ## 末尾の改行、復帰コード削除 str_send2 = str_send.rstrip('\n') str_send2 = str_send2.rstrip('\r') str_recv2 = str_recv.rstrip('\n') str_recv2 = str_recv2.rstrip('\r') #print "rstrip after send date=(%s)" % str_send2 #print "rstrip after recv date=(%s)" % str_recv2 ## データ比較 list_send = str_send2.split(" ") list_recv = str_recv2.split(" ") for ic in range(len(list_send)): try: float_send = float(list_send[ic]); float_recv = float(list_recv[ic]); if float_send != float_recv: bret = False break; except: if str_send2 != str_recv2: bret = False break; f_recv.close() f_send.close() return bret ## # @if jp # @brief 接続と切断だけを繰り返す。 # # # # @else # @brief Only the connection and cutting are repeated. # # # # @endif def test_connect_disconnect(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_connect_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # データのチェックは行われない。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # Data is not checked. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
70 case_no = 0
71 
72 ## ケース毎のテスト回数loop_count = 1 ## 受信側activate_componentから送信側activate_componentまでのスリープ時間(秒数) sleep_recv_act_time = 1 ## activate_componentからdeactivate_componentまでのスリープ時間(秒数) sleep_act_time = 2 ## forループのスリープ時間(秒数) sleep_for_time = 1 ## connectからdisconnectまでのスリープ時間(秒数) sleep_connect_time =1 ## ネームサーバー定義 #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'] ## # @if jp # @brief ポートを接続する。 # @else # @brief Connects ports. # @endif def connect_ports(): errorFlag = True # データポート1 TimedFloat ret,porf = g_out_ports[g_port1].connect(g_conprof1) if ret!=RTC.RTC_OK: errorFlag = False # データポート2 TimedFloatSeq ret,porf = g_out_ports[g_port2].connect(g_conprof2) if ret!=RTC.RTC_OK: errorFlag = False # サービスポート MyService ret,porf = g_out_ports[g_port3].connect(g_conprof3) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief ポートを切断する。 # @else # @brief Disconnects ports. # @endif def disconnect_ports(): errorFlag = True ret = g_in_ports[g_port3].disconnect(g_conprof3.connector_id) if ret!=RTC.RTC_OK: errorFlag = False ret = g_in_ports[g_port2].disconnect(g_conprof2.connector_id) if ret!=RTC.RTC_OK: errorFlag = False ret = g_in_ports[g_port1].disconnect(g_conprof1.connector_id) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief ポートを活性化する。 # @else # @brief Activate components. # @endif def activate_components(sleep_recv_act_time): errorFlag = True ret = ec_recv[0].activate_component(g_compo_recv.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False time.sleep(sleep_recv_act_time) ret = ec_send[0].activate_component(g_compo_send.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief ポートを非活性化する。 # @else # @brief Deactivate components. # @endif def deactivate_components(): errorFlag = True ret = ec_send[0].deactivate_component(g_compo_send.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False ret = ec_recv[0].deactivate_component(g_compo_recv.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief AutoTestOut と AutoTestIn を起動させる。 # @else # @brief AutoTestOut and AutoTestIn are started. # @endif def components_entry(): global g_compo_send,g_compo_recv global ec_send,ec_recv global g_out_ports,g_in_ports global g_conprof1,g_conprof2,g_conprof3 global env os.system('./AutoTestOutComp >/dev/null 2>&1 &') os.system('./AutoTestInComp >/dev/null 2>&1 &') time.sleep(2) #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'] g_compo_send = ns.rtc_handles["AutoTestOut0.rtc"] g_compo_recv = ns.rtc_handles["AutoTestIn0.rtc"] ec_send = g_compo_send.rtc_ref.get_owned_contexts() ec_recv = g_compo_recv.rtc_ref.get_owned_contexts() g_out_ports = g_compo_send.rtc_ref.get_ports() g_in_ports = g_compo_recv.rtc_ref.get_ports() 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))]) return ## # @if jp # @brief AutoTestOut と AutoTestIn を終了させる。 # @else # @brief AutoTestOut and AutoTestIn are ended. # @endif def components_exit(): g_compo_send.rtc_ref.exit(); g_compo_recv.rtc_ref.exit(); time.sleep(1) return ## # @if jp # @brief グローバル変数の初期化 # @else # @brief Initialization of global variable # @endif def initGlobal(): global env env = RtmEnv(sys.argv, ["localhost:2809"]) return ##-------------------------------------------------------------------- ## 内部関数:コネクタープロファイル設定(データポート) ## ## (引数) ## subscription_type : "flush", "new", "periodic" ## push_policy : "ALL", "FIFO", "SKIP", "NEW", "" ## connect_direction : 0:outport -> inport, 1:inport -> outport ##-------------------------------------------------------------------- def make_connecter_profile(subscription_type, push_policy, connect_direction): global g_conprof1, g_conprof2, g_conprof3 if connect_direction == 0: ## outport -> inport Set 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))]) 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))]) #print "outport -> inport set >>>" #print "g_conprof1=",g_conprof1 #print "g_conprof2=",g_conprof2 else: ## inport -> outport Set 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))]) 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))]) #print "inport -> outport set >>>" #print "g_conprof1=",g_conprof1 #print "g_conprof2=",g_conprof2 return ##-------------------------------------------------------------------- ## 内部関数:受信ファイル削除 ## ## (引数) ## なし ##-------------------------------------------------------------------- def delete_recv_file(): ## ファイルが存在する場合 if os.path.isfile(g_diff_recv_file) == True: os.remove(g_diff_recv_file) return ##-------------------------------------------------------------------- ## 内部関数:送受信ファイルのデータ比較 ## ## (引数) ## なし ## (戻り値) True : 一致、 False : 不一致 ##-------------------------------------------------------------------- def diff_file(): bret = True ## if connect_direction == 0: ## else: ## 送信ファイル有無判定 if os.path.isfile(g_diff_send_file) == False: print "send_file (%s) not found." % send_file return False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: print "recv_file (%s) not found." % recv_file return False ## 送受信データ差分判定 f_send = open(g_diff_send_file, 'r') f_recv = open(g_diff_recv_file, 'r') while(1): str_send = f_send.readline() str_recv = f_recv.readline() if len(str_send) == 0: break #print "original send date=(%s)" % str_send #print ''.join(['%x ' % ord(s) for s in str_send]) #print "original recv date=(%s)" % str_recv #print ''.join(['%x ' % ord(s) for s in str_recv]) ## 末尾の改行、復帰コード削除 str_send2 = str_send.rstrip('\n') str_send2 = str_send2.rstrip('\r') str_recv2 = str_recv.rstrip('\n') str_recv2 = str_recv2.rstrip('\r') #print "rstrip after send date=(%s)" % str_send2 #print "rstrip after recv date=(%s)" % str_recv2 ## データ比較 list_send = str_send2.split(" ") list_recv = str_recv2.split(" ") for ic in range(len(list_send)): try: float_send = float(list_send[ic]); float_recv = float(list_recv[ic]); if float_send != float_recv: bret = False break; except: if str_send2 != str_recv2: bret = False break; f_recv.close() f_send.close() return bret ## # @if jp # @brief 接続と切断だけを繰り返す。 # # # # @else # @brief Only the connection and cutting are repeated. # # # # @endif def test_connect_disconnect(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_connect_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # データのチェックは行われない。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # Data is not checked. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
73 loop_count = 1
74 
75 ## 受信側activate_componentから送信側activate_componentまでのスリープ時間(秒数)
76 sleep_recv_act_time = 1
77 
78 ## activate_componentからdeactivate_componentまでのスリープ時間(秒数)
79 sleep_act_time = 2
80 
81 ## forループのスリープ時間(秒数)
82 sleep_for_time = 1
83 
84 ## connectからdisconnectまでのスリープ時間(秒数)
85 sleep_connect_time =1
86 
87 
88 ## ネームサーバー定義#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'] ## # @if jp # @brief ポートを接続する。 # @else # @brief Connects ports. # @endif def connect_ports(): errorFlag = True # データポート1 TimedFloat ret,porf = g_out_ports[g_port1].connect(g_conprof1) if ret!=RTC.RTC_OK: errorFlag = False # データポート2 TimedFloatSeq ret,porf = g_out_ports[g_port2].connect(g_conprof2) if ret!=RTC.RTC_OK: errorFlag = False # サービスポート MyService ret,porf = g_out_ports[g_port3].connect(g_conprof3) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief ポートを切断する。 # @else # @brief Disconnects ports. # @endif def disconnect_ports(): errorFlag = True ret = g_in_ports[g_port3].disconnect(g_conprof3.connector_id) if ret!=RTC.RTC_OK: errorFlag = False ret = g_in_ports[g_port2].disconnect(g_conprof2.connector_id) if ret!=RTC.RTC_OK: errorFlag = False ret = g_in_ports[g_port1].disconnect(g_conprof1.connector_id) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief ポートを活性化する。 # @else # @brief Activate components. # @endif def activate_components(sleep_recv_act_time): errorFlag = True ret = ec_recv[0].activate_component(g_compo_recv.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False time.sleep(sleep_recv_act_time) ret = ec_send[0].activate_component(g_compo_send.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief ポートを非活性化する。 # @else # @brief Deactivate components. # @endif def deactivate_components(): errorFlag = True ret = ec_send[0].deactivate_component(g_compo_send.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False ret = ec_recv[0].deactivate_component(g_compo_recv.rtc_ref) if ret!=RTC.RTC_OK: errorFlag = False return errorFlag ## # @if jp # @brief AutoTestOut と AutoTestIn を起動させる。 # @else # @brief AutoTestOut and AutoTestIn are started. # @endif def components_entry(): global g_compo_send,g_compo_recv global ec_send,ec_recv global g_out_ports,g_in_ports global g_conprof1,g_conprof2,g_conprof3 global env os.system('./AutoTestOutComp >/dev/null 2>&1 &') os.system('./AutoTestInComp >/dev/null 2>&1 &') time.sleep(2) #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'] g_compo_send = ns.rtc_handles["AutoTestOut0.rtc"] g_compo_recv = ns.rtc_handles["AutoTestIn0.rtc"] ec_send = g_compo_send.rtc_ref.get_owned_contexts() ec_recv = g_compo_recv.rtc_ref.get_owned_contexts() g_out_ports = g_compo_send.rtc_ref.get_ports() g_in_ports = g_compo_recv.rtc_ref.get_ports() 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))]) return ## # @if jp # @brief AutoTestOut と AutoTestIn を終了させる。 # @else # @brief AutoTestOut and AutoTestIn are ended. # @endif def components_exit(): g_compo_send.rtc_ref.exit(); g_compo_recv.rtc_ref.exit(); time.sleep(1) return ## # @if jp # @brief グローバル変数の初期化 # @else # @brief Initialization of global variable # @endif def initGlobal(): global env env = RtmEnv(sys.argv, ["localhost:2809"]) return ##-------------------------------------------------------------------- ## 内部関数:コネクタープロファイル設定(データポート) ## ## (引数) ## subscription_type : "flush", "new", "periodic" ## push_policy : "ALL", "FIFO", "SKIP", "NEW", "" ## connect_direction : 0:outport -> inport, 1:inport -> outport ##-------------------------------------------------------------------- def make_connecter_profile(subscription_type, push_policy, connect_direction): global g_conprof1, g_conprof2, g_conprof3 if connect_direction == 0: ## outport -> inport Set 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))]) 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))]) #print "outport -> inport set >>>" #print "g_conprof1=",g_conprof1 #print "g_conprof2=",g_conprof2 else: ## inport -> outport Set 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))]) 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))]) #print "inport -> outport set >>>" #print "g_conprof1=",g_conprof1 #print "g_conprof2=",g_conprof2 return ##-------------------------------------------------------------------- ## 内部関数:受信ファイル削除 ## ## (引数) ## なし ##-------------------------------------------------------------------- def delete_recv_file(): ## ファイルが存在する場合 if os.path.isfile(g_diff_recv_file) == True: os.remove(g_diff_recv_file) return ##-------------------------------------------------------------------- ## 内部関数:送受信ファイルのデータ比較 ## ## (引数) ## なし ## (戻り値) True : 一致、 False : 不一致 ##-------------------------------------------------------------------- def diff_file(): bret = True ## if connect_direction == 0: ## else: ## 送信ファイル有無判定 if os.path.isfile(g_diff_send_file) == False: print "send_file (%s) not found." % send_file return False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: print "recv_file (%s) not found." % recv_file return False ## 送受信データ差分判定 f_send = open(g_diff_send_file, 'r') f_recv = open(g_diff_recv_file, 'r') while(1): str_send = f_send.readline() str_recv = f_recv.readline() if len(str_send) == 0: break #print "original send date=(%s)" % str_send #print ''.join(['%x ' % ord(s) for s in str_send]) #print "original recv date=(%s)" % str_recv #print ''.join(['%x ' % ord(s) for s in str_recv]) ## 末尾の改行、復帰コード削除 str_send2 = str_send.rstrip('\n') str_send2 = str_send2.rstrip('\r') str_recv2 = str_recv.rstrip('\n') str_recv2 = str_recv2.rstrip('\r') #print "rstrip after send date=(%s)" % str_send2 #print "rstrip after recv date=(%s)" % str_recv2 ## データ比較 list_send = str_send2.split(" ") list_recv = str_recv2.split(" ") for ic in range(len(list_send)): try: float_send = float(list_send[ic]); float_recv = float(list_recv[ic]); if float_send != float_recv: bret = False break; except: if str_send2 != str_recv2: bret = False break; f_recv.close() f_send.close() return bret ## # @if jp # @brief 接続と切断だけを繰り返す。 # # # # @else # @brief Only the connection and cutting are repeated. # # # # @endif def test_connect_disconnect(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_connect_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # データのチェックは行われない。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # Data is not checked. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
89 #env = RtmEnv(sys.argv, ["localhost:2809"])
90 #list0 = env.name_space["localhost:2809"].list_obj()
91 #env.name_space['localhost:2809'].rtc_handles.keys()
92 #ns = env.name_space['localhost:2809']
93 
94 
101 
102  errorFlag = True
103 
104  # データポート1 TimedFloat
105  ret,porf = g_out_ports[g_port1].connect(g_conprof1)
106  if ret!=RTC.RTC_OK:
107  errorFlag = False
108 
109  # データポート2 TimedFloatSeq
110  ret,porf = g_out_ports[g_port2].connect(g_conprof2)
111  if ret!=RTC.RTC_OK:
112  errorFlag = False
113 
114  # サービスポート MyService
115  ret,porf = g_out_ports[g_port3].connect(g_conprof3)
116  if ret!=RTC.RTC_OK:
117  errorFlag = False
118 
119 
120  return errorFlag
121 
128 
129  errorFlag = True
130 
131  ret = g_in_ports[g_port3].disconnect(g_conprof3.connector_id)
132  if ret!=RTC.RTC_OK:
133  errorFlag = False
134  ret = g_in_ports[g_port2].disconnect(g_conprof2.connector_id)
135  if ret!=RTC.RTC_OK:
136  errorFlag = False
137  ret = g_in_ports[g_port1].disconnect(g_conprof1.connector_id)
138  if ret!=RTC.RTC_OK:
139  errorFlag = False
140 
141  return errorFlag
142 
143 
149 def activate_components(sleep_recv_act_time):
150  errorFlag = True
151 
152  ret = ec_recv[0].activate_component(g_compo_recv.rtc_ref)
153  if ret!=RTC.RTC_OK:
154  errorFlag = False
155 
156  time.sleep(sleep_recv_act_time)
157 
158  ret = ec_send[0].activate_component(g_compo_send.rtc_ref)
159 
160  if ret!=RTC.RTC_OK:
161  errorFlag = False
162 
163  return errorFlag
164 
171  errorFlag = True
172 
173  ret = ec_send[0].deactivate_component(g_compo_send.rtc_ref)
174  if ret!=RTC.RTC_OK:
175  errorFlag = False
176  ret = ec_recv[0].deactivate_component(g_compo_recv.rtc_ref)
177  if ret!=RTC.RTC_OK:
178  errorFlag = False
179 
180  return errorFlag
181 
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
192  global env
193 
194  os.system('./AutoTestOutComp >/dev/null 2>&1 &')
195  os.system('./AutoTestInComp >/dev/null 2>&1 &')
196 
197  time.sleep(2)
198 
199  #env = RtmEnv(sys.argv, ["localhost:2809"])
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']
203 
204  g_compo_send = ns.rtc_handles["AutoTestOut0.rtc"]
205  g_compo_recv = ns.rtc_handles["AutoTestIn0.rtc"]
206 
207  ec_send = g_compo_send.rtc_ref.get_owned_contexts()
208  ec_recv = g_compo_recv.rtc_ref.get_owned_contexts()
209 
210  g_out_ports = g_compo_send.rtc_ref.get_ports()
211  g_in_ports = g_compo_recv.rtc_ref.get_ports()
212 
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))])
214 
215  return
216 
217 
224  g_compo_send.rtc_ref.exit();
225  g_compo_recv.rtc_ref.exit();
226 
227  time.sleep(1)
228  return
229 
230 
237  global env
238 
239  env = RtmEnv(sys.argv, ["localhost:2809"])
240 
241  return
242 
243 ##--------------------------------------------------------------------
244 ## 内部関数:コネクタープロファイル設定(データポート)
245 
251 def make_connecter_profile(subscription_type, push_policy, connect_direction):
252  global g_conprof1, g_conprof2, g_conprof3
253 
254  if connect_direction == 0:
255  ## outport -> inport Set
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))])
257 
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))])
259 
260  #print "outport -> inport set >>>"
261  #print "g_conprof1=",g_conprof1
262  #print "g_conprof2=",g_conprof2
263  else:
264  ## inport -> outport Set
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))])
266 
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))])
268 
269  #print "inport -> outport set >>>"
270  #print "g_conprof1=",g_conprof1
271  #print "g_conprof2=",g_conprof2
272  return
273 
274 
275 ##--------------------------------------------------------------------
276 ## 内部関数:受信ファイル削除## ## (引数) ## なし ##-------------------------------------------------------------------- def delete_recv_file(): ## ファイルが存在する場合 if os.path.isfile(g_diff_recv_file) == True: os.remove(g_diff_recv_file) return ##-------------------------------------------------------------------- ## 内部関数:送受信ファイルのデータ比較 ## ## (引数) ## なし ## (戻り値) True : 一致、 False : 不一致 ##-------------------------------------------------------------------- def diff_file(): bret = True ## if connect_direction == 0: ## else: ## 送信ファイル有無判定 if os.path.isfile(g_diff_send_file) == False: print "send_file (%s) not found." % send_file return False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: print "recv_file (%s) not found." % recv_file return False ## 送受信データ差分判定 f_send = open(g_diff_send_file, 'r') f_recv = open(g_diff_recv_file, 'r') while(1): str_send = f_send.readline() str_recv = f_recv.readline() if len(str_send) == 0: break #print "original send date=(%s)" % str_send #print ''.join(['%x ' % ord(s) for s in str_send]) #print "original recv date=(%s)" % str_recv #print ''.join(['%x ' % ord(s) for s in str_recv]) ## 末尾の改行、復帰コード削除 str_send2 = str_send.rstrip('\n') str_send2 = str_send2.rstrip('\r') str_recv2 = str_recv.rstrip('\n') str_recv2 = str_recv2.rstrip('\r') #print "rstrip after send date=(%s)" % str_send2 #print "rstrip after recv date=(%s)" % str_recv2 ## データ比較 list_send = str_send2.split(" ") list_recv = str_recv2.split(" ") for ic in range(len(list_send)): try: float_send = float(list_send[ic]); float_recv = float(list_recv[ic]); if float_send != float_recv: bret = False break; except: if str_send2 != str_recv2: bret = False break; f_recv.close() f_send.close() return bret ## # @if jp # @brief 接続と切断だけを繰り返す。 # # # # @else # @brief Only the connection and cutting are repeated. # # # # @endif def test_connect_disconnect(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_connect_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # データのチェックは行われない。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # Data is not checked. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
277 
282  ## ファイルが存在する場合 if os.path.isfile(g_diff_recv_file) == True: os.remove(g_diff_recv_file) return ##-------------------------------------------------------------------- ## 内部関数:送受信ファイルのデータ比較 ## ## (引数) ## なし ## (戻り値) True : 一致、 False : 不一致 ##-------------------------------------------------------------------- def diff_file(): bret = True ## if connect_direction == 0: ## else: ## 送信ファイル有無判定 if os.path.isfile(g_diff_send_file) == False: print "send_file (%s) not found." % send_file return False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: print "recv_file (%s) not found." % recv_file return False ## 送受信データ差分判定 f_send = open(g_diff_send_file, 'r') f_recv = open(g_diff_recv_file, 'r') while(1): str_send = f_send.readline() str_recv = f_recv.readline() if len(str_send) == 0: break #print "original send date=(%s)" % str_send #print ''.join(['%x ' % ord(s) for s in str_send]) #print "original recv date=(%s)" % str_recv #print ''.join(['%x ' % ord(s) for s in str_recv]) ## 末尾の改行、復帰コード削除 str_send2 = str_send.rstrip('\n') str_send2 = str_send2.rstrip('\r') str_recv2 = str_recv.rstrip('\n') str_recv2 = str_recv2.rstrip('\r') #print "rstrip after send date=(%s)" % str_send2 #print "rstrip after recv date=(%s)" % str_recv2 ## データ比較 list_send = str_send2.split(" ") list_recv = str_recv2.split(" ") for ic in range(len(list_send)): try: float_send = float(list_send[ic]); float_recv = float(list_recv[ic]); if float_send != float_recv: bret = False break; except: if str_send2 != str_recv2: bret = False break; f_recv.close() f_send.close() return bret ## # @if jp # @brief 接続と切断だけを繰り返す。 # # # # @else # @brief Only the connection and cutting are repeated. # # # # @endif def test_connect_disconnect(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_connect_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # データのチェックは行われない。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # Data is not checked. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
283  if os.path.isfile(g_diff_recv_file) == True:
284  os.remove(g_diff_recv_file)
285  return
286 
287 
288 ##--------------------------------------------------------------------
289 ## 内部関数:送受信ファイルのデータ比較## ## (引数) ## なし ## (戻り値) True : 一致、 False : 不一致 ##-------------------------------------------------------------------- def diff_file(): bret = True ## if connect_direction == 0: ## else: ## 送信ファイル有無判定 if os.path.isfile(g_diff_send_file) == False: print "send_file (%s) not found." % send_file return False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: print "recv_file (%s) not found." % recv_file return False ## 送受信データ差分判定 f_send = open(g_diff_send_file, 'r') f_recv = open(g_diff_recv_file, 'r') while(1): str_send = f_send.readline() str_recv = f_recv.readline() if len(str_send) == 0: break #print "original send date=(%s)" % str_send #print ''.join(['%x ' % ord(s) for s in str_send]) #print "original recv date=(%s)" % str_recv #print ''.join(['%x ' % ord(s) for s in str_recv]) ## 末尾の改行、復帰コード削除 str_send2 = str_send.rstrip('\n') str_send2 = str_send2.rstrip('\r') str_recv2 = str_recv.rstrip('\n') str_recv2 = str_recv2.rstrip('\r') #print "rstrip after send date=(%s)" % str_send2 #print "rstrip after recv date=(%s)" % str_recv2 ## データ比較 list_send = str_send2.split(" ") list_recv = str_recv2.split(" ") for ic in range(len(list_send)): try: float_send = float(list_send[ic]); float_recv = float(list_recv[ic]); if float_send != float_recv: bret = False break; except: if str_send2 != str_recv2: bret = False break; f_recv.close() f_send.close() return bret ## # @if jp # @brief 接続と切断だけを繰り返す。 # # # # @else # @brief Only the connection and cutting are repeated. # # # # @endif def test_connect_disconnect(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_connect_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # データのチェックは行われない。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # Data is not checked. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
290 
295 def diff_file():
296  bret = True
297 
298  ## if connect_direction == 0:
299  ## else:
300  ## 送信ファイル有無判定
301  if os.path.isfile(g_diff_send_file) == False:
302  print "send_file (%s) not found." % send_file
303  return False
304 
305  ## 受信ファイル有無判定
306  if os.path.isfile(g_diff_recv_file) == False:
307  print "recv_file (%s) not found." % recv_file
308  return False
309 
310  ## 送受信データ差分判定
311  f_send = open(g_diff_send_file, 'r')
312  f_recv = open(g_diff_recv_file, 'r')
313 
314  while(1):
315  str_send = f_send.readline()
316  str_recv = f_recv.readline()
317  if len(str_send) == 0:
318  break
319 
320  #print "original send date=(%s)" % str_send
321  #print ''.join(['%x ' % ord(s) for s in str_send])
322  #print "original recv date=(%s)" % str_recv
323  #print ''.join(['%x ' % ord(s) for s in str_recv])
324 
325  ## 末尾の改行、復帰コード削除 str_send2 = str_send.rstrip('\n') str_send2 = str_send2.rstrip('\r') str_recv2 = str_recv.rstrip('\n') str_recv2 = str_recv2.rstrip('\r') #print "rstrip after send date=(%s)" % str_send2 #print "rstrip after recv date=(%s)" % str_recv2 ## データ比較 list_send = str_send2.split(" ") list_recv = str_recv2.split(" ") for ic in range(len(list_send)): try: float_send = float(list_send[ic]); float_recv = float(list_recv[ic]); if float_send != float_recv: bret = False break; except: if str_send2 != str_recv2: bret = False break; f_recv.close() f_send.close() return bret ## # @if jp # @brief 接続と切断だけを繰り返す。 # # # # @else # @brief Only the connection and cutting are repeated. # # # # @endif def test_connect_disconnect(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_connect_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # データのチェックは行われない。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # Data is not checked. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
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')
330 
331  #print "rstrip after send date=(%s)" % str_send2
332  #print "rstrip after recv date=(%s)" % str_recv2
333 
334  ## データ比較 list_send = str_send2.split(" ") list_recv = str_recv2.split(" ") for ic in range(len(list_send)): try: float_send = float(list_send[ic]); float_recv = float(list_recv[ic]); if float_send != float_recv: bret = False break; except: if str_send2 != str_recv2: bret = False break; f_recv.close() f_send.close() return bret ## # @if jp # @brief 接続と切断だけを繰り返す。 # # # # @else # @brief Only the connection and cutting are repeated. # # # # @endif def test_connect_disconnect(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_connect_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # データのチェックは行われない。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # Data is not checked. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
335  list_send = str_send2.split(" ")
336  list_recv = str_recv2.split(" ")
337  for ic in range(len(list_send)):
338  try:
339  float_send = float(list_send[ic]);
340  float_recv = float(list_recv[ic]);
341  if float_send != float_recv:
342  bret = False
343  break;
344  except:
345  if str_send2 != str_recv2:
346  bret = False
347  break;
348 
349 
350  f_recv.close()
351  f_send.close()
352  return bret
353 
354 
355 
367 def test_connect_disconnect(message,arg0,arg1,arg2):
368 
369  errorFlag = True
370  for i in range(loop_count):
371 
372  ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_connect_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # データのチェックは行われない。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # Data is not checked. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
373  make_connecter_profile(arg0,arg1,arg2)
374 
375  ## 3 ポート接続
376  bool_ret = connect_ports()
377  if bool_ret!=True:
378  errorFlag = False
379 
380  time.sleep(sleep_connect_time)
381 
382  ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # データのチェックは行われない。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # Data is not checked. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
383  bool_ret = disconnect_ports()
384  if bool_ret!=True:
385  errorFlag = False
386 
387  ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # データのチェックは行われない。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # Data is not checked. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
388  fout = open(g_test_result_file, 'a')
389  if errorFlag:
390  message = g_test_ok
391  else :
392  message = g_test_ng
393  print message ,
394  sys.stdout.flush()
395  fout.write(message)
396  fout.close()
397 
398  time.sleep(sleep_for_time)
399 
400  return errorFlag
401 
402 
403 
417 def test_activate_deactivate_2(message,arg0,arg1,arg2):
418 
419  errorFlag = True
420  ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
421  make_connecter_profile(arg0,arg1,arg2)
422 
423  ## 3 ポート接続
424  bool_ret = connect_ports()
425  if bool_ret!=True:
426  errorFlag = False
427 
428  for i in range(loop_count):
429 
430  ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
432 
433  ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
434  bool_ret = activate_components(sleep_recv_act_time)
435  if bool_ret!=True:
436  errorFlag = False
437 
438  time.sleep(sleep_act_time)
439 
440  ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
441  bool_ret = deactivate_components()
442  if bool_ret!=True:
443  errorFlag = False
444 
445  ## 受信ファイル有無判定
446  if os.path.isfile(g_diff_recv_file) == False:
447  errorFlag = False
448  fout = open(g_test_result_file, 'a')
449  #message = message + g_check_message
450  message = g_test_ng
451  fout.write(message)
452  fout.close()
453  print message ,
454  sys.stdout.flush()
455  time.sleep(sleep_for_time)
456  continue
457 
458  ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
459  time.sleep(sleep_act_time)
460  fout = open(g_test_result_file, 'a')
461  fsize=os.path.getsize(g_diff_recv_file)
462  if fsize > 0:
463  message = g_test_ok
464  print message ,
465  sys.stdout.flush()
466  fout.write(message)
467  else:
468  errorFlag = False
469  # テスト結果 NG
470  message = g_test_ng
471  print message ,
472  sys.stdout.flush()
473  fout.write(message)
474 
475  fout.close()
476 
477  time.sleep(sleep_for_time)
478 
479  ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続した状態で Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated while connected. # # @endif def test_activate_deactivate(message,arg0,arg1,arg2): errorFlag = True ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
480  bool_ret = disconnect_ports()
481 
482  return errorFlag
483 
495 def test_activate_deactivate(message,arg0,arg1,arg2):
496 
497  errorFlag = True
498  ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
499  make_connecter_profile(arg0,arg1,arg2)
500 
501  ## 3 ポート接続
502  bool_ret = connect_ports()
503  if bool_ret!=True:
504  errorFlag = False
505 
506  for i in range(loop_count):
507 
508  ## 2 受信データファイル削除 delete_recv_file() ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
510 
511  ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
512  bool_ret = activate_components(sleep_recv_act_time)
513  if bool_ret!=True:
514  errorFlag = False
515 
516  time.sleep(sleep_act_time)
517 
518  ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') #message = message + g_check_message message = g_test_ng fout.write(message) fout.close() print message , sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
519  bool_ret = deactivate_components()
520  if bool_ret!=True:
521  errorFlag = False
522 
523  ## 受信ファイル有無判定
524  if os.path.isfile(g_diff_recv_file) == False:
525  errorFlag = False
526  fout = open(g_test_result_file, 'a')
527  #message = message + g_check_message
528  message = g_test_ng
529  fout.write(message)
530  fout.close()
531  print message ,
532  sys.stdout.flush()
533  time.sleep(sleep_for_time)
534  continue
535 
536  ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
537  time.sleep(sleep_act_time)
538  bret = diff_file()
539 
540  ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
541  fout = open(g_test_result_file, 'a')
542  # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
543  if bret == True:
544  # テスト結果 OK
545  message = g_test_ok
546  print message ,
547  sys.stdout.flush()
548  fout.write(message + '\n')
549  else:
550  errorFlag = False
551  # テスト結果 NG
552  message = g_test_ng
553  print message ,
554  sys.stdout.flush()
555  fout.write(message + '\n')
556  # 受信データをテスト結果ファイルへコピー
557  fin2 = open(g_diff_recv_file, 'r')
558  while(1):
559  s2 = fin2.readline()
560  if len(s2) == 0:
561  break
562  fout.write(s2)
563  fin2.close()
564  fout.close()
565 
566  time.sleep(sleep_for_time)
567 
568  ## 6 ポート切断 bool_ret = disconnect_ports() return errorFlag ## # @if jp # @brief ActivateとDeactivateだけを繰り返す。 # # 接続せずに Activate と Deactivate を繰り返す。 # # @else # @brief Only activation and deactivation are repeated. # # Activate and Deactivate are repeated without connecting it. # # @endif def test_activate_deactivate_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
569  bool_ret = disconnect_ports()
570 
571  return errorFlag
572 
573 
585 def test_activate_deactivate_2(message,arg0,arg1,arg2):
586 
587  errorFlag = True
588 
589  for i in range(loop_count):
590 
591  ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
592  make_connecter_profile(arg0,arg1,arg2)
593 
594  ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
595  bool_ret = activate_components(sleep_recv_act_time)
596  if bool_ret!=True:
597  errorFlag = False
598 
599  time.sleep(sleep_act_time)
600 
601  ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
602  bool_ret = deactivate_components()
603  if bool_ret!=True:
604  errorFlag = False
605 
606  ## テスト結果出力 fout = open(g_test_result_file, 'a') if errorFlag: message = g_test_ok else : message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # Data is not checked. # # @endif def test_connection_5(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
607  fout = open(g_test_result_file, 'a')
608  if errorFlag:
609  message = g_test_ok
610  else :
611  message = g_test_ng
612  print message ,
613  sys.stdout.flush()
614  fout.write(message)
615  fout.close()
616 
617  time.sleep(sleep_for_time)
618 
619  return errorFlag
620 
621 
636 def test_connection_5(message,arg0,arg1,arg2):
637 
638  errorFlag = True
639  for i in range(loop_count):
640 
641  ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
643 
644  ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
645  make_connecter_profile(arg0,arg1,arg2)
646 
647  ## 3 ポート接続
648  bool_ret = connect_ports()
649  if bool_ret!=True:
650  errorFlag = False
651 
652  ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
653  bool_ret = activate_components(sleep_recv_act_time)
654  if bool_ret!=True:
655  errorFlag = False
656 
657  time.sleep(sleep_act_time)
658 
659  ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
660  bool_ret = deactivate_components()
661  if bool_ret!=True:
662  errorFlag = False
663 
664  ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
665  bool_ret = disconnect_ports()
666  if bool_ret!=True:
667  errorFlag = False
668 
669  ## 受信ファイル有無判定
670  if os.path.isfile(g_diff_recv_file) == False:
671  errorFlag = False
672  fout = open(g_test_result_file, 'a')
673  message = g_test_ng
674  fout.write(message + '\n')
675  fout.close()
676  print message,
677  sys.stdout.flush()
678  time.sleep(sleep_for_time)
679  continue
680 
681  ## ファイルサイズをチェックする time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、deactivate、切断を繰り返す。 # # # @else # @brief The connection, activate, deactivate, and cutting are repeated. # # # @endif def test_connection(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
682  time.sleep(sleep_act_time)
683  fout = open(g_test_result_file, 'a')
684  fsize=os.path.getsize(g_diff_recv_file)
685  if fsize > 0:
686  message = g_test_ok
687  print message ,
688  sys.stdout.flush()
689  fout.write(message)
690  else:
691  errorFlag = False
692  # テスト結果 NG
693  message = g_test_ng
694  print message ,
695  sys.stdout.flush()
696  fout.write(message)
697 
698  fout.close()
699 
700  time.sleep(sleep_for_time)
701 
702  return errorFlag
703 
713 def test_connection(message,arg0,arg1,arg2):
714 
715  errorFlag = True
716  for i in range(loop_count):
717 
718  ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
720 
721  ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
722  make_connecter_profile(arg0,arg1,arg2)
723 
724  ## 3 ポート接続
725  bool_ret = connect_ports()
726  if bool_ret!=True:
727  errorFlag = False
728 
729  ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
730  bool_ret = activate_components(sleep_recv_act_time)
731  if bool_ret!=True:
732  errorFlag = False
733 
734  time.sleep(sleep_act_time)
735 
736  ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
737  bool_ret = deactivate_components()
738  if bool_ret!=True:
739  errorFlag = False
740 
741  ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
742  bool_ret = disconnect_ports()
743  if bool_ret!=True:
744  errorFlag = False
745 
746 
747  ## 受信ファイル有無判定
748  if os.path.isfile(g_diff_recv_file) == False:
749  errorFlag = False
750  fout = open(g_test_result_file, 'a')
751  message = g_test_ng
752  fout.write(message + '\n')
753  fout.close()
754  print message,
755  sys.stdout.flush()
756  time.sleep(sleep_for_time)
757  continue
758 
759  ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
760  time.sleep(sleep_act_time)
761  bret = diff_file()
762 
763  ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
764  fout = open(g_test_result_file, 'a')
765  # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief 接続、activate、切断、deactivateを繰り返す。 # # # @else # @brief # # # @endif def test_connection_2(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
766  if bret == True:
767  # テスト結果 OK
768  message = g_test_ok
769  print message ,
770  sys.stdout.flush()
771  fout.write(message + '\n')
772  else:
773  errorFlag = False
774  # テスト結果 NG
775  message = g_test_ng
776  print message ,
777  sys.stdout.flush()
778  fout.write(message + '\n')
779  # 受信データをテスト結果ファイルへコピー
780  fin2 = open(g_diff_recv_file, 'r')
781  while(1):
782  s2 = fin2.readline()
783  if len(s2) == 0:
784  break
785  fout.write(s2)
786  fin2.close()
787  fout.close()
788 
789  time.sleep(sleep_for_time)
790 
791  return errorFlag
792 
793 
794 
804 def test_connection_2(message,arg0,arg1,arg2):
805 
806  errorFlag = True
807 
808  for i in range(loop_count):
809 
810  ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
812 
813  ## 1 コネクタープロファイル設定 make_connecter_profile("flush", "", 0) ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
814  make_connecter_profile("flush", "", 0)
815 
816  ## 3 ポート接続
817  bool_ret = connect_ports()
818  if bool_ret!=True:
819  errorFlag = False
820 
821  ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
822  bool_ret = activate_components(sleep_recv_act_time)
823  if bool_ret!=True:
824  errorFlag = False
825 
826  time.sleep(sleep_act_time)
827 
828  ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
829  bool_ret = disconnect_ports()
830  if bool_ret!=True:
831  errorFlag = False
832 
833  ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
834  bool_ret = deactivate_components()
835  if bool_ret!=True:
836  errorFlag = False
837 
838  ## 受信ファイル有無判定
839  if os.path.isfile(g_diff_recv_file) == False:
840  errorFlag = False
841  fout = open(g_test_result_file, 'a')
842  message = g_test_ng
843  fout.write(message + '\n')
844  fout.close()
845  print message,
846  sys.stdout.flush()
847  time.sleep(sleep_for_time)
848  continue
849 
850  ## 7 送受信データ比較 time.sleep(sleep_act_time) bret = diff_file() ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
851  time.sleep(sleep_act_time)
852  bret = diff_file()
853 
854  ## 差分ファイルからテスト結果出力 fout = open(g_test_result_file, 'a') # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
855  fout = open(g_test_result_file, 'a')
856  # bret==True なら送受信データ一致 if bret == True: # テスト結果 OK message = g_test_ok print message , sys.stdout.flush() fout.write(message + '\n') else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message + '\n') # 受信データをテスト結果ファイルへコピー fin2 = open(g_diff_recv_file, 'r') while(1): s2 = fin2.readline() if len(s2) == 0: break fout.write(s2) fin2.close() fout.close() ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
857  if bret == True:
858  # テスト結果 OK
859  message = g_test_ok
860  print message ,
861  sys.stdout.flush()
862  fout.write(message + '\n')
863  else:
864  errorFlag = False
865  # テスト結果 NG
866  message = g_test_ng
867  print message ,
868  sys.stdout.flush()
869  fout.write(message + '\n')
870  # 受信データをテスト結果ファイルへコピー
871  fin2 = open(g_diff_recv_file, 'r')
872  while(1):
873  s2 = fin2.readline()
874  if len(s2) == 0:
875  break
876  fout.write(s2)
877  fin2.close()
878  fout.close()
879  ## 差分ファイルからテスト結果出力 time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、deactivate、切断を繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_3(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
880  time.sleep(sleep_for_time)
881 
882  return errorFlag
883 
884 
885 
899 def test_connection_3(message,arg0,arg1,arg2):
900 
901  errorFlag = True
902 
903  for i in range(loop_count):
904 
905  ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
907 
908  ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
909  make_connecter_profile(arg0,arg1,arg2)
910 
911  ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
912  bool_ret = activate_components(sleep_recv_act_time)
913  if bool_ret!=True:
914  errorFlag = False
915 
916  ## 3 ポート接続
917  bool_ret = connect_ports()
918  if bool_ret!=True:
919  errorFlag = False
920 
921  time.sleep(sleep_act_time)
922 
923  ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
924  bool_ret = deactivate_components()
925  if bool_ret!=True:
926  errorFlag = False
927 
928  ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
929  bool_ret = disconnect_ports()
930  if bool_ret!=True:
931  errorFlag = False
932 
933  ## 受信ファイル有無判定
934  if os.path.isfile(g_diff_recv_file) == False:
935  errorFlag = False
936  fout = open(g_test_result_file, 'a')
937  message = g_test_ng
938  fout.write(message + '\n')
939  fout.close()
940  print message,
941  sys.stdout.flush()
942  time.sleep(sleep_for_time)
943  continue
944 
945  ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief activate、接続、切断、deactivateを繰り返す。 # # データのチェックは行われない。 # 注意:Activateを先に行っている為、受信データは途中からの内容になります。 # periodic,newの接続テストでは、ポリシーがSKIP,NEWの場合、 # データの確認は行わない。 # # @else # @brief # # # @endif def test_connection_4(message,arg0,arg1,arg2): errorFlag = True for i in range(loop_count): ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
946  time.sleep(sleep_act_time)
947  fout = open(g_test_result_file, 'a')
948  fsize=os.path.getsize(g_diff_recv_file)
949  if fsize > 0:
950  message = g_test_ok
951  print message ,
952  sys.stdout.flush()
953  fout.write(message)
954  else:
955  errorFlag = False
956  # テスト結果 NG
957  message = g_test_ng
958  print message ,
959  sys.stdout.flush()
960  fout.write(message)
961 
962  fout.close()
963 
964  time.sleep(sleep_for_time)
965 
966  return errorFlag
967 
968 
969 
983 def test_connection_4(message,arg0,arg1,arg2):
984 
985  errorFlag = True
986  for i in range(loop_count):
987 
988  ## 2 受信データファイル削除 delete_recv_file() ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
990 
991  ## 1 コネクタープロファイル設定 make_connecter_profile(arg0,arg1,arg2) ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
992  make_connecter_profile(arg0,arg1,arg2)
993 
994  ## 4 アクティベート bool_ret = activate_components(sleep_recv_act_time) if bool_ret!=True: errorFlag = False ## 3 ポート接続 bool_ret = connect_ports() if bool_ret!=True: errorFlag = False time.sleep(sleep_act_time) ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
995  bool_ret = activate_components(sleep_recv_act_time)
996  if bool_ret!=True:
997  errorFlag = False
998 
999  ## 3 ポート接続
1000  bool_ret = connect_ports()
1001  if bool_ret!=True:
1002  errorFlag = False
1003 
1004  time.sleep(sleep_act_time)
1005 
1006  ## 6 ポート切断 bool_ret = disconnect_ports() if bool_ret!=True: errorFlag = False ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
1007  bool_ret = disconnect_ports()
1008  if bool_ret!=True:
1009  errorFlag = False
1010 
1011  ## 5 ディアクティベート bool_ret = deactivate_components() if bool_ret!=True: errorFlag = False ## 受信ファイル有無判定 if os.path.isfile(g_diff_recv_file) == False: errorFlag = False fout = open(g_test_result_file, 'a') message = g_test_ng fout.write(message + '\n') fout.close() print message, sys.stdout.flush() time.sleep(sleep_for_time) continue ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
1012  bool_ret = deactivate_components()
1013  if bool_ret!=True:
1014  errorFlag = False
1015 
1016  ## 受信ファイル有無判定
1017  if os.path.isfile(g_diff_recv_file) == False:
1018  errorFlag = False
1019  fout = open(g_test_result_file, 'a')
1020  message = g_test_ng
1021  fout.write(message + '\n')
1022  fout.close()
1023  print message,
1024  sys.stdout.flush()
1025  time.sleep(sleep_for_time)
1026  continue
1027 
1028  ## 7 送受信データ比較 time.sleep(sleep_act_time) fout = open(g_test_result_file, 'a') fsize=os.path.getsize(g_diff_recv_file) if fsize > 0: message = g_test_ok print message , sys.stdout.flush() fout.write(message) else: errorFlag = False # テスト結果 NG message = g_test_ng print message , sys.stdout.flush() fout.write(message) fout.close() time.sleep(sleep_for_time) return errorFlag ## # @if jp # @brief テストテーブル # @else # @brief Test table # @endif test_table = [ [ test_connect_disconnect, "Connect(out->in, flush) -> Disconnect", "flush", "", 0 ], [ test_connect_disconnect, "Connect(in->out, flush) -> Disconnect", "flush", "", 1 ], [ test_activate_deactivate, "Connecting(out->in, flush), Activate -> send/recv -> Deactivate", "flush", "", 0 ], [ test_activate_deactivate, "Connecting(in->out, flush), Activate -> send/recv -> Deactivate", "flush", "", 1 ], [ test_activate_deactivate_2, "Not Connect(out->in, flush), Activate -> Deactivate", "flush", "", 0 ], [ test_connection, "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection, "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_2, "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_2, "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connection_3, "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 0 ], [ test_connection_3, "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect", "flush", "", 1 ], [ test_connection_4, "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 0 ], [ test_connection_4, "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate", "flush", "", 1 ], [ test_connect_disconnect, "Connect(out->in, new,ALL) -> Disconnect", "new", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, new,FIFO) -> Disconnect", "new", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, new,NEW) -> Disconnect", "new", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, new,SKIP) -> Disconnect", "new", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, new,ALL) -> Disconnect", "new", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, new,FIFO) -> Disconnect", "new", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, new,NEW) -> Disconnect", "new", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, new,SKIP) -> Disconnect", "new", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 0 ], [ test_activate_deactivate, "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate", "new", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate", "new", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate", "new", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate", "new", "SKIP", 1 ], [ test_connection, "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 0 ], [ test_connection, "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 0 ], [ test_connection_5, "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 0 ], [ test_connection, "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "ALL", 1 ], [ test_connection, "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "NEW", 1 ], [ test_connection_5, "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "new", "SKIP", 1 ], [ test_connect_disconnect, "Connect(out->in, periodic,ALL) -> Disconnect", "periodic", "ALL", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,NEW) -> Disconnect", "periodic", "NEW", 0 ], [ test_connect_disconnect, "Connect(out->in, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 0 ], [ test_connect_disconnect, "Connect(in->out, periodic,ALL) -> Disconnect", "periodic", "ALL", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,FIFO) -> Disconnect", "periodic", "FIFO", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,NEW) -> Disconnect", "periodic", "NEW", 1 ], [ test_connect_disconnect, "Connect(in->out, periodic,SKIP) -> Disconnect", "periodic", "SKIP", 1 ], [ test_activate_deactivate, "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 0 ], [ test_activate_deactivate, "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 0 ], [ test_activate_deactivate_2, "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 0 ], [ test_activate_deactivate, "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate", "periodic", "ALL", 1 ], [ test_activate_deactivate, "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate", "periodic", "FIFO", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate", "periodic", "NEW", 1 ], [ test_activate_deactivate_2, "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate", "periodic", "SKIP", 1 ], [ test_connection, "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 0 ], [ test_connection, "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 0 ], [ test_connection_5, "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 0 ], [ test_connection_5, "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 0 ], [ test_connection, "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "ALL", 1 ], [ test_connection, "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "FIFO", 1 ], [ test_connection_5, "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "NEW", 1 ], [ test_connection_5, "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect", "periodic", "SKIP", 1 ], ] ## # @if jp # @brief main # @else # @brief main # @endif def main(): initGlobal() ok_counter = 0 ng_counter = 0 exit = 0 result_message = "" for element in test_table: components_entry() message = g_mess_header + g_test_case message = message + element[1] message = message + g_mess_footer fout = open(g_test_result_file, 'a') fout.write('\n' + message) fout.close() print "" print message ret = element[0](message,element[2],element[3],element[4]) components_exit() if ret == False: ng_counter = ng_counter + 1 exit = 1 result_message = "!!!FAILURES!!!" break; else : ok_counter = ok_counter + 1 print "" print result_message print "Test Results: " print "Run:",ok_counter+ng_counter," Failures:", ng_counter return exit if __name__ == "__main__": main()
1029  time.sleep(sleep_act_time)
1030  fout = open(g_test_result_file, 'a')
1031  fsize=os.path.getsize(g_diff_recv_file)
1032  if fsize > 0:
1033  message = g_test_ok
1034  print message ,
1035  sys.stdout.flush()
1036  fout.write(message)
1037  else:
1038  errorFlag = False
1039  # テスト結果 NG
1040  message = g_test_ng
1041  print message ,
1042  sys.stdout.flush()
1043  fout.write(message)
1044 
1045  fout.close()
1046 
1047  time.sleep(sleep_for_time)
1048 
1049  return errorFlag
1050 
1051 
1057 test_table = [
1058  [ test_connect_disconnect,
1059  "Connect(out->in, flush) -> Disconnect",
1060  "flush", "", 0 ],
1061  [ test_connect_disconnect,
1062  "Connect(in->out, flush) -> Disconnect",
1063  "flush", "", 1 ],
1064  [ test_activate_deactivate,
1065  "Connecting(out->in, flush), Activate -> send/recv -> Deactivate",
1066  "flush", "", 0 ],
1067  [ test_activate_deactivate,
1068  "Connecting(in->out, flush), Activate -> send/recv -> Deactivate",
1069  "flush", "", 1 ],
1070  [ test_activate_deactivate_2,
1071  "Not Connect(out->in, flush), Activate -> Deactivate",
1072  "flush", "", 0 ],
1073  [ test_connection,
1074  "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect",
1075  "flush", "", 0 ],
1076  [ test_connection,
1077  "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect",
1078  "flush", "", 1 ],
1079  [ test_connection_2,
1080  "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate",
1081  "flush", "", 0 ],
1082  [ test_connection_2,
1083  "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate",
1084  "flush", "", 1 ],
1085  [ test_connection_3,
1086  "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect",
1087  "flush", "", 0 ],
1088  [ test_connection_3,
1089  "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect",
1090  "flush", "", 1 ],
1091  [ test_connection_4,
1092  "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate",
1093  "flush", "", 0 ],
1094  [ test_connection_4,
1095  "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate",
1096  "flush", "", 1 ],
1097  [ test_connect_disconnect,
1098  "Connect(out->in, new,ALL) -> Disconnect",
1099  "new", "ALL", 0 ],
1100  [ test_connect_disconnect,
1101  "Connect(out->in, new,FIFO) -> Disconnect",
1102  "new", "FIFO", 0 ],
1103  [ test_connect_disconnect,
1104  "Connect(out->in, new,NEW) -> Disconnect",
1105  "new", "NEW", 0 ],
1106  [ test_connect_disconnect,
1107  "Connect(out->in, new,SKIP) -> Disconnect",
1108  "new", "SKIP", 0 ],
1109  [ test_connect_disconnect,
1110  "Connect(in->out, new,ALL) -> Disconnect",
1111  "new", "ALL", 1 ],
1112  [ test_connect_disconnect,
1113  "Connect(in->out, new,FIFO) -> Disconnect",
1114  "new", "FIFO", 1 ],
1115  [ test_connect_disconnect,
1116  "Connect(in->out, new,NEW) -> Disconnect",
1117  "new", "NEW", 1 ],
1118  [ test_connect_disconnect,
1119  "Connect(in->out, new,SKIP) -> Disconnect",
1120  "new", "SKIP", 1 ],
1121  [ test_activate_deactivate,
1122  "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate",
1123  "new", "ALL", 0 ],
1124  [ test_activate_deactivate,
1125  "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate",
1126  "new", "FIFO", 0 ],
1127  [ test_activate_deactivate,
1128  "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate",
1129  "new", "NEW", 0 ],
1130  [ test_activate_deactivate_2,
1131  "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate",
1132  "new", "SKIP", 0 ],
1133  [ test_activate_deactivate,
1134  "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate",
1135  "new", "ALL", 1 ],
1136  [ test_activate_deactivate,
1137  "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate",
1138  "new", "FIFO", 1 ],
1139  [ test_activate_deactivate_2,
1140  "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate",
1141  "new", "NEW", 1 ],
1142  [ test_activate_deactivate_2,
1143  "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate",
1144  "new", "SKIP", 1 ],
1145  [ test_connection,
1146  "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect",
1147  "new", "ALL", 0 ],
1148  [ test_connection,
1149  "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect",
1150  "new", "FIFO", 0 ],
1151  [ test_connection_5,
1152  "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect",
1153  "new", "NEW", 0 ],
1154  [ test_connection_5,
1155  "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect",
1156  "new", "SKIP", 0 ],
1157  [ test_connection,
1158  "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect",
1159  "new", "ALL", 1 ],
1160  [ test_connection,
1161  "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect",
1162  "new", "FIFO", 1 ],
1163  [ test_connection_5,
1164  "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect",
1165  "new", "NEW", 1 ],
1166  [ test_connection_5,
1167  "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect",
1168  "new", "SKIP", 1 ],
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 ],
1217  [ test_connection,
1218  "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect",
1219  "periodic", "ALL", 0 ],
1220  [ test_connection,
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 ],
1229  [ test_connection,
1230  "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect",
1231  "periodic", "ALL", 1 ],
1232  [ test_connection,
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 ],
1241 
1242 ]
1243 
1249 def main():
1250 
1251  initGlobal()
1252  ok_counter = 0
1253  ng_counter = 0
1254 
1255  exit = 0
1256  result_message = ""
1257  for element in test_table:
1259 
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)
1265  fout.close()
1266  print ""
1267  print message
1268  ret = element[0](message,element[2],element[3],element[4])
1269  components_exit()
1270  if ret == False:
1271  ng_counter = ng_counter + 1
1272  exit = 1
1273  result_message = "!!!FAILURES!!!"
1274  break;
1275  else :
1276  ok_counter = ok_counter + 1
1277 
1278 
1279  print ""
1280  print result_message
1281  print "Test Results: "
1282  print "Run:",ok_counter+ng_counter," Failures:", ng_counter
1283  return exit
1284 if __name__ == "__main__":
1285  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[&#39;localhost:2809&#39;].rtc_handles.keys() ns = env.name_space[&#39;localhost:2809&#39;]
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.


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:26:00