00001
00002
00003
00004
00005
00006
00007
00008
00009 from rtc_handle import *
00010 from BasicDataType_idl import *
00011 import time
00012 import commands
00013 import SDOPackage
00014 import os
00015 import sys
00016
00017
00018 g_test_name = "<< component connection test >>"
00019
00020
00021
00022 g_interface_type1 = "corba_cdr"
00023 g_dataflow_type = "push"
00024 g_subscription_type = "flush"
00025 g_push_policy = "NEW"
00026 g_push_rate = "2000"
00027 g_skip_count = "4"
00028
00029
00030
00031 g_port1 = 0
00032 g_port2 = 1
00033 g_port3 = 2
00034
00035
00036 g_name1 = "out"
00037 g_connector_id1 = "001"
00038 g_data_type1 = "TimedFloat"
00039
00040
00041 g_name2 = "seqout"
00042 g_connector_id2 = "002"
00043 g_data_type2 = "TimedFloatSeq"
00044
00045
00046 g_name3 = "MyService"
00047 g_connector_id3 = "003"
00048 g_interface_type3 = "MyService"
00049
00050
00051
00052 g_diff_send_file = "./original-data"
00053 g_diff_recv_file = "./received-data"
00054 g_check_message = g_diff_recv_file + " file not found."
00055 g_test_result_file = "./ResultTest.log"
00056 g_test_case = ""
00057 g_test_cnt = "count"
00058 g_test_ok = "."
00059 g_test_ng = "F"
00060 g_test_ng_message = " < received-data >"
00061 g_mess_header = "< "
00062 g_mess_footer = " > "
00063
00064
00065
00066
00067
00068
00069
00070 case_no = 0
00071
00072
00073 loop_count = 1
00074
00075
00076 sleep_recv_act_time = 1
00077
00078
00079 sleep_act_time = 2
00080
00081
00082 sleep_for_time = 1
00083
00084
00085 sleep_connect_time =1
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 def connect_ports():
00101
00102 errorFlag = True
00103
00104
00105 ret,porf = g_out_ports[g_port1].connect(g_conprof1)
00106 if ret!=RTC.RTC_OK:
00107 errorFlag = False
00108
00109
00110 ret,porf = g_out_ports[g_port2].connect(g_conprof2)
00111 if ret!=RTC.RTC_OK:
00112 errorFlag = False
00113
00114
00115 ret,porf = g_out_ports[g_port3].connect(g_conprof3)
00116 if ret!=RTC.RTC_OK:
00117 errorFlag = False
00118
00119
00120 return errorFlag
00121
00122
00123
00124
00125
00126
00127 def disconnect_ports():
00128
00129 errorFlag = True
00130
00131 ret = g_in_ports[g_port3].disconnect(g_conprof3.connector_id)
00132 if ret!=RTC.RTC_OK:
00133 errorFlag = False
00134 ret = g_in_ports[g_port2].disconnect(g_conprof2.connector_id)
00135 if ret!=RTC.RTC_OK:
00136 errorFlag = False
00137 ret = g_in_ports[g_port1].disconnect(g_conprof1.connector_id)
00138 if ret!=RTC.RTC_OK:
00139 errorFlag = False
00140
00141 return errorFlag
00142
00143
00144
00145
00146
00147
00148
00149 def activate_components(sleep_recv_act_time):
00150 errorFlag = True
00151
00152 ret = ec_recv[0].activate_component(g_compo_recv.rtc_ref)
00153 if ret!=RTC.RTC_OK:
00154 errorFlag = False
00155
00156 time.sleep(sleep_recv_act_time)
00157
00158 ret = ec_send[0].activate_component(g_compo_send.rtc_ref)
00159
00160 if ret!=RTC.RTC_OK:
00161 errorFlag = False
00162
00163 return errorFlag
00164
00165
00166
00167
00168
00169
00170 def deactivate_components():
00171 errorFlag = True
00172
00173 ret = ec_send[0].deactivate_component(g_compo_send.rtc_ref)
00174 if ret!=RTC.RTC_OK:
00175 errorFlag = False
00176 ret = ec_recv[0].deactivate_component(g_compo_recv.rtc_ref)
00177 if ret!=RTC.RTC_OK:
00178 errorFlag = False
00179
00180 return errorFlag
00181
00182
00183
00184
00185
00186
00187 def components_entry():
00188 global g_compo_send,g_compo_recv
00189 global ec_send,ec_recv
00190 global g_out_ports,g_in_ports
00191 global g_conprof1,g_conprof2,g_conprof3
00192 global env
00193
00194 os.system('./AutoTestOutComp >/dev/null 2>&1 &')
00195 os.system('./AutoTestInComp >/dev/null 2>&1 &')
00196
00197 time.sleep(2)
00198
00199
00200 list0 = env.name_space["localhost:2809"].list_obj()
00201 env.name_space['localhost:2809'].rtc_handles.keys()
00202 ns = env.name_space['localhost:2809']
00203
00204 g_compo_send = ns.rtc_handles["AutoTestOut0.rtc"]
00205 g_compo_recv = ns.rtc_handles["AutoTestIn0.rtc"]
00206
00207 ec_send = g_compo_send.rtc_ref.get_owned_contexts()
00208 ec_recv = g_compo_recv.rtc_ref.get_owned_contexts()
00209
00210 g_out_ports = g_compo_send.rtc_ref.get_ports()
00211 g_in_ports = g_compo_recv.rtc_ref.get_ports()
00212
00213 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))])
00214
00215 return
00216
00217
00218
00219
00220
00221
00222
00223 def components_exit():
00224 g_compo_send.rtc_ref.exit();
00225 g_compo_recv.rtc_ref.exit();
00226
00227 time.sleep(1)
00228 return
00229
00230
00231
00232
00233
00234
00235
00236 def initGlobal():
00237 global env
00238
00239 env = RtmEnv(sys.argv, ["localhost:2809"])
00240
00241 return
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251 def make_connecter_profile(subscription_type, push_policy, connect_direction):
00252 global g_conprof1, g_conprof2, g_conprof3
00253
00254 if connect_direction == 0:
00255
00256 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))])
00257
00258 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))])
00259
00260
00261
00262
00263 else:
00264
00265 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))])
00266
00267 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))])
00268
00269
00270
00271
00272 return
00273
00274
00275
00276
00277
00278
00279
00280
00281 def delete_recv_file():
00282
00283 if os.path.isfile(g_diff_recv_file) == True:
00284 os.remove(g_diff_recv_file)
00285 return
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295 def diff_file():
00296 bret = True
00297
00298
00299
00300
00301 if os.path.isfile(g_diff_send_file) == False:
00302 print "send_file (%s) not found." % send_file
00303 return False
00304
00305
00306 if os.path.isfile(g_diff_recv_file) == False:
00307 print "recv_file (%s) not found." % recv_file
00308 return False
00309
00310
00311 f_send = open(g_diff_send_file, 'r')
00312 f_recv = open(g_diff_recv_file, 'r')
00313
00314 while(1):
00315 str_send = f_send.readline()
00316 str_recv = f_recv.readline()
00317 if len(str_send) == 0:
00318 break
00319
00320
00321
00322
00323
00324
00325
00326 str_send2 = str_send.rstrip('\n')
00327 str_send2 = str_send2.rstrip('\r')
00328 str_recv2 = str_recv.rstrip('\n')
00329 str_recv2 = str_recv2.rstrip('\r')
00330
00331
00332
00333
00334
00335 list_send = str_send2.split(" ")
00336 list_recv = str_recv2.split(" ")
00337 for ic in range(len(list_send)):
00338 try:
00339 float_send = float(list_send[ic]);
00340 float_recv = float(list_recv[ic]);
00341 if float_send != float_recv:
00342 bret = False
00343 break;
00344 except:
00345 if str_send2 != str_recv2:
00346 bret = False
00347 break;
00348
00349
00350 f_recv.close()
00351 f_send.close()
00352 return bret
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367 def test_connect_disconnect(message,arg0,arg1,arg2):
00368
00369 errorFlag = True
00370 for i in range(loop_count):
00371
00372
00373 make_connecter_profile(arg0,arg1,arg2)
00374
00375
00376 bool_ret = connect_ports()
00377 if bool_ret!=True:
00378 errorFlag = False
00379
00380 time.sleep(sleep_connect_time)
00381
00382
00383 bool_ret = disconnect_ports()
00384 if bool_ret!=True:
00385 errorFlag = False
00386
00387
00388 fout = open(g_test_result_file, 'a')
00389 if errorFlag:
00390 message = g_test_ok
00391 else :
00392 message = g_test_ng
00393 print message ,
00394 sys.stdout.flush()
00395 fout.write(message)
00396 fout.close()
00397
00398 time.sleep(sleep_for_time)
00399
00400 return errorFlag
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417 def test_activate_deactivate_2(message,arg0,arg1,arg2):
00418
00419 errorFlag = True
00420
00421 make_connecter_profile(arg0,arg1,arg2)
00422
00423
00424 bool_ret = connect_ports()
00425 if bool_ret!=True:
00426 errorFlag = False
00427
00428 for i in range(loop_count):
00429
00430
00431 delete_recv_file()
00432
00433
00434 bool_ret = activate_components(sleep_recv_act_time)
00435 if bool_ret!=True:
00436 errorFlag = False
00437
00438 time.sleep(sleep_act_time)
00439
00440
00441 bool_ret = deactivate_components()
00442 if bool_ret!=True:
00443 errorFlag = False
00444
00445
00446 if os.path.isfile(g_diff_recv_file) == False:
00447 errorFlag = False
00448 fout = open(g_test_result_file, 'a')
00449
00450 message = g_test_ng
00451 fout.write(message)
00452 fout.close()
00453 print message ,
00454 sys.stdout.flush()
00455 time.sleep(sleep_for_time)
00456 continue
00457
00458
00459 time.sleep(sleep_act_time)
00460 fout = open(g_test_result_file, 'a')
00461 fsize=os.path.getsize(g_diff_recv_file)
00462 if fsize > 0:
00463 message = g_test_ok
00464 print message ,
00465 sys.stdout.flush()
00466 fout.write(message)
00467 else:
00468 errorFlag = False
00469
00470 message = g_test_ng
00471 print message ,
00472 sys.stdout.flush()
00473 fout.write(message)
00474
00475 fout.close()
00476
00477 time.sleep(sleep_for_time)
00478
00479
00480 bool_ret = disconnect_ports()
00481
00482 return errorFlag
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495 def test_activate_deactivate(message,arg0,arg1,arg2):
00496
00497 errorFlag = True
00498
00499 make_connecter_profile(arg0,arg1,arg2)
00500
00501
00502 bool_ret = connect_ports()
00503 if bool_ret!=True:
00504 errorFlag = False
00505
00506 for i in range(loop_count):
00507
00508
00509 delete_recv_file()
00510
00511
00512 bool_ret = activate_components(sleep_recv_act_time)
00513 if bool_ret!=True:
00514 errorFlag = False
00515
00516 time.sleep(sleep_act_time)
00517
00518
00519 bool_ret = deactivate_components()
00520 if bool_ret!=True:
00521 errorFlag = False
00522
00523
00524 if os.path.isfile(g_diff_recv_file) == False:
00525 errorFlag = False
00526 fout = open(g_test_result_file, 'a')
00527
00528 message = g_test_ng
00529 fout.write(message)
00530 fout.close()
00531 print message ,
00532 sys.stdout.flush()
00533 time.sleep(sleep_for_time)
00534 continue
00535
00536
00537 time.sleep(sleep_act_time)
00538 bret = diff_file()
00539
00540
00541 fout = open(g_test_result_file, 'a')
00542
00543 if bret == True:
00544
00545 message = g_test_ok
00546 print message ,
00547 sys.stdout.flush()
00548 fout.write(message + '\n')
00549 else:
00550 errorFlag = False
00551
00552 message = g_test_ng
00553 print message ,
00554 sys.stdout.flush()
00555 fout.write(message + '\n')
00556
00557 fin2 = open(g_diff_recv_file, 'r')
00558 while(1):
00559 s2 = fin2.readline()
00560 if len(s2) == 0:
00561 break
00562 fout.write(s2)
00563 fin2.close()
00564 fout.close()
00565
00566 time.sleep(sleep_for_time)
00567
00568
00569 bool_ret = disconnect_ports()
00570
00571 return errorFlag
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585 def test_activate_deactivate_2(message,arg0,arg1,arg2):
00586
00587 errorFlag = True
00588
00589 for i in range(loop_count):
00590
00591
00592 make_connecter_profile(arg0,arg1,arg2)
00593
00594
00595 bool_ret = activate_components(sleep_recv_act_time)
00596 if bool_ret!=True:
00597 errorFlag = False
00598
00599 time.sleep(sleep_act_time)
00600
00601
00602 bool_ret = deactivate_components()
00603 if bool_ret!=True:
00604 errorFlag = False
00605
00606
00607 fout = open(g_test_result_file, 'a')
00608 if errorFlag:
00609 message = g_test_ok
00610 else :
00611 message = g_test_ng
00612 print message ,
00613 sys.stdout.flush()
00614 fout.write(message)
00615 fout.close()
00616
00617 time.sleep(sleep_for_time)
00618
00619 return errorFlag
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636 def test_connection_5(message,arg0,arg1,arg2):
00637
00638 errorFlag = True
00639 for i in range(loop_count):
00640
00641
00642 delete_recv_file()
00643
00644
00645 make_connecter_profile(arg0,arg1,arg2)
00646
00647
00648 bool_ret = connect_ports()
00649 if bool_ret!=True:
00650 errorFlag = False
00651
00652
00653 bool_ret = activate_components(sleep_recv_act_time)
00654 if bool_ret!=True:
00655 errorFlag = False
00656
00657 time.sleep(sleep_act_time)
00658
00659
00660 bool_ret = deactivate_components()
00661 if bool_ret!=True:
00662 errorFlag = False
00663
00664
00665 bool_ret = disconnect_ports()
00666 if bool_ret!=True:
00667 errorFlag = False
00668
00669
00670 if os.path.isfile(g_diff_recv_file) == False:
00671 errorFlag = False
00672 fout = open(g_test_result_file, 'a')
00673 message = g_test_ng
00674 fout.write(message + '\n')
00675 fout.close()
00676 print message,
00677 sys.stdout.flush()
00678 time.sleep(sleep_for_time)
00679 continue
00680
00681
00682 time.sleep(sleep_act_time)
00683 fout = open(g_test_result_file, 'a')
00684 fsize=os.path.getsize(g_diff_recv_file)
00685 if fsize > 0:
00686 message = g_test_ok
00687 print message ,
00688 sys.stdout.flush()
00689 fout.write(message)
00690 else:
00691 errorFlag = False
00692
00693 message = g_test_ng
00694 print message ,
00695 sys.stdout.flush()
00696 fout.write(message)
00697
00698 fout.close()
00699
00700 time.sleep(sleep_for_time)
00701
00702 return errorFlag
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713 def test_connection(message,arg0,arg1,arg2):
00714
00715 errorFlag = True
00716 for i in range(loop_count):
00717
00718
00719 delete_recv_file()
00720
00721
00722 make_connecter_profile(arg0,arg1,arg2)
00723
00724
00725 bool_ret = connect_ports()
00726 if bool_ret!=True:
00727 errorFlag = False
00728
00729
00730 bool_ret = activate_components(sleep_recv_act_time)
00731 if bool_ret!=True:
00732 errorFlag = False
00733
00734 time.sleep(sleep_act_time)
00735
00736
00737 bool_ret = deactivate_components()
00738 if bool_ret!=True:
00739 errorFlag = False
00740
00741
00742 bool_ret = disconnect_ports()
00743 if bool_ret!=True:
00744 errorFlag = False
00745
00746
00747
00748 if os.path.isfile(g_diff_recv_file) == False:
00749 errorFlag = False
00750 fout = open(g_test_result_file, 'a')
00751 message = g_test_ng
00752 fout.write(message + '\n')
00753 fout.close()
00754 print message,
00755 sys.stdout.flush()
00756 time.sleep(sleep_for_time)
00757 continue
00758
00759
00760 time.sleep(sleep_act_time)
00761 bret = diff_file()
00762
00763
00764 fout = open(g_test_result_file, 'a')
00765
00766 if bret == True:
00767
00768 message = g_test_ok
00769 print message ,
00770 sys.stdout.flush()
00771 fout.write(message + '\n')
00772 else:
00773 errorFlag = False
00774
00775 message = g_test_ng
00776 print message ,
00777 sys.stdout.flush()
00778 fout.write(message + '\n')
00779
00780 fin2 = open(g_diff_recv_file, 'r')
00781 while(1):
00782 s2 = fin2.readline()
00783 if len(s2) == 0:
00784 break
00785 fout.write(s2)
00786 fin2.close()
00787 fout.close()
00788
00789 time.sleep(sleep_for_time)
00790
00791 return errorFlag
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804 def test_connection_2(message,arg0,arg1,arg2):
00805
00806 errorFlag = True
00807
00808 for i in range(loop_count):
00809
00810
00811 delete_recv_file()
00812
00813
00814 make_connecter_profile("flush", "", 0)
00815
00816
00817 bool_ret = connect_ports()
00818 if bool_ret!=True:
00819 errorFlag = False
00820
00821
00822 bool_ret = activate_components(sleep_recv_act_time)
00823 if bool_ret!=True:
00824 errorFlag = False
00825
00826 time.sleep(sleep_act_time)
00827
00828
00829 bool_ret = disconnect_ports()
00830 if bool_ret!=True:
00831 errorFlag = False
00832
00833
00834 bool_ret = deactivate_components()
00835 if bool_ret!=True:
00836 errorFlag = False
00837
00838
00839 if os.path.isfile(g_diff_recv_file) == False:
00840 errorFlag = False
00841 fout = open(g_test_result_file, 'a')
00842 message = g_test_ng
00843 fout.write(message + '\n')
00844 fout.close()
00845 print message,
00846 sys.stdout.flush()
00847 time.sleep(sleep_for_time)
00848 continue
00849
00850
00851 time.sleep(sleep_act_time)
00852 bret = diff_file()
00853
00854
00855 fout = open(g_test_result_file, 'a')
00856
00857 if bret == True:
00858
00859 message = g_test_ok
00860 print message ,
00861 sys.stdout.flush()
00862 fout.write(message + '\n')
00863 else:
00864 errorFlag = False
00865
00866 message = g_test_ng
00867 print message ,
00868 sys.stdout.flush()
00869 fout.write(message + '\n')
00870
00871 fin2 = open(g_diff_recv_file, 'r')
00872 while(1):
00873 s2 = fin2.readline()
00874 if len(s2) == 0:
00875 break
00876 fout.write(s2)
00877 fin2.close()
00878 fout.close()
00879
00880 time.sleep(sleep_for_time)
00881
00882 return errorFlag
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899 def test_connection_3(message,arg0,arg1,arg2):
00900
00901 errorFlag = True
00902
00903 for i in range(loop_count):
00904
00905
00906 delete_recv_file()
00907
00908
00909 make_connecter_profile(arg0,arg1,arg2)
00910
00911
00912 bool_ret = activate_components(sleep_recv_act_time)
00913 if bool_ret!=True:
00914 errorFlag = False
00915
00916
00917 bool_ret = connect_ports()
00918 if bool_ret!=True:
00919 errorFlag = False
00920
00921 time.sleep(sleep_act_time)
00922
00923
00924 bool_ret = deactivate_components()
00925 if bool_ret!=True:
00926 errorFlag = False
00927
00928
00929 bool_ret = disconnect_ports()
00930 if bool_ret!=True:
00931 errorFlag = False
00932
00933
00934 if os.path.isfile(g_diff_recv_file) == False:
00935 errorFlag = False
00936 fout = open(g_test_result_file, 'a')
00937 message = g_test_ng
00938 fout.write(message + '\n')
00939 fout.close()
00940 print message,
00941 sys.stdout.flush()
00942 time.sleep(sleep_for_time)
00943 continue
00944
00945
00946 time.sleep(sleep_act_time)
00947 fout = open(g_test_result_file, 'a')
00948 fsize=os.path.getsize(g_diff_recv_file)
00949 if fsize > 0:
00950 message = g_test_ok
00951 print message ,
00952 sys.stdout.flush()
00953 fout.write(message)
00954 else:
00955 errorFlag = False
00956
00957 message = g_test_ng
00958 print message ,
00959 sys.stdout.flush()
00960 fout.write(message)
00961
00962 fout.close()
00963
00964 time.sleep(sleep_for_time)
00965
00966 return errorFlag
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983 def test_connection_4(message,arg0,arg1,arg2):
00984
00985 errorFlag = True
00986 for i in range(loop_count):
00987
00988
00989 delete_recv_file()
00990
00991
00992 make_connecter_profile(arg0,arg1,arg2)
00993
00994
00995 bool_ret = activate_components(sleep_recv_act_time)
00996 if bool_ret!=True:
00997 errorFlag = False
00998
00999
01000 bool_ret = connect_ports()
01001 if bool_ret!=True:
01002 errorFlag = False
01003
01004 time.sleep(sleep_act_time)
01005
01006
01007 bool_ret = disconnect_ports()
01008 if bool_ret!=True:
01009 errorFlag = False
01010
01011
01012 bool_ret = deactivate_components()
01013 if bool_ret!=True:
01014 errorFlag = False
01015
01016
01017 if os.path.isfile(g_diff_recv_file) == False:
01018 errorFlag = False
01019 fout = open(g_test_result_file, 'a')
01020 message = g_test_ng
01021 fout.write(message + '\n')
01022 fout.close()
01023 print message,
01024 sys.stdout.flush()
01025 time.sleep(sleep_for_time)
01026 continue
01027
01028
01029 time.sleep(sleep_act_time)
01030 fout = open(g_test_result_file, 'a')
01031 fsize=os.path.getsize(g_diff_recv_file)
01032 if fsize > 0:
01033 message = g_test_ok
01034 print message ,
01035 sys.stdout.flush()
01036 fout.write(message)
01037 else:
01038 errorFlag = False
01039
01040 message = g_test_ng
01041 print message ,
01042 sys.stdout.flush()
01043 fout.write(message)
01044
01045 fout.close()
01046
01047 time.sleep(sleep_for_time)
01048
01049 return errorFlag
01050
01051
01052
01053
01054
01055
01056
01057 test_table = [
01058 [ test_connect_disconnect,
01059 "Connect(out->in, flush) -> Disconnect",
01060 "flush", "", 0 ],
01061 [ test_connect_disconnect,
01062 "Connect(in->out, flush) -> Disconnect",
01063 "flush", "", 1 ],
01064 [ test_activate_deactivate,
01065 "Connecting(out->in, flush), Activate -> send/recv -> Deactivate",
01066 "flush", "", 0 ],
01067 [ test_activate_deactivate,
01068 "Connecting(in->out, flush), Activate -> send/recv -> Deactivate",
01069 "flush", "", 1 ],
01070 [ test_activate_deactivate_2,
01071 "Not Connect(out->in, flush), Activate -> Deactivate",
01072 "flush", "", 0 ],
01073 [ test_connection,
01074 "Connect(out->in, flush) -> Activate -> send/recv -> Deactivate -> Disconnect",
01075 "flush", "", 0 ],
01076 [ test_connection,
01077 "Connect(in->out, flush) -> Activate -> send/recv -> Deactivate -> Disconnect",
01078 "flush", "", 1 ],
01079 [ test_connection_2,
01080 "Connect(out->in, flush) -> Activate -> send/recv -> Disconnect -> Deactivate",
01081 "flush", "", 0 ],
01082 [ test_connection_2,
01083 "Connect(in->out, flush) -> Activate -> send/recv -> Disconnect -> Deactivate",
01084 "flush", "", 1 ],
01085 [ test_connection_3,
01086 "Activate -> Connect(out->in, flush) -> send/recv -> Deactivate -> Disconnect",
01087 "flush", "", 0 ],
01088 [ test_connection_3,
01089 "Activate -> Connect(in->out, flush) -> send/recv -> Deactivate -> Disconnect",
01090 "flush", "", 1 ],
01091 [ test_connection_4,
01092 "Activate -> Connect(out->in, flush) -> send/recv -> Disconnect -> Deactivate",
01093 "flush", "", 0 ],
01094 [ test_connection_4,
01095 "Activate -> Connect(in->out, flush) -> send/recv -> Disconnect -> Deactivate",
01096 "flush", "", 1 ],
01097 [ test_connect_disconnect,
01098 "Connect(out->in, new,ALL) -> Disconnect",
01099 "new", "ALL", 0 ],
01100 [ test_connect_disconnect,
01101 "Connect(out->in, new,FIFO) -> Disconnect",
01102 "new", "FIFO", 0 ],
01103 [ test_connect_disconnect,
01104 "Connect(out->in, new,NEW) -> Disconnect",
01105 "new", "NEW", 0 ],
01106 [ test_connect_disconnect,
01107 "Connect(out->in, new,SKIP) -> Disconnect",
01108 "new", "SKIP", 0 ],
01109 [ test_connect_disconnect,
01110 "Connect(in->out, new,ALL) -> Disconnect",
01111 "new", "ALL", 1 ],
01112 [ test_connect_disconnect,
01113 "Connect(in->out, new,FIFO) -> Disconnect",
01114 "new", "FIFO", 1 ],
01115 [ test_connect_disconnect,
01116 "Connect(in->out, new,NEW) -> Disconnect",
01117 "new", "NEW", 1 ],
01118 [ test_connect_disconnect,
01119 "Connect(in->out, new,SKIP) -> Disconnect",
01120 "new", "SKIP", 1 ],
01121 [ test_activate_deactivate,
01122 "Connecting(out->in, new,ALL), Activate -> send/recv -> Deactivate",
01123 "new", "ALL", 0 ],
01124 [ test_activate_deactivate,
01125 "Connecting(out->in, new,FIFO), Activate -> send/recv -> Deactivate",
01126 "new", "FIFO", 0 ],
01127 [ test_activate_deactivate,
01128 "Connecting(out->in, new,NEW), Activate -> send/recv -> Deactivate",
01129 "new", "NEW", 0 ],
01130 [ test_activate_deactivate_2,
01131 "Connecting(out->in, new,SKIP), Activate -> send/recv -> Deactivate",
01132 "new", "SKIP", 0 ],
01133 [ test_activate_deactivate,
01134 "Connecting(in->out, new,ALL), Activate -> send/recv -> Deactivate",
01135 "new", "ALL", 1 ],
01136 [ test_activate_deactivate,
01137 "Connecting(in->out, new,FIFO), Activate -> send/recv -> Deactivate",
01138 "new", "FIFO", 1 ],
01139 [ test_activate_deactivate_2,
01140 "Connecting(in->out, new,NEW), Activate -> send/recv -> Deactivate",
01141 "new", "NEW", 1 ],
01142 [ test_activate_deactivate_2,
01143 "Connecting(in->out, new,SKIP), Activate -> send/recv -> Deactivate",
01144 "new", "SKIP", 1 ],
01145 [ test_connection,
01146 "Connect(out->in, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect",
01147 "new", "ALL", 0 ],
01148 [ test_connection,
01149 "Connect(out->in, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect",
01150 "new", "FIFO", 0 ],
01151 [ test_connection_5,
01152 "Connect(out->in, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect",
01153 "new", "NEW", 0 ],
01154 [ test_connection_5,
01155 "Connect(out->in, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect",
01156 "new", "SKIP", 0 ],
01157 [ test_connection,
01158 "Connect(in->out, new,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect",
01159 "new", "ALL", 1 ],
01160 [ test_connection,
01161 "Connect(in->out, new,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect",
01162 "new", "FIFO", 1 ],
01163 [ test_connection_5,
01164 "Connect(in->out, new,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect",
01165 "new", "NEW", 1 ],
01166 [ test_connection_5,
01167 "Connect(in->out, new,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect",
01168 "new", "SKIP", 1 ],
01169 [ test_connect_disconnect,
01170 "Connect(out->in, periodic,ALL) -> Disconnect",
01171 "periodic", "ALL", 0 ],
01172 [ test_connect_disconnect,
01173 "Connect(out->in, periodic,FIFO) -> Disconnect",
01174 "periodic", "FIFO", 0 ],
01175 [ test_connect_disconnect,
01176 "Connect(out->in, periodic,NEW) -> Disconnect",
01177 "periodic", "NEW", 0 ],
01178 [ test_connect_disconnect,
01179 "Connect(out->in, periodic,SKIP) -> Disconnect",
01180 "periodic", "SKIP", 0 ],
01181 [ test_connect_disconnect,
01182 "Connect(in->out, periodic,ALL) -> Disconnect",
01183 "periodic", "ALL", 1 ],
01184 [ test_connect_disconnect,
01185 "Connect(in->out, periodic,FIFO) -> Disconnect",
01186 "periodic", "FIFO", 1 ],
01187 [ test_connect_disconnect,
01188 "Connect(in->out, periodic,NEW) -> Disconnect",
01189 "periodic", "NEW", 1 ],
01190 [ test_connect_disconnect,
01191 "Connect(in->out, periodic,SKIP) -> Disconnect",
01192 "periodic", "SKIP", 1 ],
01193 [ test_activate_deactivate,
01194 "Connecting(out->in, periodic,ALL), Activate -> send/recv -> Deactivate",
01195 "periodic", "ALL", 0 ],
01196 [ test_activate_deactivate,
01197 "Connecting(out->in, periodic,FIFO), Activate -> send/recv -> Deactivate",
01198 "periodic", "FIFO", 0 ],
01199 [ test_activate_deactivate_2,
01200 "Connecting(out->in, periodic,NEW), Activate -> send/recv -> Deactivate",
01201 "periodic", "NEW", 0 ],
01202 [ test_activate_deactivate_2,
01203 "Connecting(out->in, periodic,SKIP), Activate -> send/recv -> Deactivate",
01204 "periodic", "SKIP", 0 ],
01205 [ test_activate_deactivate,
01206 "Connecting(in->out, periodic,ALL), Activate -> send/recv -> Deactivate",
01207 "periodic", "ALL", 1 ],
01208 [ test_activate_deactivate,
01209 "Connecting(in->out, periodic,FIFO), Activate -> send/recv -> Deactivate",
01210 "periodic", "FIFO", 1 ],
01211 [ test_activate_deactivate_2,
01212 "Connecting(in->out, periodic,NEW), Activate -> send/recv -> Deactivate",
01213 "periodic", "NEW", 1 ],
01214 [ test_activate_deactivate_2,
01215 "Connecting(in->out, periodic,SKIP), Activate -> send/recv -> Deactivate",
01216 "periodic", "SKIP", 1 ],
01217 [ test_connection,
01218 "Connect(out->in, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect",
01219 "periodic", "ALL", 0 ],
01220 [ test_connection,
01221 "Connect(out->in, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect",
01222 "periodic", "FIFO", 0 ],
01223 [ test_connection_5,
01224 "Connect(out->in, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect",
01225 "periodic", "NEW", 0 ],
01226 [ test_connection_5,
01227 "Connect(out->in, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect",
01228 "periodic", "SKIP", 0 ],
01229 [ test_connection,
01230 "Connect(in->out, periodic,ALL) -> Activate -> send/recv -> Deactivate -> Disconnect",
01231 "periodic", "ALL", 1 ],
01232 [ test_connection,
01233 "Connect(in->out, periodic,FIFO) -> Activate -> send/recv -> Deactivate -> Disconnect",
01234 "periodic", "FIFO", 1 ],
01235 [ test_connection_5,
01236 "Connect(in->out, periodic,NEW) -> Activate -> send/recv -> Deactivate -> Disconnect",
01237 "periodic", "NEW", 1 ],
01238 [ test_connection_5,
01239 "Connect(in->out, periodic,SKIP) -> Activate -> send/recv -> Deactivate -> Disconnect",
01240 "periodic", "SKIP", 1 ],
01241
01242 ]
01243
01244
01245
01246
01247
01248
01249 def main():
01250
01251 initGlobal()
01252 ok_counter = 0
01253 ng_counter = 0
01254
01255 exit = 0
01256 result_message = ""
01257 for element in test_table:
01258 components_entry()
01259
01260 message = g_mess_header + g_test_case
01261 message = message + element[1]
01262 message = message + g_mess_footer
01263 fout = open(g_test_result_file, 'a')
01264 fout.write('\n' + message)
01265 fout.close()
01266 print ""
01267 print message
01268 ret = element[0](message,element[2],element[3],element[4])
01269 components_exit()
01270 if ret == False:
01271 ng_counter = ng_counter + 1
01272 exit = 1
01273 result_message = "!!!FAILURES!!!"
01274 break;
01275 else :
01276 ok_counter = ok_counter + 1
01277
01278
01279 print ""
01280 print result_message
01281 print "Test Results: "
01282 print "Run:",ok_counter+ng_counter," Failures:", ng_counter
01283 return exit
01284 if __name__ == "__main__":
01285 main()