diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 703e011c3..0da685bd7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -254,6 +254,8 @@ deploy_docs: - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config + # remove artifacts from last stage (UT logs) + - rm $LOG_PATH # clone test bench - git clone $GITLAB_SSH_SERVER/yinling/auto_test_script.git - cd auto_test_script @@ -277,6 +279,8 @@ deploy_docs: - base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config + # remove artifacts from last stage (UT logs) + - rm $LOG_PATH # clone test bench - git clone $GITLAB_SSH_SERVER/yinling/auto_test_script.git - cd auto_test_script @@ -345,7 +349,6 @@ IT_Function_TCPIP_02: tags: - ESP32_IDF - SSC_T1_1 - - SSC_T2_1 before_script: - CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_02.yml @@ -372,10 +375,73 @@ IT_Function_TCPIP_05: tags: - ESP32_IDF - SSC_T1_1 - - SSC_T2_1 before_script: - CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_05.yml +IT_Stress_WIFI_01: + <<: *test_template_night + tags: + - ESP32_IDF + - SSC_T5_1 + before_script: + - CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Stress_WIFI_01.yml + +IT_Stress_TCPIP_01: + <<: *test_template_night + tags: + - ESP32_IDF + - SSC_T1_1 + before_script: + - CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Stress_TCPIP_01.yml + +IT_Stress_TCPIP_02: + <<: *test_template_night + tags: + - ESP32_IDF + - SSC_T2_1 + before_script: + - CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Stress_TCPIP_02.yml + +IT_Stress_TCPIP_03: + <<: *test_template_night + tags: + - ESP32_IDF + - SSC_T1_1 + before_script: + - CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Stress_TCPIP_03.yml + +IT_Stress_TCPIP_04: + <<: *test_template_night + tags: + - ESP32_IDF + - SSC_T2_1 + before_script: + - CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Stress_TCPIP_04.yml + +IT_Stable_TCPIP_01: + <<: *test_template_night + tags: + - ESP32_IDF + - SSC_T5_1 + before_script: + - CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Stable_TCPIP_01.yml + +IT_Stable_TCPIP_02: + <<: *test_template_night + tags: + - ESP32_IDF + - SSC_T1_1 + before_script: + - CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Stable_TCPIP_02.yml + +IT_Stable_TCPIP_03: + <<: *test_template_night + tags: + - ESP32_IDF + - SSC_T5_1 + before_script: + - CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Stable_TCPIP_03.yml + IT_Function_TCPIP_06: <<: *test_template_night tags: @@ -388,7 +454,7 @@ IT_Function_WIFI_03: <<: *test_template tags: - ESP32_IDF - - SSC_T3_PhyMode + - SSC_T1_APC before_script: - CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_WIFI_03.yml @@ -396,7 +462,7 @@ IT_Function_WIFI_04: <<: *test_template tags: - ESP32_IDF - - SSC_T1_APC + - SSC_T3_PhyMode before_script: - CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_WIFI_04.yml @@ -422,7 +488,6 @@ IT_Function_TCPIP_07: - ESP32_IDF - SSC_T1_1 - SSC_T1_2 - - SSC_T2_1 before_script: - CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_07.yml @@ -431,6 +496,7 @@ IT_Function_TCPIP_08: tags: - ESP32_IDF - SSC_T1_1 + - SSC_T2_1 before_script: - CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_08.yml @@ -439,6 +505,7 @@ IT_Function_TCPIP_09: tags: - ESP32_IDF - SSC_T1_1 + - SSC_T1_2 before_script: - CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_09.yml @@ -448,7 +515,6 @@ IT_Function_TCPIP_10: - ESP32_IDF - SSC_T1_1 - SSC_T1_2 - - SSC_T2_1 before_script: - CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_10.yml @@ -457,7 +523,6 @@ IT_Function_TCPIP_11: tags: - ESP32_IDF - SSC_T1_1 - - SSC_T1_2 before_script: - CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_11.yml @@ -468,3 +533,4 @@ IT_Function_TCPIP_12: - SSC_T1_1 before_script: - CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_12.yml + diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_SYS_01.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_SYS_01.yml index 51a689902..2d332d38a 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_SYS_01.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_SYS_01.yml @@ -2,4 +2,6 @@ Config: {execute count: 1, execute order: in order} DUT: [SSC1] Filter: - Add: - ID: [SYS_MISC_0101, SYS_MISC_0201] + ID: + - SYS_MISC_0101 # test reboot function + - SYS_MISC_0201 # get heap size test diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_01.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_01.yml index e86fac28a..d9bad02c3 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_01.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_01.yml @@ -2,9 +2,34 @@ Config: {execute count: 1, execute order: in order} DUT: [SSC2, SSC1] Filter: - Add: - ID: [^TCPIP_DHCP_0302, TCPIP_DHCP_0302, TCPIP_DHCP_0301, TCPIP_TCP_0403, TCPIP_TCP_0402, - TCPIP_TCP_0401, TCPIP_TCP_0407, TCPIP_TCP_0406, ^TCPIP_TCP_0411, TCPIP_TCP_0404, - TCPIP_TCP_0408, TCPIP_TCP_0110, ^TCPIP_TCP_0111, TCPIP_TCP_0115, TCPIP_IP_0101, - TCPIP_IP_0102, ^TCPIP_IGMP_0102, ^TCPIP_IGMP_0101, ^TCPIP_IGMP_0104, TCPIP_IGMP_0104, - TCPIP_IGMP_0103, TCPIP_IGMP_0102, TCPIP_IGMP_0101, TCPIP_UDP_0108, TCPIP_UDP_0106, - TCPIP_UDP_0107, TCPIP_UDP_0105, TCPIP_UDP_0101, TCPIP_IGMP_0204, TCPIP_IGMP_0201] + ID: + - TCPIP_DHCP_0101 # dhcp client function test + - TCPIP_DHCP_0103 # dhcp status query + - TCPIP_DHCP_0201 # server dhcp lease test + - TCPIP_DHCP_0202 # dhcp server ip pool + - TCPIP_DHCP_0203 # dhcp server ip pool empty + - TCPIP_DHCP_0204 # dhcp server timeout test + - TCPIP_DHCP_0205 # disconnect STA if config dhcp server + - TCPIP_DHCP_0206 # dhcp server assign same IP to same MAC when it's not released + - TCPIP_DHCP_0207 # dhcp server prefer assign released IP to new client + - TCPIP_DHCP_0208 # dhcp server reconfig and new client able to get first IP in pool + - TCPIP_DHCP_0209 # dhcp server reconfig, old client and new client able to get IP + - TCPIP_DHCP_0210 # dhcp server reconfig, old client able to get IP (discover with requested IP) + - TCPIP_DHCP_0211 # dhcp server reconfig, old client able to renew IP (direct send request) + - TCPIP_DHCP_0212 # dhcp server function test + - TCPIP_DHCP_0301 # sta dhcp static ip interaction + - TCPIP_DHCP_0302 # ap dhcp static ip interaction + - TCPIP_IGMP_0101 # station IGMP join group address check + - TCPIP_IGMP_0102 # station IGMP leave group address check + - TCPIP_IGMP_0103 # softAP IGMP join group address check + - TCPIP_IGMP_0104 # softAP IGMP leave group address check + - TCPIP_IGMP_0201 # station IGMP recv packets + - TCPIP_IGMP_0202 # station send multicast packets + - TCPIP_IGMP_0203 # softAP IGMP recv packets + - TCPIP_IGMP_0204 # softAP send multicast packets + - TCPIP_IP_0101 # sta set and query static ip test + - TCPIP_IP_0102 # ap set and query static ip test + - TCPIP_TCP_0101 # STA mode, connect test. use different ip, port + - TCPIP_TCP_0102 # STA mode, server listen test. use different kinds of port + - TCPIP_TCP_0103 # STA mode, send/recv basic test + - TCPIP_TCP_0104 # STA mode, shutdown basic test diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_02.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_02.yml index a746cdd91..a1a927a08 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_02.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_02.yml @@ -1,10 +1,35 @@ Config: {execute count: 1, execute order: in order} -DUT: [SSC2, SSC1] +DUT: [SSC1] Filter: - Add: - ID: [TCPIP_IGMP_0202, TCPIP_IGMP_0203, ^TCPIP_TCP_0403, ^TCPIP_TCP_0408, TCPIP_UDP_0201, - ^TCPIP_DHCP_0301, ^TCPIP_TCP_0101, ^TCPIP_TCP_0103, ^TCPIP_TCP_0105, ^TCPIP_TCP_0104, - ^TCPIP_TCP_0107, ^TCPIP_TCP_0106, ^TCPIP_DHCP_0210, ^TCPIP_DHCP_0211, ^TCPIP_DHCP_0212, - ^TCPIP_TCP_0404, TCPIP_TCP_0212, TCPIP_TCP_0210, ^TCPIP_TCP_0406, ^TCPIP_TCP_0407, - ^TCPIP_TCP_0401, ^TCPIP_TCP_0210, ^TCPIP_TCP_0212, TCPIP_DHCP_0211, TCPIP_DHCP_0210, - TCPIP_DHCP_0212, TCPIP_DHCP_0101, TCPIP_DHCP_0103, TCPIP_DHCP_0206, TCPIP_DHCP_0207] + ID: + - TCPIP_TCP_0105 # STA mode, close for different types of TCP sockets test + - TCPIP_TCP_0106 # STA mode, create max TCP sockets test + - TCPIP_TCP_0107 # STA mode, accept max TCP client by server test + - TCPIP_TCP_0110 # AP mode, connect test. use different ip, port + - TCPIP_TCP_0111 # AP mode, server listen test. use different kinds of port + - TCPIP_TCP_0112 # AP mode, send/recv basic test + - TCPIP_TCP_0113 # AP mode, shutdown basic test + - TCPIP_TCP_0114 # AP mode, close for different types of TCP sockets test + - TCPIP_TCP_0115 # AP mode, create max TCP sockets test + - TCPIP_TCP_0116 # AP mode, accept max TCP client by server test + - TCPIP_TCP_0201 # STA mode, connect test. use socket in state that can't connect + - TCPIP_TCP_0202 # STA mode, server listen test. use socket in state that can't listen + - TCPIP_TCP_0203 # send test. use socket in state that can't send + - TCPIP_TCP_0204 # STA mode, recv buffer test + - TCPIP_TCP_0206 # STA mode, get active socket info test + - TCPIP_TCP_0207 # AP mode, connect test. use socket in state that can't connect + - TCPIP_TCP_0208 # AP mode, server listen test. use socket in state that can't listen + - TCPIP_TCP_0210 # AP mode, recv buffer test + - TCPIP_TCP_0212 # AP mode, get active socket info test + - TCPIP_TCP_0401 # do TCP send after WIFI disconnected + - TCPIP_TCP_0402 # close TCP socket after WIFI disconnected + - TCPIP_TCP_0403 # do TCP send after mode changed + - TCPIP_TCP_0404 # close TCP socket after mode changed + - TCPIP_TCP_0406 # close TCP socket after PC NIC disabled + - TCPIP_TCP_0407 # do TCP send after IP changed + - TCPIP_TCP_0408 # close TCP socket after IP changed + - TCPIP_TCP_0411 # do TCP send after socket changed + - TCPIP_TCP_0412 # close TCP send after socket changed + - TCPIP_UDP_0101 # STA mode, udp bind test. use different ip, port + - TCPIP_UDP_0105 # STA mode, close UDP sockets test diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_03.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_03.yml index f5f0abe5d..dcbd419ac 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_03.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_03.yml @@ -2,9 +2,34 @@ Config: {execute count: 1, execute order: in order} DUT: [SSC2, SSC1] Filter: - Add: - ID: [^TCPIP_IP_0102, ^TCPIP_UDP_0105, ^TCPIP_UDP_0107, ^TCPIP_UDP_0106, ^TCPIP_UDP_0101, - TCPIP_TCP_0202, ^TCPIP_UDP_0108, ^TCPIP_IGMP_0201, ^TCPIP_IGMP_0203, ^TCPIP_IGMP_0202, - ^TCPIP_IGMP_0103, TCPIP_UDP_0114, TCPIP_UDP_0113, TCPIP_UDP_0112, TCPIP_UDP_0202, - TCPIP_DHCP_0205, TCPIP_DHCP_0202, TCPIP_DHCP_0203, ^TCPIP_TCP_0102, TCPIP_TCP_0106, - TCPIP_TCP_0107, TCPIP_TCP_0104, TCPIP_TCP_0105, TCPIP_TCP_0102, TCPIP_TCP_0103, - TCPIP_TCP_0101, ^TCPIP_TCP_0116, ^TCPIP_TCP_0114, ^TCPIP_TCP_0115, ^TCPIP_TCP_0112] + ID: + - TCPIP_UDP_0106 # STA mode, create max udp socket test + - TCPIP_UDP_0107 # STA mode, get active socket info test + - TCPIP_UDP_0108 # AP mode, udp bind test. use different ip, port + - TCPIP_UDP_0112 # AP mode, close UDP sockets test + - TCPIP_UDP_0113 # AP mode, create max udp socket test + - TCPIP_UDP_0114 # AP mode, get active socket info test + - TCPIP_UDP_0201 # STA mode, recv buffer test + - TCPIP_UDP_0202 # AP mode, recv buffer test + - ^TCPIP_DHCP_0101 # dhcp client function test + - ^TCPIP_DHCP_0103 # dhcp status query + - ^TCPIP_DHCP_0201 # server dhcp lease test + - ^TCPIP_DHCP_0202 # dhcp server ip pool + - ^TCPIP_DHCP_0203 # dhcp server ip pool empty + - ^TCPIP_DHCP_0204 # dhcp server timeout test + - ^TCPIP_DHCP_0205 # disconnect STA if config dhcp server + - ^TCPIP_DHCP_0206 # dhcp server assign same IP to same MAC when it's not released + - ^TCPIP_DHCP_0207 # dhcp server prefer assign released IP to new client + - ^TCPIP_DHCP_0208 # dhcp server reconfig and new client able to get first IP in pool + - ^TCPIP_DHCP_0209 # dhcp server reconfig, old client and new client able to get IP + - ^TCPIP_DHCP_0210 # dhcp server reconfig, old client able to get IP (discover with requested IP) + - ^TCPIP_DHCP_0211 # dhcp server reconfig, old client able to renew IP (direct send request) + - ^TCPIP_DHCP_0212 # dhcp server function test + - ^TCPIP_DHCP_0301 # sta dhcp static ip interaction + - ^TCPIP_DHCP_0302 # ap dhcp static ip interaction + - ^TCPIP_IGMP_0101 # station IGMP join group address check + - ^TCPIP_IGMP_0102 # station IGMP leave group address check + - ^TCPIP_IGMP_0103 # softAP IGMP join group address check + - ^TCPIP_IGMP_0104 # softAP IGMP leave group address check + - ^TCPIP_IGMP_0201 # station IGMP recv packets + - ^TCPIP_IGMP_0202 # station send multicast packets diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_04.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_04.yml index b59e8c60c..17c74c6f7 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_04.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_04.yml @@ -2,9 +2,34 @@ Config: {execute count: 1, execute order: in order} DUT: [SSC2, SSC1] Filter: - Add: - ID: [^TCPIP_TCP_0113, ^TCPIP_TCP_0110, TCPIP_DHCP_0209, ^TCPIP_DHCP_0209, ^TCPIP_DHCP_0207, - ^TCPIP_DHCP_0206, ^TCPIP_DHCP_0205, ^TCPIP_DHCP_0204, ^TCPIP_DHCP_0203, ^TCPIP_DHCP_0202, - ^TCPIP_DHCP_0201, TCPIP_TCP_0204, TCPIP_TCP_0207, TCPIP_TCP_0206, TCPIP_TCP_0201, - ^TCPIP_DHCP_0101, TCPIP_TCP_0203, ^TCPIP_DHCP_0103, ^TCPIP_DHCP_0208, TCPIP_TCP_0208, - ^TCPIP_TCP_0202, ^TCPIP_TCP_0203, TCPIP_DHCP_0204, ^TCPIP_TCP_0201, ^TCPIP_TCP_0206, - ^TCPIP_TCP_0207, ^TCPIP_TCP_0204, TCPIP_DHCP_0201, ^TCPIP_TCP_0208, TCPIP_DHCP_0208] + ID: + - ^TCPIP_IGMP_0203 # softAP IGMP recv packets + - ^TCPIP_IGMP_0204 # softAP send multicast packets + - ^TCPIP_IP_0101 # sta set and query static ip test + - ^TCPIP_IP_0102 # ap set and query static ip test + - ^TCPIP_TCP_0101 # STA mode, connect test. use different ip, port + - ^TCPIP_TCP_0102 # STA mode, server listen test. use different kinds of port + - ^TCPIP_TCP_0103 # STA mode, send/recv basic test + - ^TCPIP_TCP_0104 # STA mode, shutdown basic test + - ^TCPIP_TCP_0105 # STA mode, close for different types of TCP sockets test + - ^TCPIP_TCP_0106 # STA mode, create max TCP sockets test + - ^TCPIP_TCP_0107 # STA mode, accept max TCP client by server test + - ^TCPIP_TCP_0110 # AP mode, connect test. use different ip, port + - ^TCPIP_TCP_0111 # AP mode, server listen test. use different kinds of port + - ^TCPIP_TCP_0112 # AP mode, send/recv basic test + - ^TCPIP_TCP_0113 # AP mode, shutdown basic test + - ^TCPIP_TCP_0114 # AP mode, close for different types of TCP sockets test + - ^TCPIP_TCP_0115 # AP mode, create max TCP sockets test + - ^TCPIP_TCP_0116 # AP mode, accept max TCP client by server test + - ^TCPIP_TCP_0201 # STA mode, connect test. use socket in state that can't connect + - ^TCPIP_TCP_0202 # STA mode, server listen test. use socket in state that can't listen + - ^TCPIP_TCP_0203 # send test. use socket in state that can't send + - ^TCPIP_TCP_0204 # STA mode, recv buffer test + - ^TCPIP_TCP_0206 # STA mode, get active socket info test + - ^TCPIP_TCP_0207 # AP mode, connect test. use socket in state that can't connect + - ^TCPIP_TCP_0208 # AP mode, server listen test. use socket in state that can't listen + - ^TCPIP_TCP_0210 # AP mode, recv buffer test + - ^TCPIP_TCP_0212 # AP mode, get active socket info test + - ^TCPIP_TCP_0401 # do TCP send after WIFI disconnected + - ^TCPIP_TCP_0402 # close TCP socket after WIFI disconnected + - ^TCPIP_TCP_0403 # do TCP send after mode changed diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_05.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_05.yml index 627d67c40..0b0705658 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_05.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_05.yml @@ -1,8 +1,21 @@ Config: {execute count: 1, execute order: in order} -DUT: [SSC2, SSC1] +DUT: [SSC1] Filter: - Add: - ID: [^TCPIP_IGMP_0204, ^TCPIP_TCP_0412, TCPIP_TCP_0411, TCPIP_TCP_0412, ^TCPIP_UDP_0112, - ^TCPIP_UDP_0113, ^TCPIP_UDP_0114, ^TCPIP_UDP_0202, ^TCPIP_UDP_0201, ^TCPIP_IP_0101, - ^TCPIP_TCP_0402, TCPIP_TCP_0114, TCPIP_TCP_0116, TCPIP_TCP_0111, TCPIP_TCP_0113, - TCPIP_TCP_0112] + ID: + - ^TCPIP_TCP_0404 # close TCP socket after mode changed + - ^TCPIP_TCP_0406 # close TCP socket after PC NIC disabled + - ^TCPIP_TCP_0407 # do TCP send after IP changed + - ^TCPIP_TCP_0408 # close TCP socket after IP changed + - ^TCPIP_TCP_0411 # do TCP send after socket changed + - ^TCPIP_TCP_0412 # close TCP send after socket changed + - ^TCPIP_UDP_0101 # STA mode, udp bind test. use different ip, port + - ^TCPIP_UDP_0105 # STA mode, close UDP sockets test + - ^TCPIP_UDP_0106 # STA mode, create max udp socket test + - ^TCPIP_UDP_0107 # STA mode, get active socket info test + - ^TCPIP_UDP_0108 # AP mode, udp bind test. use different ip, port + - ^TCPIP_UDP_0112 # AP mode, close UDP sockets test + - ^TCPIP_UDP_0113 # AP mode, create max udp socket test + - ^TCPIP_UDP_0114 # AP mode, get active socket info test + - ^TCPIP_UDP_0201 # STA mode, recv buffer test + - ^TCPIP_UDP_0202 # AP mode, recv buffer test diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_06.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_06.yml index 7cf627999..bdfeda4bb 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_06.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_06.yml @@ -2,4 +2,6 @@ Config: {execute count: 1, execute order: in order} DUT: [SSC1] Filter: - Add: - ID: [TCPIP_TCP_0405, ^TCPIP_TCP_0405] + ID: + - TCPIP_TCP_0405 # do TCP send after PC NIC disabled + - ^TCPIP_TCP_0405 # do TCP send after PC NIC disabled diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_07.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_07.yml index 839ac972f..862077d54 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_07.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_07.yml @@ -1,10 +1,35 @@ Config: {execute count: 1, execute order: in order} -DUT: [SSC2, SSC1] +DUT: [SSC1] Filter: - Add: - ID: [TCPIP_UDP_0303, TCPIP_UDP_0303, TCPIP_UDP_0303, TCPIP_UDP_0303, TCPIP_UDP_0303, - TCPIP_ICMP_0101, TCPIP_ICMP_0101, TCPIP_ICMP_0101, TCPIP_ICMP_0101, TCPIP_ICMP_0101, - TCPIP_DNS_0102, TCPIP_DNS_0102, TCPIP_DNS_0102, TCPIP_DNS_0102, TCPIP_DNS_0102, - TCPIP_DNS_0101, TCPIP_DNS_0101, TCPIP_DNS_0101, TCPIP_DNS_0101, TCPIP_DNS_0101, - ^TCPIP_ICMP_0101, ^TCPIP_ICMP_0101, ^TCPIP_ICMP_0101, ^TCPIP_ICMP_0101, ^TCPIP_ICMP_0101, - TCPIP_UDP_0109, TCPIP_UDP_0109, TCPIP_UDP_0109, TCPIP_UDP_0109, TCPIP_UDP_0109] + ID: + - TCPIP_DNS_0101 # get host by name test + - TCPIP_DNS_0101 # get host by name test + - TCPIP_DNS_0101 # get host by name test + - TCPIP_DNS_0101 # get host by name test + - TCPIP_DNS_0101 # get host by name test + - TCPIP_DNS_0102 # TCP connect to iot.espressif.com + - TCPIP_DNS_0102 # TCP connect to iot.espressif.com + - TCPIP_DNS_0102 # TCP connect to iot.espressif.com + - TCPIP_DNS_0102 # TCP connect to iot.espressif.com + - TCPIP_DNS_0102 # TCP connect to iot.espressif.com + - TCPIP_DNS_0103 # UDP send to iot.expressif.com + - TCPIP_DNS_0103 # UDP send to iot.expressif.com + - TCPIP_DNS_0103 # UDP send to iot.expressif.com + - TCPIP_DNS_0103 # UDP send to iot.expressif.com + - TCPIP_DNS_0103 # UDP send to iot.expressif.com + - TCPIP_ICMP_0101 # ping function test + - TCPIP_ICMP_0101 # ping function test + - TCPIP_ICMP_0101 # ping function test + - TCPIP_ICMP_0101 # ping function test + - TCPIP_ICMP_0101 # ping function test + - TCPIP_UDP_0102 # STA mode, sendto test. use different ip, port + - TCPIP_UDP_0102 # STA mode, sendto test. use different ip, port + - TCPIP_UDP_0102 # STA mode, sendto test. use different ip, port + - TCPIP_UDP_0102 # STA mode, sendto test. use different ip, port + - TCPIP_UDP_0102 # STA mode, sendto test. use different ip, port + - TCPIP_UDP_0103 # STA mode, sendto test with different length + - TCPIP_UDP_0103 # STA mode, sendto test with different length + - TCPIP_UDP_0103 # STA mode, sendto test with different length + - TCPIP_UDP_0103 # STA mode, sendto test with different length + - TCPIP_UDP_0103 # STA mode, sendto test with different length diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_08.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_08.yml index b318b0937..af6612e35 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_08.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_08.yml @@ -1,10 +1,35 @@ Config: {execute count: 1, execute order: in order} -DUT: [SSC1] +DUT: [SSC2, SSC1] Filter: - Add: - ID: [TCPIP_UDP_0104, TCPIP_UDP_0104, TCPIP_UDP_0104, TCPIP_UDP_0104, TCPIP_UDP_0104, - TCPIP_UDP_0102, TCPIP_UDP_0102, TCPIP_UDP_0102, TCPIP_UDP_0102, TCPIP_UDP_0102, - TCPIP_UDP_0103, TCPIP_UDP_0103, TCPIP_UDP_0103, TCPIP_UDP_0103, TCPIP_UDP_0103, - ^TCPIP_UDP_0307, ^TCPIP_UDP_0307, ^TCPIP_UDP_0307, ^TCPIP_UDP_0307, ^TCPIP_UDP_0307, - ^TCPIP_UDP_0306, ^TCPIP_UDP_0306, ^TCPIP_UDP_0306, ^TCPIP_UDP_0306, ^TCPIP_UDP_0306, - ^TCPIP_UDP_0305, ^TCPIP_UDP_0305, ^TCPIP_UDP_0305, ^TCPIP_UDP_0305, ^TCPIP_UDP_0305] + ID: + - TCPIP_UDP_0104 # STA mode, recvfrom basic test + - TCPIP_UDP_0104 # STA mode, recvfrom basic test + - TCPIP_UDP_0104 # STA mode, recvfrom basic test + - TCPIP_UDP_0104 # STA mode, recvfrom basic test + - TCPIP_UDP_0104 # STA mode, recvfrom basic test + - TCPIP_UDP_0109 # AP mode, sendto test. use different ip, port + - TCPIP_UDP_0109 # AP mode, sendto test. use different ip, port + - TCPIP_UDP_0109 # AP mode, sendto test. use different ip, port + - TCPIP_UDP_0109 # AP mode, sendto test. use different ip, port + - TCPIP_UDP_0109 # AP mode, sendto test. use different ip, port + - TCPIP_UDP_0110 # AP mode, sendto test with different length + - TCPIP_UDP_0110 # AP mode, sendto test with different length + - TCPIP_UDP_0110 # AP mode, sendto test with different length + - TCPIP_UDP_0110 # AP mode, sendto test with different length + - TCPIP_UDP_0110 # AP mode, sendto test with different length + - TCPIP_UDP_0111 # AP mode, recvfrom basic test + - TCPIP_UDP_0111 # AP mode, recvfrom basic test + - TCPIP_UDP_0111 # AP mode, recvfrom basic test + - TCPIP_UDP_0111 # AP mode, recvfrom basic test + - TCPIP_UDP_0111 # AP mode, recvfrom basic test + - TCPIP_UDP_0301 # do UDP send after WIFI disconnected + - TCPIP_UDP_0301 # do UDP send after WIFI disconnected + - TCPIP_UDP_0301 # do UDP send after WIFI disconnected + - TCPIP_UDP_0301 # do UDP send after WIFI disconnected + - TCPIP_UDP_0301 # do UDP send after WIFI disconnected + - TCPIP_UDP_0302 # close UDP socket after WIFI disconnected + - TCPIP_UDP_0302 # close UDP socket after WIFI disconnected + - TCPIP_UDP_0302 # close UDP socket after WIFI disconnected + - TCPIP_UDP_0302 # close UDP socket after WIFI disconnected + - TCPIP_UDP_0302 # close UDP socket after WIFI disconnected diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_09.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_09.yml index 50b50a3eb..1a78479f3 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_09.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_09.yml @@ -2,9 +2,34 @@ Config: {execute count: 1, execute order: in order} DUT: [SSC1] Filter: - Add: - ID: [^TCPIP_UDP_0304, ^TCPIP_UDP_0304, ^TCPIP_UDP_0304, ^TCPIP_UDP_0304, ^TCPIP_UDP_0304, - ^TCPIP_UDP_0302, ^TCPIP_UDP_0302, ^TCPIP_UDP_0302, ^TCPIP_UDP_0302, ^TCPIP_UDP_0302, - ^TCPIP_UDP_0301, ^TCPIP_UDP_0301, ^TCPIP_UDP_0301, ^TCPIP_UDP_0301, ^TCPIP_UDP_0301, - ^TCPIP_UDP_0104, ^TCPIP_UDP_0104, ^TCPIP_UDP_0104, ^TCPIP_UDP_0104, ^TCPIP_UDP_0104, - ^TCPIP_UDP_0103, ^TCPIP_UDP_0103, ^TCPIP_UDP_0103, ^TCPIP_UDP_0103, ^TCPIP_UDP_0103, - ^TCPIP_UDP_0102, ^TCPIP_UDP_0102, ^TCPIP_UDP_0102, ^TCPIP_UDP_0102, ^TCPIP_UDP_0102] + ID: + - TCPIP_UDP_0303 # do UDP send after mode changed + - TCPIP_UDP_0303 # do UDP send after mode changed + - TCPIP_UDP_0303 # do UDP send after mode changed + - TCPIP_UDP_0303 # do UDP send after mode changed + - TCPIP_UDP_0303 # do UDP send after mode changed + - TCPIP_UDP_0304 # close UDP socket after mode changed + - TCPIP_UDP_0304 # close UDP socket after mode changed + - TCPIP_UDP_0304 # close UDP socket after mode changed + - TCPIP_UDP_0304 # close UDP socket after mode changed + - TCPIP_UDP_0304 # close UDP socket after mode changed + - TCPIP_UDP_0305 # close UDP socket after PC NIC disabled + - TCPIP_UDP_0305 # close UDP socket after PC NIC disabled + - TCPIP_UDP_0305 # close UDP socket after PC NIC disabled + - TCPIP_UDP_0305 # close UDP socket after PC NIC disabled + - TCPIP_UDP_0305 # close UDP socket after PC NIC disabled + - TCPIP_UDP_0306 # do UDP send after IP changed + - TCPIP_UDP_0306 # do UDP send after IP changed + - TCPIP_UDP_0306 # do UDP send after IP changed + - TCPIP_UDP_0306 # do UDP send after IP changed + - TCPIP_UDP_0306 # do UDP send after IP changed + - TCPIP_UDP_0307 # close UDP socket after IP changed + - TCPIP_UDP_0307 # close UDP socket after IP changed + - TCPIP_UDP_0307 # close UDP socket after IP changed + - TCPIP_UDP_0307 # close UDP socket after IP changed + - TCPIP_UDP_0307 # close UDP socket after IP changed + - ^TCPIP_DNS_0101 # get host by name test + - ^TCPIP_DNS_0101 # get host by name test + - ^TCPIP_DNS_0101 # get host by name test + - ^TCPIP_DNS_0101 # get host by name test + - ^TCPIP_DNS_0101 # get host by name test diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_10.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_10.yml index 44b7bd189..1b7ca5675 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_10.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_10.yml @@ -1,10 +1,35 @@ Config: {execute count: 1, execute order: in order} -DUT: [SSC2, SSC1] +DUT: [SSC1] Filter: - Add: - ID: [TCPIP_UDP_0111, TCPIP_UDP_0111, TCPIP_UDP_0111, TCPIP_UDP_0111, TCPIP_UDP_0111, - TCPIP_UDP_0110, TCPIP_UDP_0110, TCPIP_UDP_0110, TCPIP_UDP_0110, TCPIP_UDP_0110, - ^TCPIP_DNS_0101, ^TCPIP_DNS_0101, ^TCPIP_DNS_0101, ^TCPIP_DNS_0101, ^TCPIP_DNS_0101, - ^TCPIP_DNS_0103, ^TCPIP_DNS_0103, ^TCPIP_DNS_0103, ^TCPIP_DNS_0103, ^TCPIP_DNS_0103, - ^TCPIP_DNS_0102, ^TCPIP_DNS_0102, ^TCPIP_DNS_0102, ^TCPIP_DNS_0102, ^TCPIP_DNS_0102, - TCPIP_UDP_0304, TCPIP_UDP_0304, TCPIP_UDP_0304, TCPIP_UDP_0304, TCPIP_UDP_0304] + ID: + - ^TCPIP_DNS_0102 # TCP connect to iot.espressif.com + - ^TCPIP_DNS_0102 # TCP connect to iot.espressif.com + - ^TCPIP_DNS_0102 # TCP connect to iot.espressif.com + - ^TCPIP_DNS_0102 # TCP connect to iot.espressif.com + - ^TCPIP_DNS_0102 # TCP connect to iot.espressif.com + - ^TCPIP_DNS_0103 # UDP send to iot.expressif.com + - ^TCPIP_DNS_0103 # UDP send to iot.expressif.com + - ^TCPIP_DNS_0103 # UDP send to iot.expressif.com + - ^TCPIP_DNS_0103 # UDP send to iot.expressif.com + - ^TCPIP_DNS_0103 # UDP send to iot.expressif.com + - ^TCPIP_ICMP_0101 # ping function test + - ^TCPIP_ICMP_0101 # ping function test + - ^TCPIP_ICMP_0101 # ping function test + - ^TCPIP_ICMP_0101 # ping function test + - ^TCPIP_ICMP_0101 # ping function test + - ^TCPIP_UDP_0102 # STA mode, sendto test. use different ip, port + - ^TCPIP_UDP_0102 # STA mode, sendto test. use different ip, port + - ^TCPIP_UDP_0102 # STA mode, sendto test. use different ip, port + - ^TCPIP_UDP_0102 # STA mode, sendto test. use different ip, port + - ^TCPIP_UDP_0102 # STA mode, sendto test. use different ip, port + - ^TCPIP_UDP_0103 # STA mode, sendto test with different length + - ^TCPIP_UDP_0103 # STA mode, sendto test with different length + - ^TCPIP_UDP_0103 # STA mode, sendto test with different length + - ^TCPIP_UDP_0103 # STA mode, sendto test with different length + - ^TCPIP_UDP_0103 # STA mode, sendto test with different length + - ^TCPIP_UDP_0104 # STA mode, recvfrom basic test + - ^TCPIP_UDP_0104 # STA mode, recvfrom basic test + - ^TCPIP_UDP_0104 # STA mode, recvfrom basic test + - ^TCPIP_UDP_0104 # STA mode, recvfrom basic test + - ^TCPIP_UDP_0104 # STA mode, recvfrom basic test diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_11.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_11.yml index be615d087..ed03676da 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_11.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_11.yml @@ -2,9 +2,34 @@ Config: {execute count: 1, execute order: in order} DUT: [SSC1] Filter: - Add: - ID: [TCPIP_UDP_0305, TCPIP_UDP_0305, TCPIP_UDP_0305, TCPIP_UDP_0305, TCPIP_UDP_0305, - TCPIP_UDP_0306, TCPIP_UDP_0306, TCPIP_UDP_0306, TCPIP_UDP_0306, TCPIP_UDP_0306, - TCPIP_UDP_0307, TCPIP_UDP_0307, TCPIP_UDP_0307, TCPIP_UDP_0307, TCPIP_UDP_0307, - TCPIP_UDP_0301, TCPIP_UDP_0301, TCPIP_UDP_0301, TCPIP_UDP_0301, TCPIP_UDP_0301, - TCPIP_UDP_0302, TCPIP_UDP_0302, TCPIP_UDP_0302, TCPIP_UDP_0302, TCPIP_UDP_0302, - TCPIP_DNS_0103, TCPIP_DNS_0103, TCPIP_DNS_0103, TCPIP_DNS_0103, TCPIP_DNS_0103] + ID: + - ^TCPIP_UDP_0110 # AP mode, sendto test with different length + - ^TCPIP_UDP_0110 # AP mode, sendto test with different length + - ^TCPIP_UDP_0110 # AP mode, sendto test with different length + - ^TCPIP_UDP_0110 # AP mode, sendto test with different length + - ^TCPIP_UDP_0110 # AP mode, sendto test with different length + - ^TCPIP_UDP_0301 # do UDP send after WIFI disconnected + - ^TCPIP_UDP_0301 # do UDP send after WIFI disconnected + - ^TCPIP_UDP_0301 # do UDP send after WIFI disconnected + - ^TCPIP_UDP_0301 # do UDP send after WIFI disconnected + - ^TCPIP_UDP_0301 # do UDP send after WIFI disconnected + - ^TCPIP_UDP_0302 # close UDP socket after WIFI disconnected + - ^TCPIP_UDP_0302 # close UDP socket after WIFI disconnected + - ^TCPIP_UDP_0302 # close UDP socket after WIFI disconnected + - ^TCPIP_UDP_0302 # close UDP socket after WIFI disconnected + - ^TCPIP_UDP_0302 # close UDP socket after WIFI disconnected + - ^TCPIP_UDP_0303 # do UDP send after mode changed + - ^TCPIP_UDP_0303 # do UDP send after mode changed + - ^TCPIP_UDP_0303 # do UDP send after mode changed + - ^TCPIP_UDP_0303 # do UDP send after mode changed + - ^TCPIP_UDP_0303 # do UDP send after mode changed + - ^TCPIP_UDP_0304 # close UDP socket after mode changed + - ^TCPIP_UDP_0304 # close UDP socket after mode changed + - ^TCPIP_UDP_0304 # close UDP socket after mode changed + - ^TCPIP_UDP_0304 # close UDP socket after mode changed + - ^TCPIP_UDP_0304 # close UDP socket after mode changed + - ^TCPIP_UDP_0305 # close UDP socket after PC NIC disabled + - ^TCPIP_UDP_0305 # close UDP socket after PC NIC disabled + - ^TCPIP_UDP_0305 # close UDP socket after PC NIC disabled + - ^TCPIP_UDP_0305 # close UDP socket after PC NIC disabled + - ^TCPIP_UDP_0305 # close UDP socket after PC NIC disabled diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_12.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_12.yml index 73b0187ee..a0f7e389d 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_12.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_TCPIP_12.yml @@ -2,5 +2,14 @@ Config: {execute count: 1, execute order: in order} DUT: [SSC1] Filter: - Add: - ID: [^TCPIP_UDP_0303, ^TCPIP_UDP_0303, ^TCPIP_UDP_0303, ^TCPIP_UDP_0303, ^TCPIP_UDP_0303, - ^TCPIP_UDP_0110, ^TCPIP_UDP_0110, ^TCPIP_UDP_0110, ^TCPIP_UDP_0110, ^TCPIP_UDP_0110] + ID: + - ^TCPIP_UDP_0306 # do UDP send after IP changed + - ^TCPIP_UDP_0306 # do UDP send after IP changed + - ^TCPIP_UDP_0306 # do UDP send after IP changed + - ^TCPIP_UDP_0306 # do UDP send after IP changed + - ^TCPIP_UDP_0306 # do UDP send after IP changed + - ^TCPIP_UDP_0307 # close UDP socket after IP changed + - ^TCPIP_UDP_0307 # close UDP socket after IP changed + - ^TCPIP_UDP_0307 # close UDP socket after IP changed + - ^TCPIP_UDP_0307 # close UDP socket after IP changed + - ^TCPIP_UDP_0307 # close UDP socket after IP changed diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_01.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_01.yml index 9f8424f6d..c59f16192 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_01.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_01.yml @@ -2,9 +2,34 @@ Config: {execute count: 1, execute order: in order} DUT: [SSC2, SSC1] Filter: - Add: - ID: [^WIFI_CONN_0601, ^WIFI_ADDR_0101, WIFI_SCAN_0103, WIFI_SCAN_0102, WIFI_SCAN_0101, - WIFI_SCAN_0105, WIFI_SCAN_0104, ^WIFI_CONN_0103, WIFI_CONN_0201, WIFI_CONN_0904, - ^WIFI_SCAN_0102, ^WIFI_SCAN_0103, ^WIFI_SCAN_0104, WIFI_CONN_0401, WIFI_ADDR_0101, - WIFI_ADDR_0102, WIFI_CONN_0301, WIFI_SCAN_0301, WIFI_SCAN_0303, ^WIFI_CONN_0801, - WIFI_SCAN_0304, ^WIFI_CONN_0301, WIFI_CONN_0501, WIFI_CONN_0502, ^WIFI_CONN_0401, - WIFI_MODE_0101, WIFI_MODE_0103, WIFI_MODE_0102, ^WIFI_CONN_0904, ^WIFI_CONN_0901] + ID: + - WIFI_ADDR_0101 # set mac, query mac + - WIFI_ADDR_0102 # set mac and do scan/JAP/SAP + - WIFI_CONN_0101 # station SAP+JAP test, different encryption + - WIFI_CONN_0102 # station SAP+JAP test, different channel + - WIFI_CONN_0103 # station SAP+JAP test, ssid hidden + - WIFI_CONN_0104 # station SAP test, max allowed sta + - WIFI_CONN_0201 # JAP query test + - WIFI_CONN_0301 # AP config query test + - WIFI_CONN_0401 # auto reconnect test + - WIFI_CONN_0501 # reconnect policy test + - WIFI_CONN_0502 # will not do reconnect after manually disconnected + - WIFI_CONN_0601 # list stations connected to soft ap test + - WIFI_CONN_0801 # test auth change event + - WIFI_CONN_0901 # test wifi disconnect reason REASON_ASSOC_LEAVE, REASON_4WAY_HANDSHAKE_TIMEOUT, REASON_NO_AP_FOUND + - WIFI_CONN_0904 # test wifi disconnect reason REASON_ASSOC_TOOMANY, REASON_HANDSHAKE_TIMEOUT, REASON_ASSOC_EXPIRE + - WIFI_MODE_0101 # mode switch test (sta mode) + - WIFI_MODE_0102 # mode switch test (AP mode) + - WIFI_MODE_0103 # mode switch test (STA+AP mode) + - WIFI_SCAN_0101 # scan with scan config ssid + - WIFI_SCAN_0102 # scan with scan config bssid + - WIFI_SCAN_0103 # scan with scan config channel + - WIFI_SCAN_0104 # scan with scan config show hidden + - WIFI_SCAN_0105 # scan with several configs + - WIFI_SCAN_0301 # reject scan request before scan finished + - WIFI_SCAN_0302 # scan in congest channel + - WIFI_SCAN_0303 # scan during JAP + - WIFI_SCAN_0304 # scan during ext STA join SoftAP + - ^WIFI_ADDR_0101 # set mac, query mac + - ^WIFI_ADDR_0102 # set mac and do scan/JAP/SAP + - ^WIFI_CONN_0101 # station SAP+JAP test, different encryption diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_02.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_02.yml index 74e6ca612..406950f79 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_02.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_02.yml @@ -2,6 +2,19 @@ Config: {execute count: 1, execute order: in order} DUT: [SSC2, SSC1] Filter: - Add: - ID: [WIFI_SCAN_0302, WIFI_CONN_0601, ^WIFI_CONN_0201, ^WIFI_ADDR_0102, WIFI_CONN_0901, - WIFI_CONN_0801, ^WIFI_CONN_0104, WIFI_CONN_0104, WIFI_CONN_0101, WIFI_CONN_0102, - WIFI_CONN_0103, ^WIFI_SCAN_0101, ^WIFI_CONN_0101, ^WIFI_CONN_0502, ^WIFI_CONN_0501] + ID: + - ^WIFI_CONN_0103 # station SAP+JAP test, ssid hidden + - ^WIFI_CONN_0104 # station SAP test, max allowed sta + - ^WIFI_CONN_0201 # JAP query test + - ^WIFI_CONN_0301 # AP config query test + - ^WIFI_CONN_0401 # auto reconnect test + - ^WIFI_CONN_0501 # reconnect policy test + - ^WIFI_CONN_0502 # will not do reconnect after manually disconnected + - ^WIFI_CONN_0601 # list stations connected to soft ap test + - ^WIFI_CONN_0801 # test auth change event + - ^WIFI_CONN_0901 # test wifi disconnect reason REASON_ASSOC_LEAVE, REASON_4WAY_HANDSHAKE_TIMEOUT, REASON_NO_AP_FOUND + - ^WIFI_CONN_0904 # test wifi disconnect reason REASON_ASSOC_TOOMANY, REASON_HANDSHAKE_TIMEOUT, REASON_ASSOC_EXPIRE + - ^WIFI_SCAN_0101 # scan with scan config ssid + - ^WIFI_SCAN_0102 # scan with scan config bssid + - ^WIFI_SCAN_0103 # scan with scan config channel + - ^WIFI_SCAN_0104 # scan with scan config show hidden diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_03.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_03.yml index 0f0b4bbaa..e5de3ea97 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_03.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_03.yml @@ -1,6 +1,7 @@ Config: {execute count: 1, execute order: in order} -DUT: [SSC3, SSC2, SSC1] +DUT: [SSC1] Filter: - Add: - ID: [WIFI_PHY_0502, WIFI_PHY_0503, WIFI_PHY_0501, WIFI_PHY_0506, WIFI_PHY_0505, - WIFI_PHY_0504] + ID: + - WIFI_CONN_0902 # test wifi disconnect reason REASON_BEACON_TIMEOUT + - ^WIFI_CONN_0902 # test wifi disconnect reason REASON_BEACON_TIMEOUT diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_04.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_04.yml index 50f8707c7..fb4950f7d 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_04.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_04.yml @@ -1,5 +1,11 @@ Config: {execute count: 1, execute order: in order} -DUT: [SSC1] +DUT: [SSC3, SSC2, SSC1] Filter: - Add: - ID: [^WIFI_CONN_0902, WIFI_CONN_0902] + ID: + - WIFI_PHY_0501 # SoftAP STA in channel1 20M, STA changed to channel2 20M + - WIFI_PHY_0502 # SoftAP STA in channel1 20M, STA changed to channel2 40M + - WIFI_PHY_0503 # SoftAP STA in channel1, SoftAP 20M, STA 40M, STA changed to channel2 20M + - WIFI_PHY_0504 # SoftAP STA in channel1, SoftAP 20M, STA 40M, STA changed to channel2 40M + - WIFI_PHY_0505 # SoftAP STA in channel1, SoftAP 40M, STA 40M, STA changed to channel2 20M + - WIFI_PHY_0506 # SoftAP STA in channel1, SoftAP 40M, STA 40M, STA changed to channel2 40M diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_05.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_05.yml index 3694a698b..298e49a5b 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_05.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_05.yml @@ -2,4 +2,6 @@ Config: {execute count: 1, execute order: in order} DUT: [SSC1] Filter: - Add: - ID: [^WIFI_CONN_0903, WIFI_CONN_0903] + ID: + - WIFI_CONN_0903 # test wifi disconnect reason REASON_AUTH_EXPIRE + - ^WIFI_CONN_0903 # test wifi disconnect reason REASON_AUTH_EXPIRE diff --git a/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_06.yml b/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_06.yml index dd42815a9..b655bbc6c 100644 --- a/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_06.yml +++ b/components/idf_test/integration_test/CIConfigs/IT_Function_WIFI_06.yml @@ -2,5 +2,13 @@ Config: {execute count: 1, execute order: in order} DUT: [SSC2, SSC1] Filter: - Add: - ID: [WIFI_SCAN_0201, WIFI_PHY_0403, WIFI_PHY_0402, WIFI_PHY_0401, WIFI_PHY_0407, - WIFI_PHY_0406, WIFI_PHY_0405, WIFI_PHY_0404, WIFI_PHY_0408] + ID: + - WIFI_PHY_0401 # SoftAP ext AP in defferent channel, both bandwidth 20M, STA connect to AP then Softap get connected + - WIFI_PHY_0402 # SoftAP ext AP in defferent channel, both bandwidth 20M, Softap get connected than STA connect to AP + - WIFI_PHY_0403 # SoftAP ext AP in defferent channel, SoftAP 20M, ext AP 40M, STA connect to AP then Softap get connected + - WIFI_PHY_0404 # SoftAP ext AP in defferent channel, SoftAP 20M, ext AP 40M, Softap get connected than STA connect to AP + - WIFI_PHY_0405 # SoftAP ext AP in defferent channel, both bandwidth 40M, STA connect to AP then Softap get connected + - WIFI_PHY_0406 # SoftAP ext AP in defferent channel, both bandwidth 40M, Softap get connected than STA connect to AP + - WIFI_PHY_0407 # SoftAP ext AP in defferent channel, SoftAP 40M, ext AP 20M, STA connect to AP then Softap get connected + - WIFI_PHY_0408 # SoftAP ext AP in defferent channel, SoftAP 40M, ext AP 20M, Softap get connected than STA connect to AP + - WIFI_SCAN_0201 # STA in differnt PHY mode to scan AP in different PHY mode diff --git a/components/idf_test/integration_test/CIConfigs/IT_Stable_TCPIP_01.yml b/components/idf_test/integration_test/CIConfigs/IT_Stable_TCPIP_01.yml new file mode 100644 index 000000000..5e9fea164 --- /dev/null +++ b/components/idf_test/integration_test/CIConfigs/IT_Stable_TCPIP_01.yml @@ -0,0 +1,6 @@ +Config: {execute count: 1, execute order: in order} +DUT: [SSC3, SSC2, SSC1, SSC5, SSC4] +Filter: +- Add: + ID: + - TCPIP_TCP_5101 # 1 AP 4 STA TCP stable test diff --git a/components/idf_test/integration_test/CIConfigs/IT_Stable_TCPIP_02.yml b/components/idf_test/integration_test/CIConfigs/IT_Stable_TCPIP_02.yml new file mode 100644 index 000000000..4f7070605 --- /dev/null +++ b/components/idf_test/integration_test/CIConfigs/IT_Stable_TCPIP_02.yml @@ -0,0 +1,6 @@ +Config: {execute count: 1, execute order: in order} +DUT: [SSC1] +Filter: +- Add: + ID: + - TCPIP_TCP_5102 # send random length segment to target diff --git a/components/idf_test/integration_test/CIConfigs/IT_Stable_TCPIP_03.yml b/components/idf_test/integration_test/CIConfigs/IT_Stable_TCPIP_03.yml new file mode 100644 index 000000000..14cc0695a --- /dev/null +++ b/components/idf_test/integration_test/CIConfigs/IT_Stable_TCPIP_03.yml @@ -0,0 +1,6 @@ +Config: {execute count: 1, execute order: in order} +DUT: [SSC3, SSC2, SSC1, SSC5, SSC4] +Filter: +- Add: + ID: + - TCPIP_TCP_5103 # TCP SoftSTA send/recv stress test diff --git a/components/idf_test/integration_test/CIConfigs/IT_Stress_TCPIP_01.yml b/components/idf_test/integration_test/CIConfigs/IT_Stress_TCPIP_01.yml new file mode 100644 index 000000000..6ec2644dc --- /dev/null +++ b/components/idf_test/integration_test/CIConfigs/IT_Stress_TCPIP_01.yml @@ -0,0 +1,6 @@ +Config: {execute count: 1, execute order: in order} +DUT: [SSC1] +Filter: +- Add: + ID: + - TCPIP_TCP_5001 # test possible TCP connect/disconnect method diff --git a/components/idf_test/integration_test/CIConfigs/IT_Stress_TCPIP_02.yml b/components/idf_test/integration_test/CIConfigs/IT_Stress_TCPIP_02.yml new file mode 100644 index 000000000..a6315ddee --- /dev/null +++ b/components/idf_test/integration_test/CIConfigs/IT_Stress_TCPIP_02.yml @@ -0,0 +1,6 @@ +Config: {execute count: 1, execute order: in order} +DUT: [SSC2, SSC1] +Filter: +- Add: + ID: + - TCPIP_TCP_5201 # TCP send/recv stress test diff --git a/components/idf_test/integration_test/CIConfigs/IT_Stress_TCPIP_03.yml b/components/idf_test/integration_test/CIConfigs/IT_Stress_TCPIP_03.yml new file mode 100644 index 000000000..6fd1ba912 --- /dev/null +++ b/components/idf_test/integration_test/CIConfigs/IT_Stress_TCPIP_03.yml @@ -0,0 +1,6 @@ +Config: {execute count: 1, execute order: in order} +DUT: [SSC1] +Filter: +- Add: + ID: + - TCPIP_TCP_5202 # TCP send/recv data validation diff --git a/components/idf_test/integration_test/CIConfigs/IT_Stress_TCPIP_04.yml b/components/idf_test/integration_test/CIConfigs/IT_Stress_TCPIP_04.yml new file mode 100644 index 000000000..0bc473a8b --- /dev/null +++ b/components/idf_test/integration_test/CIConfigs/IT_Stress_TCPIP_04.yml @@ -0,0 +1,6 @@ +Config: {execute count: 1, execute order: in order} +DUT: [SSC2, SSC1] +Filter: +- Add: + ID: + - TCPIP_UDP_5001 # UDP send/recv stress test diff --git a/components/idf_test/integration_test/CIConfigs/IT_Stress_WIFI_01.yml b/components/idf_test/integration_test/CIConfigs/IT_Stress_WIFI_01.yml new file mode 100644 index 000000000..4ab82dded --- /dev/null +++ b/components/idf_test/integration_test/CIConfigs/IT_Stress_WIFI_01.yml @@ -0,0 +1,6 @@ +Config: {execute count: 1, execute order: in order} +DUT: [SSC3, SSC2, SSC1, SSC5, SSC4] +Filter: +- Add: + ID: + - WIFI_CONN_5101 # max sta connect to SotfAP and disconnect diff --git a/components/idf_test/integration_test/TestCaseAll.yml b/components/idf_test/integration_test/TestCaseAll.yml index 9e4823a29..7e91ba7cb 100644 --- a/components/idf_test/integration_test/TestCaseAll.yml +++ b/components/idf_test/integration_test/TestCaseAll.yml @@ -4307,6 +4307,291 @@ test cases: test point 1: abnormal/special use test point 2: TCP handling abnormal event version: v1 (2016-8-15) +- CI ready: 'Yes' + ID: TCPIP_TCP_5001 + SDK: '8266_NonOS + + 8266_RTOS + + ESP32_IDF' + Test App: SSC + auto test: 'Yes' + category: Stress + cmd set: + - TCPStress/TCPConnection + - - max_connection = 5 + - [dummy] + - - execute_time = 300 + - [''] + - - connect_method = ["C_01", "C_02", "C_05", "C_07"] + - [''] + - - disconnect_method = ["D_01", "D_03", "D_05", "D_06"] + - [''] + - - pc_ip = "pc_ip" + - [''] + - - target_ip = "target_ip" + - [''] + comment: '' + execution time: 5.0 + expected result: 1. succeed + initial condition: STAM2 + initial condition description (auto): sta mode, join AP, DHCP on + level: Integration + module: TCPIP + steps: '1. random choose connect method to do connect, random choose a method to + close + + Loop executing step 1' + sub module: TCP + summary: test possible TCP connect/disconnect method + test environment: SSC_T1_1 + test environment description (auto): 'PC has 2 wired NIC connected to AP. + + PC has 1 WiFi NIC. + + 1 SSC target connect with PC by UART.' + test point 1: function + stress + test point 2: TCP connect and disconnect test + version: v2 (2016-11-15) +- CI ready: 'Yes' + ID: TCPIP_TCP_5101 + SDK: '8266_NonOS + + 8266_RTOS + + ESP32_IDF' + Test App: SSC + auto test: 'Yes' + category: Stable + cmd set: + - TCPStress/TCPAPNSTA + - - send_len = 1460 + - [dummy] + - - test_count = 0xFFFFFF + - [''] + - - server_port = "" + - [''] + - - server_echo = True + - [''] + - - sta_number = 4 + - [''] + - - send_delay = 50 + - [''] + - - pass_standard = (4*3600) + - [''] + - - ap_ip = "" + - [''] + comment: '' + execution time: 12.0 + expected result: '1. succeed + + 2. succeed + + 3. succeed + + 4. all TCP connection not disconnected' + initial condition: None + initial condition description (auto): none + level: Integration + module: TCPIP + steps: '1. all sta connect to softap + + 2. create tcp server on softap + + 3. all sta connect to softap tcp server + + 4. do bi-direction send on all tcp connections' + sub module: TCP + summary: 1 AP 4 STA TCP stable test + test environment: SSC_T5_1 + test environment description (auto): 5 SSC target connect with PC by UART. + test point 1: stable + test point 2: TCP stable test + version: v2 (2016-11-15) +- CI ready: 'Yes' + ID: TCPIP_TCP_5102 + SDK: '8266_NonOS + + 8266_RTOS + + ESP32_IDF' + Test App: SSC + auto test: 'Yes' + category: Stable + cmd set: + - TCPStress/TCPRandomSend + - - delay_config = [0, 0.01, 0.1, 0.5, 1] + - [dummy] + - - send_count = 1000 + - [''] + - - test_time = 300 + - [''] + comment: '' + execution time: 12.0 + expected result: '1. succeed + + 2. succeed' + initial condition: STAM2 + initial condition description (auto): sta mode, join AP, DHCP on + level: Integration + module: TCPIP + steps: '1. create TCP connection + + 2. PC send random length data to target' + sub module: TCP + summary: send random length segment to target + test environment: SSC_T1_1 + test environment description (auto): 'PC has 2 wired NIC connected to AP. + + PC has 1 WiFi NIC. + + 1 SSC target connect with PC by UART.' + test point 1: stable + test point 2: TCP stable test + version: v2 (2016-11-15) +- CI ready: 'Yes' + ID: TCPIP_TCP_5103 + SDK: '8266_NonOS + + 8266_RTOS + + ESP32_IDF' + Test App: SSC + auto test: 'Yes' + category: Stable + cmd set: + - TCPStress/TCPSoftAPSTASendRecv + - - send_len = 1460 + - [dummy] + - - test_count = 0xFFFFFF + - [''] + - - server_port = "" + - [''] + - - server_port_2 = "" + - [''] + - - server_echo = True + - [''] + - - sta_number = 3 + - [''] + - - send_delay = 50 + - [''] + - - pass_standard = (4*3600) + - [''] + - - ap_ip = "" + - [''] + comment: '' + execution time: 12.0 + expected result: '1. succeed + + 2. verify reciveid data on target and PC succeed' + initial condition: None + initial condition description (auto): none + level: Integration + module: TCPIP + steps: '1. create TCP connection + + 2. send specified pattern on both direction' + sub module: TCP + summary: TCP SoftSTA send/recv stress test + test environment: SSC_T5_1 + test environment description (auto): 5 SSC target connect with PC by UART. + test point 1: stable + test point 2: TCP stable test + version: v2 (2016-11-15) +- CI ready: 'Yes' + ID: TCPIP_TCP_5201 + SDK: '8266_NonOS + + 8266_RTOS + + ESP32_IDF' + Test App: SSC + auto test: 'Yes' + category: Stress + cmd set: + - TCPStress/TCPSendRecv + - - send_len = 1460 + - [dummy] + - - test_time = 300 + - [''] + - - duplex = True + - [''] + - - conn_num = 5 + - [''] + - - send_delay = 20 + - [''] + comment: '' + execution time: 12.0 + expected result: '1. succeed + + 2. succeed + + 3. all TCP connection not disconnected' + initial condition: T2_1 + initial condition description (auto): target 1 as SoftAP, target 2 as STA + level: Integration + module: TCPIP + steps: '1. sta connect to softap + + 2. create multiple tcp connection + + 3. do send/recv on all tcp connections' + sub module: TCP + summary: TCP send/recv stress test + test environment: SSC_T2_1 + test environment description (auto): 'PC has 1 wired NIC connected to AP. + + PC has 1 WiFi NIC. + + 2 SSC target connect with PC by UART.' + test point 1: stress + test point 2: TCP stress test + version: v2 (2016-11-15) +- CI ready: 'Yes' + ID: TCPIP_TCP_5202 + SDK: '8266_NonOS + + 8266_RTOS + + ESP32_IDF' + Test App: SSC + auto test: 'Yes' + category: Stress + cmd set: + - TCPStress/TCPDataValidation + - - test_time = 1440 + - [dummy] + - - tx_enable = True + - [''] + - - rx_enable = True + - [''] + - - conn_num = 1 + - [''] + - - send_len = 1024 + - [''] + comment: '' + execution time: 24.0 + expected result: '1. succeed + + 2. verify reciveid data on target and PC succeed' + initial condition: STAM2 + initial condition description (auto): sta mode, join AP, DHCP on + level: Integration + module: TCPIP + steps: '1. create TCP connection + + 2. send specified pattern on both direction' + sub module: TCP + summary: TCP send/recv data validation + test environment: SSC_T1_1 + test environment description (auto): 'PC has 2 wired NIC connected to AP. + + PC has 1 WiFi NIC. + + 1 SSC target connect with PC by UART.' + test point 1: stress + test point 2: TCP stress test + version: v2 (2016-11-15) - CI ready: 'Yes' ID: TCPIP_UDP_0101 SDK: '8266_NonOS @@ -5653,6 +5938,55 @@ test cases: test point 1: abnormal/special use test point 2: UDP handling abnormal event version: v1 (2016-8-15) +- CI ready: 'Yes' + ID: TCPIP_UDP_5001 + SDK: '8266_NonOS + + 8266_RTOS + + ESP32_IDF' + Test App: SSC + auto test: 'Yes' + category: Stress + cmd set: + - UDPStress/UDPSendRecv + - - send_len = 1460 + - [dummy] + - - test_time = 300 + - [''] + - - duplex = True + - [''] + - - conn_num = 5 + - [''] + - - send_delay = 20 + - [''] + comment: '' + execution time: 12.0 + expected result: '1. succeed + + 2. succeed + + 3. succeed' + initial condition: T2_1 + initial condition description (auto): target 1 as SoftAP, target 2 as STA + level: Integration + module: TCPIP + steps: '1. sta connect to softap + + 2. create multiple udp + + 3. do send/recv on all udp' + sub module: UDP + summary: UDP send/recv stress test + test environment: SSC_T2_1 + test environment description (auto): 'PC has 1 wired NIC connected to AP. + + PC has 1 WiFi NIC. + + 2 SSC target connect with PC by UART.' + test point 1: stress + test point 2: UDP stress test + version: v2 (2016-11-15) - CI ready: 'Yes' ID: WIFI_ADDR_0101 SDK: '8266_NonOS @@ -6666,6 +7000,53 @@ test cases: test point 1: basic function test point 2: wifi disconnect reason test version: v1 (2016-8-15) +- CI ready: 'Yes' + ID: WIFI_CONN_5101 + SDK: '8266_NonOS + + 8266_RTOS + + ESP32_IDF' + Test App: SSC + auto test: 'Yes' + category: Stress + cmd set: + - WiFiStress/SoftAPNSTA + - - sta_num = 4 + - [dummy] + - - max_sta = 4 + - [''] + - - test_time = 300 + - [''] + - - delay1 = [0, 1] + - [''] + - - delay2 = [0, 1] + - [''] + - - change_mac = True + - [''] + - - channel = 1 + - [''] + comment: '' + execution time: 5.0 + expected result: '1. succeed + + 2. JAP succeed' + initial condition: None + initial condition description (auto): none + level: Integration + module: WIFI MAC + steps: '1. 1 target set to softap mode and rest set to sta mode + + 2. all sta random join and disconnect from softap + + Loop step 2' + sub module: WIFI Connect + summary: max sta connect to SotfAP and disconnect + test environment: SSC_T5_1 + test environment description (auto): 5 SSC target connect with PC by UART. + test point 1: stress + test point 2: SoftAP WIFI connect/disconnect stress test + version: v2 (2016-11-15) - CI ready: 'Yes' ID: WIFI_MODE_0101 SDK: '8266_NonOS diff --git a/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPAPNSTA.py b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPAPNSTA.py new file mode 100755 index 000000000..71e3038be --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPAPNSTA.py @@ -0,0 +1,203 @@ +from TCAction import TCActionBase +from NativeLog import NativeLog +import time +import random +import string + + +TEST_COUNT_ONE_ROUND = 500 + + +class TestCase(TCActionBase.CommonTCActionBase): + + def __init__(self, test_case, test_env, timeout=30, log_path=TCActionBase.LOG_PATH): + TCActionBase.CommonTCActionBase.__init__(self, test_case, test_env, timeout=timeout, log_path=log_path) + # load param from excel + cmd_set = test_case["cmd set"] + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name) + pass + + def execute(self): + TCActionBase.TCActionBase.execute(self) + self.result_cntx.start() + + try: + # configurable params + send_len = self.send_len + test_count = self.test_count + server_echo = self.server_echo + sta_number = self.sta_number + test_time = self.test_time * 60 + send_delay = self.send_delay + ap_ip = self.get_parameter("target_ap_ip") + # configurable params + except StandardError, e: + NativeLog.add_trace_critical("Error configuration for TCPTransparent script, error is %s" % e) + raise StandardError("Error configuration") + + # step0 reboot + checker_stings = [] + test_action_string = [] + + for i in range(sta_number+1): + checker_stings.append("P SSC%d C !!!ready!!!" % (i+1)) + test_action_string.append("SSCC SSC%d reboot" % (i+1)) + + fail_string = "Fail, Fail to reboot" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step1 set ap on SSC1, create server + checker_stings = ["R SSC1 C +MODE:OK"] + test_action_string = ["SSCC SSC1 op -S -o 2"] + fail_string = "Fail, Fail set mode" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + ssid = "".join([random.choice(string.lowercase) for m in range(10)]) + password = "".join([random.choice(string.lowercase) for m in range(10)]) + tcp_port = random.randint(10000, 20000) + + checker_stings = ["R SSC1 C +SAP:OK"] + test_action_string = ["SSCC SSC1 ap -S -s %s -p %s -t 3 -m 8" % (ssid, password)] + fail_string = "Fail, Fail set ap" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["R SSC1 A :BIND:(\d+),OK"] + test_action_string = ["SSCC SSC1 soc -B -t TCP -p %s" % tcp_port] + fail_string = "Fail, Fail create server" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["R SSC1 RE LISTEN:(\d+),OK"] + test_action_string = ["SSCC SSC1 soc -L -s "] + fail_string = "Fail, Fail create server" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step 2, 8 SSC target(SSC2 - SSC9) join SSC1 soft AP + checker_stings = [] + test_action_string = [] + for i in range(sta_number): + checker_stings.append("P SSC%d C +MODE:OK" % (i+2)) + test_action_string.append("SSCC SSC%d op -S -o 1" % (i+2)) + fail_string = "Fail, Fail set mode" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = [] + test_action_string = [] + for i in range(sta_number): + checker_stings.append("P SSC%d C +JAP:CONNECTED,%s" % (i+2, ssid)) + test_action_string.append("SSCC SSC%d ap -C -s %s -p %s" % (i+2, ssid, password)) + fail_string = "Fail, Fail to connect to server" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step 3, create client on SSC2 - SSC9 + checker_stings = [] + test_action_string = [] + for i in range(sta_number): + checker_stings.append("P SSC%d A :BIND:(\d+),OK" % (i+2, i+2)) + test_action_string.append("SSCC SSC%d soc -B -t TCP" % (i+2)) + fail_string = "Fail, Fail to connect to server" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + for i in range(sta_number): + checker_stings = ["P SSC%d RE CONNECT:(\d+),OK" % (i+2), + "P SSC1 A :ACCEPT:(\d+),.+" % (i+2)] + test_action_string = ["SSCC SSC%d soc -C -s -i %s -p %s" % + (i+2, i+2, ap_ip, tcp_port)] + fail_string = "Fail, Fail to connect to server" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + start_time = time.time() + # step 4, do send/recv + while test_count > 0: + _tmp_count = TEST_COUNT_ONE_ROUND if test_count - TEST_COUNT_ONE_ROUND > 0 else test_count + test_count -= TEST_COUNT_ONE_ROUND + + checker_stings = [] + test_action_string = [] + for i in range(sta_number): + checker_stings.append("P SSC%d RE \+SEND:\d+,OK NC CLOSED" % (i+2)) + test_action_string.append("SSC SSC%d soc -S -s -l %d -n %d -j %d" % + (i+2, i+2, send_len, _tmp_count, send_delay)) + if server_echo is True: + test_action_string.append("SSC SSC1 soc -S -s -l %d -n %d -j %d" % + (i+2, send_len, _tmp_count, send_delay)) + checker_stings.append("P SSC1 RE \"\+SEND:%%%%s,OK\"%%%%() NC CLOSED)" % + (i+2)) + + fail_string = "Fail, Failed to send/recv data" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, + check_freq=1, check_time=300) is False: + break + + NativeLog.add_prompt_trace("time escape: %s" % (time.time() - start_time)) + + if (time.time() - start_time) >= test_time: + self.result_cntx.set_result("Succeed") + else: + checker_stings = [] + test_action_string = [] + for i in range(sta_number + 1): + checker_stings.append("P SSC%d C CLOSEALL" % (i + 1)) + test_action_string.append("SSCC SSC%d soc -T" % (i + 1)) + fail_string = "Fail, Fail to close socket" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + server_port = random.randint(20000, 30000) + checker_stings = ["R SSC1 A :BIND:(\d+),OK"] + test_action_string = ["SSCC SSC1 soc -B -t TCP -p %s" % server_port] + fail_string = "Fail, Fail to bind socket" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["R SSC1 RE LISTEN:(\d+),OK"] + test_action_string = ["SSCC SSC1 soc -L -s "] + fail_string = "Fail, Fail to listen" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = [] + test_action_string = [] + for i in range(sta_number): + checker_stings.append("P SSC%d A :BIND:(\d+),OK" % (i + 2, i + 2)) + test_action_string.append("SSCC SSC%d soc -B -t TCP" % (i + 2)) + fail_string = "Fail, Fail to connect to server" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + for i in range(sta_number): + checker_stings = ["P SSC%d RE CONNECT:(\d+),OK" % (i + 2), + "P SSC1 A :ACCEPT:(\d+),.+" % (i + 2)] + test_action_string = ["SSCC SSC%d soc -C -s -i %s -p %s" % + (i + 2, i + 2, ap_ip, server_port)] + fail_string = "Fail, Fail to connect to server" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + self.result_cntx.set_result("Failed") + + # finally, execute done + + def result_check(self, port_name, data): + TCActionBase.CommonTCActionBase.result_check(self, port_name, data) + self.result_cntx.append_data(port_name, data) + + +def main(): + pass + +if __name__ == '__main__': + main() + diff --git a/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPConnection.py b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPConnection.py new file mode 100755 index 000000000..7bedcaf8a --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPConnection.py @@ -0,0 +1,335 @@ +import random +import re +import socket +import threading +import time + +import TCPConnectionUtility +from NativeLog import NativeLog +from TCAction import PerformanceTCBase + +DELAY_RANGE = [10, 3000] +CONNECTION_STRUCTURE = ("Connection handler", "PC socket", "Target socket id", + "Target port", "PC port", "PC state", "Target state") + +# max fail count for one connection during test +MAX_FAIL_COUNT = 10 + + +class CheckerBase(threading.Thread): + + CHECK_ITEM = ("CONDITION", "NOTIFIER", "ID", "DATA") + SLEEP_TIME = 0.1 # sleep 100ms between each check action + + def __init__(self): + threading.Thread.__init__(self) + self.setDaemon(True) + self.exit_event = threading.Event() + self.sync_lock = threading.Lock() + self.check_item_list = [] + self.check_item_id = 0 + + def run(self): + while self.exit_event.isSet() is False: + self.process() + pass + + def process(self): + pass + + def add_check_item(self, condition, notifier): + with self.sync_lock: + check_item_id = self.check_item_id + self.check_item_id += 1 + self.check_item_list.append(dict(zip(self.CHECK_ITEM, (condition, notifier, check_item_id, str())))) + return check_item_id + + def remove_check_item(self, check_item_id): + ret = None + with self.sync_lock: + check_items = filter(lambda x: x["ID"] == check_item_id, self.check_item_list) + if len(check_items) > 0: + self.check_item_list.remove(check_items[0]) + ret = check_items[0]["DATA"] + return ret + + def exit(self): + self.exit_event.set() + pass + + +# check on serial port +class SerialPortChecker(CheckerBase): + def __init__(self, serial_reader): + CheckerBase.__init__(self) + self.serial_reader = serial_reader + pass + + # check condition for serial is compiled regular expression pattern + @staticmethod + def do_check(check_item, data): + match = check_item["CONDITION"].search(data) + if match is not None: + pos = data.find(match.group()) + len(match.group()) + # notify user + check_item["NOTIFIER"]("serial", match) + else: + pos = -1 + return pos + + def process(self): + # do check + with self.sync_lock: + # read data + new_data = self.serial_reader() + # NativeLog.add_trace_info("[debug][read data] %s" % new_data) + # do check each item + for check_item in self.check_item_list: + # NativeLog.add_trace_info("[debug][read data][ID][%s]" % check_item["ID"]) + check_item["DATA"] += new_data + self.do_check(check_item, check_item["DATA"]) + time.sleep(self.SLEEP_TIME) + + +# handle PC TCP server accept and notify user +class TCPServerChecker(CheckerBase): + def __init__(self, server_sock): + CheckerBase.__init__(self) + self.server_sock = server_sock + server_sock.settimeout(self.SLEEP_TIME) + self.accepted_socket_list = [] + + # check condition for tcp accepted sock is tcp source port + @staticmethod + def do_check(check_item, data): + for sock_addr_pair in data: + addr = sock_addr_pair[1] + if addr[1] == check_item["CONDITION"]: + # same port, so this is the socket that matched, notify and remove it from list + check_item["NOTIFIER"]("tcp", sock_addr_pair[0]) + data.remove(sock_addr_pair) + + def process(self): + # do accept + try: + client_sock, addr = self.server_sock.accept() + self.accepted_socket_list.append((client_sock, addr)) + except socket.error: + pass + # do check + with self.sync_lock: + check_item_list = self.check_item_list + for check_item in check_item_list: + self.do_check(check_item, self.accepted_socket_list) + pass + + +# this thread handles one tcp connection. +class ConnectionHandler(threading.Thread): + CHECK_FREQ = CheckerBase.SLEEP_TIME/2 + + def __init__(self, utility, serial_checker, tcp_checker, connect_method, disconnect_method, test_case): + threading.Thread.__init__(self) + self.setDaemon(True) + self.utility = utility + self.connect_method = connect_method + self.disconnect_method = disconnect_method + self.exit_event = threading.Event() + # following members are used in communication with checker threads + self.serial_checker = serial_checker + self.tcp_checker = tcp_checker + self.serial_notify_event = threading.Event() + self.tcp_notify_event = threading.Event() + self.serial_result = None + self.tcp_result = None + self.serial_check_item_id = None + self.tcp_check_item_id = None + self.data_cache = None + self.fail_count = 0 + self.test_case = test_case + pass + + def log_error(self): + self.fail_count += 1 + if self.fail_count > MAX_FAIL_COUNT: + self.test_case.error_detected() + + def new_connection_structure(self): + connection = dict.fromkeys(CONNECTION_STRUCTURE, None) + connection["Connection handler"] = self + return connection + + def run(self): + while self.exit_event.isSet() is False: + connection = self.new_connection_structure() + # do connect + connect_method_choice = random.choice(self.connect_method) + if self.utility.execute_tcp_method(connect_method_choice, connection) is False: + self.log_error() + # check if established + if self.utility.is_established_state(connection) is True: + time.sleep(float(random.randint(DELAY_RANGE[0], DELAY_RANGE[1]))/1000) + # do disconnect if established + disconnect_method_choice = random.choice(self.disconnect_method) + if self.utility.execute_tcp_method(disconnect_method_choice, connection) is False: + self.log_error() + # make sure target socket closed + self.utility.close_connection(connection) + time.sleep(float(random.randint(DELAY_RANGE[0], DELAY_RANGE[1]))/1000) + pass + + # serial_condition: re string + # tcp_condition: target local port + def add_checkers(self, serial_condition=None, tcp_condition=None): + # cleanup + self.serial_result = None + self.tcp_result = None + self.serial_notify_event.clear() + self.tcp_notify_event.clear() + # serial_checker + if serial_condition is not None: + pattern = re.compile(serial_condition) + self.serial_check_item_id = self.serial_checker.add_check_item(pattern, self.notifier) + else: + # set event so that serial check always pass + self.serial_notify_event.set() + if tcp_condition is not None: + self.tcp_check_item_id = self.tcp_checker.add_check_item(tcp_condition, self.notifier) + else: + # set event so that tcp check always pass + self.tcp_notify_event.set() + # NativeLog.add_trace_info("[Debug] add check item %s, connection is %s" % (self.serial_check_item_id, self)) + pass + + def get_checker_results(self, timeout=5): + time1 = time.time() + while time.time() - time1 < timeout: + # if one type of checker is not set, its event will be set in add_checkers + if self.serial_notify_event.isSet() is True and self.tcp_notify_event.isSet() is True: + break + time.sleep(self.CHECK_FREQ) + # do cleanup + # NativeLog.add_trace_info("[Debug] remove check item %s, connection is %s" % (self.serial_check_item_id, self)) + self.data_cache = self.serial_checker.remove_check_item(self.serial_check_item_id) + self.tcp_checker.remove_check_item(self.tcp_check_item_id) + # self.serial_check_item_id = None + # self.tcp_check_item_id = None + return self.serial_result, self.tcp_result + + def notifier(self, typ, result): + if typ == "serial": + self.serial_notify_event.set() + self.serial_result = result + elif typ == "tcp": + self.tcp_notify_event.set() + self.tcp_result = result + + def exit(self): + self.exit_event.set() + pass + + +class TestCase(PerformanceTCBase.PerformanceTCBase): + def __init__(self, test_case, test_env, timeout=120, log_path=None): + PerformanceTCBase.PerformanceTCBase.__init__(self, test_case, test_env, + timeout=timeout, log_path=log_path) + self.max_connection = 5 + self.execute_time = 120 # execute time default 120 minutes + self.pc_ip = "pc_ip" + self.target_ip = "target_ip" + self.connect_method = ["C_01"] + self.disconnect_method = ["D_05"] + + cmd_set = test_case["cmd set"] + # load param from excel + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + + self.error_event = threading.Event() + self.serial_lock = threading.Lock() + pass + + def serial_reader(self): + return self.serial_read_data("SSC1") + + def send_ssc_command(self, data): + with self.serial_lock: + time.sleep(0.05) + self.serial_write_line("SSC1", data) + + def error_detected(self): + self.error_event.set() + + def process(self): + # parameters + max_connection = self.max_connection + execute_time = self.execute_time * 60 + pc_ip = self.get_parameter(self.pc_ip) + target_ip = self.get_parameter(self.target_ip) + connect_method = self.connect_method + disconnect_method = self.disconnect_method + server_port = random.randint(30000, 50000) + + # step 1, create TCP server on target and PC + # create TCP server on target + self.serial_write_line("SSC1", "soc -B -t TCP -p %s" % server_port) + match = self.check_regular_expression("SSC1", re.compile("BIND:(\d+),OK")) + if match is None: + NativeLog.add_prompt_trace("Failed to create TCP server on target") + return + target_sock_id = match.group(1) + + self.serial_write_line("SSC1", "soc -L -s %s" % target_sock_id) + if self.check_response("SSC1", "+LISTEN:%s,OK" % target_sock_id) is False: + NativeLog.add_prompt_trace("Failed to create TCP server on target") + return + + # create TCP server on PC + try: + server_sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM) + server_sock.bind((pc_ip, server_port)) + server_sock.listen(5) + except StandardError: + NativeLog.add_prompt_trace("Failed to create TCP server on PC") + return + + # step 2, create checker + serial_port_checker = SerialPortChecker(self.serial_reader) + tcp_server_checker = TCPServerChecker(server_sock) + serial_port_checker.start() + tcp_server_checker.start() + + # step 3, create 5 thread and do connection + utility = TCPConnectionUtility.Utility(self, server_port, server_port, pc_ip, target_ip) + work_thread = [] + for i in range(max_connection): + t = ConnectionHandler(utility, serial_port_checker, tcp_server_checker, + connect_method, disconnect_method, self) + work_thread.append(t) + t.start() + + # step 4, wait and exit + self.error_event.wait(execute_time) + # close all threads + for t in work_thread: + t.exit() + t.join() + serial_port_checker.exit() + tcp_server_checker.exit() + serial_port_checker.join() + tcp_server_checker.join() + + if self.error_event.isSet() is False: + # no error detected + self.set_result("Succeed") + pass + + +def main(): + pass + + +if __name__ == '__main__': + main() diff --git a/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPConnectionUtility.py b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPConnectionUtility.py new file mode 100755 index 000000000..f28218af0 --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPConnectionUtility.py @@ -0,0 +1,251 @@ +import random +import socket +import threading + +from NativeLog import NativeLog + +# from NativeLog import NativeLog + +# make sure target do not listen on this port +ERROR_PORT = 62685 + + +class Utility(object): + METHOD_RESULT = {"C_01": ("ESTABLISHED", "ESTABLISHED"), # target TCP peer state, PC TCP peer state + "C_02": ("SYNC_SENT", "CLOSED"), + "C_03": ("CLOSED", "CLOSED"), + "C_04": ("SYN_RCVD", "ESTABLISHED"), + "C_05": ("ESTABLISHED", "ESTABLISHED"), + "C_06": ("CLOSED", "CLOSED"), + "C_07": ("CLOSED", "CLOSED"), + "C_08": ("CLOSED", "CLOSED"), + "D_01": ("TIME_WAIT", "CLOSED"), + "D_02": ("TIME_WAIT", "TIME_WAIT"), + "D_03": ("FIN_WAIT_2", "CLOSE_WAIT"), + "D_04": ("FIN_WAIT_1", "CLOSE_WAIT"), + "D_05": ("CLOSED", "TIME_WAIT"), + "D_06": ("CLOSED", "CLOSED"), + "D_07": ("CLOSE_WAIT", "FIN_WAIT2"), + "D_08": ("TIME_WAIT", "CLOSED"), } + + SOC_CLOSED_STATE = ("FIN_WAIT_1", "FIN_WAIT_2", "CLOSING", "TIME_WAIT", "LAST_ACK", "CLOSED") + SOC_CREATED_STATE = ("SYNC_RCVD", "ESTABLISHED") + SOC_SEND_DATA_STATE = ("ESTABLISHED", "CLOSE_WAIT") + SOC_ESTABLISHED_STATE = ("ESTABLISHED", ) + + def __init__(self, tc_action, pc_server_port, target_server_port, pc_ip, target_ip): + self.tc_action = tc_action + self.pc_server_port = pc_server_port + self.target_server_port = target_server_port + self.pc_ip = pc_ip + self.target_ip = target_ip + self.pc_close_wait_socket_list = [] + self.sync_lock = threading.Lock() + pass + + # create a tcp socket, return True or False + def __create_tcp_socket(self, connection): + connection_handler = connection["Connection handler"] + connection["Target port"] = random.randint(10000, 60000) + connection_handler.add_checkers("BIND:(\d+),OK,%s,%s" + % (self.target_ip, connection["Target port"])) + self.tc_action.send_ssc_command("soc -B -t TCP -i %s -p %s" % (self.target_ip, connection["Target port"])) + serial_result, tcp_result = connection_handler.get_checker_results() + if serial_result is not None: + connection["Target socket id"] = serial_result.group(1) + return True + else: + return False + + # target do connect, return True or False + def __target_do_connect(self, connection, dest_ip, dest_port, timeout=20): + connection_handler = connection["Connection handler"] + connection_handler.add_checkers("CONNECT:%s,OK" % connection["Target socket id"], + connection["Target port"]) + self.tc_action.send_ssc_command("soc -C -s %s -i %s -p %s" + % (connection["Target socket id"], dest_ip, dest_port)) + serial_result, tcp_result = connection_handler.get_checker_results(timeout) + if serial_result is not None and tcp_result is not None: + connection["PC socket"] = tcp_result + return True + else: + return False + pass + + # pc do connect, return True or False + def __pc_do_connect(self, connection, dest_ip, dest_port, timeout=20): + connection_handler = connection["Connection handler"] + sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM) + while True: + connection["PC port"] = random.randint(10000, 60000) + try: + sock.bind((self.pc_ip, connection["PC port"])) + break + except socket.error, e: + if e.errno == 10048: # socket port reuse + continue + sock.settimeout(timeout) + connection["PC socket"] = sock + connection_handler.add_checkers("ACCEPT:(\d+),\d+,%s,%s" + % (self.pc_ip, connection["PC port"])) + try: + sock.connect((dest_ip, dest_port)) + except socket.error: + pass + serial_result, tcp_result = connection_handler.get_checker_results() + if serial_result is not None: + connection["Target socket id"] = serial_result.group(1) + return True + else: + return False + pass + + def connect_c_01(self, connection): + if self.__create_tcp_socket(connection) is True: + return self.__target_do_connect(connection, self.pc_ip, self.pc_server_port) + else: + return False + + def connect_c_02(self, connection): + if self.__create_tcp_socket(connection) is True: + return not self.__target_do_connect(connection, self.pc_ip, ERROR_PORT, timeout=5) + else: + return False + + def connect_c_03(self, connection): + return False + + def connect_c_04(self, connection): + return False + + def connect_c_05(self, connection): + return self.__pc_do_connect(connection, self.target_ip, self.target_server_port) + + def connect_c_06(self, connection): + return False + + def connect_c_07(self, connection): + return not self.__pc_do_connect(connection, self.target_ip, ERROR_PORT) + + def connect_c_08(self, connection): + return False + + def __target_socket_close(self, connection): + connection_handler = connection["Connection handler"] + if connection["Target socket id"] is not None: + connection_handler.add_checkers("CLOSE:%s" % connection["Target socket id"]) + self.tc_action.send_ssc_command("soc -T -s %s" % connection["Target socket id"]) + serial_result, tcp_result = connection_handler.get_checker_results() + connection["Target socket id"] = None + else: + serial_result = None + return True if serial_result is not None else False + + @staticmethod + def __pc_socket_close(connection): + connection_handler = connection["Connection handler"] + if connection["PC socket"] is not None: + connection_handler.add_checkers("CLOSED:%s" % connection["Target socket id"]) + connection["PC socket"].close() + serial_result, tcp_result = connection_handler.get_checker_results() + connection["PC socket"] = None + else: + serial_result = None + return True if serial_result is not None else False + + def close_d_01(self, connection): + connection["PC socket"] = None + return self.__target_socket_close(connection) + + def close_d_02(self, connection): + pass + + def close_d_03(self, connection): + with self.sync_lock: + self.pc_close_wait_socket_list.append(connection["PC socket"]) + return self.__target_socket_close(connection) + pass + + def close_d_04(self, connection): + pass + + def close_d_05(self, connection): + return self.__pc_socket_close(connection) + + def close_d_06(self, connection): + # target send data to PC, PC don't recv and close socket + connection_handler = connection["Connection handler"] + connection_handler.add_checkers("SEND:%s,OK" % connection["Target socket id"]) + self.tc_action.send_ssc_command("soc -S -s %s -l 100" % connection["Target socket id"]) + serial_result, tcp_result = connection_handler.get_checker_results() + if serial_result is None: + return False + return self.__pc_socket_close(connection) + + def close_d_07(self, connection): + # PC shutdown WR + result = False + try: + connection["PC socket"].shutdown(socket.SHUT_WR) + result = True + except StandardError: + pass + return result + + def close_d_08(self, connection): + pass + + def close_connection(self, connection): + self.__target_socket_close(connection) + pass + + TCP_ACTION_DICT = {"C_01": connect_c_01, + "C_02": connect_c_02, + "C_03": connect_c_03, + "C_04": connect_c_04, + "C_05": connect_c_05, + "C_06": connect_c_06, + "C_07": connect_c_07, + "C_08": connect_c_08, + "D_01": close_d_01, + "D_02": close_d_02, + "D_03": close_d_03, + "D_04": close_d_04, + "D_05": close_d_05, + "D_06": close_d_06, + "D_07": close_d_07, + "D_08": close_d_08, + } + + def get_method_destination_state(self, method): + return self.METHOD_RESULT[method] + + def execute_tcp_method(self, method, connection): + if method in self.METHOD_RESULT: + result = self.TCP_ACTION_DICT[method](self, connection) + if result is True: + state = self.get_method_destination_state(method) + connection["Target state"] = state[0] + connection["PC state"] = state[1] + else: + NativeLog.add_prompt_trace("[TCPConnection] tcp method %s fail, connection is %s" + % (method, connection)) + NativeLog.add_trace_info("[TCPConnection][data cache][check item %s] %s" + % (connection["Connection handler"].serial_check_item_id, + connection["Connection handler"].data_cache)) + else: + raise StandardError("Not TCP connection method") + return result + + def is_established_state(self, connection): + return True if connection["Target state"] in self.SOC_CREATED_STATE else False + + def is_closed_state(self, connection): + return True if connection["Target state"] in self.SOC_CLOSED_STATE else False + + +def main(): + pass + +if __name__ == '__main__': + main() diff --git a/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPDataValidation.py b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPDataValidation.py new file mode 100755 index 000000000..a06824ce3 --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPDataValidation.py @@ -0,0 +1,243 @@ +import os +import random +import threading +import socket +import time +import re + +from TCAction import TCActionBase +from TCAction import PerformanceTCBase +from NativeLog import NativeLog + + +def calc_hash(index): + return (index & 0xffffffff) % 83 + (index & 0xffffffff) % 167 + + +def verify_data(data, start_index): + for i, c in enumerate(data): + if ord(c) != calc_hash(start_index + i): + NativeLog.add_trace_critical("[Data Validation Error] target sent data index %u is error." + " Sent data is %x, should be %x" + % (start_index + i, ord(c), calc_hash(start_index + i))) + return False + return True + + +def make_validation_data(length, start_index): + return bytes().join([chr(calc_hash(start_index + i)) for i in range(length)]) + + +class SendThread(threading.Thread): + def __init__(self, sock, send_len): + threading.Thread.__init__(self) + self.setDaemon(True) + self.sock = sock + self.send_len = send_len + self.exit_event = threading.Event() + pass + + def exit(self): + self.exit_event.set() + + def run(self): + index = 0 + while self.exit_event.isSet() is False: + data = make_validation_data(self.send_len, index) + try: + self.sock.send(data) + index += self.send_len + except StandardError: + # pass but not exit thread + time.sleep(1) + continue + pass + + +class RecvThread(threading.Thread): + def __init__(self, sock): + threading.Thread.__init__(self) + self.setDaemon(True) + self.sock = sock + self.exit_event = threading.Event() + + def exit(self): + self.exit_event.set() + + def run(self): + index = 0 + while self.exit_event.isSet() is False: + if self.sock is not None: + try: + data = self.sock.recv(8*1024) + except StandardError, e: + NativeLog.add_exception_log(e) + NativeLog.add_trace_critical("recv error, connection closed") + break + if verify_data(data, index) is not True: + break + index += len(data) + else: + time.sleep(1) + pass + + +class ValidationThread(threading.Thread): + def __init__(self, tc_action): + threading.Thread.__init__(self) + self.setDaemon(True) + self.tc_action = tc_action + self.exit_event = threading.Event() + + def exit(self): + self.exit_event.set() + + def run(self): + while self.exit_event.isSet() is False: + if self.tc_action.check_response("SSC1", "DATA_ERROR", 5) is True: + NativeLog.add_trace_critical("[Data Validation Error] target recv data error") + break + pass + + +class TestCase(PerformanceTCBase.PerformanceTCBase): + + def __init__(self, test_case, test_env, timeout=30, log_path=TCActionBase.LOG_PATH): + PerformanceTCBase.PerformanceTCBase.__init__(self, test_case, test_env, timeout=timeout, log_path=log_path) + self.send_len = 0 + self.tx_enable = None + self.rx_enable = None + self.conn_num = 0 + self.test_time = 0 + # load param from excel + cmd_set = test_case["cmd set"] + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + pass + + def execute(self): + TCActionBase.TCActionBase.execute(self) + + try: + # configurable params + send_len = self.send_len + tx_enable = self.tx_enable + rx_enable = self.rx_enable + conn_num = self.conn_num + test_time = self.test_time * 60 # convert minutes to seconds + # configurable params + except StandardError, e: + NativeLog.add_trace_critical("Error configuration for TCPThroughput script, error is %s" % e) + raise StandardError("Error configuration") + + # init throughput result data + test_item = "" + if tx_enable is True: + test_item += "Tx" + if rx_enable is True: + test_item += "Rx" + if test_item == "": + raise StandardError("no throughput test item") + + pc_ip = self.get_parameter("pc_ip") + tcp_port = random.randint(10000, 50000) + + # disable recv print during throughput test + self.serial_write_line("SSC1", "soc -R -o 0") + if self.check_response("SSC1", "+RECVPRINT", 2) is False: + NativeLog.add_trace_critical("Fail, Fail to disable recv print") + + # create server + server_sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM) + server_sock.bind((pc_ip, tcp_port)) + server_sock.settimeout(5) + server_sock.listen(5) + + sock_id_list = [] + send_thread_list = [] + recv_thread_list = [] + + # step 4 create tcp connection + for i in range(conn_num): + self.serial_write_line("SSC1", "soc -B -t TCP") + match = self.check_regular_expression("SSC1", re.compile("\+BIND:(\d+),OK"), 2) + if match is None: + NativeLog.add_trace_critical("Fail, Fail to bind") + return + else: + sock_id_list.append(int(match.group(1))) + + self.serial_write_line("SSC1", "soc -V -s %s -o 3" % sock_id_list[-1]) + if self.check_regular_expression("SSC1", re.compile("\+DATA_VALIDATION:\d+,OK"), 2) is None: + NativeLog.add_trace_critical("Fail, Failed to enable validation") + return + + self.serial_write_line("SSC1", "soc -C -s %s -i %s -p %s" % (sock_id_list[-1], pc_ip, tcp_port)) + try: + sock, addr = server_sock.accept() + except socket.error, e: + NativeLog.add_trace_critical("%s" % e) + raise e + + if self.check_regular_expression("SSC1", re.compile("\+CONNECT:\d+,OK"), 5) is None: + NativeLog.add_trace_critical("Fail, Failed to connect") + return + + sock.settimeout(10) + + send_thread_list.append(SendThread(sock if rx_enable is True else None, send_len)) + recv_thread_list.append(RecvThread(sock if tx_enable is True else None)) + recv_thread_list[-1].start() + + # step 5 do test + validation_thread = ValidationThread(self) + validation_thread.start() + + for send_thread in send_thread_list: + send_thread.start() + + if tx_enable is True: + # do send from target + for sock_id in sock_id_list: + self.serial_write_line("SSC1", "soc -S -s %s -l %s -n 10000000" % (sock_id, send_len)) + + time1 = time.time() + exit_flag = False + + while time.time() - time1 < test_time and exit_flag is False: + for i in sock_id_list: + send_thread_list[i].join(0.5) + recv_thread_list[i].join(0.5) + validation_thread.join(0.5) + if send_thread_list[i].isAlive() is False \ + or recv_thread_list[i].isAlive() is False \ + or validation_thread.isAlive() is False: + NativeLog.add_trace_critical("validation error found") + exit_flag = True + break + + NativeLog.add_prompt_trace("time escape: %s" % (time.time() - time1)) + + if time.time() - time1 >= test_time: + self.set_result("Succeed") + else: + self.set_result("Failed") + + # exit all thread + for i in sock_id_list: + send_thread_list[i].exit() + recv_thread_list[i].exit() + send_thread_list[i].join() + send_thread_list[i].join() + + validation_thread.exit() + validation_thread.join() + + +def main(): + pass + +if __name__ == '__main__': + main() diff --git a/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPMultiSTASendRecv.py b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPMultiSTASendRecv.py new file mode 100644 index 000000000..56cb7e692 --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPMultiSTASendRecv.py @@ -0,0 +1,165 @@ +from TCAction import TCActionBase +from NativeLog import NativeLog +import time +import random +import string + +TEST_COUNT_ONE_ROUND = 500 + + +class TestCase(TCActionBase.CommonTCActionBase): + def __init__(self, test_case, test_env, timeout=45, log_path=TCActionBase.LOG_PATH): + TCActionBase.CommonTCActionBase.__init__(self, test_case, test_env, timeout=timeout, log_path=log_path) + # load param from excel + cmd_set = test_case["cmd set"] + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name) + pass + + def execute(self): + TCActionBase.TCActionBase.execute(self) + self.result_cntx.start() + + try: + # configurable params + send_len = self.send_len + test_time = self.test_time * 60 + server_echo = self.server_echo + sta_number = self.sta_number + send_delay = self.send_delay + # configurable params + except StandardError, e: + NativeLog.add_trace_critical("Error configuration for TCPTransparent script, error is %s" % e) + raise StandardError("Error configuration") + + # step0 reboot + for i in range(sta_number + 1): + checker_stings = ["P SSC%d C ready!!!" % (i + 1)] + test_action_string = ["SSCC SSC%d restore" % (i + 1)] + fail_string = "Fail, Fail to restore" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # turn off recv print + for i in range(sta_number + 1): + checker_stings = ["P SSC%d C +RECVPRINT:0" % (i + 1)] + test_action_string = ["SSCC SSC%d soc -R -o 0" % (i + 1)] + fail_string = "Fail, Fail to turn off recv print" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step1, set softap mode on SSC1 + checker_stings = ["R SSC1 C +MODE:OK"] + test_action_string = ["SSCC SSC1 op -S -o 2"] + fail_string = "Fail, Fail to set mode on SSC1" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step2, set STA mode on SSC2-SSCn + for i in range(sta_number): + checker_stings = ["R SSC%d C +MODE:OK" % (i + 2)] + test_action_string = ["SSCC SSC%d op -S -o 1" % (i + 2)] + fail_string = "Fail, Fail to set mode on SSC%d" % (i + 2) + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + ssid = "".join([random.choice(string.lowercase) for m in range(10)]) + password = "".join([random.choice(string.lowercase) for m in range(10)]) + tcp_port = random.randint(40000, 50000) + + # step3, set ssid/password on SSC1 + checker_stings = ["R SSC1 C +SAP:OK"] + test_action_string = ["SSCC SSC1 ap -S -s %s -p %s -n 10 -t 0 -m 10" % (ssid, password)] + fail_string = "Fail, Fail to set ssid/password on SSC1" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step4, SSC2-SSCn join SSC1(soft AP) + for i in range(sta_number): + checker_stings = ["P SSC%d C +JAP:CONNECTED,%s" % (i + 2, ssid)] + test_action_string = ["SSCC SSC%d ap -C -s %s -p %s" % (i + 2, ssid, password)] + fail_string = "Fail, SSC%d Fail to connect to SSC1" % (i + 2) + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, check_time=450) is False: + return + + # step5, create server on SSC2 + checker_stings = ["R SSC2 A :BIND:(\d+),OK"] + test_action_string = ["SSCC SSC2 soc -B -t TCP -p %s" % tcp_port] + fail_string = "Fail, Fail to create server on SSC2 while binding" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["R SSC2 RE LISTEN:(\d+),OK"] + test_action_string = ["SSCC SSC2 soc -L -s "] + fail_string = "Fail, Fail to create server on SSC2 while listening" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step6, create client on SSC3-SSCn + for i in range(sta_number - 1): + checker_stings = ["P SSC%d A :BIND:(\d+),OK" % (i + 3, i + 3)] + test_action_string = ["SSCC SSC%d soc -B -t TCP" % (i + 3)] + fail_string = "Fail, SSC%d Fail to connect to TCP server while binding" % (i + 3) + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + for i in range(sta_number - 1): + checker_stings = ["P SSC%d RE CONNECT:(\d+),OK" % (i + 3), "P SSC2 A :ACCEPT:(\d+),.+" % i] + test_action_string = [ + "SSCC SSC%d soc -C -s -i 192.168.4.2 -p %s" % (i + 3, i + 3, tcp_port)] + fail_string = "Fail, SSC%d Fail to connect to TCP server while connecting" % (i + 3) + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + start_time = time.time() + # step7, do send/recv, SSC2<---->other STAs + while time.time() - start_time < test_time: + checker_stings = [] + test_action_string = [] + # SSC2 send packets to SSC3-SSCn + if server_echo is True: + for i in range(sta_number - 1): + test_action_string.append("SSC SSC2 soc -S -s -l %d -n 1000 -j %d" % + (i, send_len, send_delay)) + checker_stings.append( + "P SSC2 RE \+SEND:%s,OK NC CLOSED NC ERROR" % self.get_parameter("accept_sock%d" % (i + 3))) + + # SSC3-SSCn send packets to SSC2 + for i in range(sta_number - 1): + checker_stings.append( + "P SSC%d RE \+SEND:%s,OK NC CLOSED NC ERROR" % (i + 3, self.get_parameter("client_sock%d" % i))) + test_action_string.append("SSC SSC%d soc -S -s -l %d -n 1000 -j %d" % + (i + 3, i + 3, send_len, send_delay)) + + fail_string = "Fail, Failed to send/recv data" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, + check_freq=1, check_time=900) is False: + break + + # drop off the delay time if it's greater than 20ms + if send_delay > 20: + send_delay -= 10 + + NativeLog.add_trace_critical("Time escape: %d" % (time.time() - start_time)) + + if (time.time() - start_time) >= test_time: + self.result_cntx.set_result("Succeed") + else: + self.result_cntx.set_result("Failed") + + # finally, execute done + + def result_check(self, port_name, data): + TCActionBase.CommonTCActionBase.result_check(self, port_name, data) + self.result_cntx.append_data(port_name, data) + + +def main(): + pass + + +if __name__ == '__main__': + main() diff --git a/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPRandomSend.py b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPRandomSend.py new file mode 100755 index 000000000..e32c63bf4 --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPRandomSend.py @@ -0,0 +1,109 @@ +import os +import time +import random +import threading +import socket +from TCAction import TCActionBase +from NativeLog import NativeLog +from NativeLog import ThroughputResult + + +class TestCase(TCActionBase.CommonTCActionBase): + + def __init__(self, test_case, test_env, timeout=30, log_path=TCActionBase.LOG_PATH): + TCActionBase.CommonTCActionBase.__init__(self, test_case, test_env, timeout=timeout, log_path=log_path) + self.send_len_config = range(1460) + self.delay_config = [0, 0.01, 0.1, 0.5, 1] + # load param from excel + cmd_set = test_case["cmd set"] + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name) + pass + + def execute(self): + TCActionBase.TCActionBase.execute(self) + self.result_cntx.start() + + try: + # configurable params + send_len_config = self.send_len_config + delay_config = self.delay_config + send_count = self.send_count + test_time = self.test_time * 60 + # configurable params + except StandardError, e: + NativeLog.add_trace_critical("Error configuration for TCPThroughput script, error is %s" % e) + raise StandardError("Error configuration") + + # disable recv print during random send test + checker_stings = ["R SSC1 C +RECVPRINT"] + test_action_string = ["SSC SSC1 soc -R -o 0"] + fail_string = "Fail, Fail to disable recv print" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + pc_ip = self.get_parameter("pc_ip") + tcp_port = random.randint(50000, 60000) + + # step 0 create tcp connection + + server_sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM) + server_sock.bind((pc_ip, tcp_port)) + server_sock.settimeout(1) + server_sock.listen(5) + + checker_stings = ["R SSC1 A :\+BIND:(\d+),OK"] + test_action_string = ["SSC SSC1 soc -B -t TCP"] + fail_string = "Fail, Fail bind" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["P SSC1 RE \+CONNECT:\d+,OK"] + test_action_string = ["SSC SSC1 soc -C -s -i %s -p %s" % (pc_ip, tcp_port)] + fail_string = "Fail, Fail to connect" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + sock, addr = server_sock.accept() + sock.settimeout(10) + # set no delay so that tcp segment will be send as soon as send called + sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) + + # step 1 start send + start_time = time.time() + while time.time() - start_time < test_time: + for delay in delay_config: + for i in xrange(send_count): + send_len = random.choice(send_len_config) + data = "A" * (send_len+1) + try: + sock.send(data) + except socket.error, e: + NativeLog.add_exception_log(e) + NativeLog.add_trace_critical("Fail to send packets") + return + pass + time.sleep(delay) + + NativeLog.add_prompt_trace("time escape: %s" % (time.time() - start_time)) + + if (time.time() - start_time) > test_time: + self.result_cntx.set_result("Succeed") + else: + self.result_cntx.set_result("Failed") + + # finally, execute done + + def result_check(self, port_name, data): + TCActionBase.CommonTCActionBase.result_check(self, port_name, data) + self.result_cntx.append_data(port_name, data) + + +def main(): + pass + +if __name__ == '__main__': + main() diff --git a/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPSTAMuitiSockSendRecv.py b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPSTAMuitiSockSendRecv.py new file mode 100644 index 000000000..5625756b9 --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPSTAMuitiSockSendRecv.py @@ -0,0 +1,159 @@ +from TCAction import TCActionBase +from NativeLog import NativeLog +import time +import random +import string + + +class TestCase(TCActionBase.CommonTCActionBase): + def __init__(self, test_case, test_env, timeout=45, log_path=TCActionBase.LOG_PATH): + TCActionBase.CommonTCActionBase.__init__(self, test_case, test_env, timeout, log_path) + # load param from excel + cmd_set = test_case["cmd set"] + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name) + pass + + def execute(self): + TCActionBase.TCActionBase.execute(self) + self.result_cntx.start() + + try: + # configurable params + send_len = self.send_len + server_echo = self.server_echo + conn_number = self.conn_number + sta_number = self.sta_number + test_time = self.test_time + send_delay = self.send_delay + # configurable params + except StandardError, e: + NativeLog.add_trace_critical("Error configuration for TCPTransparent script, error is %s" % e) + raise StandardError("Error configuration") + + # step0 reboot + for i in range(sta_number + 1): + checker_stings = ["P SSC%d C !!!ready!!!" % (i + 1)] + test_action_string = ["SSCC SSC%d reboot" % (i + 1)] + fail_string = "Fail, Fail to reboot" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step1, set ap mode on SSC1, set STA mode on SSC2-SSC3 + checker_stings = ["R SSC1 C +MODE:OK"] + test_action_string = ["SSCC SSC1 op -S -o 2"] + fail_string = "Fail, Fail to set mode on SSC1" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + for i in range(sta_number): + checker_stings = ["R SSC%d C +MODE:OK" % (i + 2)] + test_action_string = ["SSCC SSC%d op -S -o 1" % (i + 2)] + fail_string = "Fail, Fail to set mode on SSC%d" % (i + 2) + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # turn off recv print + for i in range(sta_number + 1): + checker_stings = ["P SSC%d C +RECVPRINT:0" % (i + 1)] + test_action_string = ["SSCC SSC%d soc -R -o 0" % (i + 1)] + fail_string = "Fail, Fail to turn off recv print" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step2, set ssid/password on SSC1 + ssid = "".join([random.choice(string.lowercase) for m in range(10)]) + password = "".join([random.choice(string.lowercase) for m in range(10)]) + tcp_port = random.randint(10000, 20000) + + checker_stings = ["R SSC1 C +SAP:OK"] + test_action_string = ["SSCC SSC1 ap -S -s %s -p %s -t 3 -m 8" % (ssid, password)] + fail_string = "Fail, Fail to set ssid/password on SSC1" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step3, SSC2-SSC3 connect to SSC1 + checker_stings = [] + test_action_string = [] + for i in range(sta_number): + checker_stings.append("P SSC%d C +JAP:CONNECTED,%s" % (i + 2, ssid)) + test_action_string.append("SSCC SSC%d ap -C -s %s -p %s" % (i + 2, ssid, password)) + fail_string = "Fail, SSC%d Fail to connect to SoftAP" % (i + 2) + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, check_time=450) is False: + return + + # step4, create tcp server on STA SSC2 + checker_stings = ["R SSC2 A :BIND:(\d+),OK"] + test_action_string = ["SSCC SSC2 soc -B -t TCP -p %s" % tcp_port] + fail_string = "Fail, Fail to create server on SSC2 while binding" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["R SSC2 RE LISTEN:(\d+),OK"] + test_action_string = ["SSCC SSC2 soc -L -s "] + fail_string = "Fail, Fail to create server on SSC2 while listening" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step5, create multi client on SSC3 + for i in range(conn_number): + checker_stings = ["P SSC3 A :BIND:(\d+),OK" % i] + test_action_string = ["SSCC SSC3 soc -B -t TCP"] + fail_string = "Fail, Fail to create client on SSC3" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["P SSC3 RE CONNECT:(\d+),OK", "P SSC2 A :ACCEPT:(\d+),.+" % i] + test_action_string = ["SSCC SSC3 soc -C -s -i %s -p %s" % (i, "192.168.4.2", tcp_port)] + fail_string = "Fail, Fail to connect to SSC2 server while connecting" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + start_time = time.time() + # step6, do send/recv + while time.time() - start_time < test_time: + checker_stings = [] + test_action_string = [] + # SSC2 send packets to SSC3 + if server_echo is True: + for i in range(conn_number): + checker_stings.append("P SSC2 RE \+SEND:\d+,OK NC CLOSED NC ERROR") + test_action_string.append("SSC SSC2 soc -S -s -l %d -n 1000 -j %d" % + (i, send_len, send_delay)) + # SSC3 send packets to SSC2 + for i in range(conn_number): + test_action_string.append("SSC SSC3 soc -S -s -l %d -n 1000 -j %d" % + (i, send_len, send_delay)) + checker_stings.append("P SSC3 RE \+SEND:\d+,OK NC CLOSED NC ERROR") + + fail_string = "Fail, Failed to send/recv data" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, + check_freq=1, check_time=600) is False: + break + + if send_delay > 20: + send_delay -= 10 + + NativeLog.add_trace_critical("Time escape: %d" % (time.time() - start_time)) + + if (time.time() - start_time) > test_time: + self.result_cntx.set_result("Succeed") + else: + self.result_cntx.set_result("Failed") + + # finally, execute done + + def result_check(self, port_name, data): + TCActionBase.CommonTCActionBase.result_check(self, port_name, data) + self.result_cntx.append_data(port_name, data) + + +def main(): + pass + + +if __name__ == '__main__': + main() diff --git a/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPSTAsendrecv.py b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPSTAsendrecv.py new file mode 100644 index 000000000..8fd0d7d6f --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPSTAsendrecv.py @@ -0,0 +1,167 @@ +from TCAction import TCActionBase +from NativeLog import NativeLog +import time +import random +import string + + +class TestCase(TCActionBase.CommonTCActionBase): + def __init__(self, test_case, test_env, timeout=45, log_path=TCActionBase.LOG_PATH): + TCActionBase.CommonTCActionBase.__init__(self, test_case, test_env, timeout, log_path) + # load param from excel + cmd_set = test_case["cmd set"] + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name) + pass + + def execute(self): + TCActionBase.TCActionBase.execute(self) + self.result_cntx.start() + + try: + # configurable params + send_len = self.send_len + server_echo = self.server_echo + conn_number = self.conn_number + sta_number = self.sta_number + test_time = self.test_time * 60 + send_delay = self.send_delay + # configurable params + except StandardError, e: + NativeLog.add_trace_critical("Error configuration for TCPTransparent script, error is %s" % e) + raise StandardError("Error configuration") + + # step0 reboot + for i in range(sta_number + 1): + checker_stings = ["P SSC%d C ready!!!" % (i + 1)] + test_action_string = ["SSCC SSC%d restore" % (i + 1)] + fail_string = "Fail, Fail to restore" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step1, set ap mode on SSC1, set STA mode on SSC2-SSC3 + checker_stings = ["R SSC1 C +MODE:OK"] + test_action_string = ["SSCC SSC1 op -S -o 2"] + fail_string = "Fail, Fail to set mode on SSC1" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + for i in range(sta_number): + checker_stings = ["R SSC%d C +MODE:OK" % (i + 2)] + test_action_string = ["SSCC SSC%d op -S -o 1" % (i + 2)] + fail_string = "Fail, Fail to set mode on SSC%d" % (i + 2) + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # turn off recv print + for i in range(sta_number + 1): + checker_stings = ["P SSC%d C +RECVPRINT:0" % (i + 1)] + test_action_string = ["SSCC SSC%d soc -R -o 0" % (i + 1)] + fail_string = "Fail, Fail to turn off recv print" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step2, set ssid/password on SSC1 + ssid = "".join([random.choice(string.lowercase) for m in range(10)]) + password = "".join([random.choice(string.lowercase) for m in range(10)]) + tcp_port = random.randint(10000, 20000) + + checker_stings = ["R SSC1 C +SAP:OK"] + test_action_string = ["SSCC SSC1 ap -S -s %s -p %s -n 10 -t 0 -m 10" % (ssid, password)] + fail_string = "Fail, Fail to set ssid/password on SSC1" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step3, SSC2-SSC3 connect to SSC1 + checker_stings = [] + test_action_string = [] + for i in range(sta_number): + checker_stings.append("P SSC%d C +JAP:CONNECTED,%s" % (i + 2, ssid)) + test_action_string.append("SSCC SSC%d ap -C -s %s -p %s" % (i + 2, ssid, password)) + fail_string = "Fail, SSC%d Fail to connect to SoftAP" % (i + 2) + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, check_time=450) is False: + return + + # step4, create tcp server on STA SSC2 + checker_stings = ["R SSC2 A :BIND:(\d+),OK"] + test_action_string = ["SSCC SSC2 soc -B -t TCP -p %s" % tcp_port] + fail_string = "Fail, Fail to create server on SSC2 while binding" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["R SSC2 RE LISTEN:(\d+),OK"] + test_action_string = ["SSCC SSC2 soc -L -s "] + fail_string = "Fail, Fail to create server on SSC2 while listening" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step5, create multi client on SSC3 + for i in range(conn_number): + checker_stings = ["P SSC3 A :BIND:(\d+),OK" % i] + test_action_string = ["SSCC SSC3 soc -B -t TCP"] + fail_string = "Fail, Fail to create client on SSC3" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["P SSC3 RE CONNECT:(\d+),OK", "P SSC2 A :ACCEPT:(\d+),.+ NC ERROR" % i] + test_action_string = ["SSCC SSC3 soc -C -s -i %s -p %s" % (i, "192.168.4.2", tcp_port)] + fail_string = "Fail, Fail to connect to SSC2 server while connecting" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + start_time = time.time() + # step6, do send/recv + while time.time() - start_time < test_time: + checker_stings = [] + test_action_string = [] + # SSC2 send packets to SSC3 + if server_echo is True: + for i in range(conn_number): + checker_stings.append( + "P SSC2 RE \+SEND:%s,OK NC CLOSED NC ERROR NC unexpected" % self.get_parameter( + "accept_sock%d" % i)) + test_action_string.append("SSC SSC2 soc -S -s -l %d -n 1000 -j %d" % + (i, send_len, send_delay)) + # SSC3 send packets to SSC2 + for i in range(conn_number): + test_action_string.append("SSC SSC3 soc -S -s -l %d -n 1000 -j %d" % + (i, send_len, send_delay)) + checker_stings.append( + "P SSC3 RE \+SEND:%s,OK NC CLOSED NC ERROR" % self.get_parameter("client_sock%d" % i)) + + fail_string = "Fail, Failed to send/recv data" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, + check_freq=1, check_time=900) is False: + # checker_stings = ["R SSC1 C +LSTADONE"] + # test_action_string = ["SSCC SSC1 ap -L"] + # fail_string = "" + # if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + # pass + break + + if send_delay > 20: + send_delay -= 10 + + NativeLog.add_trace_critical("Time escape: %d" % (time.time() - start_time)) + + if (time.time() - start_time) > test_time: + self.result_cntx.set_result("Succeed") + else: + self.result_cntx.set_result("Failed") + + # finally, execute done + + def result_check(self, port_name, data): + TCActionBase.CommonTCActionBase.result_check(self, port_name, data) + self.result_cntx.append_data(port_name, data) + + +def main(): + pass + + +if __name__ == '__main__': + main() diff --git a/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPSendRecv.py b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPSendRecv.py new file mode 100755 index 000000000..b741a5c4b --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPSendRecv.py @@ -0,0 +1,154 @@ +from TCAction import TCActionBase +from NativeLog import NativeLog +import time +import random +import string + +TEST_COUNT_ONE_ROUND = 1000 + + +class TestCase(TCActionBase.CommonTCActionBase): + + def __init__(self, test_case, test_env, timeout=30, log_path=TCActionBase.LOG_PATH): + TCActionBase.CommonTCActionBase.__init__(self, test_case, test_env, timeout=timeout, log_path=log_path) + # load param from excel + cmd_set = test_case["cmd set"] + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name) + pass + + def cleanup(self): + # step 0 turn on recv print + checker_stings = ["R SSC1 C +RECVPRINT:1"] + test_action_string = ["SSC SSC1 soc -R -o 1"] + fail_string = "Fail, Fail to turn on recv print" + self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) + pass + + def execute(self): + TCActionBase.TCActionBase.execute(self) + self.result_cntx.start() + + try: + # configurable params + send_len = self.send_len + test_time = self.test_time * 60 + duplex = self.duplex + conn_num = self.conn_num + send_delay = self.send_delay + # configurable params + except StandardError, e: + NativeLog.add_trace_critical("Error configuration for TCPSendRecv script, error is %s" % e) + raise StandardError("Error configuration") + + ssid = "".join([random.choice(string.lowercase) for m in range(10)]) + password = "".join([random.choice(string.lowercase) for m in range(10)]) + tcp_port = random.randint(10000, 50000) + + # step 0 set ap + checker_stings = ["R SSC1 C +SAP:OK"] + test_action_string = ["SSC SSC1 ap -S -s %s -p %s -t 3" % (ssid, password)] + fail_string = "Fail, Fail to set ap" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + self.result_cntx.set_result("Fail") + return + + # step 1 connect to ap and turn off recv print + checker_stings = ["R SSC2 C +JAP:CONNECTED"] + test_action_string = ["SSC SSC2 sta -C -s %s -p %s" % (ssid, password)] + fail_string = "Fail, Fail to connect to server" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, check_time=200) is False: + self.result_cntx.set_result("Fail") + return + + checker_stings = ["P SSC1 C +RECVPRINT:0", "P SSC2 C +RECVPRINT:0"] + test_action_string = ["SSC SSC1 soc -R -o 0", "SSC SSC2 soc -R -o 0"] + fail_string = "Fail, Fail to turn off recv print" + self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, check_time=200) is False: + self.result_cntx.set_result("Fail") + return + + # step 2 create server on AP + checker_stings = ["R SSC1 A :\+BIND:(\d+),OK"] + test_action_string = ["SSC SSC1 soc -B -t TCP -p %s" % tcp_port] + fail_string = "Fail, Fail to create server" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + self.result_cntx.set_result("Fail") + return + + checker_stings = ["R SSC1 A :\+LISTEN:(\d+),OK"] + test_action_string = ["SSC SSC1 soc -L -s "] + fail_string = "Fail, Fail to create server" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + self.result_cntx.set_result("Fail") + return + + # step 3 create conn_num tcp connections + for i in range(conn_num): + checker_stings = ["R SSC2 A :\+BIND:(\d+),OK" % i] + test_action_string = ["SSC SSC2 soc -B -t TCP"] + fail_string = "Fail, Fail to bind" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + self.result_cntx.set_result("Fail") + return + + checker_stings = ["P SSC1 A :\+ACCEPT:(\d+),\d+" % i, + "P SSC2 RE \+CONNECT:\d+,OK"] + test_action_string = ["SSC SSC2 soc -C -s -i -p %s" % (i, tcp_port)] + fail_string = "Fail, Fail to connect" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + self.result_cntx.set_result("Fail") + return + + start_time = time.time() + # step 4, do send/recv + while time.time()-start_time < test_time: + + checker_stings = ["P SSC1 NC ERROR NC CLOSE NC ERROR"] + for i in range(conn_num): + test_action_string = ["SSC SSC2 soc -S -s -l %d -n %d -j %d" % + (i, send_len, TEST_COUNT_ONE_ROUND, send_delay)] + checker_stings.append("P SSC2 RE \"\+SEND:%%%%s,OK\"%%%%() NC ERROR NC CLOSE" % i) + + if duplex is True: + checker_stings.append("P SSC1 RE \"\+SEND:%%%%s,OK\"%%%%()" % i) + test_action_string.append("SSC SSC1 soc -S -s -l %d -n %d -j %d" % + (i, send_len, TEST_COUNT_ONE_ROUND, send_delay)) + + fail_string = "Fail, Failed on send command" + if self.load_and_exe_one_step([], test_action_string, fail_string) is False: + self.result_cntx.set_result("Fail") + break + + fail_string = "Fail, Failed to send/recv data" + if self.load_and_exe_one_step(checker_stings, ["DELAY 0.1"], fail_string, + check_freq=1, check_time=300) is False: + NativeLog.add_prompt_trace("time escape: %s" % (time.time() - start_time)) + self.result_cntx.set_result("Fail") + return + + NativeLog.add_prompt_trace("time escape: %s" % (time.time() - start_time)) + + if (time.time() - start_time) >= test_time: + self.result_cntx.set_result("Succeed") + else: + self.result_cntx.set_result("Failed") + + # finally, execute done + + def result_check(self, port_name, data): + TCActionBase.CommonTCActionBase.result_check(self, port_name, data) + self.result_cntx.append_data(port_name, data) + + +def main(): + pass + +if __name__ == '__main__': + main() + + diff --git a/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPSoftAPSTASendRecv.py b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPSoftAPSTASendRecv.py new file mode 100644 index 000000000..8083560c8 --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPSoftAPSTASendRecv.py @@ -0,0 +1,319 @@ +from TCAction import TCActionBase +from NativeLog import NativeLog +import time +import random +import string + +TEST_COUNT_ONE_ROUND = 500 + + +class TestCase(TCActionBase.CommonTCActionBase): + def __init__(self, test_case, test_env, timeout=45, log_path=TCActionBase.LOG_PATH): + TCActionBase.CommonTCActionBase.__init__(self, test_case, test_env, + timeout=timeout, log_path=log_path) + # load param from excel + cmd_set = test_case["cmd set"] + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name) + pass + + def execute(self): + TCActionBase.TCActionBase.execute(self) + self.result_cntx.start() + + try: + # configurable params + send_len = self.send_len + # test count + test_count = self.test_count + # server port + server_port = self.server_port + server_port_t = self.server_port_2 + # ap ip + # ap_ip = self.ap_ip + # server echo + server_echo = self.server_echo + # station number + sta_number = self.sta_number + # pass standard + pass_standard = self.pass_standard + # send delay + send_delay = self.send_delay + # configurable params + except StandardError, e: + NativeLog.add_trace_critical("Error configuration for TCPTransparent script, error is %s" % e) + raise StandardError("Error configuration") + + # step0 reboot + checker_stings = [] + test_action_string = [] + + for i in range(sta_number + 2): + checker_stings.append("P SSC%d C !!!ready!!!" % (i + 1)) + test_action_string.append("SSCC SSC%d reboot" % (i + 1)) + + fail_string = "Fail, Fail to reboot" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step1, set ap/STA mode on all target + for i in range(sta_number + 2): + checker_stings = ["R SSC%d C +MODE:OK" % (i + 1)] + test_action_string = ["SSCC SSC%d op -S -o 3" % (i + 1)] + fail_string = "Fail, Fail to set mode on SSC%d" % (i + 1) + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # set different getway for SSC1 softAP + checker_stings = ["R SSC1 C +DHCP:AP,OK"] + test_action_string = ["SSCC SSC1 dhcp -E -o 2"] + fail_string = "Fail, SSC1 Fail to disable DHCP" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["R SSC1 C +IP:OK"] + test_action_string = ["SSCC SSC1 ip -S -o 2 -i 192.168.6.1"] + fail_string = "Fail, SSC1 Fail to set IP" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["R SSC1 C +DHCP:AP,OK"] + test_action_string = ["SSCC SSC1 dhcp -S -o 2"] + fail_string = "Fail, SSC1 Fail to enable DHCP" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # set different getway for SSC2 softAP + checker_stings = ["R SSC2 C +DHCP:AP,OK"] + test_action_string = ["SSCC SSC2 dhcp -E -o 2"] + fail_string = "Fail, SSC2 Fail to disable DHCP" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["R SSC2 C +IP:OK"] + test_action_string = ["SSCC SSC2 ip -S -o 2 -i 192.168.5.1"] + fail_string = "Fail, SSC2 Fail to set IP" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["R SSC2 C +DHCP:AP,OK"] + test_action_string = ["SSCC SSC2 dhcp -S -o 2"] + fail_string = "Fail, SSC2 Fail to enable DHCP" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step2, set ssid/password on SSC1 + ssid = "".join([random.choice(string.lowercase) for m in range(10)]) + password = "".join([random.choice(string.lowercase) for m in range(10)]) + checker_stings = ["R SSC1 C +SAP:OK"] + test_action_string = ["SSCC SSC1 ap -S -s %s -p %s -n 10 -t 0 -m 8" % (ssid, password)] + fail_string = "Fail, Fail to set ssid/password on SSC1" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step3, set ssid/password on SSC2 + ssid_1 = "".join([random.choice(string.lowercase) for m in range(10)]) + password_1 = "".join([random.choice(string.lowercase) for m in range(10)]) + checker_stings = ["R SSC2 C +SAP:OK"] + test_action_string = ["SSCC SSC2 ap -S -s %s -p %s -n 10 -t 0 -m 8" % (ssid_1, password_1)] + fail_string = "Fail, Fail to set ap ssid/password on SSC2" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step4, SSC2 join SSC1(soft AP) + checker_stings = [] + test_action_string = [] + checker_stings.append("P SSC2 C +JAP:CONNECTED,%s" % ssid) + test_action_string.append("SSCC SSC2 ap -C -s %s -p %s" % (ssid, password)) + fail_string = "Fail, Fail to connect to SSC1 SoftAP" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + # step5, create server on SSC1 + checker_stings = ["R SSC1 A :BIND:(\d+),OK"] + test_action_string = ["SSCC SSC1 soc -B -t TCP -p %s" % server_port] + fail_string = "Fail, Fail to create server on SSC1 while binding" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["R SSC1 RE LISTEN:(\d+),OK"] + test_action_string = ["SSCC SSC1 soc -L -s "] + fail_string = "Fail, Fail to create server on SSC1 while listening" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step6, create client on SSC2 + checker_stings = [] + test_action_string = [] + checker_stings.append("P SSC2 A :BIND:(\d+),OK") + test_action_string.append("SSCC SSC2 soc -B -t TCP") + fail_string = "Fail, SSC2 Fail to connect to server while binding" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["P SSC2 RE CONNECT:(\d+),OK", "P SSC1 A :ACCEPT:(\d+),.+"] + test_action_string = ["SSCC SSC2 soc -C -s -i %s -p %s" % ("192.168.6.1", server_port)] + fail_string = "Fail, SSC2 Fail to connect to server while connecting" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step7, SSC3 - SSC5 join SSC2 + checker_stings = [] + test_action_string = [] + for i in range(sta_number): + checker_stings.append("P SSC%d C +JAP:CONNECTED,%s" % (i + 3, ssid_1)) + test_action_string.append("SSCC SSC%d ap -C -s %s -p %s" % (i + 3, ssid_1, password_1)) + fail_string = "Fail, SSC%d Fail to connect to SSC2" % (i + 3) + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, check_time=450) is False: + return + + # step8, create server on SSC2 + checker_stings = ["R SSC2 A :BIND:(\d+),OK"] + test_action_string = ["SSCC SSC2 soc -B -t TCP -p %s -i 192.168.5.1" % server_port_t] + fail_string = "Fail, Fail to create server one SSC2 while binding" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["R SSC2 RE LISTEN:(\d+),OK"] + test_action_string = ["SSCC SSC2 soc -L -s "] + fail_string = "Fail, Fail to create server one SSC2 while listening" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step9, create client on SSC3 - SSC5 + checker_stings = [] + test_action_string = [] + for i in range(sta_number): + checker_stings.append("P SSC%d A :BIND:(\d+),OK" % (i + 3, i + 3)) + test_action_string.append("SSCC SSC%d soc -B -t TCP" % (i + 3)) + fail_string = "Fail, Fail to connect to SSC2 server while binding" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + for i in range(sta_number): + checker_stings = ["P SSC%d RE CONNECT:(\d+),OK" % (i + 3), + "P SSC2 A :ACCEPT:(\d+),.+" % (i + 3)] + test_action_string = ["SSCC SSC%d soc -C -s -i %s -p %s" % + (i + 3, i + 3, "192.168.5.1", server_port_t)] + fail_string = "Fail, Fail to connect to SSC2 server while connecting" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + start_time = time.time() + # step 10, do send/recv + while test_count > 0: + _tmp_count = TEST_COUNT_ONE_ROUND if test_count - TEST_COUNT_ONE_ROUND > 0 else test_count + test_count -= TEST_COUNT_ONE_ROUND + + checker_stings = [] + test_action_string = [] + if server_echo is True: + test_action_string.append("SSC SSC1 soc -S -s -l %d -n %d -j %d" % + (send_len, _tmp_count, send_delay)) + checker_stings.append("P SSC1 RE \+SEND:\d+,OK NC CLOSED") + test_action_string.append("SSC SSC2 soc -S -s -l %d -n %d -j %d" % + (send_len, _tmp_count, send_delay)) + checker_stings.append("P SSC2 RE \+SEND:\d+,OK NC CLOSED") + + for i in range(sta_number): + checker_stings.append("P SSC%d RE \+SEND:\d+,OK NC CLOSED" % (i + 3)) + test_action_string.append("SSC SSC%d soc -S -s -l %d -n %d -j %d" % + (i + 3, i + 3, send_len, _tmp_count, send_delay)) + for i in range(sta_number): + test_action_string.append("SSC SSC2 soc -S -s -l %d -n %d -j %d" % + (i + 3, send_len, _tmp_count, send_delay)) + checker_stings.append("P SSC2 RE \+SEND:\d+,OK NC CLOSED") + + fail_string = "Fail, Failed to send/recv data" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, + check_freq=1, check_time=300) is False: + break + pass + + if (time.time() - start_time) > pass_standard: + self.result_cntx.set_result("Succeed") + else: + checker_stings = [] + test_action_string = [] + for i in range(sta_number + 2): + checker_stings.append("P SSC%d C CLOSEALL" % (i + 1)) + test_action_string.append("SSCC SSC%d soc -T" % (i + 1)) + fail_string = "Fail, Fail to close socket" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + # re-set server on SSC1 + server_port = random.randint(20000, 30000) + checker_stings = ["R SSC1 A :BIND:(\d+),OK"] + test_action_string = ["SSCC SSC1 soc -B -t TCP -p %s" % server_port] + fail_string = "Fail, Fail to bind socket" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["R SSC1 RE LISTEN:(\d+),OK"] + test_action_string = ["SSCC SSC1 soc -L -s "] + fail_string = "Fail, Fail to listen" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + # SSC2 connnect SSC1 + checker_stings = [] + test_action_string = [] + checker_stings.append("P SSC2 A :BIND:(\d+),OK") + test_action_string.append("SSCC SSC2 soc -B -t TCP") + fail_string = "Fail, SSC2 Fail to bind sock" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["P SSC2 RE CONNECT:(\d+),OK", "P SSC1 A :ACCEPT:(\d+),.+"] + test_action_string = ["SSCC SSC2 soc -C -s -i %s -p %s" % ("192.168.6.1", server_port)] + fail_string = "Fail, SSC2 Fail to connect to SSC1 server" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + #create server on SSC2 + checker_stings = [] + test_action_string = [] + checker_stings.append("P SSC2 A :BIND:(\d+),OK") + test_action_string.append("SSCC SSC2 soc -B -t TCP -p %s -i 192.168.5.1" % server_port_t) + fail_string = "Fail, SSC2 Fail to bind" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + checker_stings = ["R SSC2 RE LISTEN:(\d+),OK"] + test_action_string = ["SSCC SSC2 soc -L -s "] + fail_string = "Fail, SSC2 Fail to listen" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + #create client on SSC3-SSC5 + checker_stings = [] + test_action_string = [] + for i in range(sta_number): + checker_stings.append("P SSC%d A :BIND:(\d+),OK" % (i + 3, i + 3)) + test_action_string.append("SSCC SSC%d soc -B -t TCP" % (i + 3)) + fail_string = "Fail, Fail to connect to SSC2 server while binding" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + for i in range(sta_number): + checker_stings = ["P SSC%d RE CONNECT:(\d+),OK" % (i + 3), + "P SSC2 A :ACCEPT:(\d+),.+" % (i + 3)] + test_action_string = ["SSCC SSC%d soc -C -s -i %s -p %s" % + (i + 3, i + 3, "192.168.5.1", server_port_t)] + fail_string = "Fail, Fail to connect to server" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + self.result_cntx.set_result("Failed") + + # finally, execute done + + def result_check(self, port_name, data): + TCActionBase.CommonTCActionBase.result_check(self, port_name, data) + self.result_cntx.append_data(port_name, data) + + +def main(): + pass + + +if __name__ == '__main__': + main() diff --git a/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPThroughput.py b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPThroughput.py new file mode 100755 index 000000000..85759b702 --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/TCPStress/TCPThroughput.py @@ -0,0 +1,325 @@ +import os +import time +import random +import threading +import socket + +from TCAction import TCActionBase +from NativeLog import NativeLog +from NativeLog import ThroughputResult +from Utility import RSSICalibrator + +LOG_FOLDER = os.path.join("Performance", "Throughput") + +AP_PROP_KEY = ("ssid", "password", "apc") + + +class SendThread(threading.Thread): + def __init__(self, sock, send_len): + threading.Thread.__init__(self) + self.setDaemon(True) + self.sock = sock + self.send_len = send_len + self.exit_event = threading.Event() + self.calc_event = threading.Event() + self.bytes_sent = 0 + pass + + def start_calc(self): + self.calc_event.set() + + def stop_calc(self): + self.calc_event.clear() + self.exit_event.set() + + def run(self): + data = "A" * self.send_len + if self.sock is None: + return + while True: + if self.exit_event.isSet() is True: + break + try: + self.sock.send(data) + except StandardError: + break + if self.calc_event.isSet() is True: + self.bytes_sent += self.send_len + + def get_bytes_sent(self): + return self.bytes_sent + + pass + + +class RecvThread(threading.Thread): + def __init__(self, sock): + threading.Thread.__init__(self) + self.setDaemon(True) + self.sock = sock + self.exit_event = threading.Event() + self.calc_event = threading.Event() + self.bytes_recv = 0 + + def start_calc(self): + self.calc_event.set() + + def stop_calc(self): + self.calc_event.clear() + self.exit_event.set() + + def run(self): + if self.sock is None: + return + while True: + if self.exit_event.isSet() is True: + break + try: + data = self.sock.recv(8 * 1024) + except StandardError: + break + if self.calc_event.isSet() is True: + self.bytes_recv += len(data) + + def get_bytes_recv(self): + return self.bytes_recv + + pass + + +class TestCase(TCActionBase.CommonTCActionBase): + def __init__(self, test_case, test_env, timeout=30, log_path=TCActionBase.LOG_PATH): + TCActionBase.CommonTCActionBase.__init__(self, test_case, test_env, timeout=timeout, log_path=log_path) + self.performance_folder_path = log_path + self.att_test_list = range(60) + cmd_set = test_case["cmd set"] + # load param from excel + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name) + pass + + def execute(self): + TCActionBase.TCActionBase.execute(self) + self.result_cntx.start() + + try: + # configurable params + ap_list = self.get_parameter("shield_box_ap_list") + pc_ip = self.get_parameter("pc_ip") + send_len = self.send_len + att_test_list = self.att_test_list + tx_enable = self.tx_enable + rx_enable = self.rx_enable + measure_period = self.measure_period + # configurable params + except StandardError, e: + NativeLog.add_trace_critical("Error configuration for TCPThroughput script, error is %s" % e) + raise StandardError("Error configuration") + + tcp_port = random.randint(40000, 50000) + + # init throughput result data + test_item = "" + if tx_enable is True: + test_item += "Tx" + if rx_enable is True: + test_item += "Rx" + if test_item == "": + raise StandardError("no throughput test item") + + folder_path = os.path.join(self.performance_folder_path, LOG_FOLDER) + file_name = os.path.join(folder_path, + "TCPThroughput_%s_%s" % (test_item, time.strftime("%d%H%M%S", time.localtime()))) + result = ThroughputResult.ThroughputResult(file_name, standard_required=True) + + # restart before executing throughput + checker_stings = ["R SSC1 C !!!ready!!!"] + test_action_string = ["SSC SSC1 reboot"] + fail_string = "Fail, Fail to reboot" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + self.result_cntx.set_result("Fail") + return + + # disable recv print during throughput test + checker_stings = ["R SSC1 C +RECVPRINT"] + test_action_string = ["SSC SSC1 soc -R -o 0"] + fail_string = "Fail, Fail to disable recv print" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + self.result_cntx.set_result("Fail") + return + + ret = True + for ap_prop in ap_list: + ssid = ap_prop[0] + password = ap_prop[1] + apc = ap_prop[2] + if ap_prop[1] == "": + # set a default string for open ap + password = "1" + # switch off all outlet, switch on AP outlet + outlet_config_dict = dict.fromkeys(range(1, 9), "OFF") + outlet_config_dict[apc] = "ON" + apc_cmd = "APC " + for outlet in outlet_config_dict: + apc_cmd += " %s %s" % (outlet_config_dict[outlet], outlet) + checker_stings = ["P PC_COM L OK"] + fail_string = "Fail, Fail to switch apc" + if self.load_and_exe_one_step(checker_stings, [apc_cmd], fail_string) is False: + ret = False + break + + # wait AP ready + time.sleep(20) + + # create server + server_sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM) + server_sock.bind((pc_ip, tcp_port)) + server_sock.settimeout(5) + server_sock.listen(5) + + if tx_enable is True: + result.add_test_item(ssid + "_tx") + if rx_enable is True: + result.add_test_item(ssid + "_rx") + + # create RSSI Calibrator + calibrator = RSSICalibrator.Calibrator() + + for att_value in att_test_list: + # step 0 set att value + checker_stings = ["R PC_COM L OK"] + test_action_string = ["ATT %s" % att_value] + fail_string = "Fail, Fail to set att value" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + ret = False + break + # continue + + # step 1 get AP RSSI + checker_stings = ["R SSC1 A :\+SCAN:%s,[:\d\w]+,\d+,\d+,([-\d]+)" % ssid] + test_action_string = ["SSC SSC1 sta -S -s %s" % ssid] + fail_string = "Fail, Fail to scan" + rssi = scan_count = 0 + for i in range(3): + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + continue + rssi += int(self.test_env.get_variable_by_name("rssi")[1]) + scan_count += 1 + + rssi = calibrator.calibrate_rssi(float(rssi) / scan_count if scan_count > 0 else 0, att_value) + + # step 2 connect to AP + checker_stings = ["R SSC1 C +JAP:CONNECTED"] + test_action_string = ["SSC SSC1 sta -C -s %s -p %s" % (ssid, password)] + fail_string = "Fail, Fail to JAP" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, + check_freq=1, check_time=30) is False: + if rssi < -89: + continue + else: + ret = False + break + + # step 3 close all connections + checker_stings = ["R SSC1 C +CLOSEALL"] + test_action_string = ["SSC SSC1 soc -T"] + fail_string = "Fail, Fail to close socket" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + ret = False + break + # continue + + # step 4 create tcp connection + + checker_stings = ["R SSC1 A :\+BIND:(\d+),OK"] + test_action_string = ["SSC SSC1 soc -B -t TCP"] + fail_string = "Fail, Fail to bind" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + ret = False + break + # continue + + checker_stings = ["P SSC1 RE \+CONNECT:\d+,OK"] + test_action_string = ["SSC SSC1 soc -C -s -i %s -p %s" % (pc_ip, tcp_port)] + fail_string = "Fail, Fail to connect socket" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + ret = False + break + # continue + + try: + sock, addr = server_sock.accept() + except socket.error, e: + NativeLog.add_trace_critical("%s" % e) + continue + sock.settimeout(measure_period) + + # step 5 do throughput test + send_thread = SendThread(sock if rx_enable is True else None, send_len) + send_thread.start() + + recv_thread = RecvThread(sock if tx_enable is True else None) + recv_thread.start() + + if tx_enable is True: + # do send from target + test_action_string = ["SSC SSC1 soc -S -s -l %s -n 10000000" % send_len] + fail_string = "Fail, Fail to send" + if self.load_and_exe_one_step([], test_action_string, fail_string) is False: + pass + + # start throughput calculate + send_thread.start_calc() + recv_thread.start_calc() + + # sleep for measure period + time.sleep(measure_period) + + # stop throughput calculate + send_thread.stop_calc() + recv_thread.stop_calc() + + send_thread.join() + recv_thread.join() + + sock.close() + + # output throughput result + # in Mbps + if send_thread.get_bytes_sent() > 0: + result.log_throughput(ssid + "_rx", rssi, att_value, + float(send_thread.get_bytes_sent() * 8) / (measure_period * 1000000)) + + if recv_thread.get_bytes_recv() > 0: + result.log_throughput(ssid + "_tx", rssi, att_value, + float(recv_thread.get_bytes_recv() * 8) / (measure_period * 1000000)) + + result.output_to_file() + pass + + server_sock.close() + if not ret: + NativeLog.add_trace_critical("Test SUC for %s" % ssid) + elif ret: + NativeLog.add_trace_critical("Test FAIL for %s!!!" % ssid) + if ret: + self.result_cntx.set_result("Succeed") + else: + self.result_cntx.set_result("Fail") + + # finally, execute done + + def result_check(self, port_name, data): + TCActionBase.CommonTCActionBase.result_check(self, port_name, data) + self.result_cntx.append_data(port_name, data) + + +def main(): + pass + + +if __name__ == '__main__': + main() diff --git a/components/idf_test/integration_test/TestCaseScript/TCPStress/__init__.py b/components/idf_test/integration_test/TestCaseScript/TCPStress/__init__.py new file mode 100755 index 000000000..049c1b961 --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/TCPStress/__init__.py @@ -0,0 +1 @@ +__all__ = ["TCPConnUtility", "TCPConnSingleMode", "TCPConnMixedMode"] \ No newline at end of file diff --git a/components/idf_test/integration_test/TestCaseScript/UDPStress/UDPBroadcast.py b/components/idf_test/integration_test/TestCaseScript/UDPStress/UDPBroadcast.py new file mode 100644 index 000000000..9ced966a8 --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/UDPStress/UDPBroadcast.py @@ -0,0 +1,342 @@ +import time +import random +import threading +import socket +import re + +from TCAction import PerformanceTCBase +from NativeLog import NativeLog +from Utility import Encoding + + +class SendThread(threading.Thread): + def __init__(self, sock, send_len, target_addr, delay): + threading.Thread.__init__(self) + self.sock = sock + self.send_len = send_len + self.target_addr = target_addr + self.delay = delay + self.exit_event = threading.Event() + self.send_count = 0 + pass + + def exit(self): + self.exit_event.set() + + def run(self): + data = "A" * self.send_len + if self.sock is None: + return + while True: + if self.exit_event.isSet() is True: + break + try: + self.sock.sendto(data, self.target_addr) + except StandardError: + break + self.send_count += 1 + time.sleep(self.delay * 0.001) + + pass + + def get_send_count(self): + return self.send_count + + +class RecvThread(threading.Thread): + def __init__(self, sock): + threading.Thread.__init__(self) + self.sock = sock + self.exit_event = threading.Event() + self.calc_event = threading.Event() + self.bytes_recv = 0 + self.Max = 0.0 + + def start_calc(self): + self.calc_event.set() + + def stop_calc(self): + self.calc_event.clear() + self.exit_event.set() + + def run(self): + if self.sock is None: + return + while True: + if self.exit_event.isSet() is True: + break + try: + data, addr = self.sock.recvfrom(2048) + except StandardError: + break + if self.calc_event.isSet() is True: + self.bytes_recv += len(data) + if len(data) == 0: + start = time.time() + while True: + try: + data, addr = self.sock.recvfrom(2048) + except StandardError: + break + if len(data) > 0: + if self.calc_event.isSet() is True: + self.bytes_recv += len(data) + end = time.time() + break + if end - start > self.Max: + self.Max = end - start + + def get_bytes_recv(self): + return self.bytes_recv + + pass + + def get_Max_time(self): + return self.Max + + pass + + +class device_check(threading.Thread): + def __init__(self, port): + threading.Thread.__init__(self) + self.Max = 0.0 + self.port = port + self.recv_data_cache = "" + self.cache_lock = threading.Lock() + self.exit_event = threading.Event() + + def data_recv_callback(self, data): + with self.cache_lock: + self.recv_data_cache += data + pass + + def exit(self): + self.exit_event.set() + pass + + def run(self): + while self.exit_event.isSet() is False: + while True: + if self.recv_data_cache: + match = re.search("\+RECVFROM:\d+,\d+,\d+\.\d+\.\d+\.\d+,\d+", self.recv_data_cache) + if match is not None: + self.recv_data_cache = self.recv_data_cache[len(match.group()):] + else: + start = time.time() + end = 0.0 + while True: + res = re.search("\+RECVFROM:\d+,\d+,\d+\.\d+\.\d+\.\d+,\d+", self.recv_data_cache) + if res is not None: + self.recv_data_cache = self.recv_data_cache[len(res.group()):] + end = time.time() + break + if end - start > self.Max: + self.Max = end - start + pass + + def get_max_time(self): + return self.Max + + +class TestCase(PerformanceTCBase.PerformanceTCBase): + def __init__(self, test_case, test_env, timeout, log_path): + PerformanceTCBase.PerformanceTCBase.__init__(self, test_case, test_env, timeout, log_path) + self.send_len = 0 + self.pc_send = 0 + self.target_send = 0 + self.test_time = 0 + self.delay = 0 + # load param from excel + cmd_set = test_case["cmd set"] + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + self.recv_cb_lock = threading.Lock() + self.recv_cb = dict.fromkeys(["SSC1"]) + pass + + def register_recv_callback(self, port_name, callback): + with self.recv_cb_lock: + if self.recv_cb[port_name] is None: + self.recv_cb[port_name] = [callback] + else: + self.recv_cb[port_name].append(callback) + pass + + def process(self): + try: + # configurable params + send_len = self.send_len + pc_send = self.pc_send + target_send = self.target_send + test_time = self.test_time + delay = self.delay + ap_ssid = self.get_parameter("ap_ssid") + ap_password = self.get_parameter("ap_password") + pc_ip = self.get_parameter("pc_ip") + target_ip = self.get_parameter("target_ip") + except StandardError, e: + NativeLog.add_trace_critical("Error configuration for UDP script, error is %s" % e) + raise StandardError("Error configuration") + + udp_port = random.randint(40000, 50000) + + # reboot before executing + self.flush_data("SSC1") + self.serial_write_line("SSC1", "reboot") + if self.check_response("SSC1", "ready!!!", 5) is False: + NativeLog.add_trace_critical("Fail to reboot") + return + + # set target as STA mode + self.flush_data("SSC1") + self.serial_write_line("SSC1", "op -S -o 1") + if self.check_response("SSC1", "+MODE:OK", 5) is False: + NativeLog.add_trace_critical("Fail to set mode") + return + + # connect to AP + self.flush_data("SSC1") + self.serial_write_line("SSC1", "sta -C -s %s -p %s" % (ap_ssid, ap_password)) + if self.check_response("SSC1", "+JAP:CONNECTED", 30) is False: + NativeLog.add_trace_critical("Fail to JAP") + return + + # disable recv print on target + self.flush_data("SSC1") + self.serial_write_line("SSC1", "soc -R -o 0") + if self.check_response("SSC1", "+RECVPRINT", 5) is False: + NativeLog.add_trace_critical("Fail to disable recv print") + return + + # get broadcast ip + res = re.search("(\d+\.\d+\.\d+\.)\d+", pc_ip) + if res is not None: + udp = res.group(1) + broadcast_ip = udp + "255" + else: + NativeLog.add_trace_critical("No ip addr found") + return + + # close all connection on target + self.flush_data("SSC1") + self.serial_write_line("SSC1", "soc -T") + if self.check_response("SSC1", "+CLOSEALL", 5) is False: + NativeLog.add_trace_critical("Fail to close sock") + return + + # create socket on pc + pc_sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM) + pc_sock.bind((pc_ip, udp_port)) + pc_sock.settimeout(1) + + # create socket on target + self.flush_data("SSC1") + self.serial_write_line("SSC1", "soc -B -t UDP -i %s -p %s" % (target_ip, udp_port)) + if self.check_response("SSC1", "+BIND:0,OK,", 5) is False: + NativeLog.add_trace_critical("Fail to bind") + return + + thread_dict = dict.fromkeys(["SSC1"]) + thread_dict["SSC1"] = dict(zip(["check"], [None])) + thread_dict["SSC1"]["check"] = device_check(self.test_env.get_port_by_name("SSC1")) + self.register_recv_callback("SSC1", thread_dict["SSC1"]["check"].data_recv_callback) + + send_thread = SendThread(pc_sock if pc_send is True else None, send_len, (broadcast_ip, udp_port), delay) + send_thread.start() + + recv_thread = RecvThread(pc_sock if target_send is True else None) + recv_thread.start() + + # start calculate + recv_thread.start_calc() + thread_dict["SSC1"]["check"].start() + send_count = 0 + if target_send is True: + # do send from target + start = time.time() + while time.time() - start < test_time * 60: + self.flush_data("SSC1") + self.serial_write_line("SSC1", "soc -S -s 0 -l %s -n 1000 -i %s -p %s -j %s" % ( + send_len, broadcast_ip, udp_port, delay)) + if self.check_response("SSC1", "+SEND:0,OK", 300) is False: + NativeLog.add_trace_critical("Fail to send") + return + send_count += 1000 + else: + time.sleep(test_time * 60) + + send_thread.exit() + send_thread.join() + + # stop throughput calculate + while True: + if recv_thread.isAlive() is False: + recv_thread.stop_calc() + recv_thread.join() + break + + Max = 0.0 + recv_count = 0 + if pc_send is True: + send_count = send_thread.get_send_count() + start = time.time() + rx_data_len = 0 + suc_time = 0 + while time.time() - start < 30: + self.flush_data("SSC1") + self.serial_write_line("SSC1", "soc -Q -s 0 -o 1") + time.sleep(0.05) + data = self.serial_read_data("SSC1") + if data is not None: + res = re.search("\+RECVLEN:(\d+)", data) + if res is not None: + if rx_data_len < int(res.group(1)): + rx_data_len = int(res.group(1)) + time.sleep(0.5) + else: + suc_time += 1 + if suc_time > 5: + break + + if (rx_data_len * 8 % send_len) > 0: + recv_count = rx_data_len / send_len + 1 + else: + recv_count = rx_data_len / send_len + + if recv_thread.get_bytes_recv() > 0: + if (recv_thread.get_bytes_recv() % send_len) > 0: + recv_count = recv_thread.get_bytes_recv() / send_len + 1 + else: + recv_count = recv_thread.get_bytes_recv() / send_len + Max = recv_thread.get_Max_time() + + thread_dict["SSC1"]["check"].exit() + pc_sock.close() + + self.set_result("Succeed") + NativeLog.add_trace_critical("send_count is %s, recv_count is %s" % (send_count, recv_count)) + NativeLog.add_trace_critical( + "UDP Broadcast lose rate is %.2f%%" % (float(send_count - recv_count) / send_count * 100)) + NativeLog.add_trace_critical("UDP Broadcast lose test MAX time is %.4f" % Max) + + @Encoding.encode_utf8(3) + def result_check(self, port_name, data): + PerformanceTCBase.PerformanceTCBase.result_check(self, port_name, data) + if port_name in self.recv_cb: + with self.recv_cb_lock: + callback_list = self.recv_cb[port_name] + if callback_list is not None: + for callback in callback_list: + callback(data) + pass + + +def main(): + pass + + +if __name__ == '__main__': + main() diff --git a/components/idf_test/integration_test/TestCaseScript/UDPStress/UDPMultiSTASendRecv.py b/components/idf_test/integration_test/TestCaseScript/UDPStress/UDPMultiSTASendRecv.py new file mode 100644 index 000000000..82c615d4e --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/UDPStress/UDPMultiSTASendRecv.py @@ -0,0 +1,156 @@ +from TCAction import TCActionBase +from NativeLog import NativeLog +import time +import random +import string + + +class TestCase(TCActionBase.CommonTCActionBase): + def __init__(self, test_case, test_env, timeout=45, log_path=TCActionBase.LOG_PATH): + TCActionBase.CommonTCActionBase.__init__(self, test_case, test_env, timeout=timeout, log_path=log_path) + # load param from excel + cmd_set = test_case["cmd set"] + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name) + pass + + def execute(self): + TCActionBase.TCActionBase.execute(self) + self.result_cntx.start() + + try: + # configurable params + send_len = self.send_len + test_time = self.test_time * 60 + server_echo = self.server_echo + sta_number = self.sta_number + send_delay = self.send_delay + # configurable params + except StandardError, e: + NativeLog.add_trace_critical("Error configuration for TCPTransparent script, error is %s" % e) + raise StandardError("Error configuration") + + # step0 reboot + for i in range(sta_number + 1): + checker_stings = ["P SSC%d C ready!!!" % (i + 1)] + test_action_string = ["SSCC SSC%d restore" % (i + 1)] + fail_string = "Fail, Fail to restore" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # turn off recv print + for i in range(sta_number + 1): + checker_stings = ["P SSC%d C +RECVPRINT:0" % (i + 1)] + test_action_string = ["SSCC SSC%d soc -R -o 0" % (i + 1)] + fail_string = "Fail, Fail to turn off recv print" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step1, set softAP mode on SSC1 + checker_stings = ["R SSC1 C +MODE:OK"] + test_action_string = ["SSCC SSC1 op -S -o 2"] + fail_string = "Fail, Fail to set mode on SSC1" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step2, set STA mode on SSC2-SSCn + for i in range(sta_number): + checker_stings = ["R SSC%d C +MODE:OK" % (i + 2)] + test_action_string = ["SSCC SSC%d op -S -o 1" % (i + 2)] + fail_string = "Fail, Fail to set mode on SSC%d" % (i + 2) + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step3, set ssid/password on SSC1 + ssid = "".join([random.choice(string.lowercase) for m in range(10)]) + password = "".join([random.choice(string.lowercase) for m in range(10)]) + udp_port = random.randint(10000, 20000) + + checker_stings = ["R SSC1 C +SAP:OK"] + test_action_string = ["SSCC SSC1 ap -S -s %s -p %s -n 10 -t 0 -m 10" % (ssid, password)] + fail_string = "Fail, Fail to set ssid/password on SSC1" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step4, all STA join SSC1(soft AP) + for i in range(sta_number): + checker_stings = ["R SSC%d C +JAP:CONNECTED,%s" % (i + 2, ssid)] + test_action_string = ["SSCC SSC%d ap -C -s %s -p %s" % (i + 2, ssid, password)] + fail_string = "Fail, Fail to connect to SSC1" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, check_time=450) is False: + return + + # step5, get all the STA ip + for i in range(sta_number): + checker_stings = ["R SSC%d A :\+STAIP:192.168.4.(\d+)" % (i + 2, i + 2)] + test_action_string = ["SSCC SSC%d ip -Q" % (i + 2)] + fail_string = "Fail, Fail to get SSC%d ip" % (i + 2) + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + # else: + # print "SSC%d ip is:" % (i + 2), self.get_parameter("SSC%d_IP" % (i + 2)) + + # step6, create UDP socket on all targets + for i in range(sta_number): + checker_stings = ["R SSC%d A :\+BIND:(\d+),OK" % (i + 2, i + 2)] + test_action_string = ["SSCC SSC%d soc -B -t UDP -p %s" % (i + 2, udp_port + i + 2)] + fail_string = "Fail, SSC%d Fail to bind" % (i + 2) + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + start_time = time.time() + # step7, do send/recv, SSC2<---->other STAs + while time.time() - start_time < test_time: + checker_stings = [] + test_action_string = [] + if server_echo is True: + + # SSC2 send packets to SSC3-SSCn + for i in range(sta_number - 1): + ip = "192.168.4." + self.get_parameter("SSC%d_IP" % (i + 3)) + test_action_string.append( + "SSC SSC2 soc -S -s -i %s -p %s -l %d -n 1000 -j %d" % ( + i + 3, ip, udp_port + i + 3, send_len, send_delay)) + checker_stings.append( + "P SSC2 RE \+SEND:%s,OK NC CLOSED NC ERROR" % self.get_parameter("sock%d" % (i + 3))) + + # SSC3-SSCn send packets to SSC2 + ssc2_ip = "192.168.4." + self.get_parameter("SSC2_IP") + for i in range(sta_number - 1): + test_action_string.append( + "SSC SSC%d soc -S -s -i %s -p %s -l %d -n 1000 -j %d" % ( + i + 3, i + 3, ssc2_ip, udp_port + 2, send_len, send_delay)) + checker_stings.append( + "P SSC%d RE \+SEND:%s,OK NC CLOSED NC ERROR" % (i + 3, self.get_parameter("sock%d" % (i + 3)))) + + fail_string = "Fail, Failed to send/recv data" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, + check_freq=1, check_time=300) is False: + break + + # drop off the delay time if it's greater than 20ms + if send_delay > 20: + send_delay -= 10 + + NativeLog.add_trace_critical("time escape: %s" % (time.time() - start_time)) + if (time.time() - start_time) >= test_time: + self.result_cntx.set_result("Succeed") + else: + self.result_cntx.set_result("Failed") + + # finally, execute done + + def result_check(self, port_name, data): + TCActionBase.CommonTCActionBase.result_check(self, port_name, data) + self.result_cntx.append_data(port_name, data) + + +def main(): + pass + + +if __name__ == '__main__': + main() diff --git a/components/idf_test/integration_test/TestCaseScript/UDPStress/UDPPacketLose.py b/components/idf_test/integration_test/TestCaseScript/UDPStress/UDPPacketLose.py new file mode 100644 index 000000000..4cb0c1e8d --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/UDPStress/UDPPacketLose.py @@ -0,0 +1,246 @@ +import os +import time +import random +import threading +import socket + +from TCAction import TCActionBase +from NativeLog import NativeLog + +AP_PROP_KEY = ("ssid", "password", "apc") + + +class SendThread(threading.Thread): + def __init__(self, sock, send_len, target_addr, delay): + threading.Thread.__init__(self) + self.sock = sock + self.send_len = send_len + self.target_addr = target_addr + self.delay = delay + self.count = 0 + self.exit_event = threading.Event() + pass + + def exit(self): + self.exit_event.set() + + def run(self): + data = "A" * self.send_len + if self.sock is None: + return + while True: + if self.exit_event.isSet() is True: + break + try: + self.sock.sendto(data, self.target_addr) + except StandardError: + break + self.count += 1 + time.sleep(self.delay * 0.001) + + def calculate(self): + return self.count + + +class RecvThread(threading.Thread): + def __init__(self, sock): + threading.Thread.__init__(self) + self.sock = sock + self.exit_event = threading.Event() + self.calc_event = threading.Event() + self.bytes_recv = 0 + + def start_calc(self): + self.calc_event.set() + + def stop_calc(self): + self.calc_event.clear() + self.exit_event.set() + + def run(self): + if self.sock is None: + return + ret = True + while ret: + if self.exit_event.isSet() is True: + break + try: + data, addr = self.sock.recvfrom(65535) + except StandardError: + break + if self.calc_event.isSet() is True: + self.bytes_recv += len(data) + if len(data) == 0: + start = time.time() + while time.time() - start < 30: + try: + data, addr = self.sock.recvfrom(65535) + except StandardError: + break + if len(data) == 0: + break + else: + self.bytes_recv += len(data) + else: + ret = False + + def get_bytes_recv(self): + return self.bytes_recv + + pass + + +class TestCase(TCActionBase.CommonTCActionBase): + def __init__(self, test_case, test_env, timeout=30, log_path=TCActionBase.LOG_PATH): + TCActionBase.CommonTCActionBase.__init__(self, test_case, test_env, timeout, log_path) + self.att_test_list = range(60) + # load param from excel + cmd_set = test_case["cmd set"] + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name) + pass + + def execute(self): + TCActionBase.TCActionBase.execute(self) + self.result_cntx.start() + + try: + # configurable params + send_len = self.send_len + pc_send = self.pc_send + target_send = self.target_send + test_time = self.test_time + delay = self.delay + ap_ssid = self.get_parameter("ap_ssid") + ap_password = self.get_parameter("ap_password") + pc_ip = self.get_parameter("pc_ip") + target_ip = self.get_parameter("target_ip") + # configurable params + except StandardError, e: + NativeLog.add_trace_critical("Error configuration for UDP script, error is %s" % e) + raise StandardError("Error configuration") + + udp_port = random.randint(40000, 50000) + + # reboot before executing + checker_stings = ["R SSC1 C ready!!!"] + test_action_string = ["SSC SSC1 reboot"] + fail_string = "Fail, Fail to reboot" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # disable recv print on target + checker_stings = ["R SSC1 C +RECVPRINT"] + test_action_string = ["SSC SSC1 soc -R -o 0"] + fail_string = "Fail, Fail to disable recv print" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # create socket on pc + udp_sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM) + udp_sock.bind((pc_ip, udp_port)) + udp_sock.settimeout(1) + + # connect to AP + checker_stings = ["R SSC1 C +JAP:CONNECTED"] + test_action_string = ["SSC SSC1 sta -C -s %s -p %s" % (ap_ssid, ap_password)] + fail_string = "Fail, Fail to JAP" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, + check_freq=1, check_time=30) is False: + return + + # close all connection + checker_stings = ["R SSC1 C +CLOSEALL"] + test_action_string = ["SSC SSC1 soc -T"] + fail_string = "Fail, Fail to create server" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # create UDP socket on target + checker_stings = ["R SSC1 A :\+BIND:(\d+),OK"] + test_action_string = ["SSC SSC1 soc -B -t UDP -p %s" % udp_port] + fail_string = "Fail, Fail bind" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + send_thread = SendThread(udp_sock if pc_send is True else None, + send_len, (target_ip, udp_port), delay) + send_thread.start() + + recv_thread = RecvThread(udp_sock if target_send is True else None) + recv_thread.start() + + # start calculate + recv_thread.start_calc() + send_count = 0 + if target_send is True: + # do send from target + start = time.time() + while time.time() - start < test_time * 60: + checker_stings = ["P SSC1 RE \+SEND:0,OK"] + test_action_string = ["SSC SSC1 soc -S -s -l %s -n 1000 -i %s -p %s -j %s" % ( + send_len, pc_ip, udp_port, delay)] + fail_string = "Fail, Fail to send" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, check_freq=0.1, + check_time=3000) is False: + return + send_count += 1000 + else: + time.sleep(test_time * 60) + + send_thread.exit() + send_thread.join() + + # stop throughput calculate + while True: + if recv_thread.isAlive() is False: + recv_thread.stop_calc() + recv_thread.join() + break + + recv_count = 0 + if pc_send is True: + # get received data len from PC + self.load_and_exe_one_step(["R SSC1 A :RECVLEN:(\d+)"], + ["SSC SSC1 soc -Q -s -o 1"], + "Fail, Fail to get recv data len") + try: + rx_data_len = int(self.get_parameter("recv_len")) + except StandardError: + rx_data_len = 0 + + if (rx_data_len % send_len) > 0: + recv_count = rx_data_len / send_len + 1 + else: + recv_count = rx_data_len / send_len + + send_count = send_thread.calculate() + + if recv_thread.get_bytes_recv() > 0: + if (recv_thread.get_bytes_recv() % send_len) > 0: + recv_count = recv_thread.get_bytes_recv() / send_len + 1 + else: + recv_count = recv_thread.get_bytes_recv() / send_len + udp_sock.close() + + NativeLog.add_trace_critical("send_count is %s, recv_count is %s" % (send_count, recv_count)) + self.result_cntx.set_result("Succeed") + NativeLog.add_trace_critical( + "UDP Packet lose rate is %.2f%%" % (float(send_count - recv_count) / send_count * 100)) + + # finally, execute done + + def result_check(self, port_name, data): + TCActionBase.CommonTCActionBase.result_check(self, port_name, data) + self.result_cntx.append_data(port_name, data) + + +def main(): + pass + + +if __name__ == '__main__': + main() diff --git a/components/idf_test/integration_test/TestCaseScript/UDPStress/UDPSTAMuitiSocketSendRecv.py b/components/idf_test/integration_test/TestCaseScript/UDPStress/UDPSTAMuitiSocketSendRecv.py new file mode 100644 index 000000000..ca9457261 --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/UDPStress/UDPSTAMuitiSocketSendRecv.py @@ -0,0 +1,163 @@ +from TCAction import TCActionBase +from NativeLog import NativeLog +import time +import random +import string + + +class TestCase(TCActionBase.CommonTCActionBase): + def __init__(self, test_case, test_env, timeout=45, log_path=TCActionBase.LOG_PATH): + TCActionBase.CommonTCActionBase.__init__(self, test_case, test_env, timeout=timeout, log_path=log_path) + # load param from excel + cmd_set = test_case["cmd set"] + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name) + pass + + def execute(self): + TCActionBase.TCActionBase.execute(self) + self.result_cntx.start() + + try: + # configurable params + send_len = self.send_len + test_time = self.test_time * 60 + server_echo = self.server_echo + conn_number = self.conn_number + sta_number = self.sta_number + send_delay = self.send_delay + # configurable params + except StandardError, e: + NativeLog.add_trace_critical("Error configuration for TCPTransparent script, error is %s" % e) + raise StandardError("Error configuration") + + # step0 reboot + for i in range(sta_number + 1): + checker_stings = ["P SSC%d C !!!ready!!!" % (i + 1)] + test_action_string = ["SSCC SSC%d reboot" % (i + 1)] + fail_string = "Fail, Fail to reboot" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # turn off recv print + for i in range(sta_number + 1): + checker_stings = ["P SSC%d C +RECVPRINT:0" % (i + 1)] + test_action_string = ["SSCC SSC%d soc -R -o 0" % (i + 1)] + fail_string = "Fail, Fail to turn off recv print" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step1, set softAP mode on SSC1 + checker_stings = ["R SSC1 C +MODE:OK"] + test_action_string = ["SSCC SSC1 op -S -o 2"] + fail_string = "Fail, Fail to set mode on SSC1" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step2, set STA mode on SSC2-SSCn + for i in range(sta_number): + checker_stings = ["R SSC%d C +MODE:OK" % (i + 2)] + test_action_string = ["SSCC SSC%d op -S -o 1" % (i + 2)] + fail_string = "Fail, Fail to set mode on SSC%d" % (i + 2) + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step3, set ssid/password on SSC1 + ssid = "".join([random.choice(string.lowercase) for m in range(10)]) + password = "".join([random.choice(string.lowercase) for m in range(10)]) + + checker_stings = ["R SSC1 C +SAP:OK"] + test_action_string = ["SSCC SSC1 ap -S -s %s -p %s -n 10 -t 0 -m 8" % (ssid, password)] + fail_string = "Fail, Fail to set ssid/password on SSC1" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step4, all STA join SSC1(soft AP) + for i in range(sta_number): + checker_stings = ["R SSC%d C +JAP:CONNECTED,%s" % (i + 2, ssid)] + test_action_string = ["SSCC SSC%d ap -C -s %s -p %s" % (i + 2, ssid, password)] + fail_string = "Fail, Fail to connect to SSC1" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, check_time=450) is False: + return + + # step5, get all the STA ip + for i in range(sta_number): + checker_stings = ["R SSC%d A :\+STAIP:192.168.4.(\d+)" % (i + 2, i + 2)] + test_action_string = ["SSCC SSC%d ip -Q" % (i + 2)] + fail_string = "Fail, Fail to get SSC%d ip" % (i + 2) + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + else: + print "SSC%d ip is:" % (i + 2), self.get_parameter("SSC%d_IP" % (i + 2)) + + udp_port_list = [] + # step6, create multi UDP socket on all targets + for i in range(conn_number): + + udp_port = random.randint(10000, 20000) + udp_port_list.append(udp_port) + + checker_stings = ["R SSC2 A :\+BIND:(\d+),OK" % i] + test_action_string = ["SSCC SSC2 soc -B -t UDP -p %s" % udp_port] + fail_string = "Fail, SSC2 Fail to bind" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + checker_stings = ["R SSC3 A :\+BIND:(\d+),OK" % i] + test_action_string = ["SSCC SSC3 soc -B -t UDP -p %s" % (udp_port + 1)] + fail_string = "Fail, SSC3 Fail to bind" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + start_time = time.time() + # step7, do send/recv, SSC2<---->other STAs + while time.time() - start_time < test_time: + # drop off the delay time if it's greater than 20ms + if send_delay > 20: + send_delay -= 10 + + checker_stings = [] + test_action_string = [] + if server_echo is True: + + # SSC2 send packets to SSC3 + ssc3_ip = "192.168.4." + self.get_parameter("SSC3_IP") + for i in range(conn_number): + test_action_string.append("SSC SSC2 soc -S -s -i %s -p %s -l %d -n 1000 -j %d" % ( + i, ssc3_ip, udp_port_list[i] + 1, send_len, send_delay)) + checker_stings.append("P SSC2 RE \+SEND:\d+,OK NC CLOSED NC ERROR") + + # SSC3 send packets to SSC2 + ssc2_ip = "192.168.4." + self.get_parameter("SSC2_IP") + for i in range(conn_number): + test_action_string.append("SSC SSC3 soc -S -s -i %s -p %s -l %d -n 1000 -j %d" % ( + i, ssc2_ip, udp_port_list[i], send_len, send_delay)) + checker_stings.append("P SSC3 RE \+SEND:\d+,OK NC CLOSED NC ERROR") + + fail_string = "Fail, Failed to send/recv data" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, + check_freq=1, check_time=300) is False: + break + + NativeLog.add_trace_critical("time escape: %s" % (time.time() - start_time)) + if (time.time() - start_time) >= test_time: + self.result_cntx.set_result("Succeed") + else: + self.result_cntx.set_result("Failed") + + # finally, execute done + + def result_check(self, port_name, data): + TCActionBase.CommonTCActionBase.result_check(self, port_name, data) + self.result_cntx.append_data(port_name, data) + + +def main(): + pass + + +if __name__ == '__main__': + main() diff --git a/components/idf_test/integration_test/TestCaseScript/UDPStress/UDPSendRecv.py b/components/idf_test/integration_test/TestCaseScript/UDPStress/UDPSendRecv.py new file mode 100755 index 000000000..032062ad2 --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/UDPStress/UDPSendRecv.py @@ -0,0 +1,133 @@ +from TCAction import TCActionBase +from NativeLog import NativeLog +import time +import random +import string + +TEST_COUNT_ONE_ROUND = 1000 + + +class TestCase(TCActionBase.CommonTCActionBase): + + def __init__(self, test_case, test_env, timeout=30, log_path=TCActionBase.LOG_PATH): + TCActionBase.CommonTCActionBase.__init__(self, test_case, test_env, timeout=timeout, log_path=log_path) + # load param from excel + cmd_set = test_case["cmd set"] + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name) + pass + + def cleanup(self): + # step 0 turn on recv print + checker_stings = ["R SSC1 C +RECVPRINT:1"] + test_action_string = ["SSC SSC1 soc -R -o 1"] + fail_string = "Fail, Fail to turn on recv print" + self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) + pass + + def execute(self): + TCActionBase.TCActionBase.execute(self) + self.result_cntx.start() + + try: + # configurable params + send_len = self.send_len + test_time = self.test_time * 60 + duplex = self.duplex + conn_num = self.conn_num + send_delay = self.send_delay + # configurable params + except StandardError, e: + NativeLog.add_trace_critical("Error configuration for UDPSendRecv script, error is %s" % e) + raise StandardError("Error configuration") + + ssid = "".join([random.choice(string.lowercase) for m in range(10)]) + password = "".join([random.choice(string.lowercase) for m in range(10)]) + + # step 0 set ap + checker_stings = ["R SSC1 C +SAP:OK"] + test_action_string = ["SSC SSC1 ap -S -s %s -p %s -t 3" % (ssid, password)] + fail_string = "Fail, Fail to set ap" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + # step 1 connect to ap and turn off recv print + checker_stings = ["R SSC2 C +JAP:CONNECTED"] + test_action_string = ["SSC SSC2 sta -C -s %s -p %s" % (ssid, password)] + fail_string = "Fail, Fail to connect to server" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, check_time=200) is False: + return + + checker_stings = ["R SSC2 A :\+STAIP:(\d+\.\d+\.\d+\.\d+)\r"] + test_action_string = ["SSC SSC2 ip -Q -o 1"] + fail_string = "Fail, Fail to connect to server" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, check_time=200) is False: + return + + checker_stings = ["P SSC1 C +RECVPRINT:0", "P SSC2 C +RECVPRINT:0"] + test_action_string = ["SSC SSC1 soc -R -o 0", "SSC SSC2 soc -R -o 0"] + fail_string = "Fail, Fail to turn off recv print" + self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, check_time=200) is False: + return + + # step 2 create conn_num udp socket + for i in range(1, conn_num+1): + checker_stings = ["R SSC1 A :\+BIND:(\d+),OK" % i, + "R SSC2 A :\+BIND:(\d+),OK" % i] + test_action_string = ["SSC SSC1 soc -B -t UDP -p " % i, + "SSC SSC2 soc -B -t UDP -p " % i] + fail_string = "Fail, Fail to create socket" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + return + + start_time = time.time() + # step 3, do send/recv + while time.time()-start_time < test_time: + + checker_stings = ["P SSC1 NC ERROR NC CLOSE NC ERROR"] + for i in range(1, conn_num+1): + test_action_string = ["SSC SSC2 soc -S -s -l %d -n %d -j %d " + "-i -p " % + (i, send_len, TEST_COUNT_ONE_ROUND, send_delay, i)] + checker_stings.append("P SSC2 RE \"\+SEND:%%%%s,OK\"%%%%() NC ERROR NC CLOSE NC ERROR" % i) + if duplex is True: + test_action_string.append("SSC SSC1 soc -S -s -l %d -n %d -j %d" + " -i -p " % + (i, send_len, TEST_COUNT_ONE_ROUND, send_delay, i)) + checker_stings.append("P SSC1 RE \"\+SEND:%%%%s,OK\"%%%%()" % i) + + fail_string = "Fail, Failed on send command" + if self.load_and_exe_one_step([], test_action_string, fail_string) is False: + break + time.sleep(1) + + fail_string = "Fail, Failed to send/recv data" + if self.load_and_exe_one_step(checker_stings, ["DELAY 0.1"], fail_string, + check_freq=1, check_time=300) is False: + break + pass + + NativeLog.add_prompt_trace("time escape: %s" % (time.time() - start_time)) + if time.time() - start_time >= test_time: + self.result_cntx.set_result("Succeed") + else: + self.result_cntx.set_result("Fail") + + # finally, execute done + + def result_check(self, port_name, data): + TCActionBase.CommonTCActionBase.result_check(self, port_name, data) + self.result_cntx.append_data(port_name, data) + + +def main(): + pass + +if __name__ == '__main__': + main() + + diff --git a/components/idf_test/integration_test/TestCaseScript/UDPStress/UDPThroughput.py b/components/idf_test/integration_test/TestCaseScript/UDPStress/UDPThroughput.py new file mode 100755 index 000000000..861f6010d --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/UDPStress/UDPThroughput.py @@ -0,0 +1,321 @@ +import os +import time +import random +import threading +import socket + +from TCAction import TCActionBase +from NativeLog import NativeLog +from NativeLog import ThroughputResult +from Utility import RSSICalibrator +from Utility import MakeFolder + + +LOG_FOLDER = os.path.join("Performance", "Throughput") + + +AP_PROP_KEY = ("ssid", "password", "apc") + + +class SendThread(threading.Thread): + def __init__(self, sock, send_len, target_addr): + threading.Thread.__init__(self) + self.setDaemon(True) + self.sock = sock + self.send_len = send_len + self.target_addr = target_addr + self.exit_event = threading.Event() + pass + + def exit(self): + self.exit_event.set() + + def run(self): + data = "A" * self.send_len + if self.sock is None: + return + while True: + if self.exit_event.isSet() is True: + break + try: + self.sock.sendto(data, self.target_addr) + except StandardError: + break + pass + + +class RecvThread(threading.Thread): + def __init__(self, sock): + threading.Thread.__init__(self) + self.setDaemon(True) + self.sock = sock + self.exit_event = threading.Event() + self.calc_event = threading.Event() + self.bytes_recv = 0 + + def start_calc(self): + self.calc_event.set() + + def stop_calc(self): + self.calc_event.clear() + self.exit_event.set() + + def run(self): + if self.sock is None: + return + while True: + if self.exit_event.isSet() is True: + break + try: + data, addr = self.sock.recvfrom(65535) + except StandardError: + break + if self.calc_event.isSet() is True: + self.bytes_recv += len(data) + + def get_bytes_recv(self): + return self.bytes_recv + pass + + +class TestCase(TCActionBase.CommonTCActionBase): + + def __init__(self, test_case, test_env, timeout=30, log_path=TCActionBase.LOG_PATH): + TCActionBase.CommonTCActionBase.__init__(self, test_case, test_env, timeout=timeout, log_path=log_path) + self.performance_folder_path = log_path + self.att_test_list = range(60) + # load param from excel + cmd_set = test_case["cmd set"] + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name) + pass + + def execute(self): + TCActionBase.TCActionBase.execute(self) + self.result_cntx.start() + + try: + # configurable params + ap_list = self.get_parameter("shield_box_ap_list") + pc_ip = self.get_parameter("pc_ip") + send_len = self.send_len + att_test_list = self.att_test_list + tx_enable = self.tx_enable + rx_enable = self.rx_enable + measure_period = self.measure_period + # configurable params + except StandardError, e: + NativeLog.add_trace_critical("Error configuration for TCPThroughput script, error is %s" % e) + raise StandardError("Error configuration") + + udp_port = random.randint(40000, 50000) + + # init throughput result data + test_item = "" + if tx_enable is True: + test_item += "Tx" + if rx_enable is True: + test_item += "Rx" + if test_item == "": + raise StandardError("no throughput test item") + + folder_path = os.path.join(self.performance_folder_path, LOG_FOLDER) + file_name = os.path.join(folder_path, + "UDPThroughput_%s_%s" % (test_item, time.strftime("%d%H%M%S", time.localtime()))) + + result = ThroughputResult.ThroughputResult(file_name) + + # restart before executing throughput + checker_stings = ["R SSC1 C !!!ready!!!"] + test_action_string = ["SSC SSC1 reboot"] + fail_string = "Fail, Fail to reboot" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + self.result_cntx.set_result("Fail") + return + + # disable recv print during throughput test + checker_stings = ["R SSC1 C +RECVPRINT"] + test_action_string = ["SSC SSC1 soc -R -o 0"] + fail_string = "Fail, Fail to disable recv print" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + self.result_cntx.set_result("Fail") + return + + ret = True + for ap_prop in ap_list: + ssid = ap_prop[0] + password = ap_prop[1] + apc = ap_prop[2] + if ap_prop[1] == "": + # set a default string for open ap + password = "1" + + # switch off all outlet, switch on AP outlet + outlet_config_dict = dict.fromkeys(range(1, 9), "OFF") + outlet_config_dict[apc] = "ON" + apc_cmd = "APC " + for outlet in outlet_config_dict: + apc_cmd += " %s %s" % (outlet_config_dict[outlet], outlet) + checker_stings = ["P PC_COM L OK"] + fail_string = "Fail, Fail to switch apc" + if self.load_and_exe_one_step(checker_stings, [apc_cmd], fail_string) is False: + ret = False + break + + # wait AP ready + time.sleep(20) + + # create server + udp_sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM) + udp_sock.bind((pc_ip, udp_port)) + udp_sock.settimeout(1) + + if tx_enable is True: + result.add_test_item(ssid + "_tx") + if rx_enable is True: + result.add_test_item(ssid + "_rx") + + # create RSSI Calibrator + calibrator = RSSICalibrator.Calibrator() + + for att_value in att_test_list: + # step 0 set att value + checker_stings = ["R PC_COM L OK"] + test_action_string = ["ATT %s" % att_value] + fail_string = "Fail, Fail to set att value" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + ret = False + break + # continue + # step 1 get AP RSSI + checker_stings = ["R SSC1 A :\+SCAN:%s,[:\d\w]+,\d+,\d+,([-\d]+)\r" % ssid] + test_action_string = ["SSC SSC1 sta -S -s %s" % ssid] + fail_string = "Fail, Fail to scan" + rssi = scan_count = 0 + for i in range(3): + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + continue + rssi += int(self.test_env.get_variable_by_name("rssi")[1]) + scan_count += 1 + + rssi = calibrator.calibrate_rssi(float(rssi)/scan_count if scan_count > 0 else 0, att_value) + # step 2 connect to AP + checker_stings = ["R SSC1 C +JAP:CONNECTED"] + test_action_string = ["SSC SSC1 sta -C -s %s -p %s" % (ssid, password)] + fail_string = "Fail, Fail to JAP" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, + check_freq=1, check_time=30) is False: + if rssi < -89: + continue + else: + ret = False + break + # continue + checker_stings = ["R SSC1 A :STAIP:(\d+\.\d+\.\d+\.\d+)"] + test_action_string = ["SSC SSC1 ip -Q"] + fail_string = "Fail, Fail to get ip" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, + check_freq=1, check_time=30) is False: + if rssi < -89: + continue + else: + ret = False + break + # continue + target_ip = self.get_parameter("target_ip") + + # step 3 close all connections + checker_stings = ["R SSC1 C +CLOSEALL"] + test_action_string = ["SSC SSC1 soc -T"] + fail_string = "Fail, Fail to close socket" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + ret = False + break + # continue + + # step 4 create UDP socket + checker_stings = ["R SSC1 A :\+BIND:(\d+),OK"] + test_action_string = ["SSC SSC1 soc -B -t UDP -i %s -p %s" % (target_ip, udp_port)] + fail_string = "Fail, Fail to bind" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + ret = False + break + # continue + + # step 5 do throughput test + send_thread = SendThread(udp_sock if rx_enable is True else None, + send_len, (target_ip, udp_port)) + send_thread.start() + + recv_thread = RecvThread(udp_sock if tx_enable is True else None) + recv_thread.start() + + if tx_enable is True: + # do send from target + test_action_string = ["SSC SSC1 soc -S -s -l %s -n 10000000 -i %s -p %s" + % (send_len, pc_ip, udp_port)] + fail_string = "Fail, Fail to send" + if self.load_and_exe_one_step([], test_action_string, fail_string) is False: + pass + + # start throughput calculate + recv_thread.start_calc() + + # sleep for measure period + time.sleep(measure_period) + + # stop throughput calculate + recv_thread.stop_calc() + send_thread.exit() + + send_thread.join() + recv_thread.join() + + # output throughput result + # in Mbps + if rx_enable is True: + # get received data len from PC + self.load_and_exe_one_step(["R SSC1 A :RECVLEN:(\d+)"], + ["SSC SSC1 soc -Q -s -o 1"], + "Fail, Fail to get recv data len") + try: + rx_data_len = int(self.get_parameter("recv_len")) + except StandardError: + rx_data_len = 0 + + result.log_throughput(ssid + "_rx", rssi, att_value, + float(rx_data_len * 8) / (measure_period * 1000000)) + + if recv_thread.get_bytes_recv() > 0: + result.log_throughput(ssid + "_tx", rssi, att_value, + float(recv_thread.get_bytes_recv() * 8) / (measure_period * 1000000)) + + result.output_to_file() + pass + + udp_sock.close() + if not ret: + NativeLog.add_trace_critical("Test SUC for %s" % ssid) + elif ret: + NativeLog.add_trace_critical("Test FAIL for %s!!!" % ssid) + + if ret: + self.result_cntx.set_result("Succeed") + else: + self.result_cntx.set_result("Fail") + + # finally, execute done + + def result_check(self, port_name, data): + TCActionBase.CommonTCActionBase.result_check(self, port_name, data) + self.result_cntx.append_data(port_name, data) + + +def main(): + pass + +if __name__ == '__main__': + main() diff --git a/components/idf_test/integration_test/TestCaseScript/UDPStress/__init__.py b/components/idf_test/integration_test/TestCaseScript/UDPStress/__init__.py new file mode 100755 index 000000000..d29ee405a --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/UDPStress/__init__.py @@ -0,0 +1 @@ +__all__ = ["UDPSendRecv", ] diff --git a/components/idf_test/integration_test/TestCaseScript/WiFiStress/SoftAPNSTA.py b/components/idf_test/integration_test/TestCaseScript/WiFiStress/SoftAPNSTA.py new file mode 100755 index 000000000..b8eb75a58 --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/WiFiStress/SoftAPNSTA.py @@ -0,0 +1,178 @@ +import random +import time +import string +import threading + +from TCAction import TCActionBase +from NativeLog import NativeLog +from TCAction import PerformanceTCBase +from Utility import Encoding + + +class STAJAPThread(threading.Thread): + def __init__(self, test_action, port_name, ssid, password, delay1, delay2, change_mac): + threading.Thread.__init__(self) + self.setDaemon(True) + self.test_action = test_action + self.port_name = port_name + self.ssid = ssid + self.password = password + self.delay1 = delay1 + self.delay2 = delay2 + self.change_mac = change_mac + self.exit_flag = threading.Event() + pass + + def exit(self): + self.exit_flag.set() + pass + + def run(self): + total_test_count = 0 + fail_count = 0 + while self.exit_flag.isSet() is False: + # change mac + if self.change_mac is True: + mac = Encoding.generate_random_mac() + self.test_action.serial_write_line(self.port_name, "mac -S -o 1 -m %s" % mac) + self.test_action.check_response(self.port_name, "+MAC:STA,OK") + + time.sleep(1) + + # JAP + total_test_count += 1 + # flush current port data + self.test_action.flush_data(self.port_name) + self.test_action.serial_write_line(self.port_name, "sta -C -s %s -p %s" % (self.ssid, self.password)) + if self.test_action.check_response(self.port_name, "+JAP:CONNECTED", 45) is False: + fail_count += 1 + NativeLog.add_trace_critical("[%s] Failed to JAP, Failed/Total : %d/%d" + % (self.port_name, fail_count, total_test_count)) + continue + time.sleep(random.randint(self.delay1[0], self.delay1[1])) + + # QAP + self.test_action.serial_write_line(self.port_name, "sta -D") + if self.test_action.check_response(self.port_name, "+QAP:OK", 5) is False: + NativeLog.add_trace_critical("[%s] Failed to QAP" % self.port_name) + time.sleep(random.randint(self.delay2[0], self.delay2[1])) + + # make sure quit AP + self.test_action.serial_write_line(self.port_name, "sta -D") + pass + pass + + +class TestCase(PerformanceTCBase.PerformanceTCBase): + + def __init__(self, test_case, test_env, timeout=30, log_path=TCActionBase.LOG_PATH): + PerformanceTCBase.PerformanceTCBase.__init__(self, test_case, test_env, timeout=timeout, log_path=log_path) + self.sta_num = 0 + self.max_sta = 4 + self.test_time = 60 + self.delay1 = [5, 30] + self.delay2 = [5, 10] + self.change_mac = True + self.channel = 11 + # load param from excel + cmd_set = test_case["cmd set"] + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy" and cmd_set[i][0] != "": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + pass + + def process(self): + # configurable parameters + try: + sta_num = self.sta_num + max_sta = self.max_sta + test_time = self.test_time + # delay between JAP succeed and QAP + delay1 = self.delay1 + # delay between QAP and JAP + delay2 = self.delay2 + # if change mac each time before JAP + change_mac = self.change_mac + # channel + channel = self.channel + except StandardError, e: + raise StandardError("miss mandatory parameters") + + # step 0, set op mode and enable dhcp + self.serial_write_line("SSC1", "op -S -o 2") + if self.check_response("SSC1", "+MODE:OK", 2) is False: + NativeLog.add_trace_critical("Failed to set ap mode") + return + self.serial_write_line("SSC1", "dhcp -E -o 2") + if self.check_response("SSC1", "+DHCP:AP,OK", 2) is False: + NativeLog.add_trace_critical("Failed to enable ap dhcp") + return + self.serial_write_line("SSC1", "dhcp -L -s 192.168.4.2 -e 192.168.4.100 -t 1") + if self.check_response("SSC1", "+DHCP:LEASE,OK", 2) is False: + NativeLog.add_trace_critical("Failed to enable ap dhcp") + return + self.serial_write_line("SSC1", "dhcp -S -o 2") + if self.check_response("SSC1", "+DHCP:AP,OK", 2) is False: + NativeLog.add_trace_critical("Failed to enable ap dhcp") + return + + for i in range(sta_num): + self.serial_write_line("SSC%d" % (i+2), "op -S -o 1") + if self.check_response("SSC%d" % (i+2), "+MODE:OK", 2) is False: + NativeLog.add_trace_critical("Failed to set sta mode") + return + self.serial_write_line("SSC%d" % (i+2), "dhcp -S -o 1") + if self.check_response("SSC%d" % (i+2), "+DHCP:STA,OK", 2) is False: + NativeLog.add_trace_critical("Failed to enable sta dhcp") + + # step 1, set ap config and load + ap_ssid = "".join([random.choice(string.uppercase) for m in range(15)]) + ap_password = "".join([random.choice(string.lowercase) for m in range(15)]) + + self.serial_write_line("SSC1", "ap -S -s %s -p %s -t 3 -m %s -n %s" + % (ap_ssid, ap_password, max_sta, channel)) + if self.check_response("SSC1", "+SAP:OK", 2) is False: + NativeLog.add_trace_critical("Failed to set AP") + return + + # step 2, start thread to let STA JAP + sta_thread_list = [] + for i in range(sta_num): + sta_thread_list.append(STAJAPThread(self, "SSC%d" % (i+2), + ap_ssid, ap_password, delay1, delay2, change_mac)) + for sta_thread in sta_thread_list: + sta_thread.start() + + # step 3, sleep for test time + for i in range(test_time): + self.flush_data("SSC1") + time.sleep(60) + + # step 4, close all thread, will disconnect when exit thread + for sta_thread in sta_thread_list: + sta_thread.exit() + for sta_thread in sta_thread_list: + sta_thread.join() + # wait and make sure disconnect done + time.sleep(1) + + # step 5, join AP and check + sta_num_temp = max_sta if sta_num > max_sta else sta_num + + for i in range(sta_num_temp): + self.serial_write_line("SSC%d" % (i+2), "sta -C -s %s -p %s" % (ap_ssid, ap_password)) + if self.check_response("SSC%d" % (i+2), "+JAP:CONNECTED", 45) is False: + self.set_result("Fail") + break + pass + else: + self.set_result("Succeed") + + +def main(): + pass + +if __name__ == '__main__': + main() + diff --git a/components/idf_test/integration_test/TestCaseScript/WiFiStress/WifiConnUtility.py b/components/idf_test/integration_test/TestCaseScript/WiFiStress/WifiConnUtility.py new file mode 100755 index 000000000..24702bfc8 --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/WiFiStress/WifiConnUtility.py @@ -0,0 +1,240 @@ +from NativeLog import NativeLog +import time +import random + + +ERROR_AP_PROP = {"ssid": "123456789012345678901234567890", + "ssid_len": 30, + "pwd": "12345678901234567890", + "pwd_len": 20, + "channel": 10, + "enc": 3, + "apc": 9, # invalid apc count + } + + +class WifiConnUtilError(StandardError): + pass + + +class WifiConnUtility(object): + + def __init__(self, tc_action): + self.tc_action = tc_action + self.target_type = tc_action.target_type + pass + + def set_mode(self, mode): + ret = True + fail_string = "set mode fail" + cmd = [] + checker_stings = [] + for i in range(2): + if self.target_type[0] == "SSC": + cmd.append("SSCC SSC%d op -S -o %d" % (i+1, mode[i])) + checker_stings.append("SSCP SSC%d C +MODE:OK" % (i+1)) + pass + else: + cmd.append("ATC AT%d CWMODE %d" % (i+1, mode[i])) + checker_stings.append("ATP AT%d L OK" % (i+1)) + pass + if self.tc_action.load_and_exe_one_step(checker_stings, cmd, + fail_string, check_time=50) is False: + NativeLog.add_trace_critical("Failed to set mode") + ret = False + return ret + pass + + def _apc_switch(self, outlet_list, action_list): + checker_stings = ["R PC_COM C OK"] + switch_cmd = "APC " + fail_string = "Error when switching APC" + ret = True + + for [_outlet, _action] in zip(action_list, outlet_list): + switch_cmd += " %s %d" % (_action, _outlet) + + if self.tc_action.load_and_exe_one_step(checker_stings, [switch_cmd], + fail_string, check_time=50) is False: + NativeLog.add_trace_critical("Error when switching APC") + ret = False + return ret + pass + + def _set_target_ap(self, ap_prop): + ret = True + fail_string = "set target ap fail, %s, %s" % (ap_prop["ssid"], ap_prop["pwd"]) + if self.target_type[1] == "SSC": + if ap_prop["pwd"] == "": + cmd = ["SSCC SSC2 ap -S -s %s -t %d" % (ap_prop["ssid"], + ap_prop["enc"]) + ] + else: + cmd = ["SSCC SSC2 ap -S -s %s -p %s -t %d" % (ap_prop["ssid"], + ap_prop["pwd"], + ap_prop["enc"]) + ] + checker_stings = ["SSCP SSC2 C +SAP:OK"] + pass + else: + cmd = ["ATC AT2 CWSAP \"%s\" \"%s\" %d %d" % (ap_prop["ssid"], + ap_prop["pwd"], + ap_prop["channel"], + ap_prop["enc"]) + ] + checker_stings = ["ATR AT2 L OK"] + pass + if self.tc_action.load_and_exe_one_step(checker_stings, cmd, + fail_string, check_time=50) is False: + NativeLog.add_trace_critical("set target ap fail") + ret = False + return ret + pass + + def setup_ap(self, ap_type, ap_prop): + if ap_type == "target": + ret = self._set_target_ap(ap_prop) + pass + else: + ret = self._apc_switch(["ON"], [ap_prop["apc"]]) + # delay for 5 seconds, wait AP ready + time.sleep(5) + pass + return ret + + def do_scan(self, ap_prop): + fail_string = "Scan fail" + ret = True + # do not check if the set AP can be scanned + if self.target_type[1] == "SSC": + cmd = ["SSCC SSC1 sta -S"] + checker_stings = ["SSCR SSC1 C +SCANDONE"] + pass + else: + cmd = ["ATS AT1 AT+CWLAP"] + checker_stings = ["ATR AT1 L OK"] + pass + if self.tc_action.load_and_exe_one_step(checker_stings, cmd, + fail_string, check_time=100) is False: + NativeLog.add_trace_critical("Scan fail") + ret = False + return ret + pass + + def _switch_off_target_ap(self, delay): + time.sleep(delay) + self._set_target_ap(ERROR_AP_PROP) + pass + + def _switch_on_target_ap(self, ap_prop, delay): + time.sleep(delay) + self._set_target_ap(ap_prop) + pass + + def _switch_off_ap(self, ap_type, ap_prop, delay_range): + delay = random.randint(delay_range[0]*10, delay_range[1]*10)/10 + if ap_type == "target": + self._switch_off_target_ap(delay) + else: + delay -= 1.5 + time.sleep(delay if delay > 0 else 0) + self._apc_switch(["OFF"], [ap_prop["apc"]]) + pass + + def _switch_on_ap(self, ap_type, ap_prop, delay_range): + delay = random.randint(delay_range[0]*10, delay_range[1]*10)/10 + if ap_type == "target": + self._switch_on_target_ap(ap_prop, delay) + else: + delay -= 1.5 + time.sleep(delay if delay > 0 else 0) + self._apc_switch(["ON"], [ap_prop["apc"]]) + pass + + def _join_ap(self, ap_prop, test_method): + fail_string = "join target ap fail, %s, %s" % (ap_prop["ssid"], ap_prop["pwd"]) + if self.target_type[1] == "SSC": + cmd = ["SSCC SSC1 ap -C -s %s -p %s" % (ap_prop["ssid"], + ap_prop["pwd"],) + ] + checker_stings = ["SSCR SSC1 C +JAP:CONNECTED"] + pass + else: + cmd = ["ATC AT1 CWJAP \"%s\" \"%s\"" % (ap_prop["ssid"], + ap_prop["pwd"]) + ] + checker_stings = ["ATR AT1 NC ERROR NC FAIL L OK"] + pass + if test_method == "Normal": + ret = self.tc_action.load_and_exe_one_step(checker_stings, cmd, + fail_string, check_freq=0.1, check_time=350) + if ret is not False: + ret *= 0.1 + else: + ret = self.tc_action.load_and_exe_one_step([], cmd, fail_string) + return ret + pass + + def _check_join_ap_result(self, ap_prop): + ret = False + fail_string = "join ap fail, %s, %s" % (ap_prop["ssid"], ap_prop["pwd"]) + + if self.target_type[1] == "SSC": + checker_stings = ["SSCR SSC1 C +JAP:CONNECTED"] + ret = self.tc_action.load_and_exe_one_step(checker_stings, ["DELAY 0"], + fail_string, check_freq=1, check_time=120) + pass + else: + cmd = ["ATS AT1 AT+CWJAP?"] + checker_stings = ["ATR AT1 NC busy NC No%20AP C +CWJAP"] + for i in range(3): + ret = self.tc_action.load_and_exe_one_step(checker_stings, cmd, + fail_string, check_freq=1, check_time=2) + if ret is not False: + break + time.sleep(15) + + return ret + pass + + def join_ap(self, join_test_method, ap_type, ap_prop, delay): + + if join_test_method == "WRONG_PROP": + _prop = ERROR_AP_PROP + else: + _prop = ap_prop + + ret = self._join_ap(_prop, join_test_method) + + if join_test_method == "OFF_ON": + self._switch_off_ap(ap_type, ap_prop, delay[0]) + self._switch_on_ap(ap_type, ap_prop, delay[1]) + ret = self._check_join_ap_result(_prop) + pass + elif join_test_method == "OFF": + self._switch_off_ap(ap_type, ap_prop, delay[0]) + time.sleep(25) + pass + + return ret + pass + + def do_reconnect(self, reconnect_test_method, ap_type, ap_prop, delay): + ret = True + if reconnect_test_method == "OFF_ON": + self._switch_off_ap(ap_type, ap_prop, delay[0]) + self._switch_on_ap(ap_type, ap_prop, delay[1]) + ret = self._check_join_ap_result(ap_prop) + pass + elif reconnect_test_method == "OFF": + self._switch_off_ap(ap_type, ap_prop, delay[0]) + pass + return ret + pass + + +def main(): + pass + +if __name__ == '__main__': + main() diff --git a/components/idf_test/integration_test/TestCaseScript/WiFiStress/WifiJAP.py b/components/idf_test/integration_test/TestCaseScript/WiFiStress/WifiJAP.py new file mode 100755 index 000000000..64346be17 --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/WiFiStress/WifiJAP.py @@ -0,0 +1,219 @@ +import os +import random +import time + +import WifiConnUtility +from NativeLog import NativeLog +from TCAction import TCActionBase +from Utility import Encoding +from Utility import MakeFolder + +STEPS = {"SCAN1": 0x01, "JAP": 0x02, "SCAN2": 0x04, "RECONNECT": 0x08} + +AP_PROP = ("ssid", "ssid_len", "pwd", + "pwd_len", "channel", "enc", "apc") + +JAP_TEST_METHOD = ("Normal", "OFF_ON", "OFF", "WRONG_PROP") + +RECONNECT_TEST_METHOD = ("OFF_ON", "OFF") + +LOG_FOLDER = os.path.join("Performance", "JAP") + + +SSID_LEN_RANGE = (1, 32) # in bytes +ENC_TYPE = (0, 2, 3, 4) # do not support WEP for 8266 soft AP +PWD_RANGE = {0: [0, 0], + 1: [5, 5], + 2: [8, 63], + 3: [8, 63], + 4: [8, 63], + } + + +class TestCase(TCActionBase.CommonTCActionBase): + + def __init__(self, test_case, test_env, timeout=30, log_path=TCActionBase.LOG_PATH): + TCActionBase.CommonTCActionBase.__init__(self, test_case, test_env, timeout=timeout, log_path=log_path) + # default value for optional configurable params + self.performance_folder_path = log_path + self.pwd_len = [8, 64] + self.step_config = [0x03, 0x01, 0x02, 0x0B, 0x0F] + self.join_test_method = ["Normal"] + self.join_delay = [[1.5, 5], [1.5, 5]] + self.reconnect_test_method = ["OFF_ON"] + self.reconnect_delay = [[1.5, 5], [1.5, 6]] + # load param from excel + cmd_set = test_case["cmd set"] + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy" and cmd_set[i][0] != "": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + # read AP list + self.ap_list = [] + for i in range(1, len(cmd_set)): + for j in range(len(cmd_set[i][1])): + if cmd_set[i][1][j] != "": + cmd_string = "self.ap_list.append(dict(zip(AP_PROP, " + cmd_set[i][1][j] + ")))" + exec cmd_string + + folder_path = MakeFolder.make_folder(self.performance_folder_path + "\\" + LOG_FOLDER) + file_name = "JAP_log_%s.log" % (time.strftime("%m%d%H%M%S", time.localtime())) + self._performance_log_file = os.path.join(folder_path, file_name) + + # test statistics + self._succeed_count = self._fail_count = self._time_cost_count = 0 + self._total_time = self._longest_time = 0 + + self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name) + # get target type "SSC" or "AT" + self.target_type = ["SSC" if test_env.get_port_by_name("AT1") is None else "AT"] + self.target_type.append("SSC" if test_env.get_port_by_name("AT2") is None else "AT") + self._utility = WifiConnUtility.WifiConnUtility(self) + pass + + def _generate_random_ap_prop(self): + ap_prop = dict.fromkeys(AP_PROP) + # generate target ap_value + ap_prop["ssid_len"] = random.randint(SSID_LEN_RANGE[0], SSID_LEN_RANGE[1]) + ap_prop["channel"] = random.choice(range(1, 14)) + ap_prop["enc"] = random.choice(ENC_TYPE) + ap_prop["pwd_len"] = random.randint(PWD_RANGE[ap_prop["enc"]][0], PWD_RANGE[ap_prop["enc"]][1]) + # generate string + if self.target_type[0] == self.target_type[1] == "AT": + ap_prop["ssid"] = Encoding.generate_random_utf8_str(ap_prop["ssid_len"]) + ap_prop["pwd"] = Encoding.generate_random_utf8_str(ap_prop["pwd_len"]) + # NativeLog.add_trace_info("ssid hex is : %x" % ap_prop["ssid"]) + # NativeLog.add_trace_info("pwd hex is : %x" % ap_prop["pwd"]) + else: + ap_prop["ssid"] = Encoding.generate_random_printable_str(ap_prop["ssid_len"]) + ap_prop["pwd"] = Encoding.generate_random_printable_str(ap_prop["pwd_len"]) + + return ap_prop + + def _logging_performance(self, ssid, join_method="Normal", time_cost=0): + # log performance to performance log file + with open(self._performance_log_file, "ab+") as f: + # log time and ssid + f.write("\r\n[%s]:\r\n[AP name] %s\r\n" % + (time.strftime("%m-%d %H:%M:%S", time.localtime()), ssid)) + if join_method == "Normal" or join_method == "OFF_ON": + if time_cost is not False: + self._succeed_count += 1 + if join_method == "Normal": + f.write("[Succeed][%f]\r\n" % time_cost) + self._longest_time = (time_cost > self._longest_time and + [time_cost] or [self._longest_time])[0] + self._time_cost_count += 1 + self._total_time += time_cost + else: + f.write("[Succeed][%s]\r\n" % join_method) + else: + self._fail_count += 1 + f.write("[Fail][%s]\r\n" % join_method) + pass + + def _logging_fail_step(self, ssid, step): + with open(self._performance_log_file, "ab+") as f: + f.write("\r\n[%s]:\r\n[AP name] %s\r\n" % + (time.strftime("%m-%d %H:%M:%S", time.localtime()), ssid)) + f.write("[Fail][%s]\r\n" % step) + pass + + def _generate_performance_report(self): + with open(self._performance_log_file, "ab+") as f: + f.write("[Test report] Succeed: %d\r\n" % self._succeed_count) + f.write("[Test report] Failed: %d\r\n" % self._fail_count) + if self._succeed_count > 0 or self._fail_count > 0: + f.write("[Test report] Pass Rate: %f\r\n" % + (self._succeed_count/(self._fail_count+self._succeed_count))) + if self._time_cost_count > 0: + f.write("[Test report] Average time: %f\r\n" % (self._total_time/self._time_cost_count)) + f.write("[Test report] Longest time: %f\r\n" % self._longest_time) + + def execute(self): + TCActionBase.TCActionBase.execute(self) + self.result_cntx.start() + + # mandatory configurable params + try: + target_ap_num = self.target_ap_num + test_count = self.test_count + except StandardError, e: + NativeLog.add_trace_critical("Error configuration for WifiJAP script, error is %s" % e) + raise StandardError("Error configuration") + + # prepare ap list + _ap_list = [["target", None]] * target_ap_num + for _ap_prop in self.ap_list: + _ap_list.append(["AP", _ap_prop]) + + # set to correct mode first + self._utility.set_mode([1, 2]) + + for i in xrange(test_count): + _ap = random.choice(_ap_list) + # arrange ap + _ap_type = _ap[0] + _ap_prop = _ap[1] + if _ap_type == "target": + _ap_prop = self._generate_random_ap_prop() + pass + + # step 1 : mandatory step, set up AP + if self._utility.setup_ap(_ap_type, _ap_prop) is False: + self._logging_fail_step(_ap_prop["ssid"], "Set AP") + NativeLog.add_prompt_trace("[Step1] setup AP Fail") + continue + step_config = random.choice(self.step_config) + NativeLog.add_prompt_trace("[Step1] setup AP succeed") + + # step 2 : optional step, do scan before connect + if step_config & STEPS["SCAN1"] != 0: # check option + if self._utility.do_scan(_ap_prop) is False: + self._logging_fail_step(_ap_prop["ssid"], "Scan before JAP") + NativeLog.add_prompt_trace("[Step2] Scan Done") + + # step 3 : mandatory step, join AP + if step_config & STEPS["JAP"] != 0: # check option + _join_test_method = random.choice(self.join_test_method) + time_cost = self._utility.join_ap(_join_test_method, _ap_type, _ap_prop, self.join_delay) + # log performance to performance log file + self._logging_performance(_ap_prop["ssid"], _join_test_method, time_cost) + if time_cost is False: + # do scan once to check if AP exist + self._utility.do_scan(_ap_prop) + continue + NativeLog.add_prompt_trace("[Step3] Join AP done") + + # step 4 : optional step, scan after join AP + if step_config & STEPS["SCAN2"] != 0: # check option + if self._utility.do_scan(_ap_prop) is False: + self._logging_fail_step(_ap_prop["ssid"], "Scan after JAP") + NativeLog.add_prompt_trace("[Step4] Scan done") + + # step 5 : optional step, reconnect test + if step_config & STEPS["RECONNECT"] != 0: # check option + _reconnect_test_method = random.choice(self.reconnect_test_method) + if self._utility.do_reconnect(_reconnect_test_method, + _ap_type, _ap_prop, self.reconnect_delay) is False: + self._logging_fail_step(_ap_prop["ssid"], "Reconnect") + + NativeLog.add_prompt_trace("[Step5] Reconnect done") + # continue to next loop + NativeLog.add_prompt_trace("[WifiJAP] Test count %d done" % i) + + # generate report and cleanup + self._generate_performance_report() + + self.result_cntx.set_result("Succeed") + + def result_check(self, port_name, data): + TCActionBase.CommonTCActionBase.result_check(self, port_name, data) + self.result_cntx.append_data(port_name, data) + + +def main(): + pass + +if __name__ == '__main__': + main() diff --git a/components/idf_test/integration_test/TestCaseScript/WiFiStress/WifiJAPAtt.py b/components/idf_test/integration_test/TestCaseScript/WiFiStress/WifiJAPAtt.py new file mode 100755 index 000000000..23eeba3f0 --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/WiFiStress/WifiJAPAtt.py @@ -0,0 +1,193 @@ +import os +import time +from TCAction import TCActionBase +from NativeLog import NativeLog +from Utility import RSSICalibrator +from Utility import MakeFolder + +MAX_RSSI = 0 +MIN_RSSI = -110 +MAX_ATT = 60 +LOG_FOLDER = os.path.join("Performance", "JAP") +AP_PROP_KEY = ("ssid", "password", "apc") + + +class Performance(object): + RSSI_THRESHOLD = -90 + + def __init__(self): + self.succeed_rssi = dict.fromkeys(range(MIN_RSSI, MAX_RSSI), 0) + self.failed_rssi = dict.fromkeys(range(MIN_RSSI, MAX_RSSI), 0) + self.failed_att = dict.fromkeys(range(MAX_ATT), 0) + self.result = True + pass + + def log_performance(self, result, att, rssi): + if result == "Succeed": + self.succeed_rssi[rssi] += 1 + else: + if rssi == 0: + self.failed_att[att] += 1 + else: + self.failed_rssi[rssi] += 1 + if rssi > self.RSSI_THRESHOLD: + self.result = False + pass + + def get_result(self): + return self.result + + def __str__(self): + data = "Succeed:\r\n" + for rssi in self.succeed_rssi: + if self.succeed_rssi[rssi] > 0: + data += "\tRSSI%4d: %2d times\r\n" % (rssi, self.succeed_rssi[rssi]) + + data += "Failed during scan:\r\n" + for att in self.failed_att: + if self.failed_att[att] > 0: + data += "\tATT%3d: %2d times\r\n" % (att, self.failed_att[att]) + + data += "Failed during JAP:\r\n" + for rssi in self.failed_rssi: + if self.failed_rssi[rssi] > 0: + data += "\tRSSI%4d: %2d times\r\n" % (rssi, self.failed_rssi[rssi]) + + return data + + pass + + +class TestCase(TCActionBase.CommonTCActionBase): + def __init__(self, test_case, test_env, timeout=30, log_path=TCActionBase.LOG_PATH): + TCActionBase.CommonTCActionBase.__init__(self, test_case, test_env, timeout=timeout, log_path=log_path) + self.att_test_list = range(60) + self.performance_folder_path = log_path + # load param from excel + cmd_set = test_case["cmd set"] + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + + self.ap_list = self.get_parameter("shield_box_ap_list") + + self.performance = dict([(ap_prop["ssid"], Performance()) for ap_prop in self.ap_list]) + # create log file + folder_path = MakeFolder.make_folder(self.performance_folder_path + "\\" + LOG_FOLDER) + self.performance_log = os.path.join(folder_path, + "JAP_Att_%s.log" % time.strftime("%d%H%M%S", time.localtime())) + + self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name) + pass + + def log_performance(self, att, rssi, ssid, result): + NativeLog.add_prompt_trace("[%s][ssid %s] [att %s] [rssi %s]" % (result, ssid, att, rssi)) + data = "" + self.performance[ssid].log_performance(result, att, rssi) + for _ssid in self.performance: + data += "[ssid] %s\r\n%s\r\n" % (_ssid, self.performance[_ssid]) + with open(self.performance_log, "wb+") as f: + f.write(data) + pass + + def execute(self): + TCActionBase.TCActionBase.execute(self) + self.result_cntx.start() + + try: + # configurable params + ap_list = self.ap_list + att_test_list = self.att_test_list + test_count = self.test_count + # configurable params + except StandardError, e: + NativeLog.add_trace_critical("Error configuration for JAPAtt script, error is %s" % e) + raise StandardError("Error configuration") + + for x in xrange(test_count): + for ap_prop in ap_list: + ssid = ap_prop[0] + password = ap_prop[1] + apc = ap_prop[2] + if ap_prop[1] == "": + # set a default string for open ap + password = "1" + + # switch off all outlet, switch on AP outlet + outlet_config_dict = dict.fromkeys(range(1, 9), "OFF") + outlet_config_dict[apc] = "ON" + apc_cmd = "APC " + for outlet in outlet_config_dict: + apc_cmd += " %s %s" % (outlet_config_dict[outlet], outlet) + checker_stings = ["P PC_COM L OK"] + fail_string = "Fail, Fail to switch apc" + if self.load_and_exe_one_step(checker_stings, [apc_cmd], fail_string) is False: + return + + # wait AP ready + time.sleep(20) + + # create RSSI Calibrator + calibrator = RSSICalibrator.Calibrator() + + ret = True + for att_value in att_test_list: + # step 0 set att value + checker_stings = ["R PC_COM L OK"] + test_action_string = ["ATT %s" % att_value] + fail_string = "Fail, Fail to set att value" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False: + continue + + # step 1 get AP RSSI + checker_stings = ["R SSC1 A :\+SCAN:%s,[:\d\w]+,\d+,\d+,([-\d]+)" % ssid] + test_action_string = ["SSC SSC1 sta -S -s %s" % ssid] + fail_string = "Fail, Fail to scan" + rssi = scan_count = 0 + for i in range(3): + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, + check_freq=1, check_time=5) is False: + self.log_performance(att_value, 0, ssid, "Failed to measure RSSI") + continue + rssi += int(self.test_env.get_variable_by_name("rssi")[1]) + scan_count += 1 + + rssi = calibrator.calibrate_rssi(float(rssi) / scan_count if scan_count > 0 else 0, att_value) + + # step 2 connect to AP + checker_stings = ["R SSC1 C +JAP:CONNECTED"] + test_action_string = ["SSC SSC1 sta -C -s %s -p %s" % (ssid, password)] + fail_string = "Fail, Fail to JAP" + if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, + check_freq=1, check_time=45) is False: + self.log_performance(att_value, rssi, ssid, "Failed to JAP") + if rssi < -90: + continue + else: + ret = False + break + if ret: + self.log_performance(att_value, rssi, ssid, "Succeed") + else: + self.log_performance(att_value, rssi, ssid, "Failed") + + # finally, execute done + for ssid in self.performance: + if self.performance[ssid].get_result() is False: + self.result_cntx.set_result("Failed") + break + else: + self.result_cntx.set_result("Succeed") + + def result_check(self, port_name, data): + TCActionBase.CommonTCActionBase.result_check(self, port_name, data) + self.result_cntx.append_data(port_name, data) + + +def main(): + pass + + +if __name__ == '__main__': + main() diff --git a/components/idf_test/integration_test/TestCaseScript/WiFiStress/WifiSmartConfig.py b/components/idf_test/integration_test/TestCaseScript/WiFiStress/WifiSmartConfig.py new file mode 100755 index 000000000..830de766c --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/WiFiStress/WifiSmartConfig.py @@ -0,0 +1,274 @@ +import random +import os +import time +import copy + +from TCAction import TCActionBase +from NativeLog import NativeLog +from Utility import Encoding +from Utility import MakeFolder + +AP_PROP = ("ssid", "ssid_len", "pwd", + "pwd_len", "channel", "enc", "apc") + +SMART_TYPE = ("esp-touch", "airkiss") + +TEST_METHOD = ("ssid_broadcast", "ssid_hidden") + +HT = ("ht20", "ht40") + +TEST_STAT = ("total count", "fail count", "total time", "longest time") + +_TEST_STAT_INIT_DICT = {"total count": 0, + "fail count": 0, + "total time": 0, + "longest time": 0, + } + +LOG_FOLDER = os.path.join("Performance", "SmartConfig") + + +SSID_LEN_RANGE = (1, 32) # in bytes +ENC_TYPE = (0, 2, 3, 4) # do not support WEP for 8266 soft AP +PWD_RANGE = {0: [0, 0], + 1: [5, 5], + 2: [8, 32], + 3: [8, 32], + 4: [8, 32], + } + + +class TestCase(TCActionBase.CommonTCActionBase): + + def __init__(self, test_case, test_env, timeout=30, log_path=TCActionBase.LOG_PATH): + TCActionBase.CommonTCActionBase.__init__(self, test_case, test_env, timeout=timeout, log_path=log_path) + self.performance_folder_path = log_path + # default value for optional configurable params + self.test_method = ["ssid_hidden", "ssid_broadcast"] + self.bssid = "ff:ff:ff:ff:ff:ff" + self.ht_ap = dict(zip(HT, [("", ""), + ("", "")])) + self.ap_channel = {"ht20": 1, "ht40": 1} + self.delay_time = 3 # default 3s, wait for scan done + # load param from excel + cmd_set = test_case["cmd set"] + for i in range(1, len(cmd_set)): + if cmd_set[i][0] != "dummy" and cmd_set[i][0] != "": + cmd_string = "self." + cmd_set[i][0] + exec cmd_string + + folder_path = MakeFolder.make_folder(self.performance_folder_path + "\\" + LOG_FOLDER) + file_name = "SmartConfig_log_%s.log" % (time.strftime("%m%d%H%M%S", time.localtime())) + self._performance_log_file = os.path.join(folder_path, file_name) + + # type + self.target_type = ["SSC" if test_env.get_port_by_name("AT1") is None else "AT"] + self.target_type.append("SSC" if test_env.get_port_by_name("AT2") is None else "AT") + + # test statistics + # better ways to create? + _test_stat = dict.fromkeys(TEST_STAT, 0) + _test_method = dict.fromkeys(TEST_METHOD) + _test_ht = dict.fromkeys(HT) + self.test_stat = dict.fromkeys(SMART_TYPE) + for i in SMART_TYPE: + self.test_stat[i] = copy.deepcopy(_test_ht) + for j in HT: + self.test_stat[i][j] = copy.deepcopy(_test_method) + for k in TEST_METHOD: + self.test_stat[i][j][k] = copy.deepcopy(_test_stat) + + self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name) + pass + + def _generate_random_ap_prop(self, ht_type): + ap_prop = dict.fromkeys(AP_PROP) + # generate target ap_value + ap_prop["ssid_len"] = random.randint(SSID_LEN_RANGE[0], SSID_LEN_RANGE[1]) + ap_prop["channel"] = self.ap_channel[ht_type] + ap_prop["enc"] = random.choice(ENC_TYPE) + ap_prop["pwd_len"] = random.randint(PWD_RANGE[ap_prop["enc"]][0], PWD_RANGE[ap_prop["enc"]][1]) + ap_prop["ssid"] = Encoding.generate_random_printable_str(ap_prop["ssid_len"]) + ap_prop["pwd"] = Encoding.generate_random_printable_str(ap_prop["pwd_len"]) + + return ap_prop + + def _logging_performance(self, time_cost, ssid, password, smart_type, test_method, ht_type): + # update test statistics + stat = self.test_stat[smart_type][ht_type][test_method] + stat["total count"] += 1 + # log performance to performance log file + with open(self._performance_log_file, "ab+") as f: + # log time and ssid + if time_cost is not False: + time_tmp = float(time_cost)/10 + f.write("\r\n[%s]:\r\n[Succeed] [%.2f]\r\n" % + (time.strftime("%m-%d %H:%M:%S", time.localtime()), time_tmp)) + stat["total time"] += time_tmp + stat["longest time"] = time_tmp if time_tmp > stat["longest time"] else stat["longest time"] + else: + f.write("\r\n[%s]:\r\n[Fail]\r\n" % + time.strftime("%m-%d %H:%M:%S", time.localtime())) + stat["fail count"] += 1 + + f.write("[%s] [%s] [%s]\r\n" % + (smart_type, test_method, ht_type)) + f.write("[ssid] %s \r\n[password] %s\r\n" % + (ssid, password)) + pass + + def _generate_performance_report(self): + with open(self._performance_log_file, "ab+") as f: + for i in SMART_TYPE: + for j in HT: + for k in TEST_METHOD: + stat = self.test_stat[i][j][k] + f.write("\r\n[Test report] [%s] [%s] [%s]\r\n" % (i, j, k)) + if stat["total count"] > 0: + f.write("[Total]: %d\r\n" % stat["total count"]) + f.write("[Failed]: %d\r\n" % stat["fail count"]) + f.write("[Fail ratio]: %.2f%%\r\n" % + (float(stat["fail count"])/stat["total count"] * 100)) + f.write("[Longest time cost]: %.2f\r\n" % stat["longest time"]) + if (stat["total count"] - stat["fail count"]) > 0: + f.write("[Average time cost]: %.2f\r\n" % + (stat["total time"]/(stat["total count"]-stat["fail count"]))) + + @staticmethod + def cmd_exception_catcher(e): + raise e + pass + + def execute(self): + TCActionBase.TCActionBase.execute(self) + self.result_cntx.start() + + # mandatory configurable params + try: + test_count = self.test_count + delay_time = self.delay_time + except StandardError, e: + NativeLog.add_trace_critical("Error configuration for WifiJAP script, error is %s" % e) + raise StandardError("Error configuration") + + # step 0 : set AT1 mode + fail_string = "Fail to restore init condition" + if self.target_type[0] == "AT": + cmd = ["ATS AT1 AT+CWMODE=1"] + checker_stings = ["R AT1 L OK"] + else: + cmd = ["SSC SSC1 op -S -o 1"] + checker_stings = ["R SSC1 C +MODE:OK"] + if self.target_type[1] == "AT": + cmd.append("ATS AT2 AT+CWMODE=2") + checker_stings.append("R AT2 L OK") + else: + cmd.append("SSC SSC2 op -S -o 2") + checker_stings.append("R SSC2 C +MODE:OK") + + if self.load_and_exe_one_step(checker_stings, cmd, + fail_string, check_time=150) is False: + NativeLog.add_trace_critical(fail_string) + return + + for i in xrange(test_count): + _method = random.choice(self.test_method) + _ht = random.choice(self.ht) + _ap_prop = self._generate_random_ap_prop(_ht) + _smart_type = random.choice(self.smart_type) + _ht_ap = self.ht_ap[_ht] + is_hidden = 0 if _method == "ssid_broadcast" else 1 + # get ip and + + # step 1 : restore init condition + fail_string = "Fail to restore init condition" + if self.target_type[0] == "AT": + cmd = ["ATS AT1 AT+CWSTOPSMART", "WIFI CONN %s %s " % (_ht_ap[0], _ht_ap[1])] + checker_stings = ["P AT1 L OK", "P PC_COM L OK"] + else: + cmd = ["SSC SSC1 smart -E", "WIFI CONN %s %s " % (_ht_ap[0], _ht_ap[1])] + checker_stings = ["P SSC1 C +SC:OK", "P PC_COM L OK"] + + if self.load_and_exe_one_step(checker_stings, cmd, + fail_string, check_time=200) is False: + NativeLog.add_trace_critical(fail_string) + continue + NativeLog.add_prompt_trace("Step1 Done") + + # step 2 : test method is ssid_broadcast, then set AP on target 2 + if _method == "ssid_broadcast": + fail_string = "Fail to set AP" + if self.target_type[1] == "AT": + cmd = ["ATS AT2 AT+CWSAP=\"%s\",\"%s\",%d,%d" % (_ap_prop["ssid"], _ap_prop["pwd"], + _ap_prop["channel"], _ap_prop["enc"])] + checker_stings = ["R AT2 L OK"] + else: + cmd = ["SSC SSC2 ap -S -s %s -p %s -n %d -t %d" % (_ap_prop["ssid"], _ap_prop["pwd"], + _ap_prop["channel"], _ap_prop["enc"])] + checker_stings = ["R SSC2 C +SAP:OK"] + + if self.load_and_exe_one_step(checker_stings, cmd, + fail_string, check_time=50) is False: + NativeLog.add_trace_critical(fail_string) + continue + NativeLog.add_prompt_trace("Step2 Done") + + # step 3 : start SMART + fail_string = "Fail to start smart config" + if self.target_type[0] == "AT": + cmd = ["ATS AT1 AT+CWSTARTSMART"] + checker_stings = ["R AT1 L OK"] + else: + cmd = ["SSC SSC1 smart -S -a 0"] + checker_stings = ["R SSC1 C +SC:OK"] + + if self.load_and_exe_one_step(checker_stings, cmd, + fail_string, check_time=50) is False: + NativeLog.add_trace_critical(fail_string) + continue + # sleep for delay_time seconds to wait scan done or simulate delay config situation + time.sleep(delay_time) + NativeLog.add_prompt_trace("Step3 Done") + + # step 4 : do smart config + fail_string = "Fail in smart config" + cmd = ["SMART %s %s %s %s %d" + % (_smart_type, _ap_prop["ssid"], _ap_prop["pwd"], self.bssid, is_hidden)] + if self.target_type[0] == "AT": + checker_stings = ["P AT1 C Smart%20get%20wifi%20info", + "P LOG1 C %s C %s" % (_ap_prop["ssid"], _ap_prop["pwd"])] + else: + checker_stings = ["P SSC1 C %s C %s" % (_ap_prop["ssid"], _ap_prop["pwd"])] + + try: + time_cost = self.load_and_exe_one_step(checker_stings, cmd, + fail_string, check_time=400, + cmd_exception_catcher=self.cmd_exception_catcher) + except StandardError: + NativeLog.add_prompt_trace("Exception occurred during executing cmd") + continue + pass + self._logging_performance(time_cost, _ap_prop["ssid"], _ap_prop["pwd"], + _smart_type, _method, _ht) + if time_cost is False: + NativeLog.add_prompt_trace(fail_string) + continue + + # continue to next loop + NativeLog.add_prompt_trace("[WifiSmartConfig] Test count %d done" % i) + + # generate report and cleanup + self._generate_performance_report() + + self.result_cntx.set_result("Succeed") + + def result_check(self, port_name, data): + TCActionBase.CommonTCActionBase.result_check(self, port_name, data) + self.result_cntx.append_data(port_name, data) + + +def main(): + pass + +if __name__ == '__main__': + main() diff --git a/components/idf_test/integration_test/TestCaseScript/WiFiStress/__init__.py b/components/idf_test/integration_test/TestCaseScript/WiFiStress/__init__.py new file mode 100755 index 000000000..7960a3ce8 --- /dev/null +++ b/components/idf_test/integration_test/TestCaseScript/WiFiStress/__init__.py @@ -0,0 +1 @@ +__all__ = ["WifiJAP", ] \ No newline at end of file