mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
rename components/test to idf_test:
1. test will be categorized by test level 2. add test level as attribute to test cases 3. will select TestCaseScript by the test cases added to CI (currently no test case uses test case script) 4. adding test level to test jobs 5. update .gitlab-ci.yml, each job need to set its test case file path 6. update .gitlab-ci.yml, test case path for test report is changed to idf_test
This commit is contained in:
parent
685c1084ba
commit
b72d22041c
141
.gitlab-ci.yml
141
.gitlab-ci.yml
@ -115,7 +115,7 @@ test_report:
|
||||
allow_failure: true
|
||||
variables:
|
||||
LOG_PATH: "$CI_PROJECT_DIR/$CI_BUILD_REF"
|
||||
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/test"
|
||||
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test"
|
||||
REPORT_PATH: "$CI_PROJECT_DIR/CI_Test_Report"
|
||||
artifacts:
|
||||
when: always
|
||||
@ -170,8 +170,8 @@ push_master_to_github:
|
||||
BIN_PATH: "$CI_PROJECT_DIR/SSC/build/"
|
||||
APP_NAME: "ssc"
|
||||
LOG_PATH: "$CI_PROJECT_DIR/$CI_BUILD_REF"
|
||||
# assume tests are put in "components/test"
|
||||
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/test"
|
||||
# append test level folder to TEST_CASE_FILE_PATH in before_script of test job
|
||||
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test"
|
||||
# jobs MUST set CONFIG_FILE in before_script, and overwrite the variables above if necessary
|
||||
|
||||
artifacts:
|
||||
@ -217,144 +217,131 @@ push_master_to_github:
|
||||
# run test
|
||||
- python CIRunner.py -l $LOG_PATH -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH bin_path $APP_NAME $BIN_PATH
|
||||
|
||||
Function_SYS_01:
|
||||
IT_Function_SYS_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_SYS_01.yml
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_SYS_01.yml
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
||||
Function_WIFI_01:
|
||||
IT_Function_WIFI_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- SSC_T2_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_WIFI_01.yml
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_WIFI_01.yml
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
||||
Function_WIFI_02:
|
||||
IT_Function_WIFI_02:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- SSC_T2_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_WIFI_02.yml
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_WIFI_02.yml
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
||||
Function_TCPIP_01:
|
||||
IT_Function_TCPIP_01:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- SSC_T2_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_TCPIP_01.yml
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_01.yml
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
||||
Function_TCPIP_02:
|
||||
IT_Function_TCPIP_02:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- SSC_T2_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_TCPIP_02.yml
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_02.yml
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
||||
Function_TCPIP_03:
|
||||
IT_Function_TCPIP_03:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- SSC_T2_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_TCPIP_03.yml
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_03.yml
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
||||
Function_TCPIP_04:
|
||||
IT_Function_TCPIP_04:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- SSC_T2_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_TCPIP_04.yml
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_04.yml
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
||||
Function_TCPIP_05:
|
||||
IT_Function_TCPIP_05:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- SSC_T2_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_TCPIP_05.yml
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_05.yml
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
||||
Function_TCPIP_06:
|
||||
IT_Function_TCPIP_06:
|
||||
<<: *test_template_night
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_TCPIP_06.yml
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_06.yml
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
||||
Function_WIFI_03:
|
||||
IT_Function_WIFI_03:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T3_PhyMode
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_WIFI_03.yml
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_WIFI_03.yml
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
||||
Function_WIFI_04:
|
||||
IT_Function_WIFI_04:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_APC
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_WIFI_04.yml
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_WIFI_04.yml
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
||||
Function_WIFI_05:
|
||||
IT_Function_WIFI_05:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_WEP
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_WIFI_05.yml
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_WIFI_05.yml
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
||||
Function_WIFI_06:
|
||||
IT_Function_WIFI_06:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_PhyMode
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_WIFI_06.yml
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_WIFI_06.yml
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
||||
Function_TCPIP_07:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- SSC_T1_2
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_TCPIP_07.yml
|
||||
|
||||
Function_TCPIP_08:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- SSC_T2_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_TCPIP_08.yml
|
||||
|
||||
Function_TCPIP_09:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_TCPIP_09.yml
|
||||
|
||||
Function_TCPIP_10:
|
||||
IT_Function_TCPIP_07:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
@ -362,21 +349,53 @@ Function_TCPIP_10:
|
||||
- SSC_T1_2
|
||||
- SSC_T2_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_TCPIP_10.yml
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_07.yml
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
||||
Function_TCPIP_11:
|
||||
IT_Function_TCPIP_08:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_TCPIP_11.yml
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_08.yml
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
||||
Function_TCPIP_12:
|
||||
IT_Function_TCPIP_09:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_09.yml
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
||||
IT_Function_TCPIP_10:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- 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
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
||||
IT_Function_TCPIP_11:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_11.yml
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
||||
IT_Function_TCPIP_12:
|
||||
<<: *test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_1
|
||||
- SSC_T1_2
|
||||
before_script:
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/Function_TCPIP_12.yml
|
||||
- CONFIG_FILE=$TEST_CASE_FILE_PATH/CIConfigs/IT_Function_TCPIP_12.yml
|
||||
- TEST_CASE_FILE_PATH=$TEST_CASE_FILE_PATH/integration_test
|
||||
|
61
components/idf_test/README.md
Normal file
61
components/idf_test/README.md
Normal file
@ -0,0 +1,61 @@
|
||||
|
||||
# Note: The test cases in this folder are for Espressif internal use.
|
||||
|
||||
# Goto internal project wiki Testing page for detail about this folder.
|
||||
|
||||
## File Structure
|
||||
|
||||
```
|
||||
test --- CIConfigs --- sanity_test1.yml (Runner config files)
|
||||
| |-- stress_test1.yml
|
||||
|-- TestCaseAll.yml (TestCaseFiles)
|
||||
|-- TestEnvAll.yml (TestCaseFiles)
|
||||
|-- InitialConditionAll.yml (TestCaseFiles)
|
||||
|-- TestCaseScript --- ... (Test case scripts)
|
||||
```
|
||||
|
||||
1. CIConfigs folder
|
||||
* config for CI config files are put in this folder
|
||||
* CI config files configs the cases and some other options for the CI job with same name
|
||||
1. Test case files
|
||||
* TestCaseAll.yml (test cases)
|
||||
* InitialConditionAll.yml (initial conditions)
|
||||
* TestEnvAll.yml (test environments)
|
||||
* [how to modify test cases](https://gitlab.espressif.cn:6688/yinling/auto_test_script/blob/master/public/Design/TestCaseFiles.DesignNote.md)
|
||||
1. Test case scripts
|
||||
* some cases are implemented by specified script. those scripts are put in this folder.
|
||||
|
||||
|
||||
## Modify test cases
|
||||
|
||||
1. check if the "SDK" of the test case only contain the current SDK
|
||||
* if Yes, then just modify the test case behavior
|
||||
* if No:
|
||||
1. then remove current SDK name from "SDK" of the test case
|
||||
2. Add a new test case, and set "SDK" only support current SDK name
|
||||
2. use [auto_test_script](https://gitlab.espressif.cn:6688/yinling/auto_test_script) to load the modified case and verify the modification
|
||||
3. create a merge request and assign to HYL (or add comment @yinling for merging test).
|
||||
After review it will be merged to SDK and will be The cases will be synced to database in auto_test_script.
|
||||
|
||||
|
||||
## Run test case locally
|
||||
|
||||
1. clone auto_test_script (ssh://git@gitlab.espressif.cn:27227/yinling/auto_test_script.git) from gitlab
|
||||
2. create test environment:
|
||||
1. search test case (search test case ID in components/test/TestCaseAll.yml, get the "test environment" value
|
||||
2. goto [test environment list](https://gitlab.espressif.cn:6688/yinling/auto_test_script/blob/master/public/Documents/TestEnvList.md), find the link and goto the environment detail page
|
||||
3. create test environment according to figure and description
|
||||
4. [config test environment](https://gitlab.espressif.cn:6688/yinling/auto_test_script/blob/master/public/Design/TestEnvConfig.DesignNote.md). All parameters in table "Parameters require config before use" MUST be configured.
|
||||
3. run test cases with [CIRunner.py](https://gitlab.espressif.cn:6688/yinling/auto_test_script/blob/master/public/Design/RunnerConfigs.DesignNote.md)
|
||||
|
||||
|
||||
|
||||
## exclude known issues for CI
|
||||
the test cases listed in file "KnownIssues" will be excluded by CI when calculating results
|
||||
|
||||
Editing KnownIssues file is very simple, one single line for the ID for each case.
|
||||
```
|
||||
TCPIP_TCP_0101
|
||||
TCPIP_TCP_0201
|
||||
...
|
||||
```
|
@ -0,0 +1,10 @@
|
||||
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_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, TCPIP_IGMP_0202]
|
@ -0,0 +1,10 @@
|
||||
Config: {execute count: 1, execute order: in order}
|
||||
DUT: [SSC2, SSC1]
|
||||
Filter:
|
||||
- Add:
|
||||
ID: [TCPIP_IGMP_0203, ^TCPIP_TCP_0403, ^TCPIP_TCP_0408, TCPIP_UDP_0201, TCPIP_UDP_0202,
|
||||
^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_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_0101,
|
||||
TCPIP_DHCP_0103, TCPIP_DHCP_0102, TCPIP_DHCP_0206, TCPIP_DHCP_0207, ^TCPIP_IP_0102]
|
@ -0,0 +1,10 @@
|
||||
Config: {execute count: 1, execute order: in order}
|
||||
DUT: [SSC2, SSC1]
|
||||
Filter:
|
||||
- Add:
|
||||
ID: [^TCPIP_UDP_0105, ^TCPIP_UDP_0107, ^TCPIP_UDP_0106, ^TCPIP_UDP_0101, TCPIP_TCP_0203,
|
||||
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_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, ^TCPIP_TCP_0113]
|
@ -0,0 +1,10 @@
|
||||
Config: {execute count: 1, execute order: in order}
|
||||
DUT: [SSC2, SSC1]
|
||||
Filter:
|
||||
- Add:
|
||||
ID: [^TCPIP_TCP_0110, ^TCPIP_TCP_0111, 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_DHCP_0102, ^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]
|
@ -0,0 +1,8 @@
|
||||
Config: {execute count: 1, execute order: in order}
|
||||
DUT: [SSC2, 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]
|
@ -2,9 +2,9 @@ Config: {execute count: 1, execute order: in order}
|
||||
DUT: [SSC2, SSC1]
|
||||
Filter:
|
||||
- Add:
|
||||
ID: [^TCPIP_UDP_0110, ^TCPIP_UDP_0110, ^TCPIP_UDP_0110, ^TCPIP_UDP_0110, ^TCPIP_UDP_0110,
|
||||
ID: [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,
|
||||
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_0104, TCPIP_UDP_0104, TCPIP_UDP_0104, TCPIP_UDP_0104, TCPIP_UDP_0104]
|
@ -2,9 +2,9 @@ Config: {execute count: 1, execute order: in order}
|
||||
DUT: [SSC1]
|
||||
Filter:
|
||||
- Add:
|
||||
ID: [^TCPIP_UDP_0307, ^TCPIP_UDP_0307, ^TCPIP_UDP_0307, ^TCPIP_UDP_0307, ^TCPIP_UDP_0307,
|
||||
ID: [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,
|
||||
^TCPIP_UDP_0304, ^TCPIP_UDP_0304, ^TCPIP_UDP_0304, ^TCPIP_UDP_0304, ^TCPIP_UDP_0304,
|
||||
^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_0304, ^TCPIP_UDP_0304, ^TCPIP_UDP_0304, ^TCPIP_UDP_0304, ^TCPIP_UDP_0304]
|
@ -0,0 +1,10 @@
|
||||
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_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]
|
@ -2,9 +2,9 @@ Config: {execute count: 1, execute order: in order}
|
||||
DUT: [SSC2, SSC1]
|
||||
Filter:
|
||||
- Add:
|
||||
ID: [^TCPIP_UDP_0102, ^TCPIP_UDP_0102, ^TCPIP_UDP_0102, ^TCPIP_UDP_0102, ^TCPIP_UDP_0102,
|
||||
TCPIP_UDP_0111, TCPIP_UDP_0111, TCPIP_UDP_0111, TCPIP_UDP_0111, TCPIP_UDP_0111,
|
||||
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_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]
|
@ -2,9 +2,9 @@ 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_0305, TCPIP_UDP_0305, TCPIP_UDP_0305, TCPIP_UDP_0305, TCPIP_UDP_0305,
|
||||
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_UDP_0302, TCPIP_UDP_0302, TCPIP_UDP_0302, TCPIP_UDP_0302, TCPIP_UDP_0302,
|
||||
TCPIP_UDP_0303, TCPIP_UDP_0303, TCPIP_UDP_0303, TCPIP_UDP_0303, TCPIP_UDP_0303]
|
@ -0,0 +1,6 @@
|
||||
Config: {execute count: 1, execute order: in order}
|
||||
DUT: [SSC1]
|
||||
Filter:
|
||||
- Add:
|
||||
ID: [TCPIP_DNS_0103, TCPIP_DNS_0103, TCPIP_DNS_0103, TCPIP_DNS_0103, TCPIP_DNS_0103,
|
||||
^TCPIP_UDP_0110, ^TCPIP_UDP_0110, ^TCPIP_UDP_0110, ^TCPIP_UDP_0110, ^TCPIP_UDP_0110]
|
@ -0,0 +1,10 @@
|
||||
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_SCAN_0105, WIFI_CONN_0401,
|
||||
WIFI_ADDR_0101, WIFI_ADDR_0102, WIFI_CONN_0301, ^WIFI_CONN_0801, ^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, WIFI_CONN_0601, ^WIFI_CONN_0201]
|
@ -0,0 +1,7 @@
|
||||
Config: {execute count: 1, execute order: in order}
|
||||
DUT: [SSC2, SSC1]
|
||||
Filter:
|
||||
- Add:
|
||||
ID: [^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]
|
@ -0,0 +1,7 @@
|
||||
Config: {execute count: 1, execute order: in order}
|
||||
DUT: [SSC2, SSC1]
|
||||
Filter:
|
||||
- Add:
|
||||
ID: [WIFI_SCAN_0301, WIFI_SCAN_0303, WIFI_SCAN_0304, WIFI_SCAN_0302, 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]
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,82 +1,18 @@
|
||||
test environment:
|
||||
- {PC OS: '', Special: N, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T2_SmartConfig,
|
||||
test environment detail: '2 SSC target connect with PC by UART.
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
One HT20 AP and One HT40 AP are placed near target.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 2.0, script path: EnvBase.py, tag: AT_T2_SmartConfig,
|
||||
test environment detail: '2 AT target connect with PC by UART (AT and LOG port).
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
One HT20 AP and One HT40 AP are placed near target.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_IOT1,
|
||||
test environment detail: 'PC has 1 WiFi NIC.
|
||||
|
||||
1 SSC target connect with PC by UART.
|
||||
|
||||
AP todo IOT test are placed near SSC1.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, UART ports: 'SSC1
|
||||
|
||||
SSC2', additional param list: '', basic param list: '', script path: EnvBase.py,
|
||||
tag: SSC_T2_GPIO3, test environment detail: '[TBD] 2个ESP_8266通过UART连到PC, ESP_8266之间需要测试的Target_GPIO相连',
|
||||
test script: EnvBase}
|
||||
- {PC OS: linux, Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: WebServer_T1_1,
|
||||
test environment detail: 'Web Server target connect with PC by UART.
|
||||
|
||||
PC has 1 wired NIC connected to switch.
|
||||
|
||||
APC, AP also connect with swtich.
|
||||
|
||||
All devices connected with switch use same IP subnet.
|
||||
|
||||
APC control AP power supply.', test script: EnvBase}
|
||||
- {PC OS: linux, Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: WebServer_T1_2,
|
||||
test environment detail: 'Web Server target connect with PC by UART.
|
||||
|
||||
4 PC with WiFi NIC placed near WebServer1.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, UART ports: 'SSC1
|
||||
|
||||
SSC2', additional param list: '', basic param list: '', script path: EnvBase.py,
|
||||
tag: SSC_T2_GPIO1, test environment detail: '[TBD] 2个ESP_8266通过UART连到PC, ESP_8266的
|
||||
GPIO_6相连', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_Enterprise,
|
||||
test environment detail: "AP use WPA2-Etherprise is placed near SSC1. \n1 SSC target\
|
||||
\ connect with PC by UART.", test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, UART ports: 'SSC1
|
||||
|
||||
SSC2', additional param list: '', basic param list: '', script path: EnvBase.py,
|
||||
tag: SSC_T2_GPIO2, test environment detail: '[TBD] 1. 2个ESP_8266通过UART连到PC, ESP_8266的
|
||||
GPIO_15通过面包板相连
|
||||
|
||||
2. 可借助面包板, 将GPIO_15, 以及中断函数被打开的8266板的GPIO_2 相连', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_HighSpeedUART,
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_1,
|
||||
test environment detail: 'PC has 2 wired NIC connected to AP.
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
1 AT target connect with PC by high speed UART (AT and LOG port).', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T2_ShieldBox,
|
||||
test environment detail: '2 SSC target connect with PC by UART.
|
||||
|
||||
Put them to Shield box.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_3,
|
||||
test environment detail: 'Able to access WAN after connect to AP.
|
||||
|
||||
1 AT target connect with PC by UART (AT and LOG port).', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_2,
|
||||
test environment detail: 'PC has 1 WiFi NIC.
|
||||
|
||||
1 AT target connect with PC by UART (AT and LOG port).', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, UART ports: 'SSC1
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_3,
|
||||
test environment detail: 'Able to access WAN after connect to AP.
|
||||
|
||||
SSC2', additional param list: '', basic param list: '', script path: EnvBase.py,
|
||||
tag: UART_T1_2, test environment detail: '[TBD] ESP_8266通过UART_0通过USB, UART_1 TXD
|
||||
通过 TTLcable 连到PC', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, UART ports: SSC_1, additional param list: '',
|
||||
basic param list: '', script path: EnvBase.py, tag: UART_T1_1, test environment detail: '[TBD]
|
||||
将ESP_8266通过UART连到PC', test script: EnvBase}
|
||||
1 AT target connect with PC by UART (AT and LOG port).', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_ADC,
|
||||
test environment detail: 'PC has 1 wired NIC connected to AP.
|
||||
|
||||
@ -85,10 +21,88 @@ test environment:
|
||||
Multimeter connect to input, able to measure input voltage.
|
||||
|
||||
1 AT target connect with PC by UART (AT and LOG port).', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_WEP,
|
||||
test environment detail: '1 SSC target connect with PC by UART.
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_APC1,
|
||||
test environment detail: "PC has 1 wired NIC connected to AP.\nPC has 1 wired NIC\
|
||||
\ connected to APC (static IP within the same subnet with APC). \nAPC control\
|
||||
\ AP power supply. \nPC has 1 WiFi NIC. \n1 AT target connect with PC by UART\
|
||||
\ (AT and LOG port).", test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_APC2,
|
||||
test environment detail: "Able to access WAN after connect to AP.\nPC has 1 wired\
|
||||
\ NIC connected to APC (static IP within the same subnet with APC). \nAPC control\
|
||||
\ AP power supply.\nPC has 1 WiFi NIC.\n1 AT target connect with PC by UART (AT\
|
||||
\ and LOG port).", test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_HighSpeedUART,
|
||||
test environment detail: 'PC has 2 wired NIC connected to AP.
|
||||
|
||||
One WEP share key AP placed near SSC1.', test script: EnvBase}
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
1 AT target connect with PC by high speed UART (AT and LOG port).', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_SmartConfigIOT,
|
||||
test environment detail: '1 AT target connect with PC by UART (AT and LOG port).
|
||||
|
||||
PC has 1 wired NIC connect to Common AP.
|
||||
|
||||
Several AP are placed near AT target.
|
||||
|
||||
Several smart phone installed test APK are placed near AT target.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 2.0, script path: EnvBase.py, tag: AT_T2_1,
|
||||
test environment detail: 'PC has 1 wired NIC connected to AP.
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
2 AT target connect with PC by UART (AT and LOG port).', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: AT_T2_JAP,
|
||||
test environment detail: "Several AP are placed near AT target.\nPC has 1 wired\
|
||||
\ NIC connected to APC (static IP within the same subnet with APC).\nAPC control\
|
||||
\ power supply for all APs. \n2 AT target connect with PC by UART (AT and LOG\
|
||||
\ port).", test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: AT_T2_Sleep,
|
||||
test environment detail: 'AP support DTIM placed with AT target.
|
||||
|
||||
2 AT target connect with PC by UART (AT and LOG port).
|
||||
|
||||
Multimeter connect with PC via GPIB.
|
||||
|
||||
Series multimeter between GND and VCC of AT1.
|
||||
|
||||
AT1''s light sleep wakeup pin and wakeup indication connect with AT2''s GPIO.',
|
||||
test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 2.0, script path: EnvBase.py, tag: AT_T2_SmartConfig,
|
||||
test environment detail: '2 AT target connect with PC by UART (AT and LOG port).
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
One HT20 AP and One HT40 AP are placed near target.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, UART ports: 'SSC1
|
||||
|
||||
SSC2', additional param list: '', basic param list: '', script path: EnvBase.py,
|
||||
tag: IR_T2_1, test environment detail: '[TBD] 本测试为非自动测试, 红外能够做到数据收发吻合即可通过', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: NVS_T1_1,
|
||||
test environment detail: '1 NVS target connect with PC by UART.
|
||||
|
||||
1 SSC target connect with PC by UART.
|
||||
|
||||
SSC2 GPIO connect to NVS1 power control pin.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, UART ports: SSC_1, additional param list: '',
|
||||
basic param list: '', script path: EnvBase.py, tag: PWM_T1_1, test environment detail: "[TBD]\
|
||||
\ 1. PWM OS SDK 以及 Non-OS SDK的测试建议分开进行, 放在不同的文件夹, 防止文件命名混淆\n2. 分析CSV文件的Python脚本只能分析单个channel\
|
||||
\ \n3. 如果Init脚本打印\"Network Error\" 检查TCP Server是不是正常发送data", test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_1,
|
||||
test environment detail: 'PC has 2 wired NIC connected to AP.
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
1 SSC target connect with PC by UART.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_2,
|
||||
test environment detail: 'Able to access WAN after connect to AP.
|
||||
|
||||
1 SSC target connect with PC by UART.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_8089,
|
||||
test environment detail: 'PC has 1 wired NIC connected to AP.
|
||||
|
||||
1 8089 tablet able to run iperf test placed near SSC1.
|
||||
|
||||
1 SSC target connect with PC by UART.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_ADC,
|
||||
test environment detail: 'PC has 1 wired NIC connected to AP.
|
||||
|
||||
@ -102,12 +116,15 @@ test environment:
|
||||
\ connected to APC (static IP within the same subnet with APC). \nAPC control\
|
||||
\ AP power supply. \nPC has 1 WiFi NIC. \n1 SSC target connect with PC by UART.",
|
||||
test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_8089,
|
||||
test environment detail: 'PC has 1 wired NIC connected to AP.
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_Enterprise,
|
||||
test environment detail: "AP use WPA2-Etherprise is placed near SSC1. \n1 SSC target\
|
||||
\ connect with PC by UART.", test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_IOT1,
|
||||
test environment detail: 'PC has 1 WiFi NIC.
|
||||
|
||||
1 8089 tablet able to run iperf test placed near SSC1.
|
||||
1 SSC target connect with PC by UART.
|
||||
|
||||
1 SSC target connect with PC by UART.', test script: EnvBase}
|
||||
AP todo IOT test are placed near SSC1.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T1_InitData,
|
||||
test environment detail: '2 SSC target connect with PC by UART.
|
||||
|
||||
@ -116,30 +133,6 @@ test environment:
|
||||
SSC2 use normal 26M crystal oscillator.
|
||||
|
||||
SSC2 GPIO connect to SSC1 power control pin.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, UART ports: SSC_1, additional param list: '',
|
||||
basic param list: '', script path: EnvBase.py, tag: SSC_T1_Timer, test environment detail: '[TBD]
|
||||
通过串口工具调节Timer, 将GPIO_13端口连接到逻辑分析仪', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 3.0, script path: EnvBase.py, tag: SSC_T3_PhyMode,
|
||||
test environment detail: '3 SSC target connect with PC by UART.
|
||||
|
||||
PC has one WiFi NIC support capture wlan packet using libpcap.
|
||||
|
||||
Set 4 AP with (HT20, channel1), (HT20, channel2), (HT40, channel1), (HT40, channel2).
|
||||
|
||||
Put 4 APs near SSC targets.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: AT_T2_JAP,
|
||||
test environment detail: "Several AP are placed near AT target.\nPC has 1 wired\
|
||||
\ NIC connected to APC (static IP within the same subnet with APC).\nAPC control\
|
||||
\ power supply for all APs. \n2 AT target connect with PC by UART (AT and LOG\
|
||||
\ port).", test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T2_PhyMode,
|
||||
test environment detail: '2 SSC target connect with PC by UART.
|
||||
|
||||
PC has one WiFi NIC support capture wlan packet using libpcap.
|
||||
|
||||
Set 4 AP with phy mode 11b, 11g, 11n HT20, 11n HT40.
|
||||
|
||||
Put 4 APs near SSC targets.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_ShieldBox,
|
||||
test environment detail: 'refer to figure.
|
||||
|
||||
@ -148,12 +141,100 @@ test environment:
|
||||
PC wired NIC should set static IP address within the same subnet with AP.
|
||||
|
||||
Must use onboard wired NIC.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_TempBox,
|
||||
test environment detail: '1 SSC target connect with PC by UART.
|
||||
|
||||
Put SSC target to temperature box.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, UART ports: SSC_1, additional param list: '',
|
||||
basic param list: '', script path: EnvBase.py, tag: SSC_T1_Timer, test environment detail: '[TBD]
|
||||
通过串口工具调节Timer, 将GPIO_13端口连接到逻辑分析仪', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_VDD33,
|
||||
test environment detail: '1 SSC target connect with PC by UART.
|
||||
|
||||
Multimeter connect to VDD33, able to measure voltage.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_WEP,
|
||||
test environment detail: '1 SSC target connect with PC by UART.
|
||||
|
||||
One WEP share key AP placed near SSC1.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T2_1,
|
||||
test environment detail: 'PC has 1 wired NIC connected to AP.
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
2 SSC target connect with PC by UART.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, UART ports: 'SSC1
|
||||
|
||||
SSC2', additional param list: '', basic param list: '', script path: EnvBase.py,
|
||||
tag: SSC_T2_GPIO1, test environment detail: '[TBD] 2个ESP_8266通过UART连到PC, ESP_8266的
|
||||
GPIO_6相连', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, UART ports: 'SSC1
|
||||
|
||||
SSC2', additional param list: '', basic param list: '', script path: EnvBase.py,
|
||||
tag: SSC_T2_GPIO2, test environment detail: '[TBD] 1. 2个ESP_8266通过UART连到PC, ESP_8266的
|
||||
GPIO_15通过面包板相连
|
||||
|
||||
2. 可借助面包板, 将GPIO_15, 以及中断函数被打开的8266板的GPIO_2 相连', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, UART ports: 'SSC1
|
||||
|
||||
SSC2', additional param list: '', basic param list: '', script path: EnvBase.py,
|
||||
tag: SSC_T2_GPIO3, test environment detail: '[TBD] 2个ESP_8266通过UART连到PC, ESP_8266之间需要测试的Target_GPIO相连',
|
||||
test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T2_PhyMode,
|
||||
test environment detail: '2 SSC target connect with PC by UART.
|
||||
|
||||
PC has one WiFi NIC support capture wlan packet using libpcap.
|
||||
|
||||
Set 4 AP with phy mode 11b, 11g, 11n HT20, 11n HT40.
|
||||
|
||||
Put 4 APs near SSC targets.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T2_ShieldBox,
|
||||
test environment detail: '2 SSC target connect with PC by UART.
|
||||
|
||||
Put them to Shield box.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T2_Sleep1,
|
||||
test environment detail: 'AP support DTIM placed with AT target.
|
||||
|
||||
2 SSC target connect with PC by UART.
|
||||
|
||||
Multimeter connect with PC via GPIB.
|
||||
|
||||
Series multimeter between GND and VCC of SSC1.
|
||||
|
||||
SSC1''s light sleep wakeup pin and wakeup indication connect with AT2''s GPIO.
|
||||
|
||||
SSC1''s XPD connect with RSTB.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T2_Sleep2,
|
||||
test environment detail: 'AP support DTIM placed with AT target.
|
||||
|
||||
2 SSC target connect with PC by UART.
|
||||
|
||||
Multimeter connect with PC via GPIB.
|
||||
|
||||
Series multimeter between GND and VCC of SSC1.
|
||||
|
||||
SSC1''s RSTB pin connect with AT2''s GPIO.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T2_SmartConfig,
|
||||
test environment detail: '2 SSC target connect with PC by UART.
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
One HT20 AP and One HT40 AP are placed near target.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 3.0, script path: EnvBase.py, tag: SSC_T3_PhyMode,
|
||||
test environment detail: '3 SSC target connect with PC by UART.
|
||||
|
||||
PC has one WiFi NIC support capture wlan packet using libpcap.
|
||||
|
||||
Set 4 AP with (HT20, channel1), (HT20, channel2), (HT40, channel1), (HT40, channel2).
|
||||
|
||||
Put 4 APs near SSC targets.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 5.0, script path: EnvBase.py, tag: SSC_T5_1,
|
||||
test environment detail: 5 SSC target connect with PC by UART., test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T6_1,
|
||||
test environment detail: 'PC has 1 wired NIC connected to AP.
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
6 SSC target connect with PC by UART.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: TempSensor_T1_1,
|
||||
test environment detail: 'Tempeture sensor target connect with PC by UART.
|
||||
|
||||
@ -170,106 +251,25 @@ test environment:
|
||||
All devices connected with switch use the same IP subnet.
|
||||
|
||||
APC control AP power supply.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_SmartConfigIOT,
|
||||
test environment detail: '1 AT target connect with PC by UART (AT and LOG port).
|
||||
|
||||
PC has 1 wired NIC connect to Common AP.
|
||||
|
||||
Several AP are placed near AT target.
|
||||
|
||||
Several smart phone installed test APK are placed near AT target.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: AT_T2_Sleep,
|
||||
test environment detail: 'AP support DTIM placed with AT target.
|
||||
|
||||
2 AT target connect with PC by UART (AT and LOG port).
|
||||
|
||||
Multimeter connect with PC via GPIB.
|
||||
|
||||
Series multimeter between GND and VCC of AT1.
|
||||
|
||||
AT1''s light sleep wakeup pin and wakeup indication connect with AT2''s GPIO.',
|
||||
test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 5.0, script path: EnvBase.py, tag: SSC_T5_1,
|
||||
test environment detail: 5 SSC target connect with PC by UART., test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_TempBox,
|
||||
test environment detail: '1 SSC target connect with PC by UART.
|
||||
|
||||
Put SSC target to temperature box.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_1,
|
||||
test environment detail: 'PC has 2 wired NIC connected to AP.
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
1 AT target connect with PC by UART (AT and LOG port).', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T6_1,
|
||||
test environment detail: 'PC has 1 wired NIC connected to AP.
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
6 SSC target connect with PC by UART.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, UART ports: SSC_1, additional param list: '',
|
||||
basic param list: '', script path: EnvBase.py, tag: UART_T1_1, test environment detail: '[TBD]
|
||||
将ESP_8266通过UART连到PC', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, UART ports: 'SSC1
|
||||
|
||||
SSC2', additional param list: '', basic param list: '', script path: EnvBase.py,
|
||||
tag: IR_T2_1, test environment detail: '[TBD] 本测试为非自动测试, 红外能够做到数据收发吻合即可通过', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_VDD33,
|
||||
test environment detail: '1 SSC target connect with PC by UART.
|
||||
tag: UART_T1_2, test environment detail: '[TBD] ESP_8266通过UART_0通过USB, UART_1 TXD
|
||||
通过 TTLcable 连到PC', test script: EnvBase}
|
||||
- {PC OS: linux, Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: WebServer_T1_1,
|
||||
test environment detail: 'Web Server target connect with PC by UART.
|
||||
|
||||
Multimeter connect to VDD33, able to measure voltage.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, UART ports: SSC_1, additional param list: '',
|
||||
basic param list: '', script path: EnvBase.py, tag: PWM_T1_1, test environment detail: "[TBD]\
|
||||
\ 1. PWM OS SDK 以及 Non-OS SDK的测试建议分开进行, 放在不同的文件夹, 防止文件命名混淆\n2. 分析CSV文件的Python脚本只能分析单个channel\
|
||||
\ \n3. 如果Init脚本打印\"Network Error\" 检查TCP Server是不是正常发送data", test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: NVS_T1_1,
|
||||
test environment detail: '1 NVS target connect with PC by UART.
|
||||
PC has 1 wired NIC connected to switch.
|
||||
|
||||
1 SSC target connect with PC by UART.
|
||||
APC, AP also connect with swtich.
|
||||
|
||||
SSC2 GPIO connect to NVS1 power control pin.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T2_Sleep2,
|
||||
test environment detail: 'AP support DTIM placed with AT target.
|
||||
All devices connected with switch use same IP subnet.
|
||||
|
||||
2 SSC target connect with PC by UART.
|
||||
APC control AP power supply.', test script: EnvBase}
|
||||
- {PC OS: linux, Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: WebServer_T1_2,
|
||||
test environment detail: 'Web Server target connect with PC by UART.
|
||||
|
||||
Multimeter connect with PC via GPIB.
|
||||
|
||||
Series multimeter between GND and VCC of SSC1.
|
||||
|
||||
SSC1''s RSTB pin connect with AT2''s GPIO.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T2_Sleep1,
|
||||
test environment detail: 'AP support DTIM placed with AT target.
|
||||
|
||||
2 SSC target connect with PC by UART.
|
||||
|
||||
Multimeter connect with PC via GPIB.
|
||||
|
||||
Series multimeter between GND and VCC of SSC1.
|
||||
|
||||
SSC1''s light sleep wakeup pin and wakeup indication connect with AT2''s GPIO.
|
||||
|
||||
SSC1''s XPD connect with RSTB.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 2.0, script path: EnvBase.py, tag: AT_T2_1,
|
||||
test environment detail: 'PC has 1 wired NIC connected to AP.
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
2 AT target connect with PC by UART (AT and LOG port).', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_1,
|
||||
test environment detail: 'PC has 2 wired NIC connected to AP.
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
1 SSC target connect with PC by UART.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_2,
|
||||
test environment detail: 'Able to access WAN after connect to AP.
|
||||
|
||||
1 SSC target connect with PC by UART.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_APC2,
|
||||
test environment detail: "Able to access WAN after connect to AP.\nPC has 1 wired\
|
||||
\ NIC connected to APC (static IP within the same subnet with APC). \nAPC control\
|
||||
\ AP power supply.\nPC has 1 WiFi NIC.\n1 AT target connect with PC by UART (AT\
|
||||
\ and LOG port).", test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_APC1,
|
||||
test environment detail: "PC has 1 wired NIC connected to AP.\nPC has 1 wired NIC\
|
||||
\ connected to APC (static IP within the same subnet with APC). \nAPC control\
|
||||
\ AP power supply. \nPC has 1 WiFi NIC. \n1 AT target connect with PC by UART\
|
||||
\ (AT and LOG port).", test script: EnvBase}
|
||||
4 PC with WiFi NIC placed near WebServer1.', test script: EnvBase}
|
2935
components/idf_test/uint_test/InitialConditionAll.yml
Normal file
2935
components/idf_test/uint_test/InitialConditionAll.yml
Normal file
File diff suppressed because it is too large
Load Diff
1
components/idf_test/uint_test/TestCaseAll.yml
Normal file
1
components/idf_test/uint_test/TestCaseAll.yml
Normal file
@ -0,0 +1 @@
|
||||
test cases: []
|
275
components/idf_test/uint_test/TestEnvAll.yml
Normal file
275
components/idf_test/uint_test/TestEnvAll.yml
Normal file
@ -0,0 +1,275 @@
|
||||
test environment:
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_1,
|
||||
test environment detail: 'PC has 2 wired NIC connected to AP.
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
1 AT target connect with PC by UART (AT and LOG port).', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_2,
|
||||
test environment detail: 'PC has 1 WiFi NIC.
|
||||
|
||||
1 AT target connect with PC by UART (AT and LOG port).', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_3,
|
||||
test environment detail: 'Able to access WAN after connect to AP.
|
||||
|
||||
1 AT target connect with PC by UART (AT and LOG port).', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_ADC,
|
||||
test environment detail: 'PC has 1 wired NIC connected to AP.
|
||||
|
||||
Analog input connect to AT1 TOUT.
|
||||
|
||||
Multimeter connect to input, able to measure input voltage.
|
||||
|
||||
1 AT target connect with PC by UART (AT and LOG port).', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_APC1,
|
||||
test environment detail: "PC has 1 wired NIC connected to AP.\nPC has 1 wired NIC\
|
||||
\ connected to APC (static IP within the same subnet with APC). \nAPC control\
|
||||
\ AP power supply. \nPC has 1 WiFi NIC. \n1 AT target connect with PC by UART\
|
||||
\ (AT and LOG port).", test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_APC2,
|
||||
test environment detail: "Able to access WAN after connect to AP.\nPC has 1 wired\
|
||||
\ NIC connected to APC (static IP within the same subnet with APC). \nAPC control\
|
||||
\ AP power supply.\nPC has 1 WiFi NIC.\n1 AT target connect with PC by UART (AT\
|
||||
\ and LOG port).", test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_HighSpeedUART,
|
||||
test environment detail: 'PC has 2 wired NIC connected to AP.
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
1 AT target connect with PC by high speed UART (AT and LOG port).', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: AT_T1_SmartConfigIOT,
|
||||
test environment detail: '1 AT target connect with PC by UART (AT and LOG port).
|
||||
|
||||
PC has 1 wired NIC connect to Common AP.
|
||||
|
||||
Several AP are placed near AT target.
|
||||
|
||||
Several smart phone installed test APK are placed near AT target.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 2.0, script path: EnvBase.py, tag: AT_T2_1,
|
||||
test environment detail: 'PC has 1 wired NIC connected to AP.
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
2 AT target connect with PC by UART (AT and LOG port).', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: AT_T2_JAP,
|
||||
test environment detail: "Several AP are placed near AT target.\nPC has 1 wired\
|
||||
\ NIC connected to APC (static IP within the same subnet with APC).\nAPC control\
|
||||
\ power supply for all APs. \n2 AT target connect with PC by UART (AT and LOG\
|
||||
\ port).", test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: AT_T2_Sleep,
|
||||
test environment detail: 'AP support DTIM placed with AT target.
|
||||
|
||||
2 AT target connect with PC by UART (AT and LOG port).
|
||||
|
||||
Multimeter connect with PC via GPIB.
|
||||
|
||||
Series multimeter between GND and VCC of AT1.
|
||||
|
||||
AT1''s light sleep wakeup pin and wakeup indication connect with AT2''s GPIO.',
|
||||
test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 2.0, script path: EnvBase.py, tag: AT_T2_SmartConfig,
|
||||
test environment detail: '2 AT target connect with PC by UART (AT and LOG port).
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
One HT20 AP and One HT40 AP are placed near target.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, UART ports: 'SSC1
|
||||
|
||||
SSC2', additional param list: '', basic param list: '', script path: EnvBase.py,
|
||||
tag: IR_T2_1, test environment detail: '[TBD] 本测试为非自动测试, 红外能够做到数据收发吻合即可通过', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: NVS_T1_1,
|
||||
test environment detail: '1 NVS target connect with PC by UART.
|
||||
|
||||
1 SSC target connect with PC by UART.
|
||||
|
||||
SSC2 GPIO connect to NVS1 power control pin.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, UART ports: SSC_1, additional param list: '',
|
||||
basic param list: '', script path: EnvBase.py, tag: PWM_T1_1, test environment detail: "[TBD]\
|
||||
\ 1. PWM OS SDK 以及 Non-OS SDK的测试建议分开进行, 放在不同的文件夹, 防止文件命名混淆\n2. 分析CSV文件的Python脚本只能分析单个channel\
|
||||
\ \n3. 如果Init脚本打印\"Network Error\" 检查TCP Server是不是正常发送data", test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_1,
|
||||
test environment detail: 'PC has 2 wired NIC connected to AP.
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
1 SSC target connect with PC by UART.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_2,
|
||||
test environment detail: 'Able to access WAN after connect to AP.
|
||||
|
||||
1 SSC target connect with PC by UART.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_8089,
|
||||
test environment detail: 'PC has 1 wired NIC connected to AP.
|
||||
|
||||
1 8089 tablet able to run iperf test placed near SSC1.
|
||||
|
||||
1 SSC target connect with PC by UART.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_ADC,
|
||||
test environment detail: 'PC has 1 wired NIC connected to AP.
|
||||
|
||||
Analog input connect to SSC1 TOUT.
|
||||
|
||||
Multimeter connect to input, able to measure input voltage.
|
||||
|
||||
1 SSC target connect with PC by UART.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_APC,
|
||||
test environment detail: "PC has 1 wired NIC connected to AP.\nPC has 1 wired NIC\
|
||||
\ connected to APC (static IP within the same subnet with APC). \nAPC control\
|
||||
\ AP power supply. \nPC has 1 WiFi NIC. \n1 SSC target connect with PC by UART.",
|
||||
test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_Enterprise,
|
||||
test environment detail: "AP use WPA2-Etherprise is placed near SSC1. \n1 SSC target\
|
||||
\ connect with PC by UART.", test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_IOT1,
|
||||
test environment detail: 'PC has 1 WiFi NIC.
|
||||
|
||||
1 SSC target connect with PC by UART.
|
||||
|
||||
AP todo IOT test are placed near SSC1.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T1_InitData,
|
||||
test environment detail: '2 SSC target connect with PC by UART.
|
||||
|
||||
SSC1 use 40M crystal oscillator.
|
||||
|
||||
SSC2 use normal 26M crystal oscillator.
|
||||
|
||||
SSC2 GPIO connect to SSC1 power control pin.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_ShieldBox,
|
||||
test environment detail: 'refer to figure.
|
||||
|
||||
All APs and APC should be set to the same IP subnet.
|
||||
|
||||
PC wired NIC should set static IP address within the same subnet with AP.
|
||||
|
||||
Must use onboard wired NIC.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_TempBox,
|
||||
test environment detail: '1 SSC target connect with PC by UART.
|
||||
|
||||
Put SSC target to temperature box.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, UART ports: SSC_1, additional param list: '',
|
||||
basic param list: '', script path: EnvBase.py, tag: SSC_T1_Timer, test environment detail: '[TBD]
|
||||
通过串口工具调节Timer, 将GPIO_13端口连接到逻辑分析仪', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_VDD33,
|
||||
test environment detail: '1 SSC target connect with PC by UART.
|
||||
|
||||
Multimeter connect to VDD33, able to measure voltage.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T1_WEP,
|
||||
test environment detail: '1 SSC target connect with PC by UART.
|
||||
|
||||
One WEP share key AP placed near SSC1.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T2_1,
|
||||
test environment detail: 'PC has 1 wired NIC connected to AP.
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
2 SSC target connect with PC by UART.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, UART ports: 'SSC1
|
||||
|
||||
SSC2', additional param list: '', basic param list: '', script path: EnvBase.py,
|
||||
tag: SSC_T2_GPIO1, test environment detail: '[TBD] 2个ESP_8266通过UART连到PC, ESP_8266的
|
||||
GPIO_6相连', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, UART ports: 'SSC1
|
||||
|
||||
SSC2', additional param list: '', basic param list: '', script path: EnvBase.py,
|
||||
tag: SSC_T2_GPIO2, test environment detail: '[TBD] 1. 2个ESP_8266通过UART连到PC, ESP_8266的
|
||||
GPIO_15通过面包板相连
|
||||
|
||||
2. 可借助面包板, 将GPIO_15, 以及中断函数被打开的8266板的GPIO_2 相连', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, UART ports: 'SSC1
|
||||
|
||||
SSC2', additional param list: '', basic param list: '', script path: EnvBase.py,
|
||||
tag: SSC_T2_GPIO3, test environment detail: '[TBD] 2个ESP_8266通过UART连到PC, ESP_8266之间需要测试的Target_GPIO相连',
|
||||
test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T2_PhyMode,
|
||||
test environment detail: '2 SSC target connect with PC by UART.
|
||||
|
||||
PC has one WiFi NIC support capture wlan packet using libpcap.
|
||||
|
||||
Set 4 AP with phy mode 11b, 11g, 11n HT20, 11n HT40.
|
||||
|
||||
Put 4 APs near SSC targets.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T2_ShieldBox,
|
||||
test environment detail: '2 SSC target connect with PC by UART.
|
||||
|
||||
Put them to Shield box.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T2_Sleep1,
|
||||
test environment detail: 'AP support DTIM placed with AT target.
|
||||
|
||||
2 SSC target connect with PC by UART.
|
||||
|
||||
Multimeter connect with PC via GPIB.
|
||||
|
||||
Series multimeter between GND and VCC of SSC1.
|
||||
|
||||
SSC1''s light sleep wakeup pin and wakeup indication connect with AT2''s GPIO.
|
||||
|
||||
SSC1''s XPD connect with RSTB.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T2_Sleep2,
|
||||
test environment detail: 'AP support DTIM placed with AT target.
|
||||
|
||||
2 SSC target connect with PC by UART.
|
||||
|
||||
Multimeter connect with PC via GPIB.
|
||||
|
||||
Series multimeter between GND and VCC of SSC1.
|
||||
|
||||
SSC1''s RSTB pin connect with AT2''s GPIO.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 2.0, script path: EnvBase.py, tag: SSC_T2_SmartConfig,
|
||||
test environment detail: '2 SSC target connect with PC by UART.
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
One HT20 AP and One HT40 AP are placed near target.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 3.0, script path: EnvBase.py, tag: SSC_T3_PhyMode,
|
||||
test environment detail: '3 SSC target connect with PC by UART.
|
||||
|
||||
PC has one WiFi NIC support capture wlan packet using libpcap.
|
||||
|
||||
Set 4 AP with (HT20, channel1), (HT20, channel2), (HT40, channel1), (HT40, channel2).
|
||||
|
||||
Put 4 APs near SSC targets.', test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 5.0, script path: EnvBase.py, tag: SSC_T5_1,
|
||||
test environment detail: 5 SSC target connect with PC by UART., test script: EnvBase}
|
||||
- {PC OS: '', Special: N, Target Count: 1.0, script path: EnvBase.py, tag: SSC_T6_1,
|
||||
test environment detail: 'PC has 1 wired NIC connected to AP.
|
||||
|
||||
PC has 1 WiFi NIC.
|
||||
|
||||
6 SSC target connect with PC by UART.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: TempSensor_T1_1,
|
||||
test environment detail: 'Tempeture sensor target connect with PC by UART.
|
||||
|
||||
AP support DTIM placed with AT target.
|
||||
|
||||
Multimeter connect with PC via GPIB.
|
||||
|
||||
Series multimeter between GND and VCC of TempSensor1.
|
||||
|
||||
PC has 1 wired NIC connected to switch.
|
||||
|
||||
APC, AP also connect with swtich.
|
||||
|
||||
All devices connected with switch use the same IP subnet.
|
||||
|
||||
APC control AP power supply.', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, UART ports: SSC_1, additional param list: '',
|
||||
basic param list: '', script path: EnvBase.py, tag: UART_T1_1, test environment detail: '[TBD]
|
||||
将ESP_8266通过UART连到PC', test script: EnvBase}
|
||||
- {PC OS: '', Special: Y, Target Count: 1.0, UART ports: 'SSC1
|
||||
|
||||
SSC2', additional param list: '', basic param list: '', script path: EnvBase.py,
|
||||
tag: UART_T1_2, test environment detail: '[TBD] ESP_8266通过UART_0通过USB, UART_1 TXD
|
||||
通过 TTLcable 连到PC', test script: EnvBase}
|
||||
- {PC OS: linux, Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: WebServer_T1_1,
|
||||
test environment detail: 'Web Server target connect with PC by UART.
|
||||
|
||||
PC has 1 wired NIC connected to switch.
|
||||
|
||||
APC, AP also connect with swtich.
|
||||
|
||||
All devices connected with switch use same IP subnet.
|
||||
|
||||
APC control AP power supply.', test script: EnvBase}
|
||||
- {PC OS: linux, Special: Y, Target Count: 1.0, script path: EnvBase.py, tag: WebServer_T1_2,
|
||||
test environment detail: 'Web Server target connect with PC by UART.
|
||||
|
||||
4 PC with WiFi NIC placed near WebServer1.', test script: EnvBase}
|
@ -1,10 +0,0 @@
|
||||
Config: {execute count: 1, execute order: in order}
|
||||
DUT: [SSC2, SSC1]
|
||||
Filter:
|
||||
- Add:
|
||||
ID: [^TCPIP_DHCP_0302, ^TCPIP_DHCP_0301, ^TCPIP_UDP_0113, TCPIP_DHCP_0302, TCPIP_DHCP_0301,
|
||||
TCPIP_TCP_0412, TCPIP_TCP_0403, TCPIP_TCP_0402, TCPIP_TCP_0401, TCPIP_TCP_0407,
|
||||
TCPIP_TCP_0406, TCPIP_TCP_0404, TCPIP_TCP_0408, ^TCPIP_TCP_0202, TCPIP_TCP_0110,
|
||||
^TCPIP_TCP_0203, TCPIP_DHCP_0101, TCPIP_DHCP_0103, TCPIP_DHCP_0102, 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_0201, TCPIP_UDP_0108]
|
@ -1,10 +0,0 @@
|
||||
Config: {execute count: 1, execute order: in order}
|
||||
DUT: [SSC2, SSC1]
|
||||
Filter:
|
||||
- Add:
|
||||
ID: [TCPIP_UDP_0106, TCPIP_UDP_0107, TCPIP_UDP_0105, TCPIP_UDP_0101, TCPIP_IGMP_0204,
|
||||
TCPIP_IGMP_0201, TCPIP_IGMP_0202, TCPIP_IGMP_0203, ^TCPIP_TCP_0404, ^TCPIP_TCP_0406,
|
||||
^TCPIP_TCP_0407, ^TCPIP_TCP_0401, ^TCPIP_TCP_0402, ^TCPIP_TCP_0403, ^TCPIP_TCP_0408,
|
||||
TCPIP_UDP_0201, ^TCPIP_TCP_0101, ^TCPIP_TCP_0103, ^TCPIP_TCP_0102, ^TCPIP_TCP_0105,
|
||||
^TCPIP_TCP_0104, ^TCPIP_TCP_0107, ^TCPIP_TCP_0106, ^TCPIP_DHCP_0210, ^TCPIP_DHCP_0211,
|
||||
TCPIP_TCP_0212, TCPIP_TCP_0210, ^TCPIP_TCP_0210, ^TCPIP_TCP_0212, TCPIP_DHCP_0211]
|
@ -1,10 +0,0 @@
|
||||
Config: {execute count: 1, execute order: in order}
|
||||
DUT: [SSC2, SSC1]
|
||||
Filter:
|
||||
- Add:
|
||||
ID: [TCPIP_DHCP_0210, TCPIP_UDP_0202, TCPIP_TCP_0411, ^TCPIP_IP_0102, ^TCPIP_UDP_0105,
|
||||
^TCPIP_UDP_0107, ^TCPIP_UDP_0106, ^TCPIP_UDP_0101, ^TCPIP_DHCP_0102, ^TCPIP_DHCP_0103,
|
||||
^TCPIP_UDP_0108, ^TCPIP_IGMP_0201, ^TCPIP_IGMP_0203, ^TCPIP_IGMP_0202, ^TCPIP_IGMP_0204,
|
||||
TCPIP_UDP_0114, TCPIP_UDP_0113, TCPIP_UDP_0112, ^TCPIP_TCP_0201, ^TCPIP_TCP_0206,
|
||||
^TCPIP_TCP_0207, 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]
|
@ -1,10 +0,0 @@
|
||||
Config: {execute count: 1, execute order: in order}
|
||||
DUT: [SSC2, SSC1]
|
||||
Filter:
|
||||
- Add:
|
||||
ID: [^TCPIP_TCP_0115, ^TCPIP_TCP_0112, ^TCPIP_TCP_0113, ^TCPIP_TCP_0110, ^TCPIP_TCP_0111,
|
||||
^TCPIP_DHCP_0209, ^TCPIP_DHCP_0208, ^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_TCP_0202, TCPIP_TCP_0208, TCPIP_DHCP_0206, TCPIP_DHCP_0207, TCPIP_DHCP_0204,
|
||||
TCPIP_DHCP_0205, TCPIP_DHCP_0202, TCPIP_DHCP_0203, ^TCPIP_TCP_0204, TCPIP_DHCP_0201]
|
@ -1,8 +0,0 @@
|
||||
Config: {execute count: 1, execute order: in order}
|
||||
DUT: [SSC2, SSC1]
|
||||
Filter:
|
||||
- Add:
|
||||
ID: [^TCPIP_TCP_0208, TCPIP_DHCP_0208, TCPIP_DHCP_0209, ^TCPIP_TCP_0412, ^TCPIP_TCP_0411,
|
||||
^TCPIP_UDP_0112, ^TCPIP_UDP_0114, ^TCPIP_UDP_0202, ^TCPIP_IGMP_0103, ^TCPIP_IP_0101,
|
||||
TCPIP_TCP_0115, TCPIP_TCP_0114, TCPIP_TCP_0116, TCPIP_TCP_0111, TCPIP_TCP_0113,
|
||||
TCPIP_TCP_0112]
|
@ -1,10 +0,0 @@
|
||||
Config: {execute count: 1, execute order: in order}
|
||||
DUT: [SSC1]
|
||||
Filter:
|
||||
- Add:
|
||||
ID: [TCPIP_ICMP_0101, TCPIP_ICMP_0101, TCPIP_ICMP_0101, TCPIP_ICMP_0101, TCPIP_ICMP_0101,
|
||||
^TCPIP_UDP_0303, ^TCPIP_UDP_0303, ^TCPIP_UDP_0303, ^TCPIP_UDP_0303, ^TCPIP_UDP_0303,
|
||||
^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_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]
|
@ -1,6 +0,0 @@
|
||||
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_DNS_0103, TCPIP_DNS_0103, TCPIP_DNS_0103, TCPIP_DNS_0103, TCPIP_DNS_0103]
|
@ -1,10 +0,0 @@
|
||||
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_0201, WIFI_CONN_0904, ^WIFI_CONN_0201,
|
||||
^WIFI_SCAN_0102, ^WIFI_SCAN_0103, ^WIFI_SCAN_0104, ^WIFI_SCAN_0105, ^WIFI_ADDR_0102,
|
||||
WIFI_CONN_0401, ^WIFI_CONN_0103, WIFI_ADDR_0101, WIFI_ADDR_0102, WIFI_CONN_0301,
|
||||
^WIFI_CONN_0801, WIFI_CONN_0104, ^WIFI_CONN_0301, WIFI_CONN_0501, WIFI_CONN_0502,
|
||||
^WIFI_CONN_0401, WIFI_MODE_0101, WIFI_MODE_0103, WIFI_MODE_0102, ^WIFI_CONN_0904]
|
@ -1,7 +0,0 @@
|
||||
Config: {execute count: 1, execute order: in order}
|
||||
DUT: [SSC2, SSC1]
|
||||
Filter:
|
||||
- Add:
|
||||
ID: [^WIFI_CONN_0901, WIFI_CONN_0601, WIFI_CONN_0901, WIFI_CONN_0503, ^WIFI_CONN_0104,
|
||||
WIFI_CONN_0101, WIFI_CONN_0102, WIFI_CONN_0103, WIFI_CONN_0801, ^WIFI_CONN_0101,
|
||||
^WIFI_CONN_0503, ^WIFI_CONN_0502, ^WIFI_CONN_0501, ^WIFI_SCAN_0101]
|
@ -1,7 +0,0 @@
|
||||
Config: {execute count: 1, execute order: in order}
|
||||
DUT: [SSC2, SSC1]
|
||||
Filter:
|
||||
- Add:
|
||||
ID: [WIFI_PHY_0403, WIFI_SCAN_0301, WIFI_SCAN_0303, WIFI_SCAN_0304, WIFI_SCAN_0302,
|
||||
WIFI_SCAN_0201, WIFI_PHY_0402, WIFI_PHY_0401, WIFI_PHY_0407, WIFI_PHY_0406,
|
||||
WIFI_PHY_0405, WIFI_PHY_0404, WIFI_PHY_0408]
|
@ -1,4 +0,0 @@
|
||||
|
||||
# Note: The test cases in this folder are for Espressif internal use.
|
||||
|
||||
# Goto internal project wiki Testing page for detail about this folder.
|
@ -1,130 +0,0 @@
|
||||
from TCAction import TCActionBase
|
||||
from NativeLog import NativeLog
|
||||
from TCAction import CmdHandler
|
||||
import time
|
||||
|
||||
|
||||
ATCmdList = ["GMR",
|
||||
"UART=115200,8,1,0,0",
|
||||
"CWMODE=3",
|
||||
"CWJAP=\"TL_WR845N_T\",\"1234567890\"",
|
||||
"CWLAP",
|
||||
"CWQAP",
|
||||
"CWSAP=\"asdf\",\"123456789\",5,3",
|
||||
"CWLIF",
|
||||
"CWDHCP=3",
|
||||
"AT+CWAUTOCONN",
|
||||
"CIPSTAMAC=\"18:fe:34:97:f3:43\"",
|
||||
"CIPAPMAC=\"1a:fe:34:97:f3:43\"",
|
||||
"CIPSTA=\"192.168.1.2\"",
|
||||
"CIPAP=\"192.168.4.1\"",
|
||||
"CIPSTATUS",
|
||||
"CIPSTART=\"UDP\",\"192.168.1.4\",6531,7895,1",
|
||||
"CIPSTART=\"TCP\",\"192.168.1.4\",6531",
|
||||
"CIPCLOSE",
|
||||
"CIFSR",
|
||||
"CIPMUX=1",
|
||||
"CIPSERVER=1,4567",
|
||||
"CIPMODE=0",
|
||||
"CIPSTO=7200",
|
||||
"PING=\"192.168.1.4\""]
|
||||
|
||||
|
||||
class CmdInterruptTest(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=20, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
|
||||
self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name)
|
||||
pass
|
||||
|
||||
def load_and_exe_one_step(self, checker_stings, test_action_strings, fail_string,
|
||||
check_freq=0.1, check_time=50, sleep_time=0.1):
|
||||
# set checker for next executing step
|
||||
checkers = CmdHandler.parse_results(checker_stings, self.test_env)
|
||||
self.result_cntx.set_next_step(checkers, check_time, check_freq)
|
||||
# execute 1 step
|
||||
for action_string in test_action_strings:
|
||||
test_action = CmdHandler.parse_action(action_string, self.test_env)
|
||||
CmdHandler.do_actions(test_action, self.test_env)
|
||||
time.sleep(sleep_time)
|
||||
|
||||
ret = self.wait_to_execute()
|
||||
|
||||
if ret is False: # # timeout
|
||||
self.result_cntx.set_result(fail_string)
|
||||
if ret == check_time:
|
||||
self.result_cntx.set_result(fail_string)
|
||||
ret = False
|
||||
|
||||
self.require_waiting()
|
||||
|
||||
return ret
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.result_cntx.start()
|
||||
|
||||
# step 1, sleep time 0.1
|
||||
for cmd1 in ATCmdList:
|
||||
# check if match CMD - AT - busy - OK/ERROR pattern
|
||||
checker_stings = ["ATR AT1 C busy", "ATR AT1 R *"]
|
||||
test_action_string = ["ATS AT1 AT+%s" % cmd1, "ATS AT1 AT"]
|
||||
fail_string = "Fail, Fail on step 1"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string,
|
||||
fail_string, sleep_time=0.1) is False:
|
||||
# check again if match CMD - OK/ERROR - AT - OK pattern
|
||||
checker_stings = ["ATR AT1 R *", "ATR AT1 C AT L OK"]
|
||||
test_action_string = ["ATS AT1 AT+%s" % cmd1, "ATS AT1 AT"]
|
||||
fail_string = "Fail, Fail on step 1"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string,
|
||||
fail_string, sleep_time=0.1) is False:
|
||||
NativeLog.add_trace_critical("CMD Fail: AT+%s; sleep time is 0.1" % cmd1)
|
||||
|
||||
# step 2, sleep time 0
|
||||
for cmd1 in ATCmdList:
|
||||
# check if match CMD - AT - busy - OK/ERROR pattern
|
||||
checker_stings = ["ATR AT1 C busy", "ATR AT1 R *"]
|
||||
test_action_string = ["ATS AT1 AT+%s" % cmd1, "ATS AT1 AT"]
|
||||
fail_string = "Fail, Fail on step 1"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string,
|
||||
fail_string, sleep_time=0.1) is False:
|
||||
# check again if match CMD - OK/ERROR - AT - OK pattern
|
||||
checker_stings = ["ATR AT1 R *", "ATR AT1 C AT L OK"]
|
||||
test_action_string = ["ATS AT1 AT+%s" % cmd1, "ATS AT1 AT"]
|
||||
fail_string = "Fail, Fail on step 1"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string,
|
||||
fail_string, sleep_time=0.1) is False:
|
||||
NativeLog.add_trace_critical("CMD Fail: AT+%s; sleep time is 0" % cmd1)
|
||||
|
||||
# step 3, cat string
|
||||
for cmd1 in ATCmdList:
|
||||
# check if match CMD - AT - busy - OK/ERROR pattern
|
||||
checker_stings = ["ATR AT1 C busy", "ATR AT1 R *"]
|
||||
test_action_string = ["ATSO AT1 AT+%s\r\nAT\r\n" % cmd1]
|
||||
fail_string = "Fail, Fail on step 1"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string,
|
||||
fail_string, sleep_time=0.1) is False:
|
||||
# check again if match CMD - OK/ERROR - AT - OK pattern
|
||||
checker_stings = ["ATR AT1 R *", "ATR AT1 C AT L OK"]
|
||||
test_action_string = ["ATS AT1 AT+%s" % cmd1, "ATS AT1 AT"]
|
||||
fail_string = "Fail, Fail on step 1"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string,
|
||||
fail_string, sleep_time=0.1) is False:
|
||||
NativeLog.add_trace_critical("CMD Fail: AT+%s; cat string" % cmd1)
|
||||
|
||||
# finally, execute done
|
||||
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()
|
||||
|
@ -1,64 +0,0 @@
|
||||
from TCAction import TCActionBase
|
||||
import time
|
||||
import re
|
||||
|
||||
|
||||
class LAP(TCActionBase.CommonTCActionBase):
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
# 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 cleanup(self):
|
||||
# restore set LAPOPT
|
||||
if self.load_and_exe_one_step(["R AT1 L OK"],
|
||||
["ATS AT1 AT+CWLAPOPT=0,127"],
|
||||
"Failed to set LAP option") is False:
|
||||
return
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.result_cntx.start()
|
||||
|
||||
# step 1. set LAPOPT
|
||||
if self.load_and_exe_one_step(["R AT1 L OK"],
|
||||
["ATS AT1 AT+CWLAPOPT=1,4"],
|
||||
"Failed to set LAP option") is False:
|
||||
return
|
||||
|
||||
# step 2. LAP
|
||||
if self.load_and_exe_one_step(["R AT1 A <lap_result>:([[^OK]]+)OK"], # [] is list generator, use [[]] for []
|
||||
["ATS AT1 AT+CWLAP"],
|
||||
"Failed to LAP") is False:
|
||||
return
|
||||
lap_result = self.get_parameter("lap_result")
|
||||
rssi_list = re.findall("CWLAP:\((-\d+)\)", lap_result)
|
||||
if len(rssi_list) > 1:
|
||||
for i in range(len(rssi_list)-1):
|
||||
if int(rssi_list[i]) < int(rssi_list[i+1]):
|
||||
break
|
||||
else:
|
||||
self.result_cntx.set_result("Succeed")
|
||||
else:
|
||||
self.result_cntx.set_result("Succeed")
|
||||
pass
|
||||
|
||||
def result_check(self, port_name, data):
|
||||
TCActionBase.CommonTCActionBase.result_check(self, port_name, data)
|
||||
self.result_cntx.append_data(port_name, data)
|
||||
pass
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,161 +0,0 @@
|
||||
from TCAction import TCActionBase
|
||||
from TCAction import CmdHandler
|
||||
from NativeLog import NativeLog
|
||||
import time
|
||||
import threading
|
||||
import sys
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('iso-8859-1') # # use encoding that with 1 Byte length and contain 256 chars
|
||||
|
||||
|
||||
VALIDATION_STRING = "".join([chr((m+65) % 256) for m in range(256)]) # make it start from 'A'
|
||||
|
||||
|
||||
class ResultCheckCntx(TCActionBase.ResultCheckContext):
|
||||
|
||||
def __init__(self, test_action, test_env, name):
|
||||
TCActionBase.ResultCheckContext.__init__(self, test_action, test_env, name)
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
tx_result = -1
|
||||
rx_result = -1
|
||||
|
||||
while True:
|
||||
exit_flag = self.wait_exit_event(2)
|
||||
# force exit
|
||||
if exit_flag is True:
|
||||
break
|
||||
try:
|
||||
self.lock_data()
|
||||
rx_port = filter(lambda x: x[0] == "AT1", self.data_cache)
|
||||
tx_port = filter(lambda x: x[0] == "SOC2", self.data_cache)
|
||||
finally:
|
||||
self.unlock_data()
|
||||
|
||||
if len(rx_port) == 1:
|
||||
data = rx_port[0][1]
|
||||
rx_result = data.find(VALIDATION_STRING)
|
||||
if len(tx_port) == 1:
|
||||
data = tx_port[0][1]
|
||||
tx_result = data.find(VALIDATION_STRING)
|
||||
|
||||
if tx_result != -1:
|
||||
self.test_action.tx_check_done.set()
|
||||
if rx_result != -1:
|
||||
self.test_action.rx_check_done.set()
|
||||
|
||||
|
||||
class SendDataValidation(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
# 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)
|
||||
self.timestamp = time.strftime("%d%H%M%S", time.localtime())
|
||||
self.tx_check_done = threading.Event()
|
||||
self.rx_check_done = threading.Event()
|
||||
|
||||
pass
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.result_cntx.start()
|
||||
|
||||
try:
|
||||
# configurable params
|
||||
# enable target TCP TX
|
||||
tx_enable = self.tx_enable
|
||||
# enable target TCP RX
|
||||
rx_enable = self.rx_enable
|
||||
# transparent mode select
|
||||
is_transparent_mode = self.is_transparent_mode
|
||||
# configurable params
|
||||
except StandardError, e:
|
||||
NativeLog.add_trace_critical("Error configuration for TCPTransparent script, error is %s" % e)
|
||||
raise StandardError("Error configuration")
|
||||
|
||||
# step1 create PC server
|
||||
checker_stings = ["SOCR SOC_COM L OK"]
|
||||
test_action_string = ["SOC SOC1 LISTEN <test_tcp_port1>"]
|
||||
fail_string = "Fail, Fail on create PC server"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
# step2 target connect, switch to transparent
|
||||
checker_stings = ["SOCR SOC1 C +ACCEPT", "ATR AT1 NC CLOSE L OK"]
|
||||
test_action_strings = ["ATC AT1 CIPSTART \"TCP\" <pc_ip> <test_tcp_port1>"]
|
||||
fail_string = "Fail, Fail on connect to PC server"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["SOCR SOC_COM L OK"]
|
||||
test_action_strings = ["SOC SOC1 ACCEPT SOC2"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
# set to transparent mode
|
||||
if is_transparent_mode is True:
|
||||
checker_stings = ["ATR AT1 L OK"]
|
||||
test_action_strings = ["ATS AT1 AT+CIPMODE=1"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["ATR AT1 C >"]
|
||||
test_action_strings = ["ATS AT1 AT+CIPSEND"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
else:
|
||||
checker_stings = ["ATR AT1 C >"]
|
||||
test_action_strings = ["ATS AT1 AT+CIPSEND=256"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
# step 3
|
||||
|
||||
# switch to new result check context
|
||||
self.result_cntx.stop_thread()
|
||||
self.result_cntx.join()
|
||||
self.result_cntx = ResultCheckCntx(self, self.test_env, self.tc_name)
|
||||
self.result_cntx.start()
|
||||
|
||||
# step 3 send data
|
||||
if rx_enable is True:
|
||||
test_action = CmdHandler.parse_action("SOC SOC2 SEND 256", self.test_env)
|
||||
CmdHandler.do_actions(test_action[0], self.test_env)
|
||||
self.rx_check_done.wait(5)
|
||||
if self.rx_check_done.isSet() is False:
|
||||
# rx fail
|
||||
return
|
||||
# flush all data
|
||||
self.result_cntx.data_flush()
|
||||
self.tx_check_done.clear()
|
||||
|
||||
if tx_enable is True:
|
||||
test_action = CmdHandler.parse_action("ATSN AT1 256", self.test_env)
|
||||
CmdHandler.do_actions(test_action[0], self.test_env)
|
||||
self.tx_check_done.wait(5)
|
||||
if self.tx_check_done.isSet() is False:
|
||||
# tx fail
|
||||
return
|
||||
|
||||
# finally, execute done
|
||||
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)
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -1,164 +0,0 @@
|
||||
import socket
|
||||
import serial
|
||||
|
||||
from TCAction import PerformanceTCBase
|
||||
from TCAction import TCActionBase
|
||||
from NativeLog import NativeLog
|
||||
|
||||
|
||||
class UARTTest(PerformanceTCBase.PerformanceTCBase):
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
PerformanceTCBase.PerformanceTCBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.test_mode = "command"
|
||||
self.baudrate = None
|
||||
self.bytesize = None
|
||||
self.parity = None
|
||||
self.stopbits = None
|
||||
self.xonxoff = None
|
||||
self.rtscts = None
|
||||
|
||||
# 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 cleanup(self):
|
||||
# restore UART config
|
||||
self.restore_serial_port("AT1")
|
||||
PerformanceTCBase.PerformanceTCBase.cleanup(self)
|
||||
|
||||
STOP_BITS = {
|
||||
1: serial.STOPBITS_ONE,
|
||||
2: serial.STOPBITS_ONE_POINT_FIVE,
|
||||
3: serial.STOPBITS_TWO,
|
||||
}
|
||||
BYTE_SIZE = {
|
||||
5: serial.FIVEBITS,
|
||||
6: serial.SIXBITS,
|
||||
7: serial.SEVENBITS,
|
||||
8: serial.EIGHTBITS,
|
||||
}
|
||||
PARITY = {
|
||||
0: serial.PARITY_NONE,
|
||||
1: serial.PARITY_ODD,
|
||||
2: serial.PARITY_EVEN,
|
||||
}
|
||||
RTSCTS = {}
|
||||
|
||||
def config_serial_port(self):
|
||||
port = self.test_env.get_port_by_name("AT1")
|
||||
kwargs = dict()
|
||||
if self.baudrate is not None:
|
||||
kwargs["baudrate"] = self.baudrate
|
||||
if self.bytesize is not None:
|
||||
kwargs["bytesize"] = self.BYTE_SIZE[self.bytesize]
|
||||
if self.parity is not None:
|
||||
kwargs["parity"] = self.PARITY[self.parity]
|
||||
if self.stopbits is not None:
|
||||
kwargs["stopbits"] = self.STOP_BITS[self.stopbits]
|
||||
if self.xonxoff is not None:
|
||||
kwargs["xonxoff"] = self.xonxoff
|
||||
if self.rtscts is not None:
|
||||
kwargs["rtscts"] = self.rtscts
|
||||
NativeLog.add_prompt_trace("[change PC UART config] %s" % kwargs)
|
||||
port.reconfig(**kwargs)
|
||||
|
||||
def send_commands(self):
|
||||
# first change UART config
|
||||
self.config_serial_port()
|
||||
# do send commands
|
||||
for i in range(1, 256):
|
||||
cmd = bytes().join([chr(x % 256) for x in range(i)])
|
||||
try:
|
||||
self.serial_write_line("AT1", cmd)
|
||||
except StandardError, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
pass
|
||||
self.flush_data("AT1")
|
||||
# restore UART config
|
||||
self.restore_serial_port("AT1")
|
||||
|
||||
def send_data(self):
|
||||
# create TCP connection and enter send mode
|
||||
pc_ip = self.get_parameter("pc_ip")
|
||||
tcp_port = self.get_parameter("test_tcp_port1")
|
||||
server_sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
|
||||
server_sock.bind((pc_ip, tcp_port))
|
||||
server_sock.settimeout(10)
|
||||
server_sock.listen(5)
|
||||
self.serial_write_line("AT1", "AT+CIPSTART=\"TCP\",\"%s\",%s" % (pc_ip, tcp_port))
|
||||
self.check_response("AT1", "OK")
|
||||
sock, addr = server_sock.accept()
|
||||
server_sock.close()
|
||||
self.serial_write_line("AT1", "AT+CIPSEND=1460")
|
||||
self.check_response("AT1", ">")
|
||||
# change UART config
|
||||
self.config_serial_port()
|
||||
# send data
|
||||
try:
|
||||
self.serial_write("AT1", bytes().join([chr(x % 256) for x in range(146000)]))
|
||||
except StandardError, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
pass
|
||||
sock.send("A"*1460)
|
||||
# restore UART config
|
||||
sock.close()
|
||||
self.restore_serial_port("AT1")
|
||||
|
||||
def pass_through_mode(self):
|
||||
# create TCP connection and enter pass through mode
|
||||
pc_ip = self.get_parameter("pc_ip")
|
||||
tcp_port = self.get_parameter("test_tcp_port1")
|
||||
server_sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
|
||||
server_sock.bind((pc_ip, tcp_port))
|
||||
server_sock.settimeout(10)
|
||||
server_sock.listen(5)
|
||||
self.serial_write_line("AT1", "AT+CIPMODE=1")
|
||||
self.check_response("AT1", "OK")
|
||||
self.serial_write_line("AT1", "AT+CIPSTART=\"TCP\",\"%s\",%s" % (pc_ip, tcp_port))
|
||||
self.check_response("AT1", "OK")
|
||||
sock, addr = server_sock.accept()
|
||||
server_sock.close()
|
||||
self.serial_write_line("AT1", "AT+CIPSEND")
|
||||
self.check_response("AT1", ">")
|
||||
# change UART config
|
||||
self.config_serial_port()
|
||||
# send data
|
||||
try:
|
||||
self.serial_write("AT1", bytes().join([chr(x % 256) for x in range(146000)]))
|
||||
except StandardError, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
pass
|
||||
sock.send("A" * 1460)
|
||||
# restore UART config
|
||||
sock.close()
|
||||
self.restore_serial_port("AT1")
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
# test sending command
|
||||
try:
|
||||
if self.test_mode == "command":
|
||||
self.send_commands()
|
||||
elif self.test_mode == "send_data":
|
||||
self.send_data()
|
||||
elif self.test_mode == "pass_through":
|
||||
self.pass_through_mode()
|
||||
else:
|
||||
raise StandardError("test mode not supported: %s" % self.test_mode)
|
||||
self.set_result("Succeed")
|
||||
except StandardError, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
self.set_result("Failed")
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,2 +0,0 @@
|
||||
__all__ = ["TCPClientMulti", "TCPClientSingle", "TCPServerMulti",
|
||||
"TCPTransparent", "UDPMulti", "UDPSingle"]
|
@ -1,179 +0,0 @@
|
||||
import time
|
||||
|
||||
from TCAction import TCActionBase
|
||||
from NativeLog import NativeLog
|
||||
|
||||
|
||||
BEACON_TIMEOUT = 3
|
||||
WAIT_FOR_RECONNECT = 20
|
||||
|
||||
|
||||
class ATPassThrough(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.do_scan = True
|
||||
# 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 cleanup(self):
|
||||
TCActionBase.CommonTCActionBase.cleanup(self)
|
||||
# turn on logging
|
||||
self.test_env.uart_ports["AT1"].set_uart_logging_flag(True)
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.result_cntx.start()
|
||||
|
||||
# configurable params
|
||||
try:
|
||||
at_send_length = self.at_send_length
|
||||
soc_send_length = self.soc_send_length
|
||||
test_count = self.test_count
|
||||
tx_enable = self.tx_enable
|
||||
rx_enable = self.rx_enable
|
||||
att_set = self.att_set
|
||||
do_scan = self.do_scan
|
||||
except StandardError, e:
|
||||
NativeLog.add_trace_critical("Error configuration for TCPClientMulti script, error is %s" % e)
|
||||
raise StandardError("Error configuration")
|
||||
# configurable params
|
||||
|
||||
# step0, set att and join ap
|
||||
fail_string = "Fail, Fail on JAP, set to single link mode"
|
||||
|
||||
checker_stings = ["R PC_COM L OK"]
|
||||
test_action_string = ["ATT <att_port> 1"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R AT1 C ready"]
|
||||
test_action_string = ["ATS AT1 AT+RST"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R AT1 L OK"]
|
||||
test_action_string = ["ATS AT1 AT+CWMODE=1"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R AT1 L OK"]
|
||||
test_action_string = ["ATC AT1 CWJAP <ap_ssid> <ap_password>"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R AT1 L OK"]
|
||||
test_action_string = ["ATS AT1 AT+CIPMUX=0"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
# step1, create TCP connection and enter pass through mode
|
||||
fail_string = "Fail, Fail on create server, create connection or enter pass through mode"
|
||||
|
||||
checker_stings = ["R SOC_COM L OK"]
|
||||
test_action_string = ["SOC SOC1 LISTEN <test_tcp_port1>"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R SOC1 C +ACCEPT", "R AT1 NC CLOSE L OK"]
|
||||
test_action_string = ["ATC AT1 CIPSTART \"TCP\" <pc_ip> <test_tcp_port1>"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R AT1 L OK"]
|
||||
test_action_strings = ["ATS AT1 AT+CIPMODE=1"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R AT1 C >"]
|
||||
test_action_strings = ["ATS AT1 AT+CIPSEND"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R SOC_COM L OK"]
|
||||
test_action_strings = ["SOC SOC1 ACCEPT SOC2"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
# step2
|
||||
# while
|
||||
# set att from, send data on both direction
|
||||
# if TCP connection disconnected, then set att to 1, wait reconnect succeed, continue test
|
||||
for i in xrange(test_count):
|
||||
for _att in att_set:
|
||||
|
||||
# set att
|
||||
checker_stings = ["R PC_COM L OK"]
|
||||
test_action_string = ["ATT <att_port> %d" % _att]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
time.sleep(BEACON_TIMEOUT)
|
||||
|
||||
# do scan to get ssid
|
||||
if do_scan is True:
|
||||
checker_stings = []
|
||||
test_action_string = ["ATSO AT1 +++"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R AT1 L OK"]
|
||||
test_action_string = ["ATC AT1 CWLAP <ap_ssid>"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R AT1 C >"]
|
||||
test_action_strings = ["ATS AT1 AT+CIPSEND"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
# send data
|
||||
checker_stings = []
|
||||
test_action_string = []
|
||||
if tx_enable is True:
|
||||
checker_stings += ["P SOC2 RL %d" % at_send_length]
|
||||
test_action_string += ["ATSN AT1 %d" % at_send_length]
|
||||
if rx_enable is True:
|
||||
checker_stings += ["P AT1 RL %d" % soc_send_length]
|
||||
test_action_string += ["SOC SOC2 SEND %d" % soc_send_length]
|
||||
|
||||
if len(test_action_string) > 0:
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, "",
|
||||
check_freq=1, check_time=30) is False:
|
||||
# send data fail
|
||||
NativeLog.add_prompt_trace("Failed to send data @ att %d" % _att)
|
||||
# set att back to 1
|
||||
checker_stings = ["R PC_COM L OK"]
|
||||
test_action_string = ["ATT <att_port> 1"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
# wait for reconnect
|
||||
time.sleep(WAIT_FOR_RECONNECT)
|
||||
fail_string = "Failed, failed to accept socket"
|
||||
checker_stings = ["SOCR SOC_COM L OK"]
|
||||
test_action_strings = ["SOC SOC1 ACCEPT SOC2"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
break
|
||||
pass
|
||||
|
||||
# finally, execute done
|
||||
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()
|
||||
|
@ -1,251 +0,0 @@
|
||||
import random
|
||||
import os
|
||||
import time
|
||||
|
||||
from TCAction import TCActionBase, PerformanceTCBase
|
||||
from NativeLog import NativeLog
|
||||
from Utility import MakeFolder
|
||||
from Utility import MultimeterUtil
|
||||
|
||||
LOG_PATH = os.path.join("AT_LOG", "SLEEP")
|
||||
|
||||
SLEEP_MODE_LIST = ["none_sleep", "light_sleep", "modem_sleep"]
|
||||
SLEEP_MODE = dict(zip(SLEEP_MODE_LIST, range(len(SLEEP_MODE_LIST))))
|
||||
|
||||
SAMPLE_RATE_SLEEP_MODE_CHANGE = 0.002
|
||||
SAMPLE_NUM_SLEEP_MODE_CHANGE = 256
|
||||
|
||||
SAMPLE_RATE = 0.002
|
||||
SAMPLE_NUM = 512
|
||||
MAX_VALUE = 1
|
||||
Y_AXIS_LABEL = "Current (mA)"
|
||||
GPIO_EDGE_DELAY = 120 # 20 ms
|
||||
|
||||
NONE_SLEEP_MIN_CUR = 30
|
||||
LIGHT_SLEEP_MIN_CUR = 1.5
|
||||
MODEM_SLEEP_MIN_CUR = 20
|
||||
|
||||
GPIO_WAKE_UP = 15
|
||||
|
||||
AT_WAKE_UP_IND_PIN = 14
|
||||
AT_WAKE_UP_PIN = 12
|
||||
|
||||
|
||||
class ATSleep(PerformanceTCBase.PerformanceTCBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
PerformanceTCBase.PerformanceTCBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.test_mode = "mode_change"
|
||||
self.test_count = 100
|
||||
self.sleep_mode = SLEEP_MODE_LIST
|
||||
self.sleep_wake_pin = AT_WAKE_UP_PIN
|
||||
self.sleep_wakeup_ind_pin = AT_WAKE_UP_IND_PIN
|
||||
# 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.log_folder = MakeFolder.make_folder(os.path.join(LOG_PATH,
|
||||
"AT_AUTO_SLEEP_%s_%s" %
|
||||
(self.test_mode,
|
||||
time.strftime("%d%H%M%S", time.localtime()))))
|
||||
self.multimeter = MultimeterUtil.MultimeterUtil(self.log_folder)
|
||||
|
||||
@staticmethod
|
||||
def find_min_items(item_list, count):
|
||||
assert count < len(item_list)
|
||||
min_items = []
|
||||
for i in range(count):
|
||||
min_val = min(item_list)
|
||||
min_items.append(min_val)
|
||||
item_list.remove(min_val)
|
||||
return min_items
|
||||
|
||||
def sleep_mode_change(self, sleep_mode):
|
||||
result = True
|
||||
NativeLog.add_prompt_trace("[AutoSleep][ModeChange] %s start" % sleep_mode)
|
||||
# choose sleep mode
|
||||
sleep_mode_enum = SLEEP_MODE[sleep_mode]
|
||||
# change GPIO to make sure target exit sleep mode, so it can process SSC commands
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
# set sleep mode
|
||||
self.serial_write_line("AT1", "AT+SLEEP=%d" % sleep_mode_enum)
|
||||
self.check_response("AT1", "OK")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][ModeChange] mode set")
|
||||
time.sleep(10)
|
||||
# measure current
|
||||
current_line = self.multimeter.measure_current(sample_rate=SAMPLE_RATE_SLEEP_MODE_CHANGE,
|
||||
sample_num=SAMPLE_NUM_SLEEP_MODE_CHANGE,
|
||||
max_value=MAX_VALUE)
|
||||
# do check measure
|
||||
min_items = self.find_min_items(current_line, 10)
|
||||
average_val = float(0)
|
||||
for val in min_items:
|
||||
average_val += val
|
||||
average_val /= 10
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][ModeChange] measure done, average min current %f" % average_val)
|
||||
|
||||
if sleep_mode == "none_sleep":
|
||||
if average_val < NONE_SLEEP_MIN_CUR:
|
||||
result = False
|
||||
elif sleep_mode == "light_sleep":
|
||||
if average_val > LIGHT_SLEEP_MIN_CUR:
|
||||
result = False
|
||||
elif sleep_mode == "modem_sleep":
|
||||
if average_val > MODEM_SLEEP_MIN_CUR or average_val < LIGHT_SLEEP_MIN_CUR:
|
||||
result = False
|
||||
if result is False:
|
||||
NativeLog.add_trace_critical("[AutoSleep][ModeChange] %s failed" % sleep_mode)
|
||||
self.multimeter.draw_graph(current_line, SAMPLE_RATE, "%s_fail" % sleep_mode, Y_AXIS_LABEL)
|
||||
|
||||
time.sleep(5)
|
||||
return result
|
||||
|
||||
def sleep_current_measure(self, sleep_mode):
|
||||
result = True
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][CurrentMeasure] %s start" % sleep_mode)
|
||||
# choose sleep mode
|
||||
sleep_mode_enum = SLEEP_MODE[sleep_mode]
|
||||
# change GPIO to make sure target exit sleep mode, so it can process SSC commands
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
# set sleep mode
|
||||
self.serial_write_line("AT1", "AT+SLEEP=%d" % sleep_mode_enum)
|
||||
self.check_response("AT1", "OK")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][CurrentMeasure] set mode done")
|
||||
time.sleep(10)
|
||||
# measure current
|
||||
current_line = self.multimeter.measure_current(sample_rate=SAMPLE_RATE,
|
||||
sample_num=SAMPLE_NUM,
|
||||
max_value=MAX_VALUE)
|
||||
self.multimeter.draw_graph(current_line, SAMPLE_RATE, sleep_mode, Y_AXIS_LABEL)
|
||||
NativeLog.add_prompt_trace("[AutoSleep][CurrentMeasure] measure done")
|
||||
return result
|
||||
|
||||
def light_sleep_wakeup(self):
|
||||
result = True
|
||||
NativeLog.add_prompt_trace("[AutoSleep][LightSleepWakeup] start")
|
||||
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(1)
|
||||
self.serial_write_line("AT1", "")
|
||||
time.sleep(1)
|
||||
self.check_response("SSC2", "+GPIO_SET:OK", timeout=1)
|
||||
|
||||
for i in range(10):
|
||||
self.serial_write_line("SSC2", "gpio -G -p %d" % self.sleep_wakeup_ind_pin)
|
||||
if self.check_response("SSC2", "+GPIO_GET:0", timeout=0.73) is True:
|
||||
break
|
||||
else:
|
||||
NativeLog.add_prompt_trace("AT Sleep wakeup pin is not correct when in sleep")
|
||||
|
||||
# check if respond to uart
|
||||
self.flush_data("AT1")
|
||||
for i in range(60):
|
||||
self.serial_write("AT1", "a")
|
||||
time.sleep(0.43)
|
||||
time.sleep(0.1)
|
||||
respond_data = self.serial_read_data("AT1")
|
||||
if len(respond_data) >= 60:
|
||||
NativeLog.add_trace_critical("[AutoSleep][light sleep wakeup] "
|
||||
"Failed when recving data during sleep, %d" % len(respond_data))
|
||||
result = False
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][LightSleepWakeup] check on sleep mode done")
|
||||
|
||||
# change GPIO to make target wakeup
|
||||
self.serial_write_line("SSC2", "gpio -L -p %d -t 0" % GPIO_WAKE_UP)
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
time.sleep(0.01)
|
||||
|
||||
for i in range(3):
|
||||
self.serial_write_line("SSC2", "gpio -G -p %d" % self.sleep_wakeup_ind_pin)
|
||||
if self.check_response("SSC2", "+GPIO_GET:1") is False:
|
||||
NativeLog.add_prompt_trace("AT Sleep wakeup pin is not correct when wakeup")
|
||||
|
||||
self.serial_write_line("AT1", "")
|
||||
time.sleep(1)
|
||||
self.flush_data("AT1")
|
||||
for i in range(60):
|
||||
self.serial_write("AT1", "a")
|
||||
time.sleep(0.043)
|
||||
time.sleep(0.1)
|
||||
respond_data = self.serial_read_data("AT1")
|
||||
if len(respond_data) < 60:
|
||||
NativeLog.add_trace_critical("[AutoSleep][light sleep wakeup] "
|
||||
"Failed when recving data during wakeup, %d" % len(respond_data))
|
||||
result = False
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][LightSleepWakeup] check on wakeup mode done")
|
||||
self.serial_write_line("AT1", "")
|
||||
# restore GPIO level
|
||||
self.serial_write_line("SSC2", "gpio -L -p %d -t 1" % GPIO_WAKE_UP)
|
||||
time.sleep(2)
|
||||
return result
|
||||
|
||||
def cleanup(self):
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
self.serial_write_line("AT1", "")
|
||||
self.serial_write_line("AT1", "AT+RST")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
self.check_response("AT1", "ready")
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
|
||||
try:
|
||||
test_mode = self.test_mode
|
||||
test_count = self.test_count
|
||||
sleep_mode = self.sleep_mode
|
||||
except StandardError, e:
|
||||
return
|
||||
|
||||
# make sure enter modem sleep mode before start test
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
self.serial_write_line("AT1", "AT+RST")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
self.check_response("AT1", "ready")
|
||||
self.check_response("AT1", "WIFI GOT IP")
|
||||
# set AT light sleep wakeup pin
|
||||
self.serial_write_line("AT1", "AT+WAKEUPGPIO=1,%d,0" % self.sleep_wake_pin)
|
||||
self.check_response("AT1", "OK")
|
||||
|
||||
# start test
|
||||
if "mode_change" in test_mode:
|
||||
for i in range(test_count):
|
||||
result = self.sleep_mode_change(random.choice(SLEEP_MODE_LIST))
|
||||
|
||||
elif "measure_current" in test_mode:
|
||||
for i in range(test_count):
|
||||
for mode in sleep_mode:
|
||||
result = self.sleep_current_measure(mode)
|
||||
pass
|
||||
elif "gpio_wakeup" in test_mode:
|
||||
# change GPIO to make sure target exit sleep mode, so it can process SSC commands
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
# config wakeup gpio
|
||||
self.serial_write_line("AT1", "AT+WAKEUPGPIO=1,%d,0,%d,1" % (self.sleep_wake_pin, self.sleep_wakeup_ind_pin))
|
||||
self.check_response("AT1", "OK")
|
||||
# set sleep mode
|
||||
self.serial_write_line("AT1", "AT+SLEEP=%d" % SLEEP_MODE["light_sleep"])
|
||||
self.check_response("AT1", "OK")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
|
||||
for i in range(test_count):
|
||||
result = self.light_sleep_wakeup()
|
||||
pass
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,308 +0,0 @@
|
||||
from TCAction import PerformanceTCBase
|
||||
import time
|
||||
import socket
|
||||
import threading
|
||||
import Queue
|
||||
import re
|
||||
import random
|
||||
from NativeLog import NativeLog
|
||||
|
||||
|
||||
SEND_CMD = ("CIPSEND, CIPSENDBUF", "CIPSENDEX")
|
||||
|
||||
|
||||
class RecvThread(threading.Thread):
|
||||
def __init__(self, test_action):
|
||||
threading.Thread.__init__(self)
|
||||
self.setDaemon(True)
|
||||
self.test_action = test_action
|
||||
self.exit_flag = threading.Event()
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
data = ""
|
||||
ipd_line = re.compile("IPD,\d,\d+:")
|
||||
recv_bytes_line = re.compile("Recv \d+ bytes")
|
||||
allow_send_line = re.compile("OK\r\n>")
|
||||
send_ok_line = re.compile("SEND OK")
|
||||
while self.exit_flag.is_set() is False:
|
||||
flush_pos = 0
|
||||
data += self.test_action.serial_read_data("AT1")
|
||||
# do process IPD data
|
||||
match_set = ipd_line.findall(data)
|
||||
for match_line in match_set:
|
||||
link_id = match_line[4]
|
||||
flush_pos = data.find(match_line) + len(match_line)
|
||||
self.test_action.send_queue.put(link_id, 1)
|
||||
pass
|
||||
# do process send >
|
||||
match = allow_send_line.search(data)
|
||||
if match is not None:
|
||||
match_line = match.group()
|
||||
self.test_action.add_info_log("find OK >")
|
||||
self.test_action.send_allow_evt.set()
|
||||
pos = data.find(match_line) + len(match_line)
|
||||
flush_pos = pos if pos > flush_pos else flush_pos
|
||||
# do process Recv xx bytes
|
||||
match = recv_bytes_line.search(data)
|
||||
if match is not None:
|
||||
match_line = match.group()
|
||||
self.test_action.add_info_log("find Recv xx bytes")
|
||||
self.test_action.recv_data_evt.set()
|
||||
pos = data.find(match_line) + len(match_line)
|
||||
flush_pos = pos if pos > flush_pos else flush_pos
|
||||
|
||||
match = send_ok_line.search(data)
|
||||
if match is not None:
|
||||
match_line = match.group()
|
||||
self.test_action.add_info_log("find send ok")
|
||||
self.test_action.send_ok_evt.set()
|
||||
pos = data.find(match_line) + len(match_line)
|
||||
flush_pos = pos if pos > flush_pos else flush_pos
|
||||
# pass
|
||||
|
||||
# flush processed data
|
||||
if flush_pos > 0:
|
||||
data = data[flush_pos:]
|
||||
|
||||
pass
|
||||
|
||||
def exit(self):
|
||||
self.exit_flag.set()
|
||||
pass
|
||||
|
||||
|
||||
class TCPClientThread(threading.Thread):
|
||||
send_char = "A"
|
||||
sync_lock = threading.Lock()
|
||||
|
||||
def __init__(self, test_action, pc_ip, target_ip, target_port, request_len, response_len, client_id,
|
||||
connect_timeout, recv_timeout):
|
||||
threading.Thread.__init__(self)
|
||||
self.setDaemon(True)
|
||||
self.exit_flag = threading.Event()
|
||||
self.test_action = test_action
|
||||
self.pc_ip = pc_ip
|
||||
self.target_ip = target_ip
|
||||
self.target_port = target_port
|
||||
self.request_len = request_len
|
||||
self.response_len = response_len
|
||||
self.client_id = client_id
|
||||
self.connect_timeout = connect_timeout
|
||||
self.recv_timeout = recv_timeout
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def get_send_char(cls):
|
||||
with cls.sync_lock:
|
||||
send_char = cls.send_char
|
||||
cls.send_char = chr(ord(send_char) + 1) if ord(send_char) < ord("Z") else "A"
|
||||
return send_char
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
while self.exit_flag.is_set() is False:
|
||||
exception_occurred = False
|
||||
client_sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
|
||||
client_sock.bind((self.pc_ip, 0))
|
||||
client_sock.settimeout(20)
|
||||
time1 = time.time()
|
||||
name = client_sock.getsockname()
|
||||
|
||||
try:
|
||||
client_sock.connect((self.target_ip, self.target_port))
|
||||
except StandardError, e:
|
||||
exception_occurred = True
|
||||
self.test_action.add_critical_log("failed to connect succeed within 2 seconds %s, %d"
|
||||
% (name[0], name[1]))
|
||||
client_sock.close()
|
||||
|
||||
time2 = time.time() - time1
|
||||
if exception_occurred is True:
|
||||
self.test_action.add_critical_log("connect timeout %f; ip is %s, port is %d"
|
||||
% (time2, name[0], name[1]))
|
||||
continue
|
||||
if time2 > self.connect_timeout:
|
||||
self.test_action.add_critical_log("connect time too long %f; ip is %s, port is %d"
|
||||
% (time2, name[0], name[1]))
|
||||
|
||||
time.sleep(float(random.randint(0, 30))/100)
|
||||
send_char = self.get_send_char()
|
||||
data = send_char * self.request_len
|
||||
try:
|
||||
client_sock.send(data)
|
||||
except StandardError:
|
||||
NativeLog.add_trace_critical("send fail")
|
||||
# try:
|
||||
# data = client_sock.recv(1)
|
||||
# except socket.error, e:
|
||||
# self.handle_processing_fail("failed to receive data within 2 seconds")
|
||||
data_received = 0
|
||||
time1 = time.time()
|
||||
while data_received < self.response_len:
|
||||
try:
|
||||
data = client_sock.recv(4*1024)
|
||||
except StandardError, e:
|
||||
exception_occurred = True
|
||||
break
|
||||
data_received += len(data)
|
||||
|
||||
time2 = time.time() - time1
|
||||
if exception_occurred is True or time2 > self.recv_timeout:
|
||||
self.test_action.add_critical_log("receive time too long %f; ip is %s, port is %d"\
|
||||
% (time2, name[0], name[1]))
|
||||
client_sock.close()
|
||||
time.sleep(float(random.randint(0, 30))/100)
|
||||
pass
|
||||
pass
|
||||
|
||||
def exit(self):
|
||||
self.exit_flag.set()
|
||||
pass
|
||||
|
||||
|
||||
class SendThread(threading.Thread):
|
||||
def __init__(self, test_action, test_count, send_cmd, response_len, check_send_ok):
|
||||
threading.Thread.__init__(self)
|
||||
self.setDaemon(True)
|
||||
self.test_action = test_action
|
||||
self.test_count = test_count
|
||||
self.send_cmd = send_cmd
|
||||
self.response_len = response_len
|
||||
self.check_send_ok = check_send_ok
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
send_char = "a"
|
||||
for i in xrange(self.test_count):
|
||||
link_id = self.test_action.send_queue.get(1)
|
||||
|
||||
self.test_action.send_allow_evt.clear()
|
||||
self.test_action.serial_write_line("AT1", "AT+%s=%s,%d" % (self.send_cmd, link_id, self.response_len))
|
||||
self.test_action.add_info_log("write CIPSEND cmd")
|
||||
|
||||
self.test_action.send_allow_evt.wait(10)
|
||||
if self.test_action.send_allow_evt.is_set() is False:
|
||||
self.test_action.add_critical_log("Failed to find OK > in 10s, test break")
|
||||
break
|
||||
self.test_action.send_allow_evt.clear()
|
||||
|
||||
data = send_char * self.response_len
|
||||
send_char = chr(ord(send_char) + 1) if ord(send_char) < ord("z") else "a"
|
||||
self.test_action.recv_data_evt.clear()
|
||||
self.test_action.send_ok_evt.clear()
|
||||
self.test_action.serial_write("AT1", data)
|
||||
self.test_action.add_info_log("data write done")
|
||||
self.test_action.recv_data_evt.wait(10)
|
||||
if self.test_action.recv_data_evt.is_set() is False:
|
||||
self.test_action.add_critical_log("Failed to find Recv xx bytes in 10s, test break")
|
||||
break
|
||||
self.test_action.recv_data_evt.clear()
|
||||
# if self.test_action.send_cmd == "CIPSEND":
|
||||
if self.check_send_ok is True:
|
||||
self.test_action.send_ok_evt.wait(10)
|
||||
if self.test_action.send_ok_evt.is_set() is False:
|
||||
self.test_action.add_critical_log("Failed to find SEND OK in 10s, test break")
|
||||
break
|
||||
self.test_action.add_info_log("send ok")
|
||||
self.test_action.send_ok_evt.clear()
|
||||
pass
|
||||
pass
|
||||
|
||||
|
||||
class SoftAPServer(PerformanceTCBase.PerformanceTCBase):
|
||||
def __init__(self, name, test_env, cmd_set, timeout=120, log_path=None):
|
||||
PerformanceTCBase.PerformanceTCBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
# init value for ip and port
|
||||
self.pc_ip = "pc_ip"
|
||||
self.server_port = "test_tcp_port1"
|
||||
self.send_cmd = "CIPSEND"
|
||||
self.baudrate = 115200
|
||||
self.rtscts = 3
|
||||
self.test_count = 1000
|
||||
self.request_len = 500
|
||||
self.response_len = 1600
|
||||
self.check_send_ok = True
|
||||
self.concurrent_connections = 5
|
||||
self.connect_timeout = 3
|
||||
self.receive_timeout = 2
|
||||
# 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.send_queue = Queue.Queue(maxsize=100)
|
||||
self.send_allow_evt = threading.Event()
|
||||
self.recv_data_evt = threading.Event()
|
||||
self.send_ok_evt = threading.Event()
|
||||
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def add_critical_log(data):
|
||||
NativeLog.add_trace_critical(data+"\r\n")
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def add_info_log(data):
|
||||
NativeLog.add_trace_info(data)
|
||||
|
||||
def process(self):
|
||||
# step0, use initial condition AP3 (8266 as AP, PC connected to 8266, multiple connection)
|
||||
pc_ip = self.get_parameter(self.pc_ip)
|
||||
target_ip = self.get_parameter("target_ip")
|
||||
server_port = self.get_parameter(self.server_port)
|
||||
send_cmd = self.send_cmd
|
||||
test_count = self.test_count
|
||||
baudrate = self.baudrate
|
||||
rtscts = self.rtscts
|
||||
concurrent_connections = self.concurrent_connections
|
||||
check_send_ok = self.check_send_ok
|
||||
connect_timeout = self.connect_timeout
|
||||
receive_timeout = self.receive_timeout
|
||||
|
||||
self.serial_write_line("AT1", "AT+UART_CUR=%d,8,1,0,%d" % (baudrate, rtscts))
|
||||
self.check_response("AT1", "OK\r\n")
|
||||
self.reconfig_serial_port("AT1", baudrate, rtscts)
|
||||
# step1, create server on 8266, create client thread
|
||||
self.serial_write_line("AT1", "AT+CIPSERVER=1,%d" % server_port)
|
||||
self.check_response("AT1", "OK")
|
||||
|
||||
recv_thread = RecvThread(self)
|
||||
send_thread = SendThread(self, test_count, send_cmd, self.response_len, check_send_ok)
|
||||
send_thread.start()
|
||||
recv_thread.start()
|
||||
client_thread_list = [None] * concurrent_connections
|
||||
for i in range(concurrent_connections):
|
||||
client_thread_list[i] = TCPClientThread(self, pc_ip, target_ip, server_port,
|
||||
self.request_len, self.response_len, i,
|
||||
connect_timeout, receive_timeout)
|
||||
client_thread_list[i].start()
|
||||
pass
|
||||
|
||||
# step3, wait sending thread join
|
||||
send_thread.join()
|
||||
|
||||
recv_thread.exit()
|
||||
recv_thread.join()
|
||||
|
||||
for i in range(concurrent_connections):
|
||||
client_thread_list[i].exit()
|
||||
client_thread_list[i].join()
|
||||
pass
|
||||
|
||||
self.serial_write_line("AT1", "AT+UART_CUR=115200,8,1,0,3")
|
||||
self.check_response("AT1", "OK\r\n")
|
||||
self.restore_serial_port("AT1")
|
||||
self.set_result("Succeed")
|
||||
pass
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,116 +0,0 @@
|
||||
from TCAction import TCActionBase
|
||||
from NativeLog import NativeLog
|
||||
|
||||
|
||||
class TCPClientMulti(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
# 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)
|
||||
self.max_conn = test_env.get_variable_by_name("max_conn")[1]
|
||||
pass
|
||||
|
||||
def cleanup(self):
|
||||
TCActionBase.CommonTCActionBase.cleanup(self)
|
||||
# turn on logging
|
||||
self.test_env.uart_ports["AT1"].set_uart_logging_flag(True)
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.result_cntx.start()
|
||||
|
||||
# configurable params
|
||||
try:
|
||||
at_send_length = self.at_send_length
|
||||
soc_send_length = self.soc_send_length
|
||||
test_count = self.test_count
|
||||
tx_enable = self.tx_enable
|
||||
rx_enable = self.rx_enable
|
||||
enable_log = self.enable_log
|
||||
except StandardError, e:
|
||||
NativeLog.add_trace_critical("Error configuration for TCPClientMulti script, error is %s" % e)
|
||||
raise StandardError("Error configuration")
|
||||
# configurable params
|
||||
|
||||
# step1
|
||||
checker_stings = ["R SOC_COM L OK"]
|
||||
test_action_string = ["SOC SOC1 LISTEN <test_tcp_port1>"]
|
||||
fail_string = "Fail, Fail on create PC server"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
# step2
|
||||
for i in range(0, self.max_conn):
|
||||
checker_stings = ["R SOC1 C +ACCEPT", "R AT1 NC CLOSE L OK"]
|
||||
test_action_strings = ["ATC AT1 CIPSTART %d \"TCP\" <pc_ip> <test_tcp_port1>" % i]
|
||||
fail_string = "Fail, Fail on connect to PC server"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R SOC_COM L OK"]
|
||||
test_action_strings = ["SOC SOC1 ACCEPT SOC%d" % (i+2)]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
# step 3
|
||||
# turn off AT UART logging
|
||||
if enable_log is False:
|
||||
self.test_env.uart_ports["AT1"].set_uart_logging_flag(False)
|
||||
|
||||
data = "A" * at_send_length
|
||||
fail_string = "Fail, Fail on send and recv data"
|
||||
|
||||
for j in range(0, test_count):
|
||||
|
||||
if tx_enable is True:
|
||||
for i in range(0, self.max_conn):
|
||||
checker_stings = ["P AT1 C >"]
|
||||
test_action_strings = ["ATS AT1 AT+CIPSEND=%d,%d" % (i, at_send_length)]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=50) is False:
|
||||
NativeLog.add_trace_critical("Fail on target send command for link %d" % i)
|
||||
NativeLog.add_trace_critical("Test count is %d" % j)
|
||||
return
|
||||
|
||||
checker_stings = ["P SOC%d RL %d" % ((i+2), at_send_length), "P AT1 C OK"]
|
||||
test_action_strings = ["ATSO AT1 %s" % data]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=50) is False:
|
||||
NativeLog.add_trace_critical("Fail on target send for link %d, send or recv error" % i)
|
||||
NativeLog.add_trace_critical("Test count is %d" % j)
|
||||
return
|
||||
|
||||
if rx_enable is True:
|
||||
checker_stings = []
|
||||
test_action_strings = []
|
||||
for i in range(0, self.max_conn):
|
||||
checker_stings.extend(["P AT1 DL %d+%d" % (i, soc_send_length)])
|
||||
test_action_strings.extend(["SOC SOC%d SEND %d %s" % (i+2, soc_send_length, data)])
|
||||
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=50) is False:
|
||||
NativeLog.add_trace_critical("Fail to receive PC sent data")
|
||||
NativeLog.add_trace_critical("Test count is %d" % j)
|
||||
return
|
||||
|
||||
# finally, execute done
|
||||
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()
|
||||
|
@ -1,123 +0,0 @@
|
||||
from TCAction import TCActionBase
|
||||
from NativeLog import NativeLog
|
||||
|
||||
|
||||
class TCPClientSingle(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.link_type = "TCP"
|
||||
# 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 cleanup(self):
|
||||
TCActionBase.CommonTCActionBase.cleanup(self)
|
||||
# turn on logging
|
||||
self.test_env.uart_ports["AT1"].set_uart_logging_flag(True)
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.result_cntx.start()
|
||||
|
||||
# configurable params
|
||||
try:
|
||||
at_send_length = self.at_send_length
|
||||
soc_send_length = self.soc_send_length
|
||||
test_count = self.test_count
|
||||
tx_enable = self.tx_enable
|
||||
rx_enable = self.rx_enable
|
||||
enable_log = self.enable_log
|
||||
link_type = self.link_type
|
||||
except StandardError, e:
|
||||
NativeLog.add_trace_critical("Error configuration for TCPClientSingle script, error is %s" % e)
|
||||
raise StandardError("Error configuration")
|
||||
# configurable params
|
||||
|
||||
# step1
|
||||
checker_stings = ["R SOC_COM L OK"]
|
||||
if link_type == "TCP":
|
||||
test_action_string = ["SOC SOC1 LISTEN <test_tcp_port1>"]
|
||||
elif link_type == "SSL":
|
||||
test_action_string = ["SOC SOC1 SLISTEN <test_tcp_port1>"]
|
||||
pass
|
||||
else:
|
||||
raise StandardError()
|
||||
fail_string = "Fail, Fail on create PC server"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
# step2
|
||||
if link_type == "TCP":
|
||||
checker_stings = ["R SOC1 C +ACCEPT", "R AT1 NC CLOSE L OK"]
|
||||
test_action_strings = ["ATC AT1 CIPSTART \"TCP\" <pc_ip> <test_tcp_port1>"]
|
||||
elif link_type == "SSL":
|
||||
checker_stings = ["R SOC1 C +SACCEPT", "R AT1 NC CLOSE L OK"]
|
||||
test_action_strings = ["ATC AT1 CIPSTART \"SSL\" <pc_ip> <test_tcp_port1>"]
|
||||
else:
|
||||
raise StandardError()
|
||||
fail_string = "Fail, Fail on connect to PC server"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R SOC_COM L OK"]
|
||||
test_action_strings = ["SOC SOC1 ACCEPT SOC2"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
# step 3
|
||||
# turn off AT UART logging
|
||||
if enable_log is False:
|
||||
self.test_env.uart_ports["AT1"].set_uart_logging_flag(False)
|
||||
|
||||
for j in range(0, test_count):
|
||||
data = "A" * at_send_length
|
||||
fail_string = "Fail, Fail on send and recv data"
|
||||
|
||||
if tx_enable is True:
|
||||
checker_stings = ["P AT1 C >"]
|
||||
test_action_strings = ["ATS AT1 AT+CIPSEND=%d" % at_send_length]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=20) is False:
|
||||
NativeLog.add_trace_critical("Fail on target send command")
|
||||
NativeLog.add_trace_critical("Test count is %d" % j)
|
||||
return
|
||||
|
||||
checker_stings = ["P SOC2 RL %d" % at_send_length, "P AT1 C OK"]
|
||||
test_action_strings = ["ATSO AT1 %s" % data]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=20) is False:
|
||||
NativeLog.add_trace_critical("Fail on target send, send or recv error")
|
||||
NativeLog.add_trace_critical("Test count is %d" % j)
|
||||
return
|
||||
|
||||
if rx_enable is True:
|
||||
checker_stings = ["P AT1 DL S+%d" % soc_send_length]
|
||||
test_action_strings = ["SOC SOC2 SEND %d" % soc_send_length]
|
||||
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=20) is False:
|
||||
NativeLog.add_trace_critical("Fail to receive PC sent data")
|
||||
NativeLog.add_trace_critical("Test count is %d" % j)
|
||||
return
|
||||
|
||||
# finally, execute done
|
||||
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()
|
||||
|
@ -1,148 +0,0 @@
|
||||
import time
|
||||
import os
|
||||
import socket
|
||||
import ssl
|
||||
|
||||
from NativeLog import NativeLog
|
||||
from TCAction import PerformanceTCBase
|
||||
from Utility import MakeFolder
|
||||
|
||||
|
||||
SEND_CMD = ("CIPSEND, CIPSENDBUF", "CIPSENDEX")
|
||||
|
||||
LOG_PATH = os.path.join("AT_LOG", "Performance", "AT_SEND")
|
||||
|
||||
|
||||
class TCPSendPerf(PerformanceTCBase.PerformanceTCBase):
|
||||
def __init__(self, name, test_env, cmd_set, timeout=120, log_path=None):
|
||||
PerformanceTCBase.PerformanceTCBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
# init value for ip and port
|
||||
self.pc_ip = "pc_ip"
|
||||
self.server_port = "test_tcp_port1"
|
||||
self.packet_len = 1
|
||||
self.test_count = 100
|
||||
self.send_cmd = "CIPSEND"
|
||||
self.baudrate = 115200
|
||||
self.rtscts = 0
|
||||
self.link_type = "TCP"
|
||||
# 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
|
||||
pass
|
||||
|
||||
def process(self):
|
||||
pc_ip = self.get_parameter(self.pc_ip)
|
||||
server_port = self.get_parameter(self.server_port)
|
||||
packet_len = self.packet_len
|
||||
test_count = self.test_count
|
||||
send_cmd = self.send_cmd
|
||||
baudrate = self.baudrate
|
||||
rtscts = self.rtscts
|
||||
result = True
|
||||
link_type = self.link_type
|
||||
|
||||
# create TCP connection
|
||||
sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
|
||||
sock.bind((pc_ip, server_port))
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
sock.settimeout(10)
|
||||
sock.listen(1)
|
||||
|
||||
self.serial_write_line("AT1", "AT+CIPSTART=0,\"%s\",\"%s\",%d" % (link_type, pc_ip, server_port))
|
||||
sock_client = sock.accept()[0]
|
||||
if link_type == "SSL":
|
||||
sock_client = ssl.wrap_socket(sock_client,
|
||||
server_side=True,
|
||||
certfile=os.path.join("Certificate", "default.cer"),
|
||||
keyfile=os.path.join("Certificate", "default.key"))
|
||||
pass
|
||||
if self.check_response("AT1", "OK") is False:
|
||||
result = False
|
||||
|
||||
self.serial_write_line("AT1", "AT+UART_CUR=%d,8,1,0,%d" % (baudrate, rtscts))
|
||||
if self.check_response("AT1", "OK\r\n") is False:
|
||||
result = False
|
||||
|
||||
self.reconfig_serial_port("AT1", baudrate, rtscts)
|
||||
|
||||
# restore to read line mode
|
||||
self.test_env.uart_ports["AT1"].set_performance_flag(flag=True)
|
||||
|
||||
sock_client.settimeout(0)
|
||||
|
||||
for _dummy in range(1):
|
||||
if result is False:
|
||||
NativeLog.add_trace_critical("Fail to create TCP connection")
|
||||
break
|
||||
# send TCP packets
|
||||
data = "A" * packet_len
|
||||
time1 = time.time()
|
||||
|
||||
i = 0
|
||||
data_recv_len = 0
|
||||
while i < test_count:
|
||||
self.serial_write_line("AT1", "AT+%s=0,%d" % (send_cmd, packet_len))
|
||||
if self.check_response("AT1", ">", 0.05) is False:
|
||||
continue
|
||||
|
||||
i += 1
|
||||
self.serial_write("AT1", data)
|
||||
if send_cmd == "CIPSENDBUF":
|
||||
result = self.check_response("AT1", "Recv %d bytes" % packet_len, 3)
|
||||
else:
|
||||
result = self.check_response("AT1", "SEND OK", 3)
|
||||
if result is False:
|
||||
NativeLog.add_trace_critical("Fail during sending data")
|
||||
break
|
||||
try:
|
||||
if link_type == "TCP":
|
||||
data_recv = sock_client.recv(10*1460)
|
||||
elif link_type == "SSL":
|
||||
data_recv = sock_client.read(10*1024)
|
||||
else:
|
||||
raise StandardError()
|
||||
data_recv_len += len(data_recv)
|
||||
except socket.error, e:
|
||||
if e.errno == 10035:
|
||||
pass
|
||||
elif e.message == "The read operation timed out":
|
||||
pass
|
||||
else:
|
||||
NativeLog.add_exception_log(e)
|
||||
else:
|
||||
self.set_result("Succeed")
|
||||
|
||||
time2 = time.time()
|
||||
|
||||
folder_path = MakeFolder.make_folder(LOG_PATH)
|
||||
file_name = os.path.join(folder_path,
|
||||
"%s_%s_%s.log" % (send_cmd,
|
||||
packet_len,
|
||||
time.strftime("%d%H%M%S", time.localtime())))
|
||||
with open(file_name, "ab+") as f:
|
||||
f.write("\r\n[performance] %f packets per second "
|
||||
"(including failed send operation)"
|
||||
% (test_count/(time2-time1)))
|
||||
f.write("\r\n[performance] %f Kbps" % (data_recv_len/(125*(time2-time1))))
|
||||
|
||||
self.serial_write_line("AT1", "AT+UART_CUR=115200,8,1,0,3")
|
||||
self.check_response("AT1", "OK\r\n")
|
||||
self.restore_serial_port("AT1")
|
||||
|
||||
# restore to read line mode
|
||||
self.test_env.uart_ports["AT1"].set_performance_flag(flag=False)
|
||||
# close socket
|
||||
sock.close()
|
||||
sock_client.close()
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,126 +0,0 @@
|
||||
from TCAction import TCActionBase
|
||||
from NativeLog import NativeLog
|
||||
|
||||
|
||||
class TCPServerMulti(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
# 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)
|
||||
self.max_conn = test_env.get_variable_by_name("max_conn")[1]
|
||||
pass
|
||||
|
||||
def cleanup(self):
|
||||
TCActionBase.CommonTCActionBase.cleanup(self)
|
||||
self.test_env.uart_ports["AT1"].set_uart_logging_flag(True)
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.result_cntx.start()
|
||||
|
||||
# configurable params
|
||||
try:
|
||||
at_send_length = self.at_send_length
|
||||
soc_send_length = self.soc_send_length
|
||||
test_count = self.test_count
|
||||
target_ip_str = self.target_ip_str
|
||||
enable_log = self.enable_log
|
||||
except StandardError, e:
|
||||
NativeLog.add_trace_critical("Error configuration for TCPSeverMulti script, error is %s" % e)
|
||||
raise StandardError("Error configuration")
|
||||
# configurable params
|
||||
|
||||
# turn off AT UART logging
|
||||
if enable_log is False:
|
||||
self.test_env.uart_ports["AT1"].set_uart_logging_flag(False)
|
||||
|
||||
# step1 create TCP server on target
|
||||
checker_stings = ["R AT1 L OK"]
|
||||
test_action_string = ["ATC AT1 CIPSERVER 1 <test_tcp_port1>"]
|
||||
fail_string = "Fail, Fail on create target TCP server"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
# step2 PC connect to target server
|
||||
for j in range(0, test_count):
|
||||
data = "A" * at_send_length
|
||||
fail_string = "Fail, Fail on connect to target server"
|
||||
|
||||
# check if all connection can send data on target
|
||||
checker_stings = ["P AT1 C OK"]
|
||||
test_action_strings = ["ATS AT1 AT+CIPCLOSE=%d" % self.max_conn]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=100) is False:
|
||||
NativeLog.add_trace_critical("Fail to close all connection")
|
||||
NativeLog.add_trace_critical("Test count is %d" % j)
|
||||
continue # if fail on this step, we can recover and continue
|
||||
|
||||
# a) do connect
|
||||
fail_flag = False
|
||||
for i in range(0, self.max_conn):
|
||||
checker_stings = ["P SOC_COM C OK", "P AT1 C CONNECT"]
|
||||
test_action_strings = ["SOC SOC%d CONNECT <test_tcp_port1> %s" % (i+1, target_ip_str)]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=50) is False:
|
||||
NativeLog.add_trace_critical("Fail to connect to target for link %d" % i)
|
||||
NativeLog.add_trace_critical("Test count is %d" % j)
|
||||
# if fail on this step, we can recover and continue
|
||||
fail_flag = True
|
||||
break
|
||||
|
||||
if fail_flag is True:
|
||||
# fail on step a)
|
||||
continue
|
||||
|
||||
# b) check if all connection can recv data on target
|
||||
checker_stings = []
|
||||
test_action_strings = []
|
||||
for i in range(0, self.max_conn):
|
||||
checker_stings.extend(["P AT1 DL %d+%d" % (i, soc_send_length)])
|
||||
test_action_strings.extend(["SOC SOC%d SEND %d" % (i+1, soc_send_length)])
|
||||
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=50) is False:
|
||||
NativeLog.add_trace_critical("Fail to receive data from PC")
|
||||
NativeLog.add_trace_critical("Test count is %d" % j)
|
||||
continue # if fail on this step, we can recover and continue
|
||||
|
||||
# c) check if all connection can send data on target
|
||||
for i in range(0, self.max_conn):
|
||||
checker_stings = ["P AT1 C >"]
|
||||
test_action_strings = ["ATS AT1 AT+CIPSEND=%d,%d" % (i, at_send_length)]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=50) is False:
|
||||
NativeLog.add_trace_critical("Fail on target send command for link %d" % i)
|
||||
NativeLog.add_trace_critical("Test count is %d" % j)
|
||||
return
|
||||
|
||||
checker_stings = ["P SOC%d RL %d" % ((i+1), at_send_length), "P AT1 C OK"]
|
||||
test_action_strings = ["ATSO AT1 %s" % data]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=50) is False:
|
||||
NativeLog.add_trace_critical("Fail on target send for link %d, send or recv error" % i)
|
||||
NativeLog.add_trace_critical("Test count is %d" % j)
|
||||
return
|
||||
|
||||
# finally, execute done
|
||||
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()
|
||||
|
@ -1,280 +0,0 @@
|
||||
from TCAction import TCActionBase
|
||||
from TCAction import CmdHandler
|
||||
from NativeLog import NativeLog
|
||||
import time
|
||||
import random
|
||||
import string
|
||||
import os
|
||||
|
||||
|
||||
class TransparentResultCheckCntx(TCActionBase.ResultCheckContext):
|
||||
|
||||
def __init__(self, test_action, test_env, name):
|
||||
TCActionBase.ResultCheckContext.__init__(self, test_action, test_env, name)
|
||||
self.result_array = []
|
||||
self.at_data_recv_total = 0
|
||||
self.pc_data_recv_total = 0
|
||||
self.temp_data_at2wifi = ""
|
||||
self.temp_data_wifi2at = ""
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
validation_required = self.test_action.data_validation
|
||||
path = os.path.split(self.test_action.log_file_name)
|
||||
file_name_at2wifi = os.path.join(path[0], "%s_at2wifi_pc.bin" % self.test_action.timestamp)
|
||||
file_name_wifi2at = os.path.join(path[0], "%s_wifi2at_at.bin" % self.test_action.timestamp)
|
||||
|
||||
while True:
|
||||
exit_flag = self.wait_exit_event(2)
|
||||
# force exit
|
||||
if exit_flag is True:
|
||||
break
|
||||
rx_len = 0
|
||||
tx_len = 0
|
||||
try:
|
||||
self.lock_data()
|
||||
rx_port = filter(lambda x: x[0] == "AT1", self.data_cache)
|
||||
tx_port = filter(lambda x: x[0] == "SOC2", self.data_cache)
|
||||
self.data_cache = []
|
||||
finally:
|
||||
self.unlock_data()
|
||||
|
||||
if len(rx_port) == 1:
|
||||
rx_len = len(rx_port[0][1])
|
||||
self.at_data_recv_total += rx_len
|
||||
if validation_required is True:
|
||||
self.temp_data_wifi2at += rx_port[0][1]
|
||||
if len(tx_port) == 1:
|
||||
tx_len = len(tx_port[0][1])
|
||||
self.pc_data_recv_total += tx_len
|
||||
if validation_required is True:
|
||||
self.temp_data_at2wifi += tx_port[0][1]
|
||||
|
||||
self.result_array.append(["TX %8d %s" %
|
||||
(tx_len/2, time.strftime("%m-%d %H:%M:%S", time.localtime()))])
|
||||
self.result_array.append(["RX %8d %s" %
|
||||
(rx_len/2, time.strftime("%m-%d %H:%M:%S", time.localtime()))])
|
||||
|
||||
if validation_required is True:
|
||||
with open(file_name_at2wifi, "ab+") as f:
|
||||
f.write(self.temp_data_at2wifi)
|
||||
with open(file_name_wifi2at, "ab+") as f:
|
||||
f.write(self.temp_data_wifi2at)
|
||||
|
||||
def get_validation_data(self):
|
||||
return self.temp_data_at2wifi, self.temp_data_wifi2at
|
||||
|
||||
def get_test_results(self):
|
||||
return self.result_array, self.at_data_recv_total, self.pc_data_recv_total
|
||||
|
||||
|
||||
class TCPTransparent(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
# 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)
|
||||
self.timestamp = time.strftime("%d%H%M%S", time.localtime())
|
||||
|
||||
pass
|
||||
|
||||
def cleanup(self):
|
||||
# close current result check context
|
||||
self.result_cntx.stop_thread()
|
||||
self.result_cntx.join()
|
||||
# turn on logging
|
||||
self.test_env.uart_ports["AT1"].set_uart_logging_flag(True)
|
||||
# restore to read line mode
|
||||
self.test_env.uart_ports["AT1"].set_performance_flag(flag=False)
|
||||
|
||||
# make sure enter condition that can respond to AT command
|
||||
self.result_cntx = TCActionBase.ResultCheckContext(self, self.test_env, self.tc_name)
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.result_cntx.start()
|
||||
|
||||
checker_stings = ["ATR AT1 R *"]
|
||||
test_action_string = ["ATSO AT1 +++", "DELAY 0.1", "ATS AT1 AT"]
|
||||
fail_string = "Fail, Fail to reconfig UART"
|
||||
|
||||
result = False
|
||||
|
||||
while result is False:
|
||||
result = self.load_and_exe_one_step(checker_stings, test_action_string, fail_string)
|
||||
|
||||
# reset baudrate
|
||||
|
||||
checker_stings = ["ATR AT1 L OK"]
|
||||
test_action_string = ["ATS AT1 AT+UART_CUR=%d,8,1,0,3" % 115200]
|
||||
fail_string = "Fail, Fail to reconfig UART"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
test_action = CmdHandler.parse_action("UART AT1 %d" % 115200, self.test_env)
|
||||
CmdHandler.do_actions(test_action, self.test_env)
|
||||
TCActionBase.CommonTCActionBase.cleanup(self)
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.result_cntx.start()
|
||||
|
||||
try:
|
||||
# configurable params
|
||||
# at send data len
|
||||
at_send_data_len = self.at_send_data_len
|
||||
# pc send data len
|
||||
pc_send_data_len = self.pc_send_data_len
|
||||
# sleep time between each send, test count
|
||||
test_dispatch = self.test_dispatch
|
||||
# enable target TCP TX
|
||||
tx_enable = self.tx_enable
|
||||
# enable target TCP RX
|
||||
rx_enable = self.rx_enable
|
||||
# if need to record tx/rx data to file
|
||||
data_validation = self.data_validation
|
||||
# UART baudrate
|
||||
baudrate = self.baudrate
|
||||
# HW flow control
|
||||
rtscts = self.rtscts
|
||||
# configurable params
|
||||
except StandardError, e:
|
||||
NativeLog.add_trace_critical("Error configuration for TCPTransparent script, error is %s" % e)
|
||||
raise StandardError("Error configuration")
|
||||
|
||||
# step0 reconfig baudrate
|
||||
if baudrate != 0:
|
||||
checker_stings = ["R AT1 L OK"]
|
||||
test_action_string = ["ATS AT1 AT+UART_CUR=%d,8,1,0,%d" % (baudrate, rtscts)]
|
||||
fail_string = "Fail, Fail to reconfig UART"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
test_action = CmdHandler.parse_action("UART AT1 %d %d" % (baudrate, rtscts), self.test_env)
|
||||
CmdHandler.do_actions(test_action, self.test_env)
|
||||
|
||||
# step1 create PC server
|
||||
checker_stings = ["R SOC_COM L OK"]
|
||||
test_action_string = ["SOC SOC1 LISTEN <test_tcp_port1>"]
|
||||
fail_string = "Fail, Fail on create PC server"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
# step2 target connect, switch to transparent
|
||||
checker_stings = ["R SOC1 C +ACCEPT", "R AT1 NC CLOSE L OK"]
|
||||
test_action_strings = ["ATC AT1 CIPSTART \"TCP\" <pc_ip> <test_tcp_port1>"]
|
||||
fail_string = "Fail, Fail on connect to PC server"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R SOC_COM L OK"]
|
||||
test_action_strings = ["SOC SOC1 ACCEPT SOC2"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R AT1 L OK"]
|
||||
test_action_strings = ["ATS AT1 AT+CIPMODE=1"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R AT1 C >"]
|
||||
test_action_strings = ["ATS AT1 AT+CIPSEND"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
# step 3
|
||||
# turn off AT UART logging
|
||||
self.test_env.uart_ports["AT1"].set_uart_logging_flag(False)
|
||||
# uart try to return data ASAP
|
||||
self.test_env.uart_ports["AT1"].set_performance_flag(flag=True)
|
||||
|
||||
# switch to new result check context
|
||||
self.result_cntx.stop_thread()
|
||||
self.result_cntx.join()
|
||||
self.result_cntx = TransparentResultCheckCntx(self, self.test_env, self.tc_name)
|
||||
self.result_cntx.start()
|
||||
|
||||
at_data_sent_total = 0
|
||||
pc_data_sent_total = 0
|
||||
at2wifi_data = ""
|
||||
wifi2at_data = ""
|
||||
|
||||
for j in range(0, len(at_send_data_len) * len(pc_send_data_len)):
|
||||
at_data_len = at_send_data_len[j / len(pc_send_data_len)]
|
||||
pc_data_len = pc_send_data_len[j % len(pc_send_data_len)]
|
||||
# data = "".join(["A"] * at_data_len)
|
||||
chars = string.ascii_lowercase
|
||||
data_list = ["".join([random.choice(chars) for m in range(at_data_len-16)])]
|
||||
chars = string.ascii_uppercase
|
||||
data_list.append("".join([random.choice(chars) for m in range(at_data_len-16)]))
|
||||
chars = string.digits
|
||||
data_list.append("".join([random.choice(chars) for m in range(at_data_len-16)]))
|
||||
|
||||
for i in range(0, len(test_dispatch)):
|
||||
for k in range(0, test_dispatch[i][1]):
|
||||
data_str = "%.2d%.2d%.10d%s\r\n" % (j, i, k, data_list[k % 3])
|
||||
# time1 = time.time()
|
||||
if tx_enable is True:
|
||||
test_action = CmdHandler.parse_action("ATSO AT1 %s" % data_str, self.test_env)
|
||||
CmdHandler.do_actions(test_action, self.test_env)
|
||||
at_data_sent_total += at_data_len
|
||||
if data_validation is True:
|
||||
at2wifi_data += data_str
|
||||
# time2 = time.time()
|
||||
if rx_enable is True:
|
||||
if tx_enable is True:
|
||||
test_action = CmdHandler.parse_action("SOC SOC2 SENDNB %d %s" % (pc_data_len, data_str),
|
||||
self.test_env)
|
||||
else:
|
||||
test_action = CmdHandler.parse_action("SOC SOC2 SEND %d %s" % (pc_data_len, data_str),
|
||||
self.test_env)
|
||||
sent_len = CmdHandler.do_action(test_action[0], self.test_env)
|
||||
pc_data_sent_total += sent_len
|
||||
if data_validation is True:
|
||||
wifi2at_data += data_str[:sent_len]
|
||||
# time3 = time.time()
|
||||
# if time3-time2 > 0.1:
|
||||
# break
|
||||
if test_dispatch[i][0] != 0:
|
||||
time.sleep(test_dispatch[i][0])
|
||||
time.sleep(3) # wait 3 seconds
|
||||
|
||||
# write send data to file for data validation
|
||||
if data_validation is True:
|
||||
path = os.path.split(self.log_file_name)
|
||||
with open(os.path.join(path[0], "%s_at2wifi_at.bin" % self.timestamp), "ab+") as f:
|
||||
f.write(at2wifi_data)
|
||||
with open(os.path.join(path[0], "%s_wifi2at_pc.bin" % self.timestamp), "ab+") as f:
|
||||
f.write(wifi2at_data)
|
||||
|
||||
temp_data_at2wifi, temp_data_wifi2at = self.result_cntx.get_validation_data()
|
||||
if temp_data_at2wifi != at2wifi_data:
|
||||
NativeLog.add_prompt_trace("[Validation Fail] at2wifi")
|
||||
if temp_data_wifi2at != wifi2at_data:
|
||||
NativeLog.add_prompt_trace("[Validation Fail] wifi2at")
|
||||
|
||||
throughput_results, at_data_recv_total, pc_data_recv_total = self.result_cntx.get_test_results()
|
||||
result_str = "AT sent %15d\r\n" % at_data_sent_total
|
||||
result_str += "PC recv %15d\r\n" % pc_data_recv_total
|
||||
result_str += "PC sent %15d\r\n" % pc_data_sent_total
|
||||
result_str += "AT recv %15d\r\n" % at_data_recv_total
|
||||
for _result in throughput_results:
|
||||
result_str += "%s\r\n" % _result
|
||||
with open(self.log_file_name, "ab+") as f:
|
||||
f.write(result_str)
|
||||
|
||||
# finally, execute done
|
||||
self.result_cntx.set_result("Succeed")
|
||||
|
||||
def result_check(self, port_name, data):
|
||||
self.result_cntx.append_data(port_name, data)
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -1,113 +0,0 @@
|
||||
from TCAction import TCActionBase
|
||||
from NativeLog import NativeLog
|
||||
import time
|
||||
|
||||
|
||||
class UDPMulti(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
# 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)
|
||||
self.max_conn = test_env.get_variable_by_name("max_conn")[1]
|
||||
pass
|
||||
|
||||
def cleanup(self):
|
||||
TCActionBase.CommonTCActionBase.cleanup(self)
|
||||
# turn on logging
|
||||
self.test_env.uart_ports["AT1"].set_uart_logging_flag(True)
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.result_cntx.start()
|
||||
|
||||
# configurable params
|
||||
try:
|
||||
at_send_length = self.at_send_length
|
||||
soc_send_length = self.soc_send_length
|
||||
test_count = self.test_count
|
||||
target_ip_str = self.target_ip_str
|
||||
tx_enable = self.tx_enable
|
||||
rx_enable = self.rx_enable
|
||||
enable_log = self.enable_log
|
||||
except StandardError, e:
|
||||
NativeLog.add_trace_critical("Error configuration for UDPMulti script, error is %s" % e)
|
||||
raise StandardError("Error configuration")
|
||||
# configurable params
|
||||
|
||||
# step1, bind one PC UDP port
|
||||
checker_stings = ["R SOC_COM L OK"]
|
||||
test_action_string = ["SOC SOC1 BIND <test_udp_port9>"]
|
||||
fail_string = "Fail, Fail on binding socket"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
# step 2 create 5 UDP link on target
|
||||
for i in range(0, self.max_conn):
|
||||
checker_stings = ["R AT1 C CONNECT L OK"]
|
||||
test_action_strings = ["ATC AT1 CIPSTART %d \"UDP\" <pc_ip> <test_udp_port9> <test_udp_port%d> 1"
|
||||
% (i, i+1)]
|
||||
fail_string = "Fail, Fail on create UDP link"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
# step 3 send recv data
|
||||
# turn off AT UART logging
|
||||
if enable_log is False:
|
||||
self.test_env.uart_ports["AT1"].set_uart_logging_flag(False)
|
||||
|
||||
for j in range(0, test_count):
|
||||
data = "A" * at_send_length
|
||||
fail_string = "Fail, Fail on send/recv data"
|
||||
|
||||
if tx_enable is True:
|
||||
# target link 0-5 sendto PC
|
||||
for i in range(0, self.max_conn):
|
||||
checker_stings = ["P AT1 C >"]
|
||||
test_action_strings = ["ATS AT1 AT+CIPSEND=%d,%d" % (i, at_send_length)]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=20) is False:
|
||||
NativeLog.add_trace_critical("Target fail on send cmd on link %d" % i)
|
||||
NativeLog.add_trace_critical("Test count is %d" % j)
|
||||
|
||||
checker_stings = ["P SOC_COM C RECV_LEN=%d P <test_udp_port%d>" % (at_send_length, i+1),
|
||||
"P AT1 C OK"]
|
||||
test_action_strings = ["ATSO AT1 %s" % data]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=20) is False:
|
||||
NativeLog.add_trace_critical("Target sent UDP packet error on link %d" % i)
|
||||
NativeLog.add_trace_critical("Test count is %d" % j)
|
||||
|
||||
if rx_enable is True:
|
||||
# PC send to target
|
||||
checker_stings = []
|
||||
test_action_strings = []
|
||||
for i in range(0, self.max_conn):
|
||||
checker_stings.extend(["P AT1 DL %d+%d" % (i, soc_send_length)])
|
||||
test_action_strings.extend(["SOC SOC1 SENDTO %d <test_udp_port%d> %s"
|
||||
% (soc_send_length, i+1, target_ip_str)])
|
||||
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=20) is False:
|
||||
NativeLog.add_trace_critical("PC sent UDP packet error")
|
||||
NativeLog.add_trace_critical("Test count is %d" % j)
|
||||
|
||||
# finally, execute done
|
||||
self.result_cntx.set_result("Succeed")
|
||||
|
||||
def result_check(self, port_name, data):
|
||||
self.result_cntx.append_data(port_name, data)
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -1,105 +0,0 @@
|
||||
from TCAction import TCActionBase
|
||||
from NativeLog import NativeLog
|
||||
|
||||
|
||||
class UDPSingle(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
# 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 cleanup(self):
|
||||
TCActionBase.CommonTCActionBase.cleanup(self)
|
||||
# turn on logging
|
||||
self.test_env.uart_ports["AT1"].set_uart_logging_flag(True)
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.result_cntx.start()
|
||||
|
||||
# configurable params
|
||||
try:
|
||||
at_send_length = self.at_send_length
|
||||
soc_send_length = self.soc_send_length
|
||||
test_count = self.test_count
|
||||
target_ip_str = self.target_ip_str
|
||||
tx_enable = self.tx_enable
|
||||
rx_enable = self.rx_enable
|
||||
enable_log = self.enable_log
|
||||
except StandardError, e:
|
||||
NativeLog.add_trace_critical("Error configuration for UDPSingle script, error is %s" % e)
|
||||
raise StandardError("Error configuration")
|
||||
# configurable params
|
||||
|
||||
# step1, bind one PC UDP port
|
||||
checker_stings = ["R SOC_COM L OK"]
|
||||
test_action_string = ["SOC SOC1 BIND <test_udp_port9>"]
|
||||
fail_string = "Fail, Fail on binding UDP socket"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
# step 2 create UDP link on target
|
||||
checker_stings = ["R AT1 C CONNECT L OK"]
|
||||
test_action_strings = ["ATC AT1 CIPSTART \"UDP\" <pc_ip> <test_udp_port9> <test_udp_port1> 1"]
|
||||
fail_string = "Fail, Fail on create UDP link"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
# step 3 send recv data
|
||||
# turn off AT UART logging
|
||||
if enable_log is False:
|
||||
self.test_env.uart_ports["AT1"].set_uart_logging_flag(False)
|
||||
|
||||
for j in range(0, test_count):
|
||||
data = "A" * at_send_length
|
||||
fail_string = "Fail, Fail on send recv data"
|
||||
|
||||
# target sendto PC
|
||||
if tx_enable is True:
|
||||
checker_stings = ["P AT1 C >"]
|
||||
test_action_strings = ["ATS AT1 AT+CIPSEND=%d" % at_send_length]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=20) is False:
|
||||
NativeLog.add_trace_critical("Target fail on send cmd")
|
||||
NativeLog.add_trace_critical("Test count is %d" % j)
|
||||
|
||||
checker_stings = ["P SOC_COM C RECV_LEN=%d P <test_udp_port1>" % at_send_length,
|
||||
"P AT1 C OK"]
|
||||
test_action_strings = ["ATSO AT1 %s" % data]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=20) is False:
|
||||
NativeLog.add_trace_critical("Target sent UDP packet error")
|
||||
NativeLog.add_trace_critical("Test count is %d" % j)
|
||||
|
||||
# PC send to target
|
||||
if rx_enable is True:
|
||||
checker_stings = (["P AT1 DL S+%d" % soc_send_length])
|
||||
test_action_strings = (["SOC SOC1 SENDTO %d <test_udp_port1> %s" % (soc_send_length, target_ip_str)])
|
||||
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=20) is False:
|
||||
NativeLog.add_trace_critical("PC sent UDP packet error")
|
||||
NativeLog.add_trace_critical("Test count is %d" % j)
|
||||
|
||||
# finally, execute done
|
||||
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()
|
||||
|
@ -1,262 +0,0 @@
|
||||
from TCAction import TCActionBase
|
||||
from TCAction import CmdHandler
|
||||
from NativeLog import NativeLog
|
||||
import time
|
||||
import random
|
||||
import string
|
||||
import os
|
||||
|
||||
|
||||
class TransparentResultCheckCntx(TCActionBase.ResultCheckContext):
|
||||
|
||||
def __init__(self, test_action, test_env, name):
|
||||
TCActionBase.ResultCheckContext.__init__(self, test_action, test_env, name)
|
||||
self.result_array = []
|
||||
self.at_data_recv_total = 0
|
||||
self.pc_data_recv_total = 0
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
validation_required = self.test_action.data_validation
|
||||
temp_data_at2wifi = ""
|
||||
temp_data_wifi2at = ""
|
||||
path = os.path.split(self.test_action.log_file_name)
|
||||
file_name_at2wifi = os.path.join(path[0], "%s_at2wifi_pc.bin" % self.test_action.timestamp)
|
||||
file_name_wifi2at = os.path.join(path[0], "%s_wifi2at_at.bin" % self.test_action.timestamp)
|
||||
|
||||
while True:
|
||||
exit_flag = self.wait_exit_event(2)
|
||||
# force exit
|
||||
if exit_flag is True:
|
||||
break
|
||||
rx_len = 0
|
||||
tx_len = 0
|
||||
try:
|
||||
self.lock_data()
|
||||
rx_port = filter(lambda x: x[0] == "AT1", self.data_cache)
|
||||
tx_port = filter(lambda x: x[0] == "SOC1", self.data_cache)
|
||||
self.data_cache = []
|
||||
finally:
|
||||
self.unlock_data()
|
||||
|
||||
if len(rx_port) == 1:
|
||||
rx_len = len(rx_port[0][1])
|
||||
self.at_data_recv_total += rx_len
|
||||
if validation_required is True:
|
||||
temp_data_wifi2at += rx_port[0][1]
|
||||
if len(tx_port) == 1:
|
||||
tx_len = len(tx_port[0][1])
|
||||
self.pc_data_recv_total += tx_len
|
||||
if validation_required is True:
|
||||
temp_data_at2wifi += tx_port[0][1]
|
||||
|
||||
self.result_array.append(["TX %8d %s" %
|
||||
(tx_len/2, time.strftime("%m-%d %H:%M:%S", time.localtime()))])
|
||||
self.result_array.append(["RX %8d %s" %
|
||||
(rx_len/2, time.strftime("%m-%d %H:%M:%S", time.localtime()))])
|
||||
|
||||
if validation_required is True:
|
||||
with open(file_name_at2wifi, "ab+") as f:
|
||||
f.write(temp_data_at2wifi)
|
||||
with open(file_name_wifi2at, "ab+") as f:
|
||||
f.write(temp_data_wifi2at)
|
||||
|
||||
def get_test_results(self):
|
||||
return self.result_array, self.at_data_recv_total, self.pc_data_recv_total
|
||||
|
||||
|
||||
class UDPTransparent(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
# 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)
|
||||
self.timestamp = time.strftime("%d%H%M%S", time.localtime())
|
||||
|
||||
pass
|
||||
|
||||
def cleanup(self):
|
||||
# close current result check context
|
||||
self.result_cntx.stop_thread()
|
||||
self.result_cntx.join()
|
||||
# turn on logging
|
||||
self.test_env.uart_ports["AT1"].set_uart_logging_flag(True)
|
||||
# restore to read line mode
|
||||
self.test_env.uart_ports["AT1"].set_performance_flag(flag=False)
|
||||
|
||||
# make sure enter condition that can respond to AT command
|
||||
self.result_cntx = TCActionBase.ResultCheckContext(self, self.test_env, self.tc_name)
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.result_cntx.start()
|
||||
|
||||
checker_stings = ["R AT1 R *"]
|
||||
test_action_string = ["ATSO AT1 +++", "DELAY 0.1", "ATS AT1 AT"]
|
||||
fail_string = "Fail, Fail to reconfig UART"
|
||||
|
||||
result = False
|
||||
|
||||
while result is False:
|
||||
result = self.load_and_exe_one_step(checker_stings, test_action_string, fail_string)
|
||||
|
||||
# reset baudrate
|
||||
|
||||
checker_stings = ["R AT1 L OK"]
|
||||
test_action_string = ["ATS AT1 AT+UART_CUR=%d,8,1,0,3" % 115200]
|
||||
fail_string = "Fail, Fail to reconfig UART"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
test_action = CmdHandler.parse_action("UART AT1 %d" % 115200, self.test_env)
|
||||
CmdHandler.do_actions(test_action, self.test_env)
|
||||
TCActionBase.CommonTCActionBase.cleanup(self)
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.result_cntx.start()
|
||||
|
||||
try:
|
||||
# configurable params
|
||||
# at send data len
|
||||
at_send_data_len = self.at_send_data_len
|
||||
# pc send data len
|
||||
pc_send_data_len = self.pc_send_data_len
|
||||
# sleep time between each send, test count
|
||||
test_dispatch = self.test_dispatch
|
||||
# enable target TCP TX
|
||||
tx_enable = self.tx_enable
|
||||
# enable target TCP RX
|
||||
rx_enable = self.rx_enable
|
||||
# if need to record tx/rx data to file
|
||||
data_validation = self.data_validation
|
||||
# UART baudrate
|
||||
baudrate = self.baudrate
|
||||
# HW flow control
|
||||
rtscts = self.rtscts
|
||||
# configurable params
|
||||
except StandardError, e:
|
||||
NativeLog.add_trace_critical("Error configuration for TCPTransparent script, error is %s" % e)
|
||||
raise StandardError("Error configuration")
|
||||
|
||||
# step0 reconfig baudrate
|
||||
if baudrate != 0:
|
||||
checker_stings = ["R AT1 L OK"]
|
||||
test_action_string = ["ATS AT1 AT+UART_CUR=%d,8,1,0,%d" % (baudrate, rtscts)]
|
||||
fail_string = "Fail, Fail to reconfig UART"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
test_action = CmdHandler.parse_action("UART AT1 %d %d" % (baudrate, rtscts), self.test_env)
|
||||
CmdHandler.do_actions(test_action, self.test_env)
|
||||
|
||||
# step1 create PC server
|
||||
checker_stings = ["R SOC_COM L OK"]
|
||||
test_action_string = ["SOC SOC1 BIND <test_udp_port1> <pc_ip>"]
|
||||
fail_string = "Fail, Fail on create PC server"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
# step2 target connect, switch to transparent
|
||||
checker_stings = ["R AT1 NC CLOSE L OK"]
|
||||
test_action_strings = ["ATC AT1 CIPSTART \"UDP\" <pc_ip> <test_udp_port1> <test_udp_port1> 0"]
|
||||
fail_string = "Fail, Fail on connect to PC server"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R AT1 L OK"]
|
||||
test_action_strings = ["ATS AT1 AT+CIPMODE=1"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R AT1 C >"]
|
||||
test_action_strings = ["ATS AT1 AT+CIPSEND"]
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_strings, fail_string) is False:
|
||||
return
|
||||
|
||||
# step 3
|
||||
# turn off AT UART logging
|
||||
self.test_env.uart_ports["AT1"].set_uart_logging_flag(False)
|
||||
# restore to read data asap
|
||||
self.test_env.uart_ports["AT1"].set_performance_flag(flag=True)
|
||||
|
||||
# switch to new result check context
|
||||
self.result_cntx.stop_thread()
|
||||
self.result_cntx.join()
|
||||
self.result_cntx = TransparentResultCheckCntx(self, self.test_env, self.tc_name)
|
||||
self.result_cntx.start()
|
||||
|
||||
at_data_sent_total = 0
|
||||
pc_data_sent_total = 0
|
||||
at2wifi_data = ""
|
||||
wifi2at_data = ""
|
||||
|
||||
for j in range(0, len(at_send_data_len) * len(pc_send_data_len)):
|
||||
at_data_len = at_send_data_len[j / len(pc_send_data_len)]
|
||||
pc_data_len = pc_send_data_len[j % len(pc_send_data_len)]
|
||||
# data = "".join(["A"] * at_data_len)
|
||||
chars = string.ascii_lowercase
|
||||
data_list = ["".join([random.choice(chars) for m in range(at_data_len-16)])]
|
||||
chars = string.ascii_uppercase
|
||||
data_list.append("".join([random.choice(chars) for m in range(at_data_len-16)]))
|
||||
chars = string.digits
|
||||
data_list.append("".join([random.choice(chars) for m in range(at_data_len-16)]))
|
||||
|
||||
for i in range(0, len(test_dispatch)):
|
||||
for k in range(0, test_dispatch[i][1]):
|
||||
data_str = "%.2d%.2d%.10d%s\r\n" % (j, i, k, data_list[k % 3])
|
||||
# time1 = time.time()
|
||||
if tx_enable is True:
|
||||
test_action = CmdHandler.parse_action("ATSO AT1 %s" % data_str, self.test_env)
|
||||
CmdHandler.do_actions(test_action, self.test_env)
|
||||
at_data_sent_total += at_data_len
|
||||
if data_validation is True:
|
||||
at2wifi_data += data_str
|
||||
# time2 = time.time()
|
||||
if rx_enable is True:
|
||||
test_action = CmdHandler.parse_action("SOC SOC1 SENDTO %d %s %s %s"
|
||||
% (pc_data_len, "<test_udp_port1>",
|
||||
"<target_ip>", data_str), self.test_env)
|
||||
CmdHandler.do_actions(test_action, self.test_env)
|
||||
pc_data_sent_total += pc_data_len
|
||||
if data_validation is True:
|
||||
wifi2at_data += data_str
|
||||
# time3 = time.time()
|
||||
# if time3-time2 > 0.1:
|
||||
# pass
|
||||
if test_dispatch[i][0] != 0:
|
||||
time.sleep(test_dispatch[i][0])
|
||||
time.sleep(3) # wait 3 seconds
|
||||
|
||||
# write send data to file for data validation
|
||||
if data_validation is True:
|
||||
path = os.path.split(self.log_file_name)
|
||||
with open(os.path.join(path[0], "%s_at2wifi_at.bin" % self.timestamp), "ab+") as f:
|
||||
f.write(at2wifi_data)
|
||||
with open(os.path.join(path[0], "%s_wifi2at_pc.bin" % self.timestamp), "ab+") as f:
|
||||
f.write(wifi2at_data)
|
||||
throughput_results, at_data_recv_total, pc_data_recv_total = self.result_cntx.get_test_results()
|
||||
result_str = "AT sent %15d\r\n" % at_data_sent_total
|
||||
result_str += "PC recv %15d\r\n" % pc_data_recv_total
|
||||
result_str += "PC sent %15d\r\n" % pc_data_sent_total
|
||||
result_str += "AT recv %15d\r\n" % at_data_recv_total
|
||||
for _result in throughput_results:
|
||||
result_str += "%s\r\n" % _result
|
||||
with open(self.log_file_name, "ab+") as f:
|
||||
f.write(result_str)
|
||||
|
||||
# finally, execute done
|
||||
self.result_cntx.set_result("Succeed")
|
||||
|
||||
def result_check(self, port_name, data):
|
||||
self.result_cntx.append_data(port_name, data)
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -1,2 +0,0 @@
|
||||
__all__ = ["TCPClientMulti", "TCPClientSingle", "TCPServerMulti",
|
||||
"TCPTransparent", "UDPMulti", "UDPSingle"]
|
@ -1,357 +0,0 @@
|
||||
import Queue
|
||||
|
||||
from TCAction import TCActionBase
|
||||
from NativeLog import NativeLog
|
||||
from SCUDPServer import *
|
||||
from TCAction.CmdExecutor import CmdExecutorBasic
|
||||
from Utility import MakeFolder
|
||||
|
||||
TEST_RESULT_CATEGORY = ("AP", "Phone")
|
||||
TEST_RESULT_PROPERTY = ("model", "total", "succeed", "failed", "total time1", "total time2")
|
||||
SINGLE_TEST_RESULT = ("AP", "Phone", "result", "time1", "time2")
|
||||
|
||||
LOG_FILES = ("by_ap.tmp", "by_phone.tmp", "failed_item.tmp", "disqualified_item.tmp", "total.tmp")
|
||||
|
||||
LOG_PATH = os.path.join("AT_LOG", "IOT")
|
||||
|
||||
|
||||
def make_session_id(mac, test_id):
|
||||
return mac_to_bytes(mac) + chr((test_id & 0xFF00) >> 8) + chr(test_id & 0xFF)
|
||||
|
||||
|
||||
class TestHandler(threading.Thread):
|
||||
def __init__(self, session_id, ap, phone, udp_server, test_action):
|
||||
threading.Thread.__init__(self)
|
||||
self.setDaemon(True)
|
||||
self.udp_server = udp_server
|
||||
self.session_id = session_id
|
||||
self.ap = ap
|
||||
self.phone = phone
|
||||
self.test_action = test_action
|
||||
self.recv_queue = Queue.Queue(10)
|
||||
self.abort_event = threading.Event()
|
||||
self.start_time = time.time()
|
||||
self.test_result = None
|
||||
udp_server.register_test_handler(session_id, self)
|
||||
pass
|
||||
|
||||
def req_receiver(self, msg, address):
|
||||
self.recv_queue.put([msg, address])
|
||||
pass
|
||||
|
||||
def res_receiver(self, msg, address):
|
||||
self.recv_queue.put([msg, address])
|
||||
pass
|
||||
|
||||
def abort_handler(self):
|
||||
NativeLog.add_prompt_trace("[Test Handler][Debug] test aborted")
|
||||
self.abort_event.set()
|
||||
self.test_action.remove_from_available_list(self.phone)
|
||||
pass
|
||||
|
||||
def wait_result(self, event, timeout=None):
|
||||
time_start = time.time()
|
||||
while True:
|
||||
if self.abort_event.isSet() is True:
|
||||
return False
|
||||
|
||||
if time.time() - self.start_time > ABORT_TIMEOUT:
|
||||
return False
|
||||
|
||||
if timeout is not None:
|
||||
if time.time() - time_start > timeout:
|
||||
return False
|
||||
|
||||
if event == "ACK" or event == "result":
|
||||
try:
|
||||
ret = self.recv_queue.get(timeout=0.5)
|
||||
except Queue.Empty, e:
|
||||
continue
|
||||
else:
|
||||
msg = ret[0]
|
||||
value_list = get_value_from_msg("type", msg)
|
||||
msg_typ = ord(value_list[0])
|
||||
if msg_typ == TYPE_VAL[event]:
|
||||
NativeLog.add_prompt_trace("[Test Handler][Debug] wait message succeed")
|
||||
return msg
|
||||
elif (msg_typ & 0x80) == 0: # invalid request
|
||||
self.udp_server.send_response([[VALUE_NAME["type"], TYPE_VAL["Not support"]],
|
||||
[VALUE_NAME["session id"], self.session_id]],
|
||||
ret[1])
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
for i in range(1):
|
||||
# step1 send broadcast to SP
|
||||
msg = [[VALUE_NAME["type"], TYPE_VAL["Init new test"]],
|
||||
[VALUE_NAME["session id"], self.session_id]]
|
||||
self.udp_server.send_request(("<broadcast>", self.udp_server.udp_port), self.session_id, msg)
|
||||
# wait response
|
||||
if self.wait_result("ACK") is False:
|
||||
break
|
||||
NativeLog.add_prompt_trace("[Step1] Initial new test succeed")
|
||||
|
||||
# step2 start smart config
|
||||
checker_stings = ["ATR AT1 L OK"]
|
||||
test_action_string = ["ATS AT1 AT+CWSTOPSMART"]
|
||||
fail_string = "Fail, Failed to start smart config"
|
||||
if self.test_action.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
NativeLog.add_prompt_trace(fail_string)
|
||||
break
|
||||
checker_stings = ["ATR AT1 L OK"]
|
||||
test_action_string = ["ATS AT1 AT+CWSTARTSMART=1"]
|
||||
if self.test_action.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
NativeLog.add_prompt_trace(fail_string)
|
||||
break
|
||||
NativeLog.add_prompt_trace("[Step2] Start smart config succeed")
|
||||
|
||||
# step3 send test request to SP
|
||||
msg = [[VALUE_NAME["type"], TYPE_VAL["test request"]],
|
||||
[VALUE_NAME["session id"], self.session_id],
|
||||
[VALUE_NAME["ap ssid"], self.ap["ssid"]],
|
||||
[VALUE_NAME["ap password"], self.ap["password"]],
|
||||
[VALUE_NAME["ap bssid"], mac_to_bytes(self.ap["bssid"])],
|
||||
# [VALUE_NAME["ET version"], 0x20],
|
||||
[VALUE_NAME["ssid hidden"], self.ap["is_hidden"]],
|
||||
[VALUE_NAME["ap encryption"], AP_ENCRYPTION_VAL[self.ap["encryption"]]]
|
||||
]
|
||||
self.udp_server.send_request((self.phone["ip"], self.udp_server.udp_port), self.session_id, msg)
|
||||
# wait SP reply
|
||||
if self.wait_result("ACK") is False:
|
||||
break
|
||||
NativeLog.add_prompt_trace("[Step3] Send test request succeed")
|
||||
time_base = time.time()
|
||||
|
||||
# step4 wait target smart config succeed
|
||||
checker_stings = ["ATR AT1 C get%%20wifi%%20info C %s C %s"
|
||||
% (self.ap["ssid"], self.ap["password"])]
|
||||
test_action_string = []
|
||||
fail_string = "Fail, Fail to get ap info"
|
||||
# if check target get smart config result fail, continue and get result from SP
|
||||
ret = self.test_action.load_and_exe_one_step(checker_stings, test_action_string,
|
||||
fail_string, check_time=600)
|
||||
if ret is False:
|
||||
NativeLog.add_prompt_trace("[Step4] Target smart config fail")
|
||||
step_4_fail = True
|
||||
else:
|
||||
NativeLog.add_prompt_trace("[Step4] Target smart config succeed")
|
||||
step_4_fail = False
|
||||
time_target_succeed = time.time() - time_base
|
||||
|
||||
# step5 wait SP result
|
||||
msg = self.wait_result("result")
|
||||
if msg is False:
|
||||
NativeLog.add_prompt_trace("[Test Handler][Debug] Failed to get result from SP")
|
||||
break
|
||||
else:
|
||||
self.udp_server.send_response([[VALUE_NAME["type"], TYPE_VAL["ACK"]],
|
||||
[VALUE_NAME["session id"], self.session_id]],
|
||||
(self.phone["ip"], self.udp_server.udp_port))
|
||||
tmp = get_value_from_msg(["result code", "start SC time", "recv UDP time"], msg)
|
||||
result_code = ord(tmp[0])
|
||||
if result_code == RESULT_CODE_VAL["OK"]:
|
||||
sp_start_time = bytes_to_time(tmp[1])
|
||||
sp_recv_udp_time = bytes_to_time(tmp[2])
|
||||
smart_config_protocol_cost = time_target_succeed - sp_start_time
|
||||
user_experience_time = sp_recv_udp_time - sp_start_time
|
||||
self.test_result = ["Succeed", smart_config_protocol_cost, user_experience_time]
|
||||
elif result_code == RESULT_CODE_VAL["recv UDP fail"]:
|
||||
sp_start_time = bytes_to_time(tmp[1])
|
||||
if step_4_fail is True:
|
||||
smart_config_protocol_cost = 0
|
||||
else:
|
||||
smart_config_protocol_cost = time_target_succeed - sp_start_time
|
||||
self.test_result = ["Failed", smart_config_protocol_cost, 0]
|
||||
pass
|
||||
else:
|
||||
NativeLog.add_prompt_trace("[Test Handler][Debug] Disqualified message: %s" % tmp)
|
||||
|
||||
for k in range(RETRANSMIT_COUNT - 1):
|
||||
if self.wait_result("result", RETRANSMIT_TIMEOUT) is not False:
|
||||
self.udp_server.send_response([[VALUE_NAME["type"], TYPE_VAL["ACK"]],
|
||||
[VALUE_NAME["session id"], self.session_id]],
|
||||
(self.phone["ip"], self.udp_server.udp_port))
|
||||
|
||||
NativeLog.add_prompt_trace("[Step5] Receive test result from SP")
|
||||
|
||||
if self.test_result is None:
|
||||
self.test_result = ["Disqualified", 0, 0]
|
||||
self.udp_server.deregister_test_handler(self.session_id)
|
||||
NativeLog.add_prompt_trace("One Test Done")
|
||||
pass
|
||||
|
||||
def get_result(self):
|
||||
if self.test_result is None:
|
||||
NativeLog.add_trace_critical("Get result before test finish")
|
||||
return self.test_result
|
||||
pass
|
||||
|
||||
|
||||
class SCIOT(TCActionBase.CommonTCActionBase):
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.ap_list = []
|
||||
self.test_result = dict.fromkeys(TEST_RESULT_CATEGORY)
|
||||
self.test_result["AP"] = []
|
||||
self.test_result["Phone"] = []
|
||||
self.available_phone_list = []
|
||||
self.pc_ip = "<pc_ip>"
|
||||
self.udp_port = "<test_udp_port1>"
|
||||
self.test_id = 0x00
|
||||
self.resource_lock = threading.Lock()
|
||||
self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name)
|
||||
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
|
||||
|
||||
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_PROPERTY, " + cmd_set[i][1][j] + ")))"
|
||||
exec cmd_string
|
||||
for ap in self.ap_list:
|
||||
self.test_result["AP"].append(dict(zip(TEST_RESULT_PROPERTY, [ap["ssid"], 0, 0, 0, 0, 0])))
|
||||
|
||||
self.log_folder = MakeFolder.make_folder(os.path.join(LOG_PATH, "TEST_%s"
|
||||
% (time.strftime("%y%m%d%H%M%S", time.localtime()))))
|
||||
self.log_files = dict.fromkeys(LOG_FILES)
|
||||
for _file in self.log_files:
|
||||
self.log_files[_file] = os.path.join(self.log_folder,
|
||||
(time.strftime("%H%M%S", time.localtime())) + _file)
|
||||
pass
|
||||
|
||||
def update_phone_list(self, phone):
|
||||
with self.resource_lock:
|
||||
tmp = filter(lambda x: x["model"] == phone["model"], self.available_phone_list)
|
||||
if len(tmp) == 1:
|
||||
tmp[0]["ip"] = phone["ip"]
|
||||
else:
|
||||
self.available_phone_list.append(phone)
|
||||
|
||||
tmp = filter(lambda x: x["model"] == phone["model"], self.test_result["Phone"])
|
||||
if len(tmp) == 0:
|
||||
self.test_result["Phone"].append(dict(zip(TEST_RESULT_PROPERTY, [phone["model"], 0, 0, 0, 0, 0])))
|
||||
pass
|
||||
|
||||
def remove_from_available_list(self, phone):
|
||||
with self.resource_lock:
|
||||
tmp = filter(lambda x: x["model"] == phone["model"], self.available_phone_list)
|
||||
if len(tmp) == 1:
|
||||
self.available_phone_list.remove(tmp[0])
|
||||
pass
|
||||
|
||||
def allocate_test(self):
|
||||
phone = None
|
||||
test_count = 0xFFFF
|
||||
with self.resource_lock:
|
||||
for _phone in self.available_phone_list:
|
||||
tmp = filter(lambda x: x["model"] == _phone["model"], self.test_result["Phone"])
|
||||
if len(tmp) == 1:
|
||||
_count = tmp[0]["total"]
|
||||
if _count < test_count:
|
||||
test_count = _count
|
||||
phone = _phone
|
||||
ap_list = self.ap_list[test_count % len(self.ap_list):]
|
||||
return phone, ap_list
|
||||
pass
|
||||
|
||||
def output_test_result(self, ap, phone, test_result):
|
||||
result_str = "Time stamp" + ":\t" + NativeLog.generate_timestamp() + "\r\n"
|
||||
result_str += "AP model" + ":\t" + str(ap["ssid"]) + "\r\n"
|
||||
result_str += "AP encryption" + ":\t" + str(ap["encryption"]) + "\r\n"
|
||||
result_str += "AP HT" + ":\t" + str(ap["ht"]) + "\r\n"
|
||||
result_str += "AP ssid hidden" + ":\t" + str(ap["is_hidden"]) + "\r\n"
|
||||
result_str += "Phone model" + ":\t" + str(phone["model"]) + "\r\n"
|
||||
result_str += "Result" + ":\t" + str(test_result[0]) + "\r\n"
|
||||
result_str += "Time1" + ":\t" + str(test_result[1]) + "\r\n"
|
||||
result_str += "Time2" + ":\t" + str(test_result[2]) + "\r\n"
|
||||
|
||||
with self.resource_lock:
|
||||
tmp = [filter(lambda x: x["model"] == ap["ssid"], self.test_result["AP"])[0],
|
||||
filter(lambda x: x["model"] == phone["model"], self.test_result["Phone"])[0]]
|
||||
if test_result[0] == "Succeed":
|
||||
for _tmp in tmp:
|
||||
_tmp["total"] += 1
|
||||
_tmp["succeed"] += 1
|
||||
_tmp["total time1"] += test_result[1]
|
||||
_tmp["total time2"] += test_result[2]
|
||||
pass
|
||||
elif test_result[0] == "Disqualified":
|
||||
for _tmp in tmp:
|
||||
_tmp["total"] += 1
|
||||
pass
|
||||
else:
|
||||
for _tmp in tmp:
|
||||
_tmp["total"] += 1
|
||||
_tmp["failed"] += 1
|
||||
pass
|
||||
tmp_result = dict(zip(TEST_RESULT_CATEGORY, ["", ""]))
|
||||
for category in self.test_result:
|
||||
for _result in self.test_result[category]:
|
||||
for n in _result:
|
||||
tmp_result[category] += str(n) + ":\t" + str(_result[n]) + "\r\n"
|
||||
|
||||
# update to log file
|
||||
with open(self.log_files["by_ap.tmp"], "wb+") as f:
|
||||
f.write(tmp_result["AP"])
|
||||
with open(self.log_files["by_phone.tmp"], "wb+") as f:
|
||||
f.write(tmp_result["Phone"])
|
||||
|
||||
with open(self.log_files["total.tmp"], "ab+") as f:
|
||||
f.write(result_str)
|
||||
if test_result[0] == "Failed":
|
||||
with open(self.log_files["failed_item.tmp"], "ab+") as f:
|
||||
f.write(result_str)
|
||||
elif test_result[0] == "Disqualified":
|
||||
with open(self.log_files["disqualified_item.tmp"], "ab+") as f:
|
||||
f.write(result_str)
|
||||
|
||||
pass
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.result_cntx.start()
|
||||
|
||||
pc_ip = CmdExecutorBasic.extract_parameter(self.pc_ip, self.test_env)
|
||||
if isinstance(self.udp_port, int) is False:
|
||||
udp_port = CmdExecutorBasic.extract_parameter(self.udp_port, self.test_env)
|
||||
else:
|
||||
udp_port = self.udp_port
|
||||
|
||||
server = UDPServer(pc_ip, udp_port, self.update_phone_list)
|
||||
server.start()
|
||||
|
||||
while True:
|
||||
phone, ap_list = self.allocate_test()
|
||||
if phone is None:
|
||||
time.sleep(5)
|
||||
continue
|
||||
for ap in ap_list:
|
||||
NativeLog.add_prompt_trace("AP is %s, Phone is %s" % (ap["ssid"], phone["model"]))
|
||||
session_id = make_session_id(phone["mac"], self.test_id)
|
||||
self.test_id += 1
|
||||
test_handler = TestHandler(session_id, ap, phone, server, self)
|
||||
test_handler.start()
|
||||
test_handler.join()
|
||||
result = test_handler.get_result()
|
||||
self.output_test_result(ap, phone, result)
|
||||
|
||||
# finally, execute done
|
||||
server.join()
|
||||
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()
|
@ -1,378 +0,0 @@
|
||||
import socket
|
||||
import time
|
||||
import os
|
||||
import threading
|
||||
|
||||
from NativeLog import NativeLog
|
||||
|
||||
|
||||
RETRANSMIT_COUNT = 5
|
||||
RETRANSMIT_TIMEOUT = 0.5
|
||||
ABORT_TIMEOUT = 120
|
||||
BEACON_SEND_RATE = 30
|
||||
|
||||
|
||||
VALUE_NAME = {"type": 0x00,
|
||||
"session id": 0x01,
|
||||
"result code": 0x02,
|
||||
"ap ssid": 0x03,
|
||||
"ap password": 0x04,
|
||||
"start SC time": 0x05,
|
||||
"recv UDP time": 0x06,
|
||||
"SP model": 0x07,
|
||||
"SP mac": 0x08,
|
||||
"ET version": 0x09,
|
||||
"ap bssid": 0x0A,
|
||||
"ssid hidden": 0x0B,
|
||||
"ap encryption": 0x0C,
|
||||
}
|
||||
|
||||
TYPE_VAL = {"Init new test": 0x00,
|
||||
"test request": 0x01,
|
||||
"result": 0x02,
|
||||
"query phone": 0x03,
|
||||
"ACK": 0x80,
|
||||
"phone report": 0x81,
|
||||
"Not support": 0xFF,
|
||||
"invalid session": 0xFE,
|
||||
}
|
||||
|
||||
RESULT_CODE_VAL = {"OK": 0x80,
|
||||
"JAP fail": 0x81, # SP join AP fail, should disqualify this result
|
||||
"recv UDP fail": 0x82, # SP did not receive UDP sent by target
|
||||
}
|
||||
|
||||
AP_ENCRYPTION_VAL = {"OPEN": 0x00,
|
||||
"WEP": 0x01,
|
||||
"WPA": 0x02,
|
||||
}
|
||||
|
||||
AP_PROPERTY = ("ssid", "password", "bssid", "is_hidden", "encryption", "ht")
|
||||
PHONE_PROPERTY = ("ip", "mac", "model")
|
||||
|
||||
|
||||
SERIAL_PORT_NUM = 3
|
||||
LOG_FILE_PREFIX = "SC_IOT"
|
||||
LOG_FOLDER = os.path.join("AT_LOG", "TEMP")
|
||||
LOG_FILE_NAME = os.path.join(LOG_FOLDER, "%s_%s.log" % (LOG_FILE_PREFIX, time.strftime("%d%H%M%S", time.localtime())))
|
||||
|
||||
|
||||
REQUEST_LOCK = threading.Lock()
|
||||
HANDLER_LOCK = threading.Lock()
|
||||
|
||||
|
||||
def sync_request_list(func):
|
||||
def handle_args(*args, **kwargs):
|
||||
with REQUEST_LOCK:
|
||||
ret = func(*args, **kwargs)
|
||||
return ret
|
||||
return handle_args
|
||||
|
||||
|
||||
def sync_handler_list(func):
|
||||
def handle_args(*args, **kwargs):
|
||||
with HANDLER_LOCK:
|
||||
ret = func(*args, **kwargs)
|
||||
return ret
|
||||
return handle_args
|
||||
|
||||
|
||||
def _process_one_tlv_pair(data):
|
||||
typ = ord(data[0])
|
||||
length = ord(data[1])
|
||||
value = data[2:2+length]
|
||||
processed_data = data[2+length:]
|
||||
return (typ, value), processed_data
|
||||
pass
|
||||
|
||||
|
||||
def bytes_to_msg(data):
|
||||
data_to_process = data
|
||||
msg = []
|
||||
while True:
|
||||
one_pair, data_to_process = _process_one_tlv_pair(data_to_process)
|
||||
msg.append(one_pair)
|
||||
if len(data_to_process) == 0:
|
||||
break
|
||||
return msg
|
||||
pass
|
||||
|
||||
|
||||
def msg_to_bytes(msg):
|
||||
byte_str = ""
|
||||
for pair in msg:
|
||||
byte_str += chr(pair[0])
|
||||
if isinstance(pair[1], list) is True:
|
||||
byte_str += chr(len(pair[1]))
|
||||
byte_str.join([chr(m) for m in pair[1]])
|
||||
elif isinstance(pair[1], str) is True:
|
||||
byte_str += chr(len(pair[1]))
|
||||
byte_str += pair[1]
|
||||
elif isinstance(pair[1], int) is True:
|
||||
byte_str += chr(1)
|
||||
byte_str += chr(pair[1])
|
||||
else:
|
||||
raise TypeError("msg content only support list and string type")
|
||||
return byte_str
|
||||
|
||||
|
||||
def get_value_from_msg(type_list, msg):
|
||||
if isinstance(type_list, str) is True:
|
||||
type_list = [type_list]
|
||||
ret = [""] * len(type_list)
|
||||
for pair in msg:
|
||||
for i in range(len(type_list)):
|
||||
if pair[0] == VALUE_NAME[type_list[i]]:
|
||||
ret[i] = pair[1]
|
||||
if "" not in ret:
|
||||
# all type value found
|
||||
break
|
||||
else:
|
||||
NativeLog.add_prompt_trace("missing required type in msg")
|
||||
return ret
|
||||
|
||||
|
||||
def bytes_to_time(bytes_in):
|
||||
if len(bytes_in) != 4:
|
||||
return 0
|
||||
t = float(ord(bytes_in[0])*256*256*256 + ord(bytes_in[1])*256*256
|
||||
+ ord(bytes_in[2])*256 + ord(bytes_in[2]))/1000
|
||||
return t
|
||||
pass
|
||||
|
||||
|
||||
def mac_to_bytes(mac):
|
||||
tmp = mac.split(':')
|
||||
return "".join([chr(int(m[:2], base=16)) for m in tmp])
|
||||
pass
|
||||
|
||||
|
||||
def bytes_to_mac(bytes_in):
|
||||
mac = "".join(["%x:" % ord(m) for m in bytes_in] )
|
||||
return mac[:-1]
|
||||
|
||||
|
||||
class RetransmitHandler(threading.Thread):
|
||||
def __init__(self, udp_server):
|
||||
threading.Thread.__init__(self)
|
||||
self.setDaemon(True)
|
||||
self.udp_server = udp_server
|
||||
self.exit_event = threading.Event()
|
||||
pass
|
||||
|
||||
@sync_request_list
|
||||
def find_required_retransmit_msg(self):
|
||||
time_now = time.time()
|
||||
aborted_sessions = []
|
||||
retransmit_msg = []
|
||||
msgs = filter(lambda x: time_now - x[4] >= RETRANSMIT_TIMEOUT, self.udp_server.unconfirmed_request)
|
||||
for msg in msgs:
|
||||
if msg[3] == 0:
|
||||
aborted_sessions.append(msg[0])
|
||||
self.udp_server.unconfirmed_request.remove(msg)
|
||||
else:
|
||||
msg[3] -= 1
|
||||
msg[4] = time_now
|
||||
retransmit_msg.append(msg)
|
||||
pass
|
||||
return aborted_sessions, retransmit_msg
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
self.exit_event.wait(0.1)
|
||||
if self.exit_event.isSet() is True:
|
||||
break
|
||||
aborted_sessions, retransmit_msg = self.find_required_retransmit_msg()
|
||||
for msg in retransmit_msg:
|
||||
self.udp_server.udp_socket.sendto(msg[1], msg[2])
|
||||
for session_id in aborted_sessions:
|
||||
self.udp_server.session_aborted(session_id)
|
||||
|
||||
def exit(self):
|
||||
self.exit_event.set()
|
||||
pass
|
||||
|
||||
|
||||
class SendBeacon(threading.Thread):
|
||||
def __init__(self, sock, udp_port):
|
||||
threading.Thread.__init__(self)
|
||||
self.setDaemon(True)
|
||||
self.udp_sock = sock
|
||||
self.udp_port = udp_port
|
||||
self.exit_event = threading.Event()
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
msg = [[VALUE_NAME["type"], TYPE_VAL["query phone"]]]
|
||||
data = msg_to_bytes(msg)
|
||||
self.udp_sock.sendto(data, ("<broadcast>", self.udp_port))
|
||||
for i in range(BEACON_SEND_RATE):
|
||||
self.exit_event.wait(1)
|
||||
if self.exit_event.isSet() is True:
|
||||
return
|
||||
pass
|
||||
|
||||
def exit(self):
|
||||
self.exit_event.set()
|
||||
pass
|
||||
|
||||
|
||||
class UDPServer(threading.Thread):
|
||||
def __init__(self, pc_ip, udp_port, update_phone_handler):
|
||||
threading.Thread.__init__(self)
|
||||
self.setDaemon(True)
|
||||
sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
|
||||
sock.bind((pc_ip, udp_port))
|
||||
sock.settimeout(1)
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
|
||||
self.udp_socket = sock
|
||||
self.unconfirmed_request = []
|
||||
self.test_handler_list = []
|
||||
self.pc_ip = pc_ip
|
||||
self.udp_port = udp_port
|
||||
self.update_phone_handler = update_phone_handler
|
||||
self.retransmit_thread = RetransmitHandler(self)
|
||||
self.beacon_thread = SendBeacon(self.udp_socket, self.udp_port)
|
||||
self.retransmit_thread.start()
|
||||
self.beacon_thread.start()
|
||||
self.exit_event = threading.Event()
|
||||
pass
|
||||
|
||||
@sync_handler_list
|
||||
def register_test_handler(self, session_id, test_handler):
|
||||
tmp = filter(lambda x: x[0] == session_id, self.test_handler_list)
|
||||
if len(tmp) > 0:
|
||||
NativeLog.add_prompt_trace("handler with same session id exist")
|
||||
else:
|
||||
self.test_handler_list.append([session_id, test_handler])
|
||||
pass
|
||||
|
||||
@sync_handler_list
|
||||
def deregister_test_handler(self, session_id):
|
||||
tmp = filter(lambda x: x[0] == session_id, self.test_handler_list)
|
||||
if len(tmp) > 1:
|
||||
NativeLog.add_prompt_trace("deregister test handler fail")
|
||||
elif len(tmp) == 1:
|
||||
self.test_handler_list.remove(tmp[0])
|
||||
pass
|
||||
|
||||
@sync_handler_list
|
||||
def get_test_handler(self, session_id):
|
||||
ret = None
|
||||
tmp = filter(lambda x: x[0] == session_id, self.test_handler_list)
|
||||
if len(tmp) != 1:
|
||||
NativeLog.add_prompt_trace("failed to get test handler, "
|
||||
"%d handler found, session id %s" % (len(tmp), session_id))
|
||||
elif len(tmp) == 1:
|
||||
ret = tmp[0][1]
|
||||
return ret
|
||||
pass
|
||||
|
||||
def session_aborted(self, session_id):
|
||||
test_handler = self.get_test_handler(session_id)
|
||||
if test_handler is not None:
|
||||
test_handler.abort_handler()
|
||||
pass
|
||||
|
||||
def confirm_request(self, session_id, msg, address):
|
||||
test_handler = self.get_test_handler(session_id)
|
||||
if test_handler is not None:
|
||||
test_handler.res_receiver(msg, address)
|
||||
self.remove_pending_request(session_id)
|
||||
pass
|
||||
|
||||
def receive_request(self, msg, address):
|
||||
result = get_value_from_msg(["type", "session id"], msg)
|
||||
msg_type = ord(result[0])
|
||||
session_id = result[1]
|
||||
if msg_type != TYPE_VAL["result"]:
|
||||
self.send_response([[VALUE_NAME["type"], TYPE_VAL["Not support"]]], address)
|
||||
else:
|
||||
test_handler = self.get_test_handler(session_id)
|
||||
if test_handler is None:
|
||||
self.send_response([[VALUE_NAME["type"], TYPE_VAL["invalid session"]],
|
||||
[VALUE_NAME["session id"], session_id]],
|
||||
address)
|
||||
pass
|
||||
else:
|
||||
test_handler.req_receiver(msg, address)
|
||||
pass
|
||||
|
||||
@sync_request_list
|
||||
def add_request_to_queue(self, dest_addr, session_id, data):
|
||||
tmp = filter(lambda x: x[0] == session_id, self.unconfirmed_request)
|
||||
if len(tmp) != 0:
|
||||
NativeLog.add_prompt_trace("One pending request belong to same session id %s" % session_id)
|
||||
pass
|
||||
else:
|
||||
self.unconfirmed_request.append([session_id, data,
|
||||
dest_addr, RETRANSMIT_COUNT-1, time.time()])
|
||||
|
||||
def send_request(self, dest_addr, session_id, msg):
|
||||
data = msg_to_bytes(msg)
|
||||
self.add_request_to_queue(dest_addr, session_id, data)
|
||||
self.udp_socket.sendto(data, dest_addr)
|
||||
pass
|
||||
|
||||
def send_response(self, msg, address):
|
||||
self.udp_socket.sendto(msg_to_bytes(msg), address)
|
||||
|
||||
@sync_request_list
|
||||
def remove_pending_request(self, session_id):
|
||||
tmp = filter(lambda x: x[0] == session_id, self.unconfirmed_request)
|
||||
if len(tmp) > 0:
|
||||
self.unconfirmed_request.remove(tmp[0])
|
||||
pass
|
||||
pass
|
||||
|
||||
def handle_response(self, msg, address):
|
||||
result = get_value_from_msg(["type", "session id"], msg)
|
||||
msg_type = ord(result[0])
|
||||
session_id = result[1]
|
||||
if msg_type == TYPE_VAL["ACK"]:
|
||||
self.confirm_request(session_id, msg, address)
|
||||
elif msg_type == TYPE_VAL["phone report"]:
|
||||
# add new available phone
|
||||
tmp = get_value_from_msg(["SP model", "SP mac"], msg)
|
||||
phone = dict(zip(PHONE_PROPERTY, [address[0], bytes_to_mac(tmp[1]), tmp[0]]))
|
||||
self.update_phone_handler(phone)
|
||||
pass
|
||||
elif msg_type == TYPE_VAL["Not support"] or msg_type == TYPE_VAL["invalid session"]:
|
||||
self.session_aborted(session_id)
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
while self.exit_event.isSet() is False:
|
||||
try:
|
||||
data, address = self.udp_socket.recvfrom(65535)
|
||||
except socket.error, e:
|
||||
continue
|
||||
|
||||
if address[0] == self.pc_ip:
|
||||
continue
|
||||
|
||||
msg = bytes_to_msg(data)
|
||||
msg_type = get_value_from_msg(["type"], msg)[0]
|
||||
|
||||
if msg_type is None:
|
||||
NativeLog.add_prompt_trace("invalid incoming msg: %s" % "".join(["0x%X, " % m for m in data]))
|
||||
else:
|
||||
msg_type = ord(msg_type)
|
||||
# check if request or reply
|
||||
if (msg_type & 0x80) != 0:
|
||||
self.handle_response(msg, address)
|
||||
else:
|
||||
self.receive_request(msg, address)
|
||||
pass
|
||||
|
||||
self.retransmit_thread.exit()
|
||||
self.beacon_thread.exit()
|
||||
self.retransmit_thread.join()
|
||||
self.beacon_thread.join()
|
||||
pass
|
||||
|
||||
def exit(self):
|
||||
self.exit_event.set()
|
||||
pass
|
@ -1,244 +0,0 @@
|
||||
from NativeLog import NativeLog
|
||||
import time
|
||||
import random
|
||||
import string
|
||||
|
||||
|
||||
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 cur_mode C %d" % (i+1, mode[i]))
|
||||
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 APC1"
|
||||
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 ssc%20scan%20done"]
|
||||
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 %s" % ap_prop["ssid"],
|
||||
"SSCR SSC1 C dhcp%20client%20start",
|
||||
"SSCR SSC1 C ip C mask C gw"]
|
||||
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 dhcp%20client%20start",
|
||||
"SSCR SSC1 C ip C mask C gw"]
|
||||
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()
|
@ -1,183 +0,0 @@
|
||||
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("AT_LOG", "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 WifiJAP(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
# default value for optional configurable params
|
||||
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
|
||||
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(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("AT1") 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 _ap in _ap_list:
|
||||
# arrange ap
|
||||
_ap_type = _ap[0]
|
||||
_ap_prop = _ap[1]
|
||||
if _ap_type == "target":
|
||||
_ap_prop = self._generate_random_ap_prop()
|
||||
|
||||
for i in xrange(test_count):
|
||||
# step 3 : mandatory step, join AP
|
||||
_join_test_method = "Normal"
|
||||
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)
|
||||
NativeLog.add_prompt_trace("[Step] Join AP done")
|
||||
|
||||
NativeLog.add_prompt_trace("[WifiJAP] One AP Done")
|
||||
|
||||
# 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()
|
@ -1 +0,0 @@
|
||||
__author__ = 'Administrator'
|
@ -1,525 +0,0 @@
|
||||
from __future__ import division
|
||||
import time
|
||||
import threading
|
||||
import re
|
||||
import random
|
||||
import os
|
||||
import binascii
|
||||
|
||||
from TCAction import PerformanceTCBase
|
||||
from NativeLog import NativeLog
|
||||
from NativeLog import HTMLGenerator
|
||||
from comm import MeshPort
|
||||
from Utility import Encoding
|
||||
|
||||
# check frequency in second
|
||||
CHECK_FREQ = 0.05
|
||||
# check timeout in seconds
|
||||
CHECK_TIMEOUT = 30
|
||||
# multicast group len
|
||||
MULTICAST_GROUP_LEN = 2
|
||||
|
||||
|
||||
LOG_PATH = os.path.join("..", "log")
|
||||
|
||||
def _convert_to_mesh_mac_format(value_in):
|
||||
value_out = ""
|
||||
match_list = re.findall("([0-9a-fA-F]+)", value_in)
|
||||
try:
|
||||
for i in range(6):
|
||||
value_out += "%02X" % int(match_list[i], base=16)
|
||||
pass
|
||||
except StandardError, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
raise e
|
||||
return value_out
|
||||
|
||||
class SendRecvTime(threading.Thread):
|
||||
def __init__(self):
|
||||
threading.Thread.__init__(self)
|
||||
self.setDaemon(True)
|
||||
self.send_time = dict()
|
||||
self.recv_time = dict()
|
||||
self.send_time_lock = threading.Lock()
|
||||
self.recv_time_lock = threading.Lock()
|
||||
|
||||
def add_send_time(self, key, timestamp):
|
||||
with self.send_time_lock:
|
||||
self.send_time[key] = timestamp
|
||||
|
||||
def add_recv_time(self, key, timestamp):
|
||||
with self.recv_time_lock:
|
||||
if key in self.recv_time.keys():
|
||||
self.recv_time[key].append(timestamp)
|
||||
else:
|
||||
self.recv_time[key] = [timestamp]
|
||||
|
||||
def calculate(self):
|
||||
# add compute delay time code here
|
||||
print 'send dict len:', len(self.send_time)
|
||||
print 'recv dict len:', len(self.recv_time)
|
||||
recv_time_keys = self.recv_time.keys()
|
||||
Max_delay_time = 0.0
|
||||
Total_delay_time = 0.0
|
||||
# for i in range(len(recv_time_keys)):
|
||||
# key = recv_time_keys[i]
|
||||
for key in recv_time_keys:
|
||||
Total_delay_time_t = 0.0
|
||||
if isinstance(self.recv_time[key], list):
|
||||
for time1 in self.recv_time[key]:
|
||||
if time1 - self.send_time[key] >= Max_delay_time:
|
||||
Max_delay_time = time1 - self.send_time[key]
|
||||
Total_delay_time_t += (time1 - self.send_time[key])
|
||||
else:
|
||||
pass
|
||||
else:
|
||||
if self.recv_time[key] - self.send_time[key] > Max_delay_time:
|
||||
Max_delay_time = self.recv_time[key] - self.send_time[key]
|
||||
Total_delay_time_t += (self.recv_time[key] - self.send_time[key])
|
||||
Total_delay_time_t += (Total_delay_time_t / len(self.recv_time[key]))
|
||||
Total_delay_time += Total_delay_time_t
|
||||
Avg_delay_time = Total_delay_time / len(recv_time_keys)
|
||||
loss_rate = (len(self.send_time.keys()) - len(self.recv_time.keys())) / len(self.send_time.keys())
|
||||
return [Max_delay_time, Avg_delay_time, loss_rate]
|
||||
pass
|
||||
|
||||
class EntitySendThread(threading.Thread):
|
||||
def __init__(self, port, behavior, unicast_addr, send_delay, typ, device_mac_list, server_addr, send_recv_time):
|
||||
threading.Thread.__init__(self)
|
||||
self.setDaemon(True)
|
||||
self.recv_data_cache = ""
|
||||
self.packets_sent = 0
|
||||
self.port = port
|
||||
self.behavior = behavior
|
||||
self.typ = typ
|
||||
self.unicast_addr = unicast_addr
|
||||
self.node_num = len(device_mac_list)
|
||||
self.device_mac_list = list(device_mac_list)
|
||||
self.server_addr = server_addr
|
||||
if typ != "SERVER":
|
||||
self.device_mac_list.remove(port.device_mac)
|
||||
self.send_delay = send_delay
|
||||
self.cache_lock = threading.Lock()
|
||||
self.exit_event = threading.Event()
|
||||
self.send_recv_time = send_recv_time
|
||||
pass
|
||||
|
||||
def data_recv_callback(self, data):
|
||||
with self.cache_lock:
|
||||
self.recv_data_cache += data
|
||||
if self.typ == "SSC":
|
||||
while True:
|
||||
if self.recv_data_cache is not None:
|
||||
match = re.compile(".+\+MSEND1:\d+:OK", re.DOTALL)
|
||||
res = match.search(self.recv_data_cache)
|
||||
index = re.search("\+MSEND1:(\d+):OK", self.recv_data_cache)
|
||||
if index is not None:
|
||||
time1 = time.time()
|
||||
index1 = int(index.group(1))
|
||||
self.send_recv_time.add_send_time(index1, time1)
|
||||
#print 'send index:', index1
|
||||
process_index = res.group().split("MSEND1")
|
||||
if len(process_index) > 1:
|
||||
process_index_t = len(process_index[0]) + len("MSEND1")
|
||||
self.recv_data_cache = self.recv_data_cache[process_index_t:]
|
||||
else:
|
||||
self.recv_data_cache = self.recv_data_cache[len(res.group()):]
|
||||
else:
|
||||
break
|
||||
else:
|
||||
break
|
||||
pass
|
||||
|
||||
|
||||
def __server_send_packet(self, dst_addr, option_list=None, group_addr=None):
|
||||
ver = 0x0
|
||||
flags = 0x0
|
||||
proto = 0x0
|
||||
index = random.randint(10000, 999999999)
|
||||
if group_addr is not None:
|
||||
len_t = hex(len(group_addr) * 6).split("0x")
|
||||
if len(group_addr) <= 2:
|
||||
option_list = "070" + len_t[1]
|
||||
else:
|
||||
option_list = "07" + len_t[1]
|
||||
group = ""
|
||||
for addr in group_addr:
|
||||
group += _convert_to_mesh_mac_format(addr)
|
||||
option_list += group
|
||||
else:
|
||||
option_list = None
|
||||
if self.behavior == "broadcast":
|
||||
dst_addr = "00:00:00:00:00:00"
|
||||
elif self.behavior == "unicast":
|
||||
if self.unicast_addr == "random":
|
||||
dst_addr = random.choice(self.device_mac_list)
|
||||
else:
|
||||
dst_addr = self.unicast_addr
|
||||
elif self.behavior == "p2p":
|
||||
proto = 0x2
|
||||
if self.unicast_addr == "random":
|
||||
dst_addr = random.choice(self.device_mac_list)
|
||||
else:
|
||||
dst_addr = self.unicast_addr
|
||||
packet = MeshPort.Packet(ver=ver, flags=flags, proto=proto,
|
||||
dst_addr=dst_addr, src_addr=self.server_addr, option_list=option_list, data="A" * 100, index=index)
|
||||
send_data = packet.dumps
|
||||
try:
|
||||
self.port.socket.send(send_data)
|
||||
time2 = time.time()
|
||||
self.send_recv_time.add_send_time(index, time2)
|
||||
except StandardError, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
return False
|
||||
|
||||
def __server_do_send(self):
|
||||
if self.behavior == "broadcast":
|
||||
if self.__server_send_packet(dst_addr="00:00:00:00:00:00", group_addr=None) is True:
|
||||
self.packets_sent += self.node_num
|
||||
elif self.behavior == "multicast":
|
||||
random.shuffle(self.device_mac_list)
|
||||
group_addr_list = self.device_mac_list[:MULTICAST_GROUP_LEN]
|
||||
if self.__server_send_packet(dst_addr="01:00:5E:00:00:00", group_addr=group_addr_list) is True:
|
||||
self.packets_sent += MULTICAST_GROUP_LEN
|
||||
elif self.behavior == "unicast":
|
||||
if self.__server_send_packet(dst_addr=random.choice(self.device_mac_list), group_addr=None) is True:
|
||||
self.packets_sent += 1
|
||||
elif self.behavior == "p2p":
|
||||
if self.__server_send_packet(dst_addr=random.choice(self.device_mac_list), group_addr=None) is True:
|
||||
self.packets_sent += 1
|
||||
else:
|
||||
NativeLog.add_trace_critical("unsupported behavior [%s]" % self.behavior)
|
||||
self.exit()
|
||||
return
|
||||
|
||||
def __node_send_packet(self, dst_addr, group_addr=None):
|
||||
send_data = ""
|
||||
ret = False
|
||||
if group_addr is not None:
|
||||
len_t = hex(len(group_addr) * 6).split("0x")
|
||||
if len(group_addr) <= 2:
|
||||
option_list = "070" + len_t[1]
|
||||
else:
|
||||
option_list = "07" + len_t[1]
|
||||
group = ""
|
||||
for addr in group_addr:
|
||||
group += _convert_to_mesh_mac_format(addr)
|
||||
option_list += group
|
||||
dst_addr = "01:00:5E:00:00:00"
|
||||
send_data = "meshsend -S -d %s -o %s -l 100\r\n" % (dst_addr, option_list)
|
||||
else:
|
||||
if self.behavior == "broadcast":
|
||||
dst_addr = "00:00:00:00:00:00"
|
||||
send_data = "meshsend -S -d %s -l 100\r\n" % dst_addr
|
||||
elif self.behavior == "unicast":
|
||||
if self.unicast_addr == "random":
|
||||
dst_addr = random.choice(self.device_mac_list)
|
||||
else:
|
||||
dst_addr = self.unicast_addr
|
||||
send_data = "meshsend -S -d %s -l 100\r\n" % dst_addr
|
||||
elif self.behavior == "p2p":
|
||||
if self.unicast_addr == "random":
|
||||
dst_addr = random.choice(self.device_mac_list)
|
||||
else:
|
||||
dst_addr = self.unicast_addr
|
||||
send_data = "meshsend -S -d %s -t 1 -l 100\r\n" % dst_addr
|
||||
try:
|
||||
self.port.write(send_data)
|
||||
except StandardError, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
pass
|
||||
for i in range(int(CHECK_TIMEOUT / CHECK_FREQ)):
|
||||
time.sleep(CHECK_FREQ)
|
||||
with self.cache_lock:
|
||||
if self.recv_data_cache.find("+MESHSEND:OK") != -1:
|
||||
ret = True
|
||||
break
|
||||
elif self.recv_data_cache.find("+MESHSEND:ERROR") != -1:
|
||||
break
|
||||
return ret
|
||||
|
||||
|
||||
def __node_do_send(self):
|
||||
if self.behavior == "broadcast":
|
||||
if self.__node_send_packet("00:00:00:00:00:00", group_addr=None) is True:
|
||||
self.packets_sent += self.node_num
|
||||
elif self.behavior == "multicast":
|
||||
random.shuffle(self.device_mac_list)
|
||||
group_addr_list = self.device_mac_list[:MULTICAST_GROUP_LEN]
|
||||
if self.__node_send_packet("01:00:5E:00:00:00", group_addr_list) is True:
|
||||
self.packets_sent += MULTICAST_GROUP_LEN
|
||||
elif self.behavior == "unicast":
|
||||
if self.__node_send_packet(random.choice(self.device_mac_list), group_addr=None) is True:
|
||||
self.packets_sent += 1
|
||||
elif self.behavior == "p2p":
|
||||
if self.__node_send_packet(random.choice(self.device_mac_list), group_addr=None) is True:
|
||||
self.packets_sent += 1
|
||||
else:
|
||||
NativeLog.add_trace_critical("unsupported behavior [%s]" % self.behavior)
|
||||
self.exit()
|
||||
return
|
||||
|
||||
def get_sent_packets(self):
|
||||
return self.packets_sent
|
||||
|
||||
def exit(self):
|
||||
self.exit_event.set()
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
while self.exit_event.isSet() is False:
|
||||
if self.typ == "SSC":
|
||||
self.__node_do_send()
|
||||
elif self.typ == "SERVER":
|
||||
self.__server_do_send()
|
||||
else:
|
||||
NativeLog.add_trace_critical("type [%s] is neither SSC nor SERVER" % self.typ)
|
||||
break
|
||||
time.sleep(self.send_delay)
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class EntityRecvThread(threading.Thread):
|
||||
def __init__(self, port, typ, send_recv_time):
|
||||
threading.Thread.__init__(self)
|
||||
self.setDaemon(True)
|
||||
self.recv_data_cache = ""
|
||||
self.packets_recv = 0
|
||||
self.port = port
|
||||
self.typ = typ
|
||||
self.cache_lock = threading.Lock()
|
||||
self.exit_event = threading.Event()
|
||||
self.send_recv_time = send_recv_time
|
||||
pass
|
||||
|
||||
def data_recv_callback(self, data):
|
||||
# if self.typ == "SERVER":
|
||||
# NativeLog.add_prompt_trace("[data_recv_callback] server recv len %d" % len(data))
|
||||
with self.cache_lock:
|
||||
self.recv_data_cache += data
|
||||
pass
|
||||
|
||||
def __server_do_recv(self):
|
||||
while True:
|
||||
if self.recv_data_cache:
|
||||
data_cache = self.recv_data_cache
|
||||
data_cache_hex = binascii.hexlify(data_cache)
|
||||
packet_len = int(data_cache_hex[2:6], 16)
|
||||
if len(self.recv_data_cache) >= packet_len:
|
||||
time3 = time.time()
|
||||
data_catch_t = self.recv_data_cache[:packet_len]
|
||||
packet = binascii.hexlify(data_catch_t)
|
||||
index3 = int(packet[-8:], 16)
|
||||
self.send_recv_time.add_recv_time(index3, time3)
|
||||
self.recv_data_cache = self.recv_data_cache[packet_len:]
|
||||
else:
|
||||
break
|
||||
#self.packets_recv += 1
|
||||
else:
|
||||
break
|
||||
|
||||
def __node_do_recv(self):
|
||||
with self.cache_lock:
|
||||
while True:
|
||||
if self.recv_data_cache:
|
||||
match = re.search("\+MESHRECV:\d+", self.recv_data_cache)
|
||||
index = re.search(",(\d+),OK", self.recv_data_cache)
|
||||
res = re.compile(".+,\d+,OK", re.DOTALL)
|
||||
res_t = res.search(self.recv_data_cache)
|
||||
if match is not None:
|
||||
time4 = time.time()
|
||||
if index is not None:
|
||||
index4 = int(index.group(1))
|
||||
self.send_recv_time.add_recv_time(index4, time4)
|
||||
if len(res_t.group()) > 1:
|
||||
process_index = len(res_t.group(0))
|
||||
self.recv_data_cache = self.recv_data_cache[process_index:]
|
||||
else:
|
||||
process_index = len(res_t.group())
|
||||
self.recv_data_cache = self.recv_data_cache[process_index:]
|
||||
else:
|
||||
break
|
||||
else:
|
||||
break
|
||||
# self.packets_recv += 1
|
||||
else:
|
||||
break
|
||||
pass
|
||||
|
||||
def get_recv_packets(self):
|
||||
return self.packets_recv
|
||||
|
||||
def exit(self):
|
||||
self.exit_event.set()
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
while self.exit_event.isSet() is False:
|
||||
if self.typ == "SSC":
|
||||
self.__node_do_recv()
|
||||
elif self.typ == "SERVER":
|
||||
self.__server_do_recv()
|
||||
else:
|
||||
NativeLog.add_trace_critical("type [%s] is neither SSC nor SERVER" % self.typ)
|
||||
break
|
||||
time.sleep(CHECK_FREQ)
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class MeshSendRecv(PerformanceTCBase.PerformanceTCBase):
|
||||
def __init__(self, name, test_env, cmd_set, timeout, log_path):
|
||||
PerformanceTCBase.PerformanceTCBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.send_config = []
|
||||
self.test_time = 0
|
||||
self.loss_rate_standard = 0.8
|
||||
# load param from excel
|
||||
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
|
||||
# load node send config
|
||||
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.send_config.extend([" + cmd_set[i][1][j] + "])"
|
||||
exec cmd_string
|
||||
node_num = self.get_parameter("node_num")
|
||||
self.recv_cb = dict.fromkeys(["SSC%s" % (x + 1) for x in range(int(node_num))] + ["GSOC1"])
|
||||
self.recv_cb_lock = threading.Lock()
|
||||
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:
|
||||
test_time = self.test_time * 60
|
||||
send_config = self.send_config
|
||||
loss_rate_standard = self.loss_rate_standard
|
||||
node_num = self.get_parameter("node_num")
|
||||
pc_ip_list = self.get_parameter("pc_ip").split(".")
|
||||
port = self.get_parameter("test_tcp_port1")
|
||||
send_recv_time = SendRecvTime()
|
||||
except StandardError:
|
||||
return
|
||||
#create server_addr
|
||||
server_addr = ""
|
||||
for i in range(len(pc_ip_list)):
|
||||
if pc_ip_list[i] in ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]:
|
||||
server_addr = server_addr + "0" + pc_ip_list[i]
|
||||
else:
|
||||
list_t = hex(int(pc_ip_list[i])).split("0x")
|
||||
server_addr += list_t[1]
|
||||
port_t = hex(port).split("0x")
|
||||
port_t_list = list(port_t[1])
|
||||
server_addr = server_addr + port_t_list[2] + port_t_list[3] + port_t_list[0] + port_t_list[1]
|
||||
server_port = self.test_env.get_port_by_name("GSOC1")
|
||||
if server_port is None:
|
||||
return
|
||||
|
||||
# create thread dict
|
||||
thread_dict = dict.fromkeys(["SSC%s" % (x + 1) for x in range(int(node_num))] + ["GSOC1"])
|
||||
for port_name in thread_dict:
|
||||
thread_dict[port_name] = dict(zip(["tx", "rx"], [None, None]))
|
||||
device_mac_list = []
|
||||
# init recv thread & register port for SSC
|
||||
for port_name in ["SSC%s" % (x + 1) for x in range(int(node_num))]:
|
||||
port = self.test_env.get_port_by_name(port_name)
|
||||
thread_dict[port_name]["rx"] = EntityRecvThread(port, "SSC", send_recv_time)
|
||||
self.register_recv_callback(port_name, thread_dict[port_name]["rx"].data_recv_callback)
|
||||
device_mac_list.append(port.device_mac)
|
||||
|
||||
thread_dict["GSOC1"]["rx"] = EntityRecvThread(server_port, "SERVER", send_recv_time)
|
||||
self.register_recv_callback("GSOC1", thread_dict["GSOC1"]["rx"].data_recv_callback)
|
||||
|
||||
# config[0]: target_name; config[1]: behavior; config[2]: destination; config[3]:send_delay;
|
||||
for config in send_config:
|
||||
port = self.test_env.get_port_by_name(config[0])
|
||||
name = port.name
|
||||
if config[2] == "GSOC1":
|
||||
dst = server_addr[:2] + ":" + server_addr[2:4] + ":" + server_addr[4:6] + ":" + server_addr[6:8] + \
|
||||
":" + server_addr[8:10] + ":" + server_addr[10:12]
|
||||
elif config[2] == "random":
|
||||
dst = "random"
|
||||
else:
|
||||
dst = self.test_env.get_port_by_name(config[2]).device_mac
|
||||
if name != "GSOC1":
|
||||
server_addr = None
|
||||
if config[1] == "broadcast" or config[1] == "multicast":
|
||||
dst = None
|
||||
typ = "SSC" if isinstance(port, MeshPort.MeshPort) is False else "SERVER"
|
||||
thread_dict[name]["tx"] = EntitySendThread(port, config[1], dst, config[3], typ, device_mac_list,
|
||||
server_addr, send_recv_time)
|
||||
self.register_recv_callback(name, thread_dict[name]["tx"].data_recv_callback)
|
||||
pass
|
||||
|
||||
# start all thread
|
||||
for port_name in thread_dict:
|
||||
if thread_dict[port_name]["rx"] is not None:
|
||||
thread_dict[port_name]["rx"].start()
|
||||
if thread_dict[port_name]["tx"] is not None:
|
||||
thread_dict[port_name]["tx"].start()
|
||||
|
||||
# wait test time
|
||||
time.sleep(test_time)
|
||||
# close all send thread
|
||||
for port_name in thread_dict:
|
||||
if thread_dict[port_name]["tx"] is not None:
|
||||
thread_dict[port_name]["tx"].exit()
|
||||
thread_dict[port_name]["tx"].join()
|
||||
# make sure all packet received before close recv thread
|
||||
time.sleep(10)
|
||||
# close all recv thread
|
||||
for port_name in thread_dict:
|
||||
if thread_dict[port_name]["rx"] is not None:
|
||||
thread_dict[port_name]["rx"].exit()
|
||||
thread_dict[port_name]["rx"].join()
|
||||
|
||||
[max_delay_time, avg_delay_time, loss_rate] = send_recv_time.calculate()
|
||||
|
||||
NativeLog.add_trace_critical("[Mesh Send Recv Test] MAX Delay Time is %.3f" % max_delay_time)
|
||||
NativeLog.add_trace_critical("[Mesh Send Recv Test] Avg Delay Time is %.3f" % avg_delay_time)
|
||||
NativeLog.add_trace_critical("[Mesh Send Recv Test] loss rate is %.2f%%" % (loss_rate * 100))
|
||||
|
||||
# set succeed if loss rate higher than required
|
||||
if loss_rate < loss_rate_standard:
|
||||
self.set_result("Succeed")
|
||||
pass
|
||||
|
||||
@Encoding.encode_utf8(3)
|
||||
def result_check(self, port_name, data):
|
||||
if port_name in self.recv_cb:
|
||||
# if port_name == "GSOC1":
|
||||
# NativeLog.add_prompt_trace("[result_check] recv GSOC1 data len %s" % len(data))
|
||||
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)
|
||||
|
||||
# do logging
|
||||
timestamp = NativeLog.generate_timestamp()
|
||||
with self.sync_lock:
|
||||
_formatted_data = HTMLGenerator.process_one_log_item(data, self.log_index, port_name, timestamp)
|
||||
self.log_index += 1
|
||||
|
||||
self.append_to_log_file(_formatted_data)
|
||||
|
||||
NativeLog.add_all_tc_log(data, port_name, timestamp)
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1 +0,0 @@
|
||||
__all__ = ["StableCase1"]
|
@ -1,90 +0,0 @@
|
||||
|
||||
|
||||
class SSLCapability(object):
|
||||
CAPABILITY_TYPE = ["version", "cipher_suite", "fragment_size", # for hello capability negotiation
|
||||
"verify_server", "verify_client", # if support verify server/client
|
||||
"key_algorithm", "key_encoding", "pem_encryption", # what kind of private it supports
|
||||
"certificate_encoding", "certificate_digest", # what kind of certificate it supports
|
||||
]
|
||||
SSL_TYPE = ("TargetClient", "TargetServer", "PCClient", "PCServer")
|
||||
|
||||
def __init__(self, typ, **kwargs):
|
||||
assert typ in self.SSL_TYPE
|
||||
self.type = typ
|
||||
self.capability = dict.fromkeys(self.CAPABILITY_TYPE, None)
|
||||
for kw in kwargs:
|
||||
self.capability[kw] = kwargs[kw]
|
||||
for kw in self.capability:
|
||||
assert self.capability[kw] is not None
|
||||
pass
|
||||
|
||||
def get(self, kw):
|
||||
return self.capability[kw]
|
||||
|
||||
def set(self, **kwargs):
|
||||
for kw in kwargs:
|
||||
self.capability[kw] = kwargs[kw]
|
||||
pass
|
||||
|
||||
|
||||
class TargetSSLCapability(SSLCapability):
|
||||
DEFAULT_CAPABILITY = {
|
||||
"version": ["SSLv23_2"],
|
||||
"cipher_suite": ["TLS_RSA_WITH_AES_128_CBC_SHA",
|
||||
"TLS_RSA_WITH_AES_256_CBC_SHA",
|
||||
"TLS_RSA_WITH_RC4_128_SHA",
|
||||
"TLS_RSA_WITH_RC4_128_MD5"],
|
||||
"fragment_size": [2048, 4096, 8192],
|
||||
"verify_server": True,
|
||||
"verify_client": False,
|
||||
"key_algorithm": ["RSA512", "RSA1024", "RSA2048", "RSA4096"],
|
||||
"key_encoding": ["PEM", "DER"],
|
||||
"pem_encryption": [None, "aes128", "aes256"],
|
||||
"certificate_encoding": ["PEM", "DER"],
|
||||
"certificate_digest": ["md5", "sha1", "sha256", "sha384", "sha512"],
|
||||
}
|
||||
|
||||
def __init__(self, typ, **kwargs):
|
||||
assert typ == "TargetClient" or typ == "TargetServer"
|
||||
capability = dict(self.DEFAULT_CAPABILITY)
|
||||
for kw in kwargs:
|
||||
capability[kw] = kwargs[kw]
|
||||
SSLCapability.__init__(self, typ, **capability)
|
||||
pass
|
||||
pass
|
||||
|
||||
|
||||
class PCSSLCapability(SSLCapability):
|
||||
DEFAULT_CAPABILITY = {
|
||||
"version": ["SSLv23", "SSLv20", "SSLv30", "TLSv10", "TLSv11", "TLSv12"],
|
||||
"cipher_suite": ["TLS_RSA_WITH_AES_128_CBC_SHA",
|
||||
"TLS_RSA_WITH_AES_256_CBC_SHA",
|
||||
"TLS_RSA_WITH_RC4_128_SHA",
|
||||
"TLS_RSA_WITH_RC4_128_MD5",
|
||||
"TLS_DH_DSS_WITH_AES_128_CBC_SHA",
|
||||
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"],
|
||||
"fragment_size": [16384],
|
||||
"verify_server": True,
|
||||
"verify_client": True,
|
||||
"key_algorithm": ["RSA512", "RSA1024", "RSA2048", "RSA4096"],
|
||||
"key_encoding": ["PEM"],
|
||||
"pem_encryption": [None],
|
||||
"certificate_encoding": ["PEM"],
|
||||
"certificate_digest": ["md5", "sha1", "sha256", "sha384", "sha512"],
|
||||
}
|
||||
|
||||
def __init__(self, typ):
|
||||
assert typ == "PCClient" or typ == "PCServer"
|
||||
SSLCapability.__init__(self, typ, **self.DEFAULT_CAPABILITY)
|
||||
pass
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
pc = PCSSLCapability("PCClient")
|
||||
target = TargetSSLCapability("TargetClient")
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,333 +0,0 @@
|
||||
from PKI import PKIDict, PKIItem
|
||||
import Parameter
|
||||
|
||||
|
||||
def multiply_2_lists(list1, list2):
|
||||
def make_list(li):
|
||||
if not isinstance(li, list):
|
||||
li = [li]
|
||||
return li
|
||||
list1 = make_list(list1)
|
||||
list2 = make_list(list2)
|
||||
ret = []
|
||||
for a in list1:
|
||||
for b in list2:
|
||||
ret.append(make_list(a) + make_list(b))
|
||||
return ret
|
||||
|
||||
|
||||
def list_multiply(list1, *args):
|
||||
ret = list1
|
||||
for arg in args:
|
||||
ret = multiply_2_lists(ret, arg)
|
||||
return ret
|
||||
|
||||
|
||||
def list_and(list1, list2):
|
||||
ret = []
|
||||
for item in list1:
|
||||
if item in list2:
|
||||
ret.append(item)
|
||||
return ret
|
||||
|
||||
|
||||
class ComputeResult(object):
|
||||
NEGOTIATION_CONFIG = ["client_version", "client_cipher_suite", "client_fragment_size",
|
||||
"server_version", "server_cipher_suite", "server_fragment_size"]
|
||||
CERT_KEY_CONFIG = ["verify_server", "verify_client",
|
||||
"client_trust_anchor", "client_certificate", "client_key",
|
||||
"server_trust_anchor", "server_certificate", "server_key"]
|
||||
|
||||
TYPE_CONTEXT = "context"
|
||||
TYPE_NEGOTIATION = "negotiation"
|
||||
TYPE_CERT_KEY = "cert_key"
|
||||
TYPE_SEND_PARAM = "send_param"
|
||||
|
||||
# results
|
||||
SUCCEED = 0
|
||||
CREATE_CONTEXT_FAIL = 1
|
||||
HANDSHAKE_FAIL = 2
|
||||
CERT_KEY_FAIL = 3
|
||||
|
||||
def __init__(self, client_capability, server_capability):
|
||||
self.client_capability = client_capability
|
||||
self.server_capability = server_capability
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def __check_cert(cert, capability, check_encoding=True):
|
||||
ret = True
|
||||
if cert.name is not None:
|
||||
if check_encoding is True:
|
||||
if cert.digest not in capability.get("certificate_digest") \
|
||||
or cert.key_algorithm not in capability.get("key_algorithm") \
|
||||
or cert.file_encoding not in capability.get("certificate_encoding"):
|
||||
ret = False
|
||||
else:
|
||||
if cert.digest not in capability.get("certificate_digest") \
|
||||
or cert.key_algorithm not in capability.get("key_algorithm"):
|
||||
ret = False
|
||||
return ret
|
||||
|
||||
@staticmethod
|
||||
def __check_key(key, capability, check_encoding=True):
|
||||
ret = True
|
||||
if key.name is not None:
|
||||
if check_encoding is True:
|
||||
if key.algorithm not in capability.get("key_algorithm") \
|
||||
or key.file_encoding not in capability.get("key_encoding") \
|
||||
or key.file_encryption not in capability.get("pem_encryption"):
|
||||
ret = False
|
||||
else:
|
||||
if key.algorithm not in capability.get("key_algorithm") \
|
||||
or key.file_encryption not in capability.get("pem_encryption"):
|
||||
ret = False
|
||||
return ret
|
||||
|
||||
# compute result functions
|
||||
def check_context(self, config):
|
||||
result = self.SUCCEED
|
||||
check_list = [(self.__check_cert, PKIItem.Certificate(config["client_trust_anchor"]),
|
||||
self.client_capability),
|
||||
(self.__check_cert, PKIItem.Certificate(config["client_certificate"]),
|
||||
self.client_capability),
|
||||
(self.__check_key, PKIItem.PrivateKey(config["client_key"]),
|
||||
self.client_capability),
|
||||
(self.__check_cert, PKIItem.Certificate(config["server_trust_anchor"]),
|
||||
self.server_capability),
|
||||
(self.__check_cert, PKIItem.Certificate(config["server_certificate"]),
|
||||
self.server_capability),
|
||||
(self.__check_key, PKIItem.PrivateKey(config["server_key"]),
|
||||
self.server_capability)]
|
||||
for _check in check_list:
|
||||
if _check[0](_check[1], _check[2]) is False:
|
||||
result = self.CREATE_CONTEXT_FAIL
|
||||
break
|
||||
return result
|
||||
|
||||
def check_negotiation_param(self, config):
|
||||
result = self.SUCCEED
|
||||
# first check version
|
||||
while True:
|
||||
if Parameter.VERSION[config["client_version"]]\
|
||||
& Parameter.VERSION[config["server_version"]] == 0:
|
||||
result = self.HANDSHAKE_FAIL
|
||||
break
|
||||
# check cipher suite
|
||||
supported_cipher_suite = list_and(self.client_capability.get("cipher_suite"),
|
||||
self.server_capability.get("cipher_suite"))
|
||||
if config["client_cipher_suite"] not in supported_cipher_suite\
|
||||
or config["server_cipher_suite"] not in supported_cipher_suite\
|
||||
or config["client_cipher_suite"] != config["server_cipher_suite"]:
|
||||
result = self.HANDSHAKE_FAIL
|
||||
break
|
||||
break
|
||||
return result
|
||||
|
||||
# check cert key, if it can be supported by both client and server, if it matches
|
||||
def __check_cert_key_content(self, cert, key):
|
||||
if self.__check_cert(cert, self.client_capability, check_encoding=False) is True\
|
||||
and self.__check_cert(cert, self.server_capability, check_encoding=False) is True \
|
||||
and self.__check_key(key, self.client_capability, check_encoding=False) is True \
|
||||
and self.__check_key(key, self.server_capability, check_encoding=False) is True \
|
||||
and key.name.find(cert.private_key) != -1:
|
||||
result = True
|
||||
else:
|
||||
result = False
|
||||
return result
|
||||
|
||||
def __verify_ca(self, ca, cert, capability):
|
||||
result = True
|
||||
while True:
|
||||
# if ca supported
|
||||
if self.__check_cert(ca, capability) is False:
|
||||
result = False
|
||||
break
|
||||
# check if ca in cert chain
|
||||
try:
|
||||
index = cert.cert_chain.index(ca.name)
|
||||
except StandardError:
|
||||
result = False
|
||||
break
|
||||
|
||||
# for pem cert, it contains cert chain to issuer, any cert in chain works
|
||||
# der cert do not contain cert chain
|
||||
# only der root cert verify L1 cert and root cert works
|
||||
if cert.file_encoding == "DER":
|
||||
if len(cert.cert_chain) > 2 and index != len(cert.cert_chain) - 1:
|
||||
result = False
|
||||
break
|
||||
# check if all certs in before trust anchor supported
|
||||
for cert_name in cert.cert_chain[1:index]:
|
||||
_cert = PKIItem.Certificate(cert_name + ".pem")
|
||||
if self.__check_cert(_cert, capability) is False:
|
||||
result = False
|
||||
break
|
||||
break
|
||||
return result
|
||||
|
||||
def __check_verify_client(self, client_cert, client_key, server_ca):
|
||||
result = self.__check_cert_key_content(client_cert, client_key)
|
||||
if result is True:
|
||||
result = self.__verify_ca(server_ca, client_cert, self.server_capability)
|
||||
return result
|
||||
|
||||
def __check_verify_server(self, client_ca, server_cert):
|
||||
return self.__verify_ca(client_ca, server_cert, self.client_capability)
|
||||
|
||||
def check_cert_key(self, config):
|
||||
result = self.SUCCEED
|
||||
while True: # break if when anything failed
|
||||
if (config["verify_server"] is True and self.client_capability.get("verify_server") is False) \
|
||||
or (config["verify_client"] is True and
|
||||
(self.server_capability.get("verify_client") is False or
|
||||
self.client_capability.get("verify_client") is False)):
|
||||
result = self.CERT_KEY_FAIL
|
||||
break
|
||||
|
||||
server_cert = PKIItem.Certificate(config["server_certificate"])
|
||||
server_key = PKIItem.PrivateKey(config["server_key"])
|
||||
server_ca = PKIItem.Certificate(config["server_trust_anchor"])
|
||||
client_cert = PKIItem.Certificate(config["client_certificate"])
|
||||
client_key = PKIItem.PrivateKey(config["client_key"])
|
||||
client_ca = PKIItem.Certificate(config["client_trust_anchor"])
|
||||
# always check server cert key
|
||||
if self.__check_cert_key_content(server_cert, server_key) is False:
|
||||
result = self.CERT_KEY_FAIL
|
||||
break
|
||||
# if require to verify server
|
||||
if config["verify_server"] is True:
|
||||
if self.__check_verify_server(client_ca, server_cert) is False:
|
||||
result = self.CERT_KEY_FAIL
|
||||
break
|
||||
# if require to verify client
|
||||
if config["verify_client"] is True:
|
||||
if self.__check_verify_client(client_cert, client_key, server_ca) is False:
|
||||
result = self.CERT_KEY_FAIL
|
||||
break
|
||||
break
|
||||
return result
|
||||
|
||||
CHECK_FUNC = {
|
||||
TYPE_CONTEXT: check_context,
|
||||
TYPE_NEGOTIATION: check_negotiation_param,
|
||||
TYPE_CERT_KEY: check_cert_key,
|
||||
}
|
||||
CONFIG_KEY = {
|
||||
TYPE_CONTEXT: CERT_KEY_CONFIG,
|
||||
TYPE_NEGOTIATION: NEGOTIATION_CONFIG,
|
||||
TYPE_CERT_KEY: CERT_KEY_CONFIG,
|
||||
}
|
||||
|
||||
def compute_result(self, typ, config_list):
|
||||
succeed_list = []
|
||||
fail_list = []
|
||||
for config in config_list:
|
||||
if self.CHECK_FUNC[typ](self, dict(zip(self.CONFIG_KEY[typ], config))) != self.SUCCEED:
|
||||
fail_list.append(config)
|
||||
else:
|
||||
succeed_list.append(config)
|
||||
return succeed_list, fail_list
|
||||
pass
|
||||
|
||||
|
||||
class GenerateTestConfig(ComputeResult):
|
||||
TEST_CONFIG = ComputeResult.NEGOTIATION_CONFIG + \
|
||||
ComputeResult.CERT_KEY_CONFIG
|
||||
|
||||
def __init__(self, client_capability, server_capability):
|
||||
ComputeResult.__init__(self, client_capability, server_capability)
|
||||
self.key_dict = PKIDict.PKIDict.KEY_DICT
|
||||
self.cert_dict = PKIDict.PKIDict.CERT_DICT
|
||||
pass
|
||||
|
||||
def generate_negotiation_config(self):
|
||||
_config = list_multiply(self.client_capability.get("version"),
|
||||
self.client_capability.get("cipher_suite"),
|
||||
self.client_capability.get("fragment_size"),
|
||||
self.server_capability.get("version"),
|
||||
self.server_capability.get("cipher_suite"),
|
||||
self.server_capability.get("fragment_size"))
|
||||
return self.compute_result(self.TYPE_NEGOTIATION, _config)
|
||||
|
||||
def __choose_cert_key(self, verify_server, verify_client,
|
||||
client_ca_opt, client_cert_key_opt,
|
||||
server_ca_opt, server_cert_key_opt):
|
||||
pass
|
||||
|
||||
# CERT_KEY_CONFIG = ["verify_server", "verify_client",
|
||||
# "client_trust_anchor", "client_certificate", "client_key",
|
||||
# "server_trust_anchor", "server_certificate", "server_key"]
|
||||
def generate_cert_key_config(self):
|
||||
# first handle not verify certificate case
|
||||
_config_list = []
|
||||
for cert in PKIDict.PKIDict.CERT_DICT:
|
||||
for key in PKIDict.PKIDict.KEY_DICT:
|
||||
_config_list.append([False, False, None, None, None, None, cert, key])
|
||||
cert_key_succeed, context_fail = self.compute_result(self.TYPE_CONTEXT, _config_list)
|
||||
cert_key_succeed, cert_key_fail = self.compute_result(self.TYPE_CERT_KEY, cert_key_succeed)
|
||||
key_cert_pair = [[x[6], x[7]] for x in cert_key_succeed]
|
||||
# for succeed config, do server cert verify
|
||||
_config_list = []
|
||||
for _config in cert_key_succeed:
|
||||
for cert in PKIDict.PKIDict.CERT_DICT:
|
||||
_config_list.append([True, False, cert, None, None,
|
||||
None, _config[6], _config[7]])
|
||||
_cert_key_succeed, _context_fail = self.compute_result(self.TYPE_CONTEXT, _config_list)
|
||||
context_fail += _context_fail
|
||||
_cert_key_succeed, _cert_key_fail = self.compute_result(self.TYPE_CERT_KEY, _cert_key_succeed)
|
||||
cert_key_fail += _cert_key_fail
|
||||
cert_key_succeed += _cert_key_succeed
|
||||
# for succeed config, do client verify
|
||||
_config_list = []
|
||||
for _config in _cert_key_succeed:
|
||||
for key_cert in key_cert_pair:
|
||||
_config_list.append([True, True, _config[2], key_cert[0], key_cert[1],
|
||||
key_cert[0], _config[6], _config[7]])
|
||||
_cert_key_succeed, _context_fail = self.compute_result(self.TYPE_CONTEXT, _config_list)
|
||||
context_fail += _context_fail
|
||||
_cert_key_succeed, _cert_key_fail = self.compute_result(self.TYPE_CERT_KEY, _cert_key_succeed)
|
||||
cert_key_fail += _cert_key_fail
|
||||
cert_key_succeed += _cert_key_succeed
|
||||
# only verify client not verify server
|
||||
_config_list = []
|
||||
for _config in _cert_key_succeed:
|
||||
_config_list.append([False, True, None,
|
||||
_config[3], _config[4], _config[5], _config[6], _config[7]])
|
||||
_cert_key_succeed, _context_fail = self.compute_result(self.TYPE_CONTEXT, _config_list)
|
||||
context_fail += _context_fail
|
||||
_cert_key_succeed, _cert_key_fail = self.compute_result(self.TYPE_CERT_KEY, _cert_key_succeed)
|
||||
cert_key_fail += _cert_key_fail
|
||||
cert_key_succeed += _cert_key_succeed
|
||||
return cert_key_succeed, context_fail, cert_key_fail
|
||||
|
||||
|
||||
class ConfigUtility(GenerateTestConfig):
|
||||
# test config
|
||||
_TEST_CONFIG_DICT_KEY = ("config", "result")
|
||||
|
||||
def __init__(self, client_capability, server_capability):
|
||||
GenerateTestConfig.__init__(self, client_capability, server_capability)
|
||||
pass
|
||||
|
||||
def get_all_test_config(self):
|
||||
negotiation_succeed, negotiation_fail = self.generate_negotiation_config()
|
||||
cert_key_succeed, context_fail, cert_key_fail = self.generate_cert_key_config()
|
||||
succeed_config = list_multiply(negotiation_succeed, cert_key_succeed)
|
||||
context_fail_config = list_multiply([negotiation_succeed[0]], context_fail)
|
||||
negotiation_fail_config = list_multiply(negotiation_fail, [cert_key_succeed[0]])
|
||||
cert_key_fail_config = list_multiply([negotiation_succeed[0]], cert_key_fail)
|
||||
return dict(zip(["succeed", "context_fail", "negotiation_fail", "cert_key_fail"],
|
||||
[[dict(zip(self.TEST_CONFIG, x)) for x in succeed_config],
|
||||
[dict(zip(self.TEST_CONFIG, x)) for x in context_fail_config],
|
||||
[dict(zip(self.TEST_CONFIG, x)) for x in negotiation_fail_config],
|
||||
[dict(zip(self.TEST_CONFIG, x)) for x in cert_key_fail_config]]))
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,56 +0,0 @@
|
||||
|
||||
|
||||
VERSION = {
|
||||
"SSLv23": 0x1F,
|
||||
"SSLv23_2": 0x1C, # current target ssl implementation do not support SSLv20 and TLSv12
|
||||
"SSLv20": 0x01,
|
||||
"SSLv30": 0x02,
|
||||
"TLSv10": 0x04,
|
||||
"TLSv11": 0x08,
|
||||
"TLSv12": 0x10,
|
||||
}
|
||||
|
||||
|
||||
CIPHER_SUITE = {
|
||||
# supported algorithm
|
||||
"TLS_RSA_WITH_AES_128_CBC_SHA": "AES128-SHA",
|
||||
"TLS_RSA_WITH_AES_256_CBC_SHA": "AES256-SHA",
|
||||
"TLS_RSA_WITH_RC4_128_SHA": "RC4-SHA",
|
||||
"TLS_RSA_WITH_RC4_128_MD5": "RC4-MD5",
|
||||
"TLS_DH_DSS_WITH_AES_128_CBC_SHA": "DH-DSS-AES128-SHA",
|
||||
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256": "ECDHE-RSA-AES128-GCM-SHA256",
|
||||
}
|
||||
|
||||
|
||||
FRAGMENT_SIZE = {
|
||||
"SIZE_DEFAULT": 0,
|
||||
"SIZE_512": 512,
|
||||
"SIZE_1024": 1024,
|
||||
"SIZE_2048": 2048,
|
||||
"SIZE_4096": 4096,
|
||||
"SIZE_8192": 8192,
|
||||
}
|
||||
|
||||
|
||||
VERIFY_OPTION = {
|
||||
"NOT_VERIFY": "NOT_VERIFY",
|
||||
"VERIFY": "VERIFY",
|
||||
}
|
||||
|
||||
|
||||
SEND_OPTION = {
|
||||
"MAX_SEND_SIZE_512": 512,
|
||||
"MAX_SEND_SIZE_1K": 1024,
|
||||
"MAX_SEND_SIZE_2K": 2048,
|
||||
"MAX_SEND_SIZE_4K": 4096,
|
||||
"MAX_SEND_SIZE_8K": 8192,
|
||||
"MAX_SEND_SIZE_16K": 16384,
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,498 +0,0 @@
|
||||
import socket
|
||||
import ssl
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import threading
|
||||
|
||||
import Parameter
|
||||
from PKI import PKIDict
|
||||
from PKI import PKIItem
|
||||
from NativeLog import NativeLog
|
||||
|
||||
|
||||
class SerialPortCheckFail(StandardError):
|
||||
pass
|
||||
|
||||
|
||||
class SSLHandlerFail(StandardError):
|
||||
pass
|
||||
|
||||
|
||||
class PCFail(StandardError):
|
||||
pass
|
||||
|
||||
|
||||
class TargetFail(StandardError):
|
||||
pass
|
||||
|
||||
|
||||
def ssl_handler_wrapper(handler_type):
|
||||
if handler_type == "PC":
|
||||
exception_type = PCFail
|
||||
elif handler_type == "Target":
|
||||
exception_type = TargetFail
|
||||
else:
|
||||
exception_type = None
|
||||
|
||||
def _handle_func(func):
|
||||
def _handle_args(*args, **kwargs):
|
||||
try:
|
||||
ret = func(*args, **kwargs)
|
||||
except StandardError, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
raise exception_type(str(e))
|
||||
return ret
|
||||
return _handle_args
|
||||
return _handle_func
|
||||
|
||||
|
||||
class SerialPort(object):
|
||||
def __init__(self, tc_action, port_name):
|
||||
self.tc_action = tc_action
|
||||
self.port_name = port_name
|
||||
|
||||
def flush(self):
|
||||
self.tc_action.flush_data(self.port_name)
|
||||
|
||||
def write_line(self, data):
|
||||
self.tc_action.serial_write_line(self.port_name, data)
|
||||
|
||||
def check(self, condition, timeout=10):
|
||||
if self.tc_action.check_response(self.port_name, condition, timeout) is False:
|
||||
raise SerialPortCheckFail("serial port check fail, condition is %s" % condition)
|
||||
|
||||
def read_data(self):
|
||||
return self.tc_action.serial_read_data(self.port_name)
|
||||
pass
|
||||
|
||||
|
||||
class SSLHandler(object):
|
||||
# ssl operation timeout is 30 seconds
|
||||
TIMEOUT = 30
|
||||
|
||||
def __init__(self, typ, config, serial_port):
|
||||
self.type = typ
|
||||
self.config = config
|
||||
self.timeout = self.TIMEOUT
|
||||
self.serial_port = serial_port
|
||||
self.accept_thread = None
|
||||
self.data_validation = False
|
||||
|
||||
def set_timeout(self, timeout):
|
||||
self.timeout = timeout
|
||||
|
||||
def init_context(self):
|
||||
pass
|
||||
|
||||
def connect(self, remote_ip, remote_port, local_ip=0, local_port=0):
|
||||
pass
|
||||
|
||||
def listen(self, local_port=0, local_ip=0):
|
||||
pass
|
||||
|
||||
def send(self, size, data):
|
||||
pass
|
||||
|
||||
def recv(self, length, timeout):
|
||||
pass
|
||||
|
||||
def set_data_validation(self, validation):
|
||||
pass
|
||||
|
||||
def close(self):
|
||||
if self.accept_thread is not None:
|
||||
self.accept_thread.exit()
|
||||
self.accept_thread.join(5)
|
||||
pass
|
||||
|
||||
|
||||
class TargetSSLHandler(SSLHandler):
|
||||
def __init__(self, typ, config, serial_port):
|
||||
SSLHandler.__init__(self, typ, config, serial_port)
|
||||
self.ssl_id = None
|
||||
self.server_id = None
|
||||
|
||||
@ssl_handler_wrapper("Target")
|
||||
def init_context(self):
|
||||
self.serial_port.flush()
|
||||
self.serial_port.write_line("soc -T")
|
||||
self.serial_port.check("+CLOSEALL")
|
||||
|
||||
if self.type == "client":
|
||||
version = Parameter.VERSION[self.config["client_version"]]
|
||||
fragment = self.config["client_fragment_size"]
|
||||
ca = self.config["client_trust_anchor"]
|
||||
cert = self.config["client_certificate"]
|
||||
key = self.config["client_key"]
|
||||
verify_required = 0x01 if self.config["verify_server"] is True else 0x00
|
||||
context_type = 1
|
||||
else:
|
||||
version = Parameter.VERSION[self.config["server_version"]]
|
||||
fragment = self.config["server_fragment_size"]
|
||||
ca = self.config["server_trust_anchor"]
|
||||
cert = self.config["server_certificate"]
|
||||
key = self.config["server_key"]
|
||||
verify_required = 0x02 if self.config["verify_client"] is True else 0x00
|
||||
context_type = 2
|
||||
ssc_cmd = "ssl -I -t %u -r %u -v %u -o %u" % (context_type, fragment, version, verify_required)
|
||||
|
||||
if ca is not None:
|
||||
_index = PKIDict.PKIDict.CERT_DICT[ca]
|
||||
ssc_cmd += " -a %d" % _index
|
||||
if cert is not None:
|
||||
_index = PKIDict.PKIDict.CERT_DICT[cert]
|
||||
ssc_cmd += " -c %d" % _index
|
||||
if key is not None:
|
||||
_index = PKIDict.PKIDict.KEY_DICT[key]
|
||||
ssc_cmd += " -k %d" % _index
|
||||
# write command and check result
|
||||
self.serial_port.flush()
|
||||
self.serial_port.write_line(ssc_cmd)
|
||||
self.serial_port.check(["+SSL:OK", "AND", "!+SSL:ERROR"])
|
||||
|
||||
@ssl_handler_wrapper("Target")
|
||||
def connect(self, remote_ip, remote_port, local_ip=0, local_port=0):
|
||||
self.serial_port.flush()
|
||||
self.serial_port.write_line("soc -B -t SSL -i %s -p %s" % (local_ip, local_port))
|
||||
self.serial_port.check(["OK", "AND", "!ERROR"])
|
||||
self.serial_port.flush()
|
||||
self.serial_port.write_line("soc -C -s 0 -i %s -p %s" % (remote_ip, remote_port))
|
||||
self.serial_port.check(["OK", "AND", "!ERROR"], timeout=30)
|
||||
self.ssl_id = 0
|
||||
pass
|
||||
|
||||
def accept_succeed(self):
|
||||
self.ssl_id = 1
|
||||
|
||||
class Accept(threading.Thread):
|
||||
def __init__(self, serial_port, succeed_cb):
|
||||
threading.Thread.__init__(self)
|
||||
self.setDaemon(True)
|
||||
self.serial_port = serial_port
|
||||
self.succeed_cb = succeed_cb
|
||||
self.exit_flag = threading.Event()
|
||||
|
||||
def run(self):
|
||||
while self.exit_flag.isSet() is False:
|
||||
try:
|
||||
self.serial_port.check("+ACCEPT:", timeout=1)
|
||||
self.succeed_cb()
|
||||
break
|
||||
except StandardError:
|
||||
pass
|
||||
|
||||
def exit(self):
|
||||
self.exit_flag.set()
|
||||
|
||||
@ssl_handler_wrapper("Target")
|
||||
def listen(self, local_port=0, local_ip=0):
|
||||
self.serial_port.flush()
|
||||
self.serial_port.write_line("soc -B -t SSL -i %s -p %s" % (local_ip, local_port))
|
||||
self.serial_port.check(["OK", "AND", "!ERROR"])
|
||||
self.serial_port.flush()
|
||||
self.serial_port.write_line("soc -L -s 0")
|
||||
self.serial_port.check(["OK", "AND", "!ERROR"])
|
||||
self.server_id = 0
|
||||
self.accept_thread = self.Accept(self.serial_port, self.accept_succeed)
|
||||
self.accept_thread.start()
|
||||
pass
|
||||
|
||||
@ssl_handler_wrapper("Target")
|
||||
def send(self, size=10, data=None):
|
||||
if data is not None:
|
||||
size = len(data)
|
||||
self.serial_port.flush()
|
||||
self.serial_port.write_line("soc -S -s %s -l %s" % (self.ssl_id, size))
|
||||
self.serial_port.check(["OK", "AND", "!ERROR"])
|
||||
pass
|
||||
|
||||
@ssl_handler_wrapper("Target")
|
||||
def recv(self, length, timeout=SSLHandler.TIMEOUT):
|
||||
pattern = re.compile("\+RECV:\d+,(\d+)\r\n")
|
||||
data_len = 0
|
||||
data = ""
|
||||
time1 = time.time()
|
||||
while time.time() - time1 < timeout:
|
||||
data += self.serial_port.read_data()
|
||||
if self.data_validation is True:
|
||||
if "+DATA_ERROR" in data:
|
||||
raise SSLHandlerFail("target data validation fail")
|
||||
while True:
|
||||
match = pattern.search(data)
|
||||
if match is None:
|
||||
break
|
||||
else:
|
||||
data_len += int(match.group(1))
|
||||
data = data[data.find(match.group())+len(match.group()):]
|
||||
if data_len >= length:
|
||||
result = True
|
||||
break
|
||||
else:
|
||||
result = False
|
||||
if result is False:
|
||||
raise SSLHandlerFail("Target recv fail")
|
||||
|
||||
def set_data_validation(self, validation):
|
||||
self.data_validation = validation
|
||||
self.serial_port.flush()
|
||||
self.serial_port.write_line("soc -V -s %s -o %s" % (self.ssl_id, 1 if validation is True else 0))
|
||||
self.serial_port.check(["OK", "AND", "!ERROR"])
|
||||
|
||||
@ssl_handler_wrapper("Target")
|
||||
def close(self):
|
||||
SSLHandler.close(self)
|
||||
self.serial_port.flush()
|
||||
self.serial_port.write_line("ssl -D")
|
||||
self.serial_port.check(["+SSL:OK", "OR", "+SSL:ERROR"])
|
||||
self.serial_port.write_line("soc -T")
|
||||
self.serial_port.check("+CLOSEALL")
|
||||
pass
|
||||
|
||||
pass
|
||||
|
||||
|
||||
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 PCSSLHandler(SSLHandler):
|
||||
PROTOCOL_MAPPING = {
|
||||
"SSLv23": ssl.PROTOCOL_SSLv23,
|
||||
"SSLv23_2": ssl.PROTOCOL_SSLv23,
|
||||
"SSLv20": ssl.PROTOCOL_SSLv2,
|
||||
"SSLv30": ssl.PROTOCOL_SSLv3,
|
||||
"TLSv10": ssl.PROTOCOL_TLSv1,
|
||||
"TLSv11": ssl.PROTOCOL_TLSv1_1,
|
||||
"TLSv12": ssl.PROTOCOL_TLSv1_2,
|
||||
}
|
||||
CERT_FOLDER = os.path.join(".", "PKI", PKIDict.PKIDict.CERT_FOLDER)
|
||||
KEY_FOLDER = os.path.join(".", "PKI", PKIDict.PKIDict.KEY_FOLDER)
|
||||
|
||||
def __init__(self, typ, config, serial_port):
|
||||
SSLHandler.__init__(self, typ, config, serial_port)
|
||||
self.ssl_context = None
|
||||
self.ssl = None
|
||||
self.server_sock = None
|
||||
self.send_index = 0
|
||||
self.recv_index = 0
|
||||
|
||||
class InitContextThread(threading.Thread):
|
||||
def __init__(self, handler, version, cipher_suite, ca, cert, key, verify_required, remote_cert):
|
||||
threading.Thread.__init__(self)
|
||||
self.setDaemon(True)
|
||||
self.handler = handler
|
||||
self.version = version
|
||||
self.cipher_suite = cipher_suite
|
||||
self.ca = ca
|
||||
self.cert = cert
|
||||
self.key = key
|
||||
self.verify_required = verify_required
|
||||
self.remote_cert = remote_cert
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def handle_cert(cert_file, ca_file):
|
||||
cert = PKIItem.Certificate()
|
||||
cert.parse_file(cert_file)
|
||||
ca = PKIItem.Certificate()
|
||||
ca.parse_file(ca_file)
|
||||
if cert.file_encoding == "PEM" and ca.name in cert.cert_chain:
|
||||
cert_chain_t = cert.cert_chain[1:cert.cert_chain.index(ca.name)]
|
||||
ret = ["%s.pem" % c for c in cert_chain_t]
|
||||
else:
|
||||
ret = []
|
||||
return ret
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
ssl_context = ssl.SSLContext(self.version)
|
||||
# cipher suite
|
||||
ssl_context.set_ciphers(self.cipher_suite)
|
||||
if self.ca is not None:
|
||||
ssl_context.load_verify_locations(cafile=os.path.join(self.handler.CERT_FOLDER, self.ca))
|
||||
# python ssl can't verify cert chain, don't know why
|
||||
# need to load cert between cert and ca for pem (pem cert contains cert chain)
|
||||
if self.remote_cert is not None:
|
||||
cert_chain = self.handle_cert(self.remote_cert, self.ca)
|
||||
for c in cert_chain:
|
||||
NativeLog.add_trace_info("load ca chain %s" % c)
|
||||
ssl_context.load_verify_locations(cafile=os.path.join(self.handler.CERT_FOLDER, c))
|
||||
if self.cert is not None:
|
||||
cert = os.path.join(self.handler.CERT_FOLDER, self.cert)
|
||||
key = os.path.join(self.handler.KEY_FOLDER, self.key)
|
||||
ssl_context.load_cert_chain(cert, keyfile=key)
|
||||
if self.verify_required is True:
|
||||
ssl_context.verify_mode = ssl.CERT_REQUIRED
|
||||
else:
|
||||
ssl_context.verify_mode = ssl.CERT_NONE
|
||||
self.handler.ssl_context = ssl_context
|
||||
except StandardError, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
pass
|
||||
pass
|
||||
|
||||
@ssl_handler_wrapper("PC")
|
||||
def init_context(self):
|
||||
if self.type == "client":
|
||||
version = self.PROTOCOL_MAPPING[self.config["client_version"]]
|
||||
cipher_suite = Parameter.CIPHER_SUITE[self.config["client_cipher_suite"]]
|
||||
ca = self.config["client_trust_anchor"]
|
||||
cert = self.config["client_certificate"]
|
||||
key = self.config["client_key"]
|
||||
verify_required = self.config["verify_server"]
|
||||
remote_cert = self.config["server_certificate"]
|
||||
else:
|
||||
version = self.PROTOCOL_MAPPING[self.config["server_version"]]
|
||||
cipher_suite = Parameter.CIPHER_SUITE[self.config["server_cipher_suite"]]
|
||||
ca = self.config["server_trust_anchor"]
|
||||
cert = self.config["server_certificate"]
|
||||
key = self.config["server_key"]
|
||||
verify_required = self.config["verify_client"]
|
||||
remote_cert = self.config["client_certificate"]
|
||||
|
||||
_init_context = self.InitContextThread(self, version, cipher_suite, ca, cert, key, verify_required, remote_cert)
|
||||
_init_context.start()
|
||||
_init_context.join(5)
|
||||
if self.ssl_context is None:
|
||||
raise StandardError("Init Context Fail")
|
||||
|
||||
pass
|
||||
|
||||
@ssl_handler_wrapper("PC")
|
||||
def connect(self, remote_ip, remote_port, local_ip=0, local_port=0):
|
||||
sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
|
||||
# reuse socket in TIME_WAIT state
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
sock.settimeout(self.timeout)
|
||||
sock.bind((local_ip, local_port))
|
||||
self.ssl = self.ssl_context.wrap_socket(sock)
|
||||
self.ssl.connect((remote_ip, remote_port))
|
||||
pass
|
||||
|
||||
def accept_succeed(self, ssl_new):
|
||||
ssl_new.settimeout(self.timeout)
|
||||
self.ssl = ssl_new
|
||||
|
||||
class Accept(threading.Thread):
|
||||
def __init__(self, server_sock, ssl_context, succeed_cb):
|
||||
threading.Thread.__init__(self)
|
||||
self.setDaemon(True)
|
||||
self.server_sock = server_sock
|
||||
self.ssl_context = ssl_context
|
||||
self.succeed_cb = succeed_cb
|
||||
self.exit_flag = threading.Event()
|
||||
|
||||
def run(self):
|
||||
while self.exit_flag.isSet() is False:
|
||||
try:
|
||||
new_socket, addr = self.server_sock.accept()
|
||||
ssl_new = self.ssl_context.wrap_socket(new_socket, server_side=True)
|
||||
self.succeed_cb(ssl_new)
|
||||
break
|
||||
except StandardError:
|
||||
pass
|
||||
pass
|
||||
|
||||
def exit(self):
|
||||
self.exit_flag.set()
|
||||
|
||||
@ssl_handler_wrapper("PC")
|
||||
def listen(self, local_port=0, local_ip=0):
|
||||
self.server_sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
|
||||
# reuse socket in TIME_WAIT state
|
||||
self.server_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
self.server_sock.settimeout(1)
|
||||
self.server_sock.bind((local_ip, local_port))
|
||||
self.server_sock.listen(5)
|
||||
self.accept_thread = self.Accept(self.server_sock, self.ssl_context, self.accept_succeed)
|
||||
self.accept_thread.start()
|
||||
pass
|
||||
|
||||
@ssl_handler_wrapper("PC")
|
||||
def send(self, size=10, data=None):
|
||||
if data is None:
|
||||
self.ssl.send(make_validation_data(size, self.send_index))
|
||||
if self.data_validation is True:
|
||||
self.send_index += size
|
||||
else:
|
||||
self.ssl.send(data)
|
||||
|
||||
@ssl_handler_wrapper("PC")
|
||||
def recv(self, length, timeout=SSLHandler.TIMEOUT, data_validation=False):
|
||||
time1 = time.time()
|
||||
data_len = 0
|
||||
while time.time() - time1 < timeout:
|
||||
data = self.ssl.read()
|
||||
|
||||
if data_validation is True and len(data) > 0:
|
||||
if verify_data(data, self.recv_index) is False:
|
||||
raise SSLHandlerFail("PC data validation fail, index is %s" % self.recv_index)
|
||||
self.recv_index += len(data)
|
||||
data_len += len(data)
|
||||
if data_len >= length:
|
||||
result = True
|
||||
break
|
||||
else:
|
||||
result = False
|
||||
if result is False:
|
||||
raise SSLHandlerFail("PC recv fail")
|
||||
|
||||
def set_data_validation(self, validation):
|
||||
self.data_validation = validation
|
||||
|
||||
@ssl_handler_wrapper("PC")
|
||||
def close(self):
|
||||
SSLHandler.close(self)
|
||||
if self.ssl is not None:
|
||||
self.ssl.close()
|
||||
self.ssl = None
|
||||
if self.server_sock is not None:
|
||||
self.server_sock.close()
|
||||
self.server_sock = None
|
||||
del self.ssl_context
|
||||
|
||||
|
||||
def main():
|
||||
ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
|
||||
# cipher suite
|
||||
ssl_context.set_ciphers("AES256-SHA")
|
||||
ssl_context.load_cert_chain("D:\workspace\\auto_test_script\PKI\Certificate\\"
|
||||
"L2CertRSA512sha1_L1CertRSA512sha1_RootCertRSA512sha1.pem",
|
||||
keyfile="D:\workspace\\auto_test_script\PKI\Key\PrivateKey2RSA512.pem")
|
||||
ssl_context.verify_mode = ssl.CERT_NONE
|
||||
server_sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
|
||||
# reuse socket in TIME_WAIT state
|
||||
server_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
server_sock.settimeout(100)
|
||||
server_sock.bind(("192.168.111.5", 443))
|
||||
server_sock.listen(5)
|
||||
while True:
|
||||
try:
|
||||
new_socket, addr = server_sock.accept()
|
||||
ssl_new = ssl_context.wrap_socket(new_socket, server_side=True)
|
||||
print "server connected"
|
||||
break
|
||||
except StandardError:
|
||||
pass
|
||||
|
||||
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,240 +0,0 @@
|
||||
import os
|
||||
import random
|
||||
import time
|
||||
import re
|
||||
|
||||
from TCAction import TCActionBase
|
||||
from TCAction import PerformanceTCBase
|
||||
from NativeLog import NativeLog, HTMLGenerator
|
||||
from Utility import MakeFolder
|
||||
|
||||
import ConfigUtility
|
||||
import Capability
|
||||
import SSLHandler
|
||||
|
||||
LOG_FOLDER = os.path.join("AT_LOG", "TEMP")
|
||||
|
||||
HEAP_SIZE_LIMIT = 30000
|
||||
|
||||
|
||||
class SSLHandshake(PerformanceTCBase.PerformanceTCBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=15, log_path=TCActionBase.LOG_PATH):
|
||||
PerformanceTCBase.PerformanceTCBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.client_type = None
|
||||
self.server_type = None
|
||||
self.client_capability = dict()
|
||||
self.server_capability = dict()
|
||||
# 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
|
||||
timestamp = time.strftime("%d%H%M%S", time.localtime())
|
||||
folder = MakeFolder.make_folder(os.path.join(LOG_FOLDER, "SSLHandshake_%s" % timestamp))
|
||||
self.tested_log = os.path.join(folder, "SSLHandshakeTested.log")
|
||||
self.failed_log = os.path.join(folder, "SSLHandshakeFailed.log")
|
||||
self.memory_track_log = os.path.join(folder, "SSLHandshakeMemTrack.log")
|
||||
self.succeed_log = os.path.join(folder, "SSLHandshakeSucceed.log")
|
||||
# store test result for failed config
|
||||
self.failed_log2 = os.path.join(folder, "SSLHandshakeFailed2.log")
|
||||
self.succeed_log2 = os.path.join(folder, "SSLHandshakeSucceed2.log")
|
||||
|
||||
self.heap_size_pattern = re.compile("\+FREEHEAP:(\d+)\r\n")
|
||||
|
||||
@staticmethod
|
||||
def close(client, server):
|
||||
try:
|
||||
client.close()
|
||||
except StandardError:
|
||||
pass
|
||||
try:
|
||||
server.close()
|
||||
except StandardError:
|
||||
pass
|
||||
|
||||
def query_heap_size(self, scenario="idle"):
|
||||
self.flush_data("SSC1")
|
||||
self.serial_write_line("SSC1", "ram -H")
|
||||
match = self.check_regular_expression("SSC1", self.heap_size_pattern)
|
||||
if match is None:
|
||||
NativeLog.add_trace_critical("No response for SSC ram command")
|
||||
else:
|
||||
heap_size = int(match.group(1))
|
||||
self.log_memory("[heap size][%s] %s" % (scenario, heap_size))
|
||||
if heap_size < HEAP_SIZE_LIMIT and scenario == "idle":
|
||||
NativeLog.add_trace_critical("[HeapSize] %s" % heap_size)
|
||||
|
||||
pass
|
||||
|
||||
def prepare_handshake_test(self):
|
||||
# check if connected
|
||||
self.flush_data("SSC1")
|
||||
self.serial_write_line("SSC1", "sta -Q")
|
||||
if self.check_response("SSC1", "+JAP:CONNECTED,") is False:
|
||||
ap_ssid = self.get_parameter("ap_ssid")
|
||||
ap_password = self.get_parameter("ap_password")
|
||||
self.serial_write_line("SSC1", "sta -C -s %s -p %s" % (ap_ssid, ap_password))
|
||||
self.check_response("SSC1", "+JAP:CONNECTED,")
|
||||
self.query_heap_size()
|
||||
|
||||
@staticmethod
|
||||
def log_data_to_file(file_name, data):
|
||||
with open(file_name, "ab+") as f:
|
||||
f.write(data+"\r\n")
|
||||
|
||||
def log_test_config(self, data):
|
||||
# append to log
|
||||
with self.sync_lock:
|
||||
_formatted_data = HTMLGenerator.process_one_log_item(data)
|
||||
self.append_to_log_file(_formatted_data)
|
||||
self.log_data_to_file(self.tested_log, data)
|
||||
|
||||
def log_memory(self, data):
|
||||
self.log_data_to_file(self.memory_track_log, data)
|
||||
|
||||
def log_fail(self, data, log_type="succeed"):
|
||||
print data
|
||||
if log_type == "succeed":
|
||||
self.log_data_to_file(self.failed_log, data)
|
||||
else:
|
||||
self.log_data_to_file(self.failed_log2, data)
|
||||
|
||||
def log_succeed(self, data, log_type="succeed"):
|
||||
if log_type == "succeed":
|
||||
self.log_data_to_file(self.succeed_log, data)
|
||||
else:
|
||||
self.log_data_to_file(self.succeed_log2, data)
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
# rewrite the following code
|
||||
if self.client_type == "PC":
|
||||
client_capability = Capability.PCSSLCapability("PCClient")
|
||||
client_handler = SSLHandler.PCSSLHandler
|
||||
client_ip = self.get_parameter("pc_ip")
|
||||
else:
|
||||
client_capability = Capability.TargetSSLCapability("TargetClient", **self.client_capability)
|
||||
client_handler = SSLHandler.TargetSSLHandler
|
||||
client_ip = self.get_parameter("target_ip")
|
||||
if self.server_type == "PC":
|
||||
server_capability = Capability.PCSSLCapability("PCServer")
|
||||
server_handler = SSLHandler.PCSSLHandler
|
||||
server_ip = self.get_parameter("pc_ip")
|
||||
else:
|
||||
server_capability = Capability.TargetSSLCapability("TargetServer", **self.server_capability)
|
||||
server_handler = SSLHandler.TargetSSLHandler
|
||||
server_ip = self.get_parameter("target_ip")
|
||||
|
||||
serial_port = SSLHandler.SerialPort(self, "SSC1")
|
||||
# generate config
|
||||
config_utility = ConfigUtility.ConfigUtility(client_capability, server_capability)
|
||||
config_list_dict = config_utility.get_all_test_config()
|
||||
|
||||
# succeed
|
||||
for config in config_list_dict["succeed"]:
|
||||
self.prepare_handshake_test()
|
||||
self.log_test_config("[Succeed config] %s" % config)
|
||||
port = random.randint(500, 50000)
|
||||
client = client_handler("client", config, serial_port)
|
||||
server = server_handler("server", config, serial_port)
|
||||
try:
|
||||
client.init_context()
|
||||
server.init_context()
|
||||
server.listen(local_ip=server_ip, local_port=port)
|
||||
client.connect(server_ip, port, local_ip=client_ip)
|
||||
self.query_heap_size(scenario="connected")
|
||||
self.log_succeed("[Succeed config] %s" % config)
|
||||
except SSLHandler.TargetFail, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
self.log_fail("[Target][%s]\r\n[Failed][Succeed config] %s" % (e, config))
|
||||
except SSLHandler.PCFail, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
self.log_fail("[PC][%s]\r\n[Failed][Succeed config] %s" % (e, config))
|
||||
|
||||
self.close(client, server)
|
||||
|
||||
# init context fail
|
||||
for config in config_list_dict["context_fail"]:
|
||||
self.prepare_handshake_test()
|
||||
port = random.randint(500, 50000)
|
||||
self.log_test_config("[Init context fail config] %s" % config)
|
||||
client = client_handler("client", config, serial_port)
|
||||
server = server_handler("server", config, serial_port)
|
||||
try:
|
||||
client.init_context()
|
||||
server.init_context()
|
||||
server.listen(local_ip=server_ip, local_port=port)
|
||||
client.connect(server_ip, port, local_ip=client_ip)
|
||||
self.log_fail("[Target]\r\n[Failed][Init context fail config] %s" % config, log_type="failed")
|
||||
except StandardError, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
self.log_succeed("[init context fail] %s" % config, log_type="failed")
|
||||
self.close(client, server)
|
||||
pass
|
||||
|
||||
# negotiation fail
|
||||
for config in config_list_dict["negotiation_fail"]:
|
||||
self.prepare_handshake_test()
|
||||
self.log_test_config("[negotiation_fail] %s" % config)
|
||||
port = random.randint(500, 50000)
|
||||
client = client_handler("client", config, serial_port)
|
||||
server = server_handler("server", config, serial_port)
|
||||
try:
|
||||
client.init_context()
|
||||
server.init_context()
|
||||
server.listen(local_ip=server_ip, local_port=port)
|
||||
except SSLHandler.TargetFail, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
self.log_fail("[Target][%s]\r\n[Failed][negotiation fail config] %s" % (e, config), log_type="failed")
|
||||
self.close(client, server)
|
||||
continue
|
||||
except SSLHandler.PCFail, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
self.log_fail("[PC][%s]\r\n[Failed][negotiation fail config] %s" % (e, config), log_type="failed")
|
||||
self.close(client, server)
|
||||
continue
|
||||
try:
|
||||
client.connect(server_ip, port, local_ip=client_ip)
|
||||
self.log_fail("[Target]\r\n[Failed][negotiation fail config] %s" % config, log_type="failed")
|
||||
except StandardError, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
self.log_succeed("[negotiation fail] %s" % config, log_type="failed")
|
||||
self.close(client, server)
|
||||
|
||||
# cert key fail
|
||||
for config in config_list_dict["cert_key_fail"]:
|
||||
self.prepare_handshake_test()
|
||||
self.log_test_config("[cert_key_fail] %s" % config)
|
||||
port = random.randint(500, 50000)
|
||||
client = client_handler("client", config, serial_port)
|
||||
server = server_handler("server", config, serial_port)
|
||||
try:
|
||||
client.init_context()
|
||||
server.init_context()
|
||||
server.listen(local_ip=server_ip, local_port=port)
|
||||
except SSLHandler.TargetFail, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
self.log_fail("[Target][%s]\r\n[Failed][cert_key fail config] %s" % (e, config), log_type="failed")
|
||||
self.close(client, server)
|
||||
continue
|
||||
except SSLHandler.PCFail, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
self.log_fail("[PC][%s]\r\n[Failed][cert_key fail config] %s" % (e, config), log_type="failed")
|
||||
self.close(client, server)
|
||||
continue
|
||||
try:
|
||||
client.connect(server_ip, port, local_ip=client_ip)
|
||||
self.log_fail("[Target][Failed][cert_key fail config] %s" % config, log_type="failed")
|
||||
except StandardError, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
self.log_succeed("[cert_key_fail] %s" % config, log_type="failed")
|
||||
self.close(client, server)
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,140 +0,0 @@
|
||||
import os
|
||||
import random
|
||||
import time
|
||||
import re
|
||||
|
||||
from TCAction import TCActionBase
|
||||
from TCAction import PerformanceTCBase
|
||||
from NativeLog import NativeLog, HTMLGenerator
|
||||
from Utility import MakeFolder
|
||||
|
||||
import ConfigUtility
|
||||
import Capability
|
||||
import SSLHandler
|
||||
|
||||
LOG_FOLDER = os.path.join("AT_LOG", "TEMP")
|
||||
|
||||
HEAP_SIZE_LIMIT = 30000
|
||||
|
||||
|
||||
class SSLLowMem(PerformanceTCBase.PerformanceTCBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=15, log_path=TCActionBase.LOG_PATH):
|
||||
PerformanceTCBase.PerformanceTCBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.client_type = None
|
||||
self.server_type = None
|
||||
self.client_capability = dict()
|
||||
self.server_capability = dict()
|
||||
self.heap_usage_range = (10000, 30000)
|
||||
self.test_time = 120
|
||||
# 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
|
||||
timestamp = time.strftime("%d%H%M%S", time.localtime())
|
||||
self.heap_size_pattern = re.compile("\+FREEHEAP:(\d+)\r\n")
|
||||
|
||||
@staticmethod
|
||||
def close(client, server):
|
||||
try:
|
||||
client.close()
|
||||
except StandardError:
|
||||
pass
|
||||
try:
|
||||
server.close()
|
||||
except StandardError:
|
||||
pass
|
||||
|
||||
def query_heap_size(self, scenario="idle"):
|
||||
self.flush_data("SSC1")
|
||||
self.serial_write_line("SSC1", "ram -H")
|
||||
match = self.check_regular_expression("SSC1", self.heap_size_pattern)
|
||||
if match is None:
|
||||
NativeLog.add_trace_critical("No response for SSC ram command")
|
||||
else:
|
||||
heap_size = int(match.group(1))
|
||||
if heap_size < HEAP_SIZE_LIMIT and scenario == "idle":
|
||||
NativeLog.add_trace_critical("[HeapSize] %s" % heap_size)
|
||||
|
||||
pass
|
||||
|
||||
def prepare_handshake_test(self):
|
||||
# check if connected
|
||||
self.flush_data("SSC1")
|
||||
self.serial_write_line("SSC1", "sta -Q")
|
||||
if self.check_response("SSC1", "+JAP:CONNECTED,") is False:
|
||||
ap_ssid = self.get_parameter("ap_ssid")
|
||||
ap_password = self.get_parameter("ap_password")
|
||||
self.serial_write_line("SSC1", "sta -C -s %s -p %s" % (ap_ssid, ap_password))
|
||||
self.check_response("SSC1", "+JAP:CONNECTED,")
|
||||
# random alloc memory
|
||||
while True:
|
||||
memory_size = random.randint(self.heap_usage_range[0], self.heap_usage_range[1])
|
||||
self.serial_write_line("SSC1", "soc -M -l %s" % memory_size)
|
||||
if self.check_response("SSC1", "+SOC_BUFFER:OK", timeout=1) is True:
|
||||
break
|
||||
# query size
|
||||
self.query_heap_size()
|
||||
|
||||
@staticmethod
|
||||
def log_data_to_file(file_name, data):
|
||||
with open(file_name, "ab+") as f:
|
||||
f.write(data+"\r\n")
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
# rewrite the following code
|
||||
if self.client_type == "PC":
|
||||
client_capability = Capability.PCSSLCapability("PCClient")
|
||||
client_handler = SSLHandler.PCSSLHandler
|
||||
client_ip = self.get_parameter("pc_ip")
|
||||
else:
|
||||
client_capability = Capability.TargetSSLCapability("TargetClient", **self.client_capability)
|
||||
client_handler = SSLHandler.TargetSSLHandler
|
||||
client_ip = self.get_parameter("target_ip")
|
||||
if self.server_type == "PC":
|
||||
server_capability = Capability.PCSSLCapability("PCServer")
|
||||
server_handler = SSLHandler.PCSSLHandler
|
||||
server_ip = self.get_parameter("pc_ip")
|
||||
else:
|
||||
server_capability = Capability.TargetSSLCapability("TargetServer", **self.server_capability)
|
||||
server_handler = SSLHandler.TargetSSLHandler
|
||||
server_ip = self.get_parameter("target_ip")
|
||||
|
||||
test_time = self.test_time * 60 # convert test time from minutes to seconds
|
||||
|
||||
serial_port = SSLHandler.SerialPort(self, "SSC1")
|
||||
# generate config
|
||||
config_utility = ConfigUtility.ConfigUtility(client_capability, server_capability)
|
||||
config_list_dict = config_utility.get_all_test_config()
|
||||
|
||||
start_time = time.time()
|
||||
|
||||
# succeed
|
||||
for config in config_list_dict["succeed"]:
|
||||
if time.time() - start_time > test_time:
|
||||
break
|
||||
self.prepare_handshake_test()
|
||||
port = random.randint(500, 50000)
|
||||
client = client_handler("client", config, serial_port)
|
||||
server = server_handler("server", config, serial_port)
|
||||
try:
|
||||
client.init_context()
|
||||
server.init_context()
|
||||
server.listen(local_ip=server_ip, local_port=port)
|
||||
client.connect(server_ip, port, local_ip=client_ip)
|
||||
self.query_heap_size(scenario="connected")
|
||||
except SSLHandler.TargetFail, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
except SSLHandler.PCFail, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
self.close(client, server)
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,147 +0,0 @@
|
||||
import random
|
||||
import time
|
||||
|
||||
from TCAction import TCActionBase
|
||||
from TCAction import PerformanceTCBase
|
||||
from NativeLog import NativeLog
|
||||
import ConfigUtility
|
||||
import Capability
|
||||
import SSLHandler
|
||||
|
||||
|
||||
class SSLSendRecv(PerformanceTCBase.PerformanceTCBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=15, log_path=TCActionBase.LOG_PATH):
|
||||
PerformanceTCBase.PerformanceTCBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.target_role = "Client"
|
||||
self.max_send_len = 2048
|
||||
self.test_time = 120
|
||||
self.data_validation = False
|
||||
|
||||
self.target_capability = {"version": ["SSLv23"],
|
||||
"cipher_suite": ["TLS_RSA_WITH_AES_256_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA"],
|
||||
"fragment_size": [2048],
|
||||
"verify_server": False,
|
||||
"verify_client": False,
|
||||
"key_algorithm": ["RSA2048"],
|
||||
"key_encoding": ["PEM"],
|
||||
"pem_encryption": [None],
|
||||
"certificate_encoding": ["PEM"],
|
||||
"certificate_digest": ["sha1"],
|
||||
}
|
||||
# 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
|
||||
|
||||
@staticmethod
|
||||
def close(client, server):
|
||||
try:
|
||||
client.close()
|
||||
except StandardError:
|
||||
pass
|
||||
try:
|
||||
server.close()
|
||||
except StandardError:
|
||||
pass
|
||||
|
||||
def cleanup(self):
|
||||
self.serial_write_line("SSC1", "ssl -D")
|
||||
self.check_response("SSC1", "SSL")
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
|
||||
target_role = self.target_role
|
||||
max_send_len = self.max_send_len
|
||||
test_time = self.test_time * 60
|
||||
data_validation = self.data_validation
|
||||
|
||||
ssl_port = random.randint(10000, 50000)
|
||||
NativeLog.add_prompt_trace("SSL port is %s" % ssl_port)
|
||||
|
||||
# make sure ssl context deinit
|
||||
self.serial_write_line("SSC1", "ssl -D")
|
||||
self.check_response("SSC1", "SSL")
|
||||
|
||||
# close all sockets and enlarge send buffer
|
||||
self.serial_write_line("SSC1", "soc -T")
|
||||
self.check_response("SSC1", "CLOSEALL")
|
||||
|
||||
self.serial_write_line("SSC1", "soc -M -l %s" % max_send_len)
|
||||
self.check_response("SSC1", "+SOC_BUFFER:OK")
|
||||
|
||||
# rewrite the following code
|
||||
if target_role == "Server":
|
||||
client_capability = Capability.PCSSLCapability("PCClient")
|
||||
client_handler = SSLHandler.PCSSLHandler
|
||||
client_ip = self.get_parameter("pc_ip")
|
||||
server_capability = Capability.TargetSSLCapability("TargetServer", **self.target_capability)
|
||||
server_handler = SSLHandler.TargetSSLHandler
|
||||
server_ip = self.get_parameter("target_ip")
|
||||
elif target_role == "Client":
|
||||
client_capability = Capability.TargetSSLCapability("TargetClient", **self.target_capability)
|
||||
client_handler = SSLHandler.TargetSSLHandler
|
||||
client_ip = self.get_parameter("target_ip")
|
||||
server_capability = Capability.PCSSLCapability("PCServer")
|
||||
server_handler = SSLHandler.PCSSLHandler
|
||||
server_ip = self.get_parameter("pc_ip")
|
||||
else:
|
||||
raise StandardError("Unsupported target role %s" % target_role)
|
||||
|
||||
serial_port = SSLHandler.SerialPort(self, "SSC1")
|
||||
|
||||
# generate one succeed config
|
||||
config_utility = ConfigUtility.ConfigUtility(client_capability, server_capability)
|
||||
config_list_dict = config_utility.get_all_test_config()
|
||||
|
||||
for config in config_list_dict["succeed"]:
|
||||
try:
|
||||
# create connection
|
||||
NativeLog.add_prompt_trace(str(config)) # do print config
|
||||
client = client_handler("client", config, serial_port)
|
||||
server = server_handler("server", config, serial_port)
|
||||
client.init_context()
|
||||
server.init_context()
|
||||
server.listen(local_ip=server_ip, local_port=ssl_port)
|
||||
client.connect(server_ip, ssl_port, local_ip=client_ip)
|
||||
except StandardError, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
return
|
||||
|
||||
# set data validation
|
||||
client.set_data_validation(data_validation)
|
||||
server.set_data_validation(data_validation)
|
||||
|
||||
# do send recv
|
||||
time_start = time.time()
|
||||
while time.time() - time_start < test_time:
|
||||
send_len = random.randint(1, max_send_len)
|
||||
try:
|
||||
client.send(size=send_len)
|
||||
client.send(size=send_len)
|
||||
server.recv(send_len*2)
|
||||
except StandardError, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
NativeLog.add_prompt_trace("client send / server recv fail")
|
||||
break
|
||||
try:
|
||||
# do send twice, try to create a tcp segment with 2 records
|
||||
server.send(size=send_len)
|
||||
server.send(size=send_len)
|
||||
client.recv(send_len*2)
|
||||
except StandardError, e:
|
||||
NativeLog.add_exception_log(e)
|
||||
NativeLog.add_prompt_trace("server send / client recv fail")
|
||||
break
|
||||
else:
|
||||
self.set_result("Succeed")
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1 +0,0 @@
|
||||
__all__ = ["Capability", "ConfigUtility", "Parameter", "SSLHandler", "SSLHandshake"]
|
@ -1,561 +0,0 @@
|
||||
import random
|
||||
import os
|
||||
import time
|
||||
import string
|
||||
import re
|
||||
import threading
|
||||
|
||||
from TCAction import TCActionBase, PerformanceTCBase
|
||||
from NativeLog import NativeLog
|
||||
from Utility import MakeFolder
|
||||
from Utility import MultimeterUtil
|
||||
from Utility import ShellCmd
|
||||
|
||||
LOG_PATH = os.path.join("AT_LOG", "SLEEP")
|
||||
|
||||
SLEEP_MODE_LIST = ["none_sleep", "light_sleep", "modem_sleep"]
|
||||
SLEEP_MODE = dict(zip(SLEEP_MODE_LIST, range(len(SLEEP_MODE_LIST))))
|
||||
|
||||
SAMPLE_RATE_SLEEP_MODE_CHANGE = 0.002
|
||||
SAMPLE_NUM_SLEEP_MODE_CHANGE = 256
|
||||
|
||||
SAMPLE_RATE = 0.002
|
||||
SAMPLE_NUM = 512
|
||||
MAX_VALUE = 1
|
||||
Y_AXIS_LABEL = "Current (mA)"
|
||||
GPIO_EDGE_DELAY = 120 # 20 ms
|
||||
|
||||
NONE_SLEEP_MIN_CUR = 30
|
||||
LIGHT_SLEEP_MIN_CUR = 1.5
|
||||
MODEM_SLEEP_MIN_CUR = 20
|
||||
|
||||
GPIO_WAKE_UP = 15
|
||||
GPIO_CHIP_RESET = 14
|
||||
|
||||
SLEEP_WAKEUP_DELAY = 0.01
|
||||
|
||||
|
||||
class AutoSleep(PerformanceTCBase.PerformanceTCBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
PerformanceTCBase.PerformanceTCBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.test_mode = "mode_change"
|
||||
self.test_count = 100
|
||||
self.sleep_mode = SLEEP_MODE_LIST
|
||||
# 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.log_folder = MakeFolder.make_folder(os.path.join(LOG_PATH,
|
||||
"AUTO_SLEEP_%s_%s" % (self.test_mode,
|
||||
time.strftime("%d%H%M%S",
|
||||
time.localtime()))))
|
||||
self.multimeter = MultimeterUtil.MultimeterUtil(self.log_folder)
|
||||
|
||||
@staticmethod
|
||||
def find_min_items(item_list, count):
|
||||
assert count < len(item_list)
|
||||
min_items = []
|
||||
for i in range(count):
|
||||
min_val = min(item_list)
|
||||
min_items.append(min_val)
|
||||
item_list.remove(min_val)
|
||||
return min_items
|
||||
|
||||
def sleep_mode_change(self, sleep_mode):
|
||||
result = True
|
||||
NativeLog.add_prompt_trace("[AutoSleep][ModeChange] %s start" % sleep_mode)
|
||||
# choose sleep mode
|
||||
sleep_mode_enum = SLEEP_MODE[sleep_mode]
|
||||
# change GPIO to make sure target exit sleep mode, so it can process SSC commands
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(SLEEP_WAKEUP_DELAY)
|
||||
# set sleep mode
|
||||
self.serial_write_line("SSC1", "sleep -S -t %d" % sleep_mode_enum)
|
||||
self.check_response("SSC1", "+SLEEP_MODE:OK")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][ModeChange] mode set")
|
||||
time.sleep(6)
|
||||
# measure current
|
||||
current_line = self.multimeter.measure_current(sample_rate=SAMPLE_RATE_SLEEP_MODE_CHANGE,
|
||||
sample_num=SAMPLE_NUM_SLEEP_MODE_CHANGE,
|
||||
max_value=MAX_VALUE)
|
||||
# do check measure
|
||||
min_items = self.find_min_items(current_line, 10)
|
||||
average_val = float(0)
|
||||
for val in min_items:
|
||||
average_val += val
|
||||
average_val /= 10
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][ModeChange] measure done, average min current %f" % average_val)
|
||||
|
||||
if sleep_mode == "none_sleep":
|
||||
if average_val < NONE_SLEEP_MIN_CUR:
|
||||
result = False
|
||||
elif sleep_mode == "light_sleep":
|
||||
if average_val > LIGHT_SLEEP_MIN_CUR:
|
||||
result = False
|
||||
elif sleep_mode == "modem_sleep":
|
||||
if average_val > MODEM_SLEEP_MIN_CUR or average_val < LIGHT_SLEEP_MIN_CUR:
|
||||
result = False
|
||||
if result is False:
|
||||
NativeLog.add_trace_critical("[AutoSleep][ModeChange] %s failed" % sleep_mode)
|
||||
self.multimeter.draw_graph(current_line, SAMPLE_RATE, "%s_fail" % sleep_mode, Y_AXIS_LABEL)
|
||||
|
||||
time.sleep(5)
|
||||
return result
|
||||
|
||||
def sleep_current_measure(self, sleep_mode):
|
||||
result = True
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][CurrentMeasure] %s start" % sleep_mode)
|
||||
# choose sleep mode
|
||||
sleep_mode_enum = SLEEP_MODE[sleep_mode]
|
||||
# change GPIO to make sure target exit sleep mode, so it can process SSC commands
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
# set sleep mode
|
||||
time.sleep(SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "sleep -S -t %d" % sleep_mode_enum)
|
||||
self.check_response("SSC1", "+SLEEP_MODE:OK")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][CurrentMeasure] set mode done")
|
||||
time.sleep(10)
|
||||
# measure current
|
||||
current_line = self.multimeter.measure_current(sample_rate=SAMPLE_RATE,
|
||||
sample_num=SAMPLE_NUM,
|
||||
max_value=MAX_VALUE)
|
||||
self.multimeter.draw_graph(current_line, SAMPLE_RATE, sleep_mode, Y_AXIS_LABEL)
|
||||
NativeLog.add_prompt_trace("[AutoSleep][CurrentMeasure] measure done")
|
||||
return result
|
||||
|
||||
def light_sleep_wakeup(self):
|
||||
result = True
|
||||
NativeLog.add_prompt_trace("[AutoSleep][LightSleepWakeup] start")
|
||||
|
||||
time.sleep(1)
|
||||
self.serial_write_line("SSC1", "")
|
||||
time.sleep(1)
|
||||
# check if respond to uart
|
||||
self.flush_data("SSC1")
|
||||
for i in range(60):
|
||||
self.serial_write("SSC1", "a")
|
||||
time.sleep(0.043)
|
||||
time.sleep(0.1)
|
||||
respond_data = self.serial_read_data("SSC1")
|
||||
if len(respond_data) >= 60:
|
||||
NativeLog.add_trace_critical("[AutoSleep][light sleep wakeup] "
|
||||
"Failed when recving data during sleep, %d" % len(respond_data))
|
||||
result = False
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][LightSleepWakeup] check on sleep mode done")
|
||||
|
||||
self.serial_write_line("SSC1", "")
|
||||
time.sleep(1)
|
||||
|
||||
# change GPIO to make target wakeup
|
||||
self.serial_write_line("SSC2", "gpio -L -p %d -t 0" % GPIO_WAKE_UP)
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
|
||||
self.serial_write_line("SSC1", "")
|
||||
time.sleep(1)
|
||||
self.flush_data("SSC1")
|
||||
for i in range(60):
|
||||
self.serial_write("SSC1", "a")
|
||||
time.sleep(0.043)
|
||||
time.sleep(0.1)
|
||||
respond_data = self.serial_read_data("SSC1")
|
||||
if len(respond_data) < 60:
|
||||
NativeLog.add_trace_critical("[AutoSleep][light sleep wakeup] "
|
||||
"Failed when recving data during wakeup, %d" % len(respond_data))
|
||||
result = False
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][LightSleepWakeup] check on wakeup mode done")
|
||||
self.serial_write_line("SSC1", "")
|
||||
# restore GPIO level
|
||||
self.serial_write_line("SSC2", "gpio -L -p %d -t 1" % GPIO_WAKE_UP)
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_CHIP_RESET, GPIO_EDGE_DELAY))
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
time.sleep(2)
|
||||
return result
|
||||
|
||||
def sleep_exit_enter(self, sleep_mode, ssid, password):
|
||||
result = True
|
||||
if sleep_mode == "modem_sleep":
|
||||
max_current_for_sleep = 20
|
||||
elif sleep_mode == "light_sleep":
|
||||
max_current_for_sleep = 5
|
||||
else:
|
||||
raise StandardError("Not supported mode %s" % sleep_mode)
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][EnterExitSleep] %s start" % sleep_mode)
|
||||
|
||||
ap_ssid = self.get_parameter("ap_ssid")
|
||||
ap_password = self.get_parameter("ap_password")
|
||||
|
||||
# step A: no STA connect to SoftAP, enter modem sleep mode
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "op -S -o 1")
|
||||
self.check_response("SSC1", "+MODE:OK")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "sta -C -s %s -p %s" % (ap_ssid, ap_password))
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
self.check_response("SSC1", "+JAP:CONNECTED")
|
||||
self.check_response("SSC1", "pm open")
|
||||
|
||||
self.serial_write_line("SSC2", "sta -D")
|
||||
self.check_response("SSC2", "+QAP")
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
current_line = self.multimeter.measure_current(sample_rate=SAMPLE_RATE,
|
||||
sample_num=SAMPLE_NUM,
|
||||
max_value=MAX_VALUE)
|
||||
min_items = self.find_min_items(current_line, 10)
|
||||
average_val = float(0)
|
||||
for val in min_items:
|
||||
average_val += val
|
||||
average_val /= 10
|
||||
if average_val > max_current_for_sleep:
|
||||
NativeLog.add_trace_critical("[AutoSleep][SleepExitEnter] "
|
||||
"did not enter %s sleep, %d" % (sleep_mode, average_val))
|
||||
self.multimeter.draw_graph(current_line, SAMPLE_RATE,
|
||||
"%s_sleep_exit_enter_fail_A" % sleep_mode, Y_AXIS_LABEL)
|
||||
result = False
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][EnterExitSleep] step A done")
|
||||
# step B: STA connect to SoftAP, exit modem sleep mode
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "op -S -o 3")
|
||||
self.check_response("SSC1", "+MODE:OK")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
time.sleep(1)
|
||||
self.serial_write_line("SSC2", "sta -C -s %s -p %s" % (ssid, password))
|
||||
self.check_response("SSC2", "+JAP:CONNECTED")
|
||||
# self.check_response("SSC1", "pm close")
|
||||
time.sleep(10)
|
||||
|
||||
current_line = self.multimeter.measure_current(sample_rate=SAMPLE_RATE,
|
||||
sample_num=SAMPLE_NUM,
|
||||
max_value=MAX_VALUE)
|
||||
min_items = self.find_min_items(current_line, 10)
|
||||
average_val = float(0)
|
||||
for val in min_items:
|
||||
average_val += val
|
||||
average_val /= 10
|
||||
if average_val < 30:
|
||||
NativeLog.add_trace_critical("[AutoSleep][SleepExitEnter] did not exit %s sleep" % sleep_mode)
|
||||
self.multimeter.draw_graph(current_line, SAMPLE_RATE,
|
||||
"%s_sleep_exit_enter_fail_B" % sleep_mode, Y_AXIS_LABEL)
|
||||
result = False
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][EnterExitSleep] step B done")
|
||||
# step C: target set to STA mode, enter modem sleep
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "op -S -o 1")
|
||||
self.check_response("SSC1", "+MODE:OK")
|
||||
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
# self.check_response("SSC1", "pm open")
|
||||
time.sleep(15)
|
||||
|
||||
current_line = self.multimeter.measure_current(sample_rate=SAMPLE_RATE,
|
||||
sample_num=SAMPLE_NUM,
|
||||
max_value=MAX_VALUE)
|
||||
min_items = self.find_min_items(current_line, 10)
|
||||
average_val = float(0)
|
||||
for val in min_items:
|
||||
average_val += val
|
||||
average_val /= 10
|
||||
if average_val > max_current_for_sleep:
|
||||
NativeLog.add_trace_critical("[AutoSleep][SleepExitEnter] did not enter %s sleep" % sleep_mode)
|
||||
self.multimeter.draw_graph(current_line, SAMPLE_RATE,
|
||||
"%s_sleep_exit_enter_fail_C" % sleep_mode, Y_AXIS_LABEL)
|
||||
result = False
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][EnterExitSleep] step C done")
|
||||
# step D: target disconnect, exit modem sleep
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "sta -D")
|
||||
self.check_response("SSC1", "+QAP")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
# self.check_response("SSC1", "pm close")
|
||||
time.sleep(5)
|
||||
current_line = self.multimeter.measure_current(sample_rate=SAMPLE_RATE,
|
||||
sample_num=SAMPLE_NUM,
|
||||
max_value=MAX_VALUE)
|
||||
min_items = self.find_min_items(current_line, 10)
|
||||
average_val = float(0)
|
||||
for val in min_items:
|
||||
average_val += val
|
||||
average_val /= 10
|
||||
if average_val < 30:
|
||||
NativeLog.add_trace_critical("[AutoSleep][SleepExitEnter] did not exit %s sleep" % sleep_mode)
|
||||
self.multimeter.draw_graph(current_line, SAMPLE_RATE,
|
||||
"%s_sleep_exit_enter_fail_D" % sleep_mode, Y_AXIS_LABEL)
|
||||
result = False
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][EnterExitSleep] step D done")
|
||||
# step E: target connect to AP, enter modem sleep
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "sta -C -s %s -p %s" % (ap_ssid, ap_password))
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
self.check_response("SSC1", "+JAP:CONNECTED")
|
||||
self.check_response("SSC1", "pm open")
|
||||
time.sleep(3)
|
||||
current_line = self.multimeter.measure_current(sample_rate=SAMPLE_RATE,
|
||||
sample_num=SAMPLE_NUM,
|
||||
max_value=MAX_VALUE)
|
||||
min_items = self.find_min_items(current_line, 10)
|
||||
average_val = float(0)
|
||||
for val in min_items:
|
||||
average_val += val
|
||||
average_val /= 10
|
||||
if average_val > max_current_for_sleep:
|
||||
NativeLog.add_trace_critical("[AutoSleep][SleepExitEnter] did not enter %s sleep" % sleep_mode)
|
||||
self.multimeter.draw_graph(current_line, SAMPLE_RATE,
|
||||
"%s_sleep_exit_enter_fail_E" % sleep_mode, Y_AXIS_LABEL)
|
||||
result = False
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][EnterExitSleep] step E done")
|
||||
# step F: target set to AP mode, exit modem sleep
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "op -S -o 2")
|
||||
self.check_response("SSC1", "+MODE:OK")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
# self.check_response("SSC1", "pm close")
|
||||
time.sleep(5)
|
||||
|
||||
current_line = self.multimeter.measure_current(sample_rate=SAMPLE_RATE,
|
||||
sample_num=SAMPLE_NUM,
|
||||
max_value=MAX_VALUE)
|
||||
min_items = self.find_min_items(current_line, 10)
|
||||
average_val = float(0)
|
||||
for val in min_items:
|
||||
average_val += val
|
||||
average_val /= 10
|
||||
if average_val < 30:
|
||||
NativeLog.add_trace_critical("[AutoSleep][SleepExitEnter] did not exit %s sleep" % sleep_mode)
|
||||
self.multimeter.draw_graph(current_line, SAMPLE_RATE,
|
||||
"%s_sleep_exit_enter_fail_F" % sleep_mode, Y_AXIS_LABEL)
|
||||
result = False
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][EnterExitSleep] step F done")
|
||||
return result
|
||||
|
||||
def ping_test(self, sleep_mode):
|
||||
result = True
|
||||
NativeLog.add_prompt_trace("[AutoSleep][PingTest] %s start" % sleep_mode)
|
||||
# choose sleep mode
|
||||
sleep_mode_enum = SLEEP_MODE[sleep_mode]
|
||||
if sleep_mode == "modem_sleep":
|
||||
max_current_for_sleep = MODEM_SLEEP_MIN_CUR
|
||||
elif sleep_mode == "light_sleep":
|
||||
max_current_for_sleep = LIGHT_SLEEP_MIN_CUR
|
||||
else:
|
||||
raise StandardError("Not supported mode %s" % sleep_mode)
|
||||
|
||||
self.serial_write_line("SSC1", "op -S -o 1")
|
||||
self.check_response("SSC1", "+MODE:OK")
|
||||
|
||||
# set sleep mode
|
||||
self.serial_write_line("SSC1", "sleep -S -t %d" % sleep_mode_enum)
|
||||
self.check_response("SSC1", "+SLEEP_MODE:OK")
|
||||
NativeLog.add_prompt_trace("[AutoSleep][PingTest] set mode done")
|
||||
|
||||
# connect to AP
|
||||
ap_ssid = self.get_parameter("ap_ssid")
|
||||
ap_password = self.get_parameter("ap_password")
|
||||
target_ip = self.get_parameter("target_ip")
|
||||
|
||||
self.serial_write_line("SSC1", "sta -C -s %s -p %s" % (ap_ssid, ap_password))
|
||||
self.check_response("SSC1", "+JAP:CONNECTED")
|
||||
|
||||
time.sleep(10)
|
||||
# measure current, should be in sleep mode
|
||||
current_line = self.multimeter.measure_current(sample_rate=SAMPLE_RATE,
|
||||
sample_num=SAMPLE_NUM,
|
||||
max_value=MAX_VALUE)
|
||||
min_items = self.find_min_items(current_line, 10)
|
||||
average_val = float(0)
|
||||
for val in min_items:
|
||||
average_val += val
|
||||
average_val /= 10
|
||||
|
||||
if average_val > max_current_for_sleep:
|
||||
NativeLog.add_trace_critical("[AutoSleep][PingTest] step A did not enter %s sleep, %f"
|
||||
% (sleep_mode, average_val))
|
||||
self.multimeter.draw_graph(current_line, SAMPLE_RATE,
|
||||
"%s_ping_test_fail_not_enter_sleep" % sleep_mode, Y_AXIS_LABEL)
|
||||
result = False
|
||||
else:
|
||||
NativeLog.add_prompt_trace("[AutoSleep][PingTest] step A enter %s sleep, %f"
|
||||
% (sleep_mode, average_val))
|
||||
|
||||
class PingThread(threading.Thread):
|
||||
def __init__(self, ping_ip):
|
||||
threading.Thread.__init__(self)
|
||||
self.setDaemon(True)
|
||||
self.target_ip = ping_ip
|
||||
self.exit_event = threading.Event()
|
||||
|
||||
def run(self):
|
||||
while self.exit_event.isSet() is False:
|
||||
ShellCmd.shell_check_output("ping %s -w 500" % self.target_ip)
|
||||
time.sleep(0.1)
|
||||
pass
|
||||
|
||||
def exit(self):
|
||||
self.exit_event.set()
|
||||
|
||||
NativeLog.add_prompt_trace("[AutoSleep][PingTest] ping start")
|
||||
ping_thread = PingThread(target_ip)
|
||||
ping_thread.start()
|
||||
time.sleep(5)
|
||||
|
||||
# measure current, should not be in sleep mode
|
||||
current_line = self.multimeter.measure_current(sample_rate=SAMPLE_RATE,
|
||||
sample_num=SAMPLE_NUM,
|
||||
max_value=MAX_VALUE)
|
||||
min_items = self.find_min_items(current_line, 10)
|
||||
average_val = float(0)
|
||||
for val in min_items:
|
||||
average_val += val
|
||||
average_val /= 10
|
||||
if average_val < 30:
|
||||
NativeLog.add_trace_critical("[AutoSleep][PingTest] step B did not exit %s sleep, %f"
|
||||
% (sleep_mode, average_val))
|
||||
self.multimeter.draw_graph(current_line, SAMPLE_RATE,
|
||||
"%s_ping_test_fail_not_exit_sleep" % sleep_mode, Y_AXIS_LABEL)
|
||||
result = False
|
||||
else:
|
||||
NativeLog.add_prompt_trace("[AutoSleep][PingTest] step B exit %s sleep, %f"
|
||||
% (sleep_mode, average_val))
|
||||
|
||||
ping_thread.exit()
|
||||
ping_thread.join(20)
|
||||
NativeLog.add_prompt_trace("[AutoSleep][PingTest] ping stop")
|
||||
time.sleep(10)
|
||||
|
||||
# measure current, should not be in sleep mode
|
||||
current_line = self.multimeter.measure_current(sample_rate=SAMPLE_RATE,
|
||||
sample_num=SAMPLE_NUM,
|
||||
max_value=MAX_VALUE)
|
||||
min_items = self.find_min_items(current_line, 10)
|
||||
average_val = float(0)
|
||||
for val in min_items:
|
||||
average_val += val
|
||||
average_val /= 10
|
||||
if average_val > max_current_for_sleep:
|
||||
NativeLog.add_trace_critical("[AutoSleep][PingTest] step C did not enter %s" % sleep_mode)
|
||||
self.multimeter.draw_graph(current_line, SAMPLE_RATE,
|
||||
"%s_ping_test_fail_not_enter_sleep" % sleep_mode, Y_AXIS_LABEL)
|
||||
result = False
|
||||
else:
|
||||
NativeLog.add_prompt_trace("[AutoSleep][PingTest] step C enter %s sleep" % sleep_mode)
|
||||
|
||||
return result
|
||||
|
||||
def cleanup(self):
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "sleep -S -t %d" % SLEEP_MODE["modem_sleep"])
|
||||
self.check_response("SSC1", "OK")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
|
||||
try:
|
||||
test_mode = self.test_mode
|
||||
test_count = self.test_count
|
||||
sleep_mode = self.sleep_mode
|
||||
except StandardError, e:
|
||||
return
|
||||
|
||||
# make sure enter modem sleep mode before start test
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "sleep -S -t %d" % SLEEP_MODE["modem_sleep"])
|
||||
self.check_response("SSC1", "+SLEEP_MODE:OK")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
self.check_response("SSC1", "pm open", timeout=10)
|
||||
|
||||
self.serial_write_line("SSC1", "gpio -G -p %d" % GPIO_WAKE_UP)
|
||||
self.check_response("SSC1", "+GPIO_GET")
|
||||
self.serial_write_line("SSC1", "gpio -G -p %d" % GPIO_CHIP_RESET)
|
||||
self.check_response("SSC1", "+GPIO_GET")
|
||||
|
||||
# start test
|
||||
if "mode_change" in test_mode:
|
||||
for i in range(test_count):
|
||||
result = self.sleep_mode_change(random.choice(SLEEP_MODE_LIST))
|
||||
|
||||
elif "measure_current" in test_mode:
|
||||
for i in range(test_count):
|
||||
for mode in sleep_mode:
|
||||
result = self.sleep_current_measure(mode)
|
||||
pass
|
||||
elif "gpio_wakeup" in test_mode:
|
||||
# change GPIO to make sure target exit sleep mode, so it can process SSC commands
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(SLEEP_WAKEUP_DELAY)
|
||||
# set sleep mode
|
||||
self.serial_write_line("SSC1", "sleep -S -t %d" % SLEEP_MODE["light_sleep"])
|
||||
self.check_response("SSC1", "+SLEEP_MODE:OK")
|
||||
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
for i in range(test_count):
|
||||
result = self.light_sleep_wakeup()
|
||||
pass
|
||||
elif "sleep_exit_enter" in test_mode:
|
||||
ssid = "".join([random.choice(string.lowercase) for i in range(10)])
|
||||
password = "".join([random.choice(string.lowercase) for i in range(10)])
|
||||
self.serial_write_line("SSC2", "sta -D")
|
||||
self.check_response("SSC2", "+QAP")
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "op -S -o 3")
|
||||
self.check_response("SSC1", "+MODE:OK")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
self.serial_write_line("SSC1", "ap -S -s %s -p %s -t 3" % (ssid, password))
|
||||
self.check_response("SSC1", "+SAP:OK")
|
||||
self.serial_write_line("SSC2", "op -S -o 1")
|
||||
self.check_response("SSC2", "+MODE:OK")
|
||||
|
||||
for mode in sleep_mode:
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "sleep -S -t %d" % SLEEP_MODE[mode])
|
||||
self.check_response("SSC1", "+SLEEP_MODE:OK")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
|
||||
for i in range(test_count):
|
||||
result = self.sleep_exit_enter(mode, ssid, password)
|
||||
elif "ping" in test_mode:
|
||||
for mode in sleep_mode:
|
||||
for i in range(test_count):
|
||||
result = self.ping_test(mode)
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,259 +0,0 @@
|
||||
import random
|
||||
import os
|
||||
import time
|
||||
|
||||
from TCAction import TCActionBase, PerformanceTCBase
|
||||
from Utility import MakeFolder
|
||||
from Utility import MultimeterUtil
|
||||
from NativeLog import NativeLog
|
||||
|
||||
LOG_PATH = os.path.join("AT_LOG", "SLEEP")
|
||||
|
||||
DEEP_SLEEP_OPTION_LIST = ["up_to_bin", "normal", "no_rf_calibrate", "rf_off"]
|
||||
DEEP_SLEEP_OPTION = {
|
||||
"up_to_bin": 0,
|
||||
"normal": 1,
|
||||
"no_rf_calibrate": 2,
|
||||
"rf_off": 4,
|
||||
}
|
||||
|
||||
SAMPLE_RATE = 0.001
|
||||
SAMPLE_NUM = 512
|
||||
MAX_VALUE = 0.1
|
||||
Y_AXIS_LABEL = "Current (mA)"
|
||||
|
||||
|
||||
MEASURE_FREQ = 3600
|
||||
|
||||
GPIO_WAKE_UP = 15
|
||||
GPIO_CHIP_RESET = 14
|
||||
GPIO_EDGE_DELAY = 100 # 20 ms
|
||||
|
||||
|
||||
class DeepSleep(PerformanceTCBase.PerformanceTCBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
PerformanceTCBase.PerformanceTCBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.test_mode = "mode_change"
|
||||
self.test_count = 100
|
||||
# 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.log_folder = MakeFolder.make_folder(os.path.join(LOG_PATH,
|
||||
"DEEP_SLEEP_%s_%s" % (self.test_mode,
|
||||
time.strftime("%d%H%M%S",
|
||||
time.localtime()))))
|
||||
self.sleep_time_log = os.path.join(self.log_folder, "deep_sleep_wakeup_time.log")
|
||||
self.multimeter = MultimeterUtil.MultimeterUtil(self.log_folder)
|
||||
|
||||
def deep_sleep_stable(self):
|
||||
result = True
|
||||
RandomTime = random.randint(1, 100)
|
||||
self.serial_write_line("SSC1", "dsleep -S -t %s" % RandomTime)
|
||||
if self.check_response("SSC1", "+DSLEEP:OK") is False:
|
||||
result = False
|
||||
if self.check_response("SSC1", "ready!!!") is False:
|
||||
result = False
|
||||
NativeLog.add_trace_critical("[DeepSleep][Stable] wait ready err")
|
||||
else:
|
||||
NativeLog.add_trace_critical("[DeepSleep][Stable] SleepTime:%d" % RandomTime)
|
||||
time.sleep(1)
|
||||
|
||||
RandomTime = random.randint(100000, 1000000)
|
||||
self.serial_write_line("SSC1", "dsleep -S -t %s" % RandomTime)
|
||||
if self.check_response("SSC1", "+DSLEEP:OK") is False:
|
||||
result = False
|
||||
if self.check_response("SSC1", "ready!!!") is False:
|
||||
result = False
|
||||
NativeLog.add_trace_critical("[DeepSleep][Stable] wait ready err")
|
||||
else:
|
||||
NativeLog.add_trace_critical("[DeepSleep][Stable] SleepTime:%d" % RandomTime)
|
||||
time.sleep(1)
|
||||
return result
|
||||
|
||||
def deep_sleep_current_measure(self):
|
||||
result = True
|
||||
self.serial_write_line("SSC1", "")
|
||||
self.serial_write_line("SSC1", "dsleep -S -t 10000000")
|
||||
if self.check_response("SSC1", "+DSLEEP:OK") is False:
|
||||
result = False
|
||||
time.sleep(3)
|
||||
# measure current
|
||||
current_line = self.multimeter.measure_current(sample_rate=SAMPLE_RATE,
|
||||
sample_num=SAMPLE_NUM,
|
||||
max_value=MAX_VALUE)
|
||||
average_current = float(0)
|
||||
for current in current_line:
|
||||
average_current += current
|
||||
average_current /= SAMPLE_NUM
|
||||
|
||||
self.multimeter.draw_graph(current_line, SAMPLE_RATE,
|
||||
"deep_sleep_current", Y_AXIS_LABEL)
|
||||
|
||||
if average_current > 1:
|
||||
NativeLog.add_trace_critical("[DeepSleep][CurrentMeasure] average current %f > 1mA" % average_current)
|
||||
else:
|
||||
NativeLog.add_trace_critical("[DeepSleep][CurrentMeasure] dsleep current ok, %f" % average_current)
|
||||
|
||||
if self.check_response("SSC1", "ready!!!") is False:
|
||||
NativeLog.add_trace_critical("[DeepSleep][CurrentMeasure] CurrentMeasure wait ready err %f"
|
||||
% average_current)
|
||||
result = False
|
||||
|
||||
NativeLog.add_trace_critical("[DeepSleep][CurrentMeasure] wait ready ok")
|
||||
|
||||
return result
|
||||
|
||||
##########################################
|
||||
# gpio wake up
|
||||
##########################################
|
||||
def deep_sleep_wakeup(self):
|
||||
result = True
|
||||
|
||||
self.serial_write_line("SSC1", "dsleep -S -t 0")
|
||||
if self.check_response("SSC1", "+DSLEEP:OK") is False:
|
||||
result = False
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
# measure current
|
||||
current_line = self.multimeter.measure_current(sample_rate=SAMPLE_RATE,
|
||||
sample_num=SAMPLE_NUM,
|
||||
max_value=MAX_VALUE)
|
||||
average_current = float(0)
|
||||
for current in current_line:
|
||||
average_current += current
|
||||
average_current /= SAMPLE_NUM
|
||||
|
||||
if average_current > 1:
|
||||
NativeLog.add_trace_critical("[DeepSleep][Wakeup] average current %f > 1mA" % average_current)
|
||||
self.multimeter.draw_graph(current_line, SAMPLE_RATE,
|
||||
"deep_sleep_current", Y_AXIS_LABEL)
|
||||
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_CHIP_RESET, GPIO_EDGE_DELAY))
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
if self.check_response("SSC1", "ready!!!") is False:
|
||||
NativeLog.add_trace_critical("[DeepSleep][Wakeup] target did not wakeup")
|
||||
result = False
|
||||
else:
|
||||
NativeLog.add_trace_critical("[DeepSleep][Wakeup] target wakeup")
|
||||
|
||||
time.sleep(1)
|
||||
return result
|
||||
|
||||
#########################################
|
||||
#test one hour, Verify RTC Clock timer
|
||||
#########################################
|
||||
def deep_sleep_timeout(self):
|
||||
result = True
|
||||
Timeout = 3600
|
||||
|
||||
start_sleep_time = time.time()
|
||||
self.serial_write_line("SSC1", "")
|
||||
self.serial_write_line("SSC1", "dsleep -S -t %d" % (Timeout*1000000))
|
||||
if self.check_response("SSC1", "+DSLEEP:OK") is False:
|
||||
result = False
|
||||
self.check_response("SSC1", "ready!!!", timeout = Timeout*2)
|
||||
time_escaped = time.time() - start_sleep_time
|
||||
NativeLog.add_trace_critical("[DeepSleep][timeout] desired sleep timeout is %s, actual sleep timeout is %s" % (Timeout, time_escaped))
|
||||
with open(self.sleep_time_log, "ab+") as f:
|
||||
f.write("[DeepSleep] desired sleep timeout is %s, actual sleep timeout is %s" % (Timeout, time_escaped))
|
||||
return result
|
||||
|
||||
############################################
|
||||
# Capture current map, verify the process of power on
|
||||
# notice: option = "up_to_bin" up to byte108 in init.bin,
|
||||
############################################
|
||||
def wake_option(self):
|
||||
result = True
|
||||
for option in DEEP_SLEEP_OPTION_LIST:
|
||||
for i in range(8):
|
||||
self.serial_write_line("SSC1", "dsleep -O -m %s" % DEEP_SLEEP_OPTION[option])
|
||||
if self.check_response("SSC1", "+DSLEEP:OK") is False:
|
||||
result = False
|
||||
self.serial_write_line("SSC1", "dsleep -S -t 1200000")
|
||||
if self.check_response("SSC1", "+DSLEEP:OK") is False:
|
||||
result = False
|
||||
|
||||
# measure current
|
||||
current_line = self.multimeter.measure_current(sample_rate=0.002,
|
||||
sample_num=SAMPLE_NUM,
|
||||
max_value=1)
|
||||
self.multimeter.draw_graph(current_line, SAMPLE_RATE,
|
||||
"deep_sleep_wakeup_option_%s_%d"
|
||||
% (option, DEEP_SLEEP_OPTION[option]), Y_AXIS_LABEL)
|
||||
|
||||
NativeLog.add_trace_critical("[DeepSleep][wake_option] target wakeup option:%d"
|
||||
% DEEP_SLEEP_OPTION[option])
|
||||
time.sleep(3)
|
||||
|
||||
return result
|
||||
|
||||
def deep_sleep_wakeup_flash_gpio_status(self):
|
||||
result = True
|
||||
RandomTime = random.randint(2000000, 2000000)
|
||||
self.serial_write_line("SSC1", "dsleep -S -t %s" % RandomTime)
|
||||
if self.check_response("SSC1", "+DSLEEP:OK") is False:
|
||||
result = False
|
||||
if self.check_response("SSC1", "ready!!!") is False:
|
||||
result = False
|
||||
NativeLog.add_trace_critical("[DeepSleep][Stable] wait ready err")
|
||||
else:
|
||||
NativeLog.add_trace_critical("[DeepSleep][Stable] SleepTime:%d" % RandomTime)
|
||||
|
||||
self.serial_write_line("SSC1", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
self.check_response("SSC1", "+GPIO_SET:OK")
|
||||
|
||||
time.sleep(1)
|
||||
return result
|
||||
|
||||
def cleanup(self):
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_CHIP_RESET, GPIO_EDGE_DELAY))
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.serial_write_line("SSC2", "sta -D")
|
||||
self.check_response("SSC2", "+QAP")
|
||||
self.serial_write_line("SSC1", "sta -D")
|
||||
self.check_response("SSC1", "+QAP")
|
||||
try:
|
||||
test_mode = self.test_mode
|
||||
test_count = self.test_count
|
||||
except StandardError, e:
|
||||
return
|
||||
|
||||
# self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_CHIP_RESET, GPIO_EDGE_DELAY))
|
||||
# self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
# time.sleep(1)
|
||||
|
||||
if "stable" in test_mode:
|
||||
for i in range(test_count):
|
||||
# result = self.deep_sleep_wakeup_flash_gpio_status()
|
||||
result = self.deep_sleep_stable()
|
||||
elif "measure_current" in test_mode:
|
||||
for i in range(test_count):
|
||||
result = self.deep_sleep_current_measure()
|
||||
elif "timeout" in test_mode:
|
||||
for i in range(test_count):
|
||||
result = self.deep_sleep_timeout()
|
||||
elif "wakeup" in test_mode:
|
||||
for i in range(test_count):
|
||||
result = self.deep_sleep_wakeup()
|
||||
elif "wake_option" in test_mode:
|
||||
for i in range(test_count):
|
||||
result = self.wake_option()
|
||||
|
||||
self.set_result("Succeed")
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,254 +0,0 @@
|
||||
import random
|
||||
import os
|
||||
import time
|
||||
|
||||
from TCAction import TCActionBase, PerformanceTCBase
|
||||
from Utility import MakeFolder
|
||||
from Utility import MultimeterUtil
|
||||
from NativeLog import NativeLog
|
||||
|
||||
LOG_PATH = os.path.join("AT_LOG", "SLEEP")
|
||||
|
||||
SLEEP_MODE_LIST = ["none_sleep", "light_sleep", "modem_sleep"]
|
||||
SLEEP_MODE = dict(zip(SLEEP_MODE_LIST, range(len(SLEEP_MODE_LIST))))
|
||||
|
||||
SAMPLE_RATE = 0.002
|
||||
SAMPLE_NUM = 512
|
||||
MAX_VALUE = 1
|
||||
Y_AXIS_LABEL = "Current (mA)"
|
||||
|
||||
MEASURE_FREQ_HOUR = 3600
|
||||
|
||||
GPIO_WAKE_UP = 15
|
||||
GPIO_EDGE_DELAY = 120 # 20 ms
|
||||
GPIO_CHIP_RESET = 14
|
||||
GPIO_CHIP_RESET_DELAY = 100
|
||||
|
||||
NONE_SLEEP_MIN_CUR = 30
|
||||
LIGHT_SLEEP_MIN_CUR = 1.5
|
||||
MODEM_SLEEP_MIN_CUR = 20
|
||||
|
||||
LIGHT_SLEEP_WAKEUP_DELAY = 0.01
|
||||
|
||||
|
||||
class ForceSleep(PerformanceTCBase.PerformanceTCBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
PerformanceTCBase.PerformanceTCBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.test_mode = "mode_change"
|
||||
self.test_count = 100
|
||||
self.sleep_mode = SLEEP_MODE_LIST
|
||||
# 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.log_folder = MakeFolder.make_folder(os.path.join(LOG_PATH,
|
||||
"FORCE_SLEEP_%s_%s" % (self.test_mode,
|
||||
time.strftime("%d%H%M%S",
|
||||
time.localtime()))))
|
||||
self.multimeter = MultimeterUtil.MultimeterUtil(self.log_folder)
|
||||
|
||||
@staticmethod
|
||||
def find_min_items(item_list, count):
|
||||
assert count < len(item_list)
|
||||
min_items = []
|
||||
for i in range(count):
|
||||
min_val = min(item_list)
|
||||
min_items.append(min_val)
|
||||
item_list.remove(min_val)
|
||||
return min_items
|
||||
|
||||
def sleep_time_boundary_test(self):
|
||||
result = True
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(LIGHT_SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "op -S -o 0")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
if self.check_response("SSC1", "+MODE:OK") is False:
|
||||
result = False
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(LIGHT_SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "fsleep -S -t 1")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
if self.check_response("SSC1", "+FSLEEP_MODE:OK") is False:
|
||||
result = False
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(LIGHT_SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "fsleep -D -d 0")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
# if self.check_response("SSC1", "+FSLEEP_MODE:OK") is False:
|
||||
# result = False
|
||||
time.sleep(1)
|
||||
current_line = self.multimeter.measure_current(sample_rate=SAMPLE_RATE,
|
||||
sample_num=SAMPLE_NUM,
|
||||
max_value=MAX_VALUE)
|
||||
min_items = self.find_min_items(current_line, 10)
|
||||
average_val = float(0)
|
||||
for val in min_items:
|
||||
average_val += val
|
||||
average_val /= 10
|
||||
if average_val > LIGHT_SLEEP_MIN_CUR:
|
||||
NativeLog.add_trace_critical("[ForceSleep][Boundary] did not enter light sleep %d" % average_val)
|
||||
result = False
|
||||
return result
|
||||
else:
|
||||
NativeLog.add_trace_critical("[ForceSleep][Boundary] enter light sleep")
|
||||
|
||||
for i in range(3):
|
||||
time.sleep(MEASURE_FREQ_HOUR)
|
||||
for j in range(3):
|
||||
time.sleep(10)
|
||||
current_line = self.multimeter.measure_current(sample_rate=SAMPLE_RATE,
|
||||
sample_num=SAMPLE_NUM,
|
||||
max_value=MAX_VALUE)
|
||||
self.multimeter.draw_graph(current_line, SAMPLE_RATE,
|
||||
"light_sleep_boundary_%s_%s" % (i, j), Y_AXIS_LABEL)
|
||||
pass
|
||||
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
time.sleep(1)
|
||||
self.serial_write_line("SSC1", "reboot")
|
||||
self.check_response("SSC1", "ready!!!")
|
||||
self.serial_write_line("SSC1", "fsleep -S -t 1")
|
||||
if self.check_response("SSC1", "+FSLEEP_MODE:OK") is False:
|
||||
result = False
|
||||
self.serial_write_line("SSC1", "")
|
||||
self.serial_write_line("SSC1", "fsleep -B -t 1")
|
||||
if self.check_response("SSC1", "+FSLEEP_MODE:OK") is False:
|
||||
result = False
|
||||
time.sleep(MEASURE_FREQ_HOUR)
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_CHIP_RESET,GPIO_CHIP_RESET_DELAY))
|
||||
return result
|
||||
|
||||
def force_sleep_current_measure(self, sleep_mode):
|
||||
result = True
|
||||
# choose sleep mode
|
||||
sleep_mode_enum = SLEEP_MODE[sleep_mode]
|
||||
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(LIGHT_SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "op -S -o 0")
|
||||
if self.check_response("SSC1", "+MODE:OK") is False:
|
||||
result = False
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
|
||||
# set sleep mode
|
||||
self.serial_write_line("SSC1", "fsleep -S -t %s" % sleep_mode_enum)
|
||||
if self.check_response("SSC1", "+FSLEEP_MODE:OK") is False:
|
||||
result = False
|
||||
self.serial_write_line("SSC1", "fsleep -D -d 0")
|
||||
# if self.check_response("SSC1", "+FSLEEP_MODE:OK") is False:
|
||||
# result = False
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
for i in range(10):
|
||||
time.sleep(10)
|
||||
# measure current
|
||||
current_line = self.multimeter.measure_current(sample_rate=SAMPLE_RATE,
|
||||
sample_num=SAMPLE_NUM,
|
||||
max_value=MAX_VALUE)
|
||||
self.multimeter.draw_graph(current_line, SAMPLE_RATE,
|
||||
"force_%s_sleep_current_%s" % (sleep_mode, i), Y_AXIS_LABEL)
|
||||
NativeLog.add_trace_critical("[ForceSleep][current_measure] force_%s_%d"% (sleep_mode,i))
|
||||
|
||||
# self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP,GPIO_EDGE_DELAY))
|
||||
# self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
# self.serial_write_line("SSC1", "reboot")
|
||||
# self.check_response("SSC1", "ready!!!")
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_CHIP_RESET, GPIO_CHIP_RESET_DELAY))
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
if self.check_response("SSC1", "ready!!!") is False:
|
||||
result = False
|
||||
time.sleep(1)
|
||||
return result
|
||||
|
||||
def force_sleep_illegal_enter(self):
|
||||
result = True
|
||||
# choose sleep mode
|
||||
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(LIGHT_SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "op -S -o 2")
|
||||
if self.check_response("SSC1", "+MODE:OK") is False:
|
||||
result = False
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
|
||||
# set sleep mode
|
||||
self.serial_write_line("SSC1", "fsleep -D -d 0")
|
||||
if self.check_response("SSC1", "ready!!!", timeout=10) is False:
|
||||
result = False
|
||||
time.sleep(5)
|
||||
return result
|
||||
|
||||
def force_sleep_stable_test(self):
|
||||
result = True
|
||||
# choose sleep mode
|
||||
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(LIGHT_SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "fsleep -L")
|
||||
if self.check_response("SSC1", "+MODE:OK") is False:
|
||||
result = False
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
|
||||
time.sleep(3600)
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_CHIP_RESET, GPIO_CHIP_RESET_DELAY))
|
||||
time.sleep(5)
|
||||
return result
|
||||
|
||||
def cleanup(self):
|
||||
self.serial_write_line("SSC2", "gpio -E -p %d -t 0 -d %d" % (GPIO_WAKE_UP, GPIO_EDGE_DELAY))
|
||||
time.sleep(LIGHT_SLEEP_WAKEUP_DELAY)
|
||||
self.serial_write_line("SSC1", "reboot")
|
||||
self.check_response("SSC1", "ready!!!")
|
||||
self.check_response("SSC2", "+GPIO_SET:OK")
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.serial_write_line("SSC2", "sta -D")
|
||||
self.check_response("SSC2", "+QAP")
|
||||
self.serial_write_line("SSC1", "sta -D")
|
||||
self.check_response("SSC1", "+QAP")
|
||||
try:
|
||||
test_mode = self.test_mode
|
||||
test_count = self.test_count
|
||||
sleep_mode = self.sleep_mode
|
||||
except StandardError, e:
|
||||
return
|
||||
|
||||
# set gpio to input on sleep target
|
||||
self.serial_write_line("SSC1", "gpio -G -p %d" % GPIO_WAKE_UP)
|
||||
self.check_response("SSC1", "+GPIO_GET")
|
||||
self.serial_write_line("SSC1", "gpio -G -p %d" % GPIO_CHIP_RESET)
|
||||
self.check_response("SSC1", "+GPIO_GET")
|
||||
|
||||
if test_mode == "boundary_test":
|
||||
for i in range(test_count):
|
||||
result = self.sleep_time_boundary_test()
|
||||
pass
|
||||
elif test_mode == "measure_current":
|
||||
for j in range(test_count):
|
||||
for mode in sleep_mode:
|
||||
result = self.force_sleep_current_measure(mode)
|
||||
pass
|
||||
elif test_mode == "illegal_enter":
|
||||
for i in range(test_count):
|
||||
result = self.force_sleep_illegal_enter()
|
||||
pass
|
||||
elif test_mode == "stable_test":
|
||||
for i in range(test_count):
|
||||
result = self.force_sleep_stable_test()
|
||||
pass
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1 +0,0 @@
|
||||
__all__ = ["AutoSleep", "DeepSleep", "ForceSleep"]
|
@ -1,160 +0,0 @@
|
||||
import time
|
||||
import random
|
||||
import threading
|
||||
|
||||
from TCAction import TCActionBase
|
||||
from NativeLog import NativeLog
|
||||
|
||||
|
||||
class StableCase1(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
# 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.exit_event = threading.Event()
|
||||
self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name)
|
||||
pass
|
||||
|
||||
def check_wifi_status(self, data):
|
||||
if data.find("+JAP:DISCONNECTED") != -1:
|
||||
self.exit_event.set()
|
||||
NativeLog.add_trace_critical("[Wifi] Disconnected")
|
||||
pass
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.result_cntx.start()
|
||||
|
||||
try:
|
||||
# configurable params
|
||||
# target role
|
||||
target_role = self.target_role
|
||||
# enable tcp send/recv
|
||||
tcp_enable = self.tcp_enable
|
||||
# enable udp send/recv
|
||||
udp_enable = self.udp_enable
|
||||
# enable ping
|
||||
ping_enable = self.ping_enable
|
||||
# delay range
|
||||
delay_range = self.delay_range
|
||||
# test time in hours
|
||||
test_time = self.test_time * 3600
|
||||
# configurable params
|
||||
except StandardError, e:
|
||||
NativeLog.add_trace_critical("Error configuration for TCPTransparent script, error is %s" % e)
|
||||
raise StandardError("Error configuration")
|
||||
|
||||
if target_role == "AP":
|
||||
pc_ip = "<pc_ip_wifi>"
|
||||
target_ip = "<target_ap_ip>"
|
||||
elif target_role == "STA":
|
||||
pc_ip = "<pc_ip>"
|
||||
target_ip = "<target_ip>"
|
||||
else:
|
||||
raise StandardError("target role only support AP or STA")
|
||||
|
||||
# step 1, create UDP socket and TCP server
|
||||
checker_stings = ["R SSC1 A <udp_socket>:BIND:(\d+),OK"]
|
||||
test_action_string = ["SSC SSC1 soc -B -t UDP -p <test_udp_port1>"]
|
||||
fail_string = "Fail, Fail to create UDP socket"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R SSC1 A <tcp_server>:BIND:(\d+),OK"]
|
||||
test_action_string = ["SSC SSC1 soc -B -t TCP -p <random_port>"]
|
||||
fail_string = "Fail, Fail to create tcp 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 = ["SSC SSC1 soc -L -s <tcp_server>"]
|
||||
fail_string = "Fail, Fail to listen"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
# step 2, PC connect to 8266 tcp server, PC create UDP socket
|
||||
checker_stings = ["R SOC_COM C OK"]
|
||||
test_action_string = ["SOC SOC1 BIND <test_udp_port1> %s" % pc_ip]
|
||||
fail_string = "Fail, Fail to create udp socket on PC"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["P SSC1 A <tcp_socket>:ACCEPT:(\d+),\d+", "P SOC_COM C OK"]
|
||||
test_action_string = ["SOC SOC2 CONNECT <random_port> %s 0 %s" % (target_ip, pc_ip)]
|
||||
fail_string = "Fail, Fail to create tcp socket on PC"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
start_time = time.time()
|
||||
total_test_count = ping_fail_count = tcp_fail_count = udp_fail_count = 0
|
||||
|
||||
# step 3, start do tcp/udp/ping
|
||||
while time.time() - start_time < test_time and self.exit_event.isSet() is False:
|
||||
total_test_count += 1
|
||||
if ping_enable is True:
|
||||
# do ping
|
||||
checker_stings = ["P PC_COM RE \+PING:\d+ms"]
|
||||
test_action_string = ["PING %s -n 1 -w 1000" % target_ip]
|
||||
fail_string = "Fail, Fail to ping target"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
ping_fail_count += 1
|
||||
NativeLog.add_prompt_trace("[ping fail] fail/total = %s/%s"
|
||||
% (ping_fail_count, total_test_count))
|
||||
pass
|
||||
|
||||
data_len = random.randint(1, 1460)
|
||||
|
||||
if tcp_enable is True:
|
||||
# do tcp send/recv
|
||||
checker_stings = ["P SSC1 SL <tcp_socket>+%s" % data_len, "P SOC2 RL %s" % data_len]
|
||||
test_action_string = ["SSC SSC1 soc -S -s <tcp_socket> -l %s" % data_len,
|
||||
"SOC SOC2 SEND %s" % data_len]
|
||||
fail_string = "Fail, Fail to send/recv tcp"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
tcp_fail_count += 1
|
||||
NativeLog.add_prompt_trace("[tcp fail] fail/total = %s/%s"
|
||||
% (tcp_fail_count, total_test_count))
|
||||
# tcp fail, break
|
||||
self.exit_event.set()
|
||||
pass
|
||||
|
||||
if udp_enable is True:
|
||||
# do udp send/recv
|
||||
checker_stings = ["P SSC1 SL <udp_socket>+%s" % data_len, "P SOC1 RL %s" % data_len]
|
||||
test_action_string = ["SSC SSC1 soc -S -s <udp_socket> "
|
||||
"-i %s -p <test_udp_port1> -l %s" % (pc_ip, data_len),
|
||||
"SOC SOC1 SENDTO %s <test_udp_port1> %s" % (data_len, target_ip)]
|
||||
fail_string = "Fail, Fail to sendto/recvfrom udp"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string, check_time=20) is False:
|
||||
udp_fail_count += 1
|
||||
NativeLog.add_prompt_trace("[udp fail] fail/total = %s/%s"
|
||||
% (udp_fail_count, total_test_count))
|
||||
pass
|
||||
|
||||
# sleep
|
||||
time.sleep(random.randint(delay_range[0], delay_range[1]))
|
||||
pass
|
||||
|
||||
# finally, execute done
|
||||
if self.exit_event.isSet() is False:
|
||||
self.result_cntx.set_result("Succeed")
|
||||
|
||||
def result_check(self, port_name, data):
|
||||
self.result_cntx.append_data(port_name, data)
|
||||
if port_name != "SOC1" and port_name != "SOC2":
|
||||
# socket received data do not need to be logged
|
||||
TCActionBase.CommonTCActionBase.result_check(self, port_name, data)
|
||||
if port_name == "SSC1":
|
||||
self.check_wifi_status(data)
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1 +0,0 @@
|
||||
__all__ = ["StableCase1"]
|
@ -1,121 +0,0 @@
|
||||
import time
|
||||
|
||||
from NativeLog import NativeLog
|
||||
from TCAction import TCActionBase
|
||||
from comm.NIC import Adapter
|
||||
|
||||
WARNING_COUNT = 5
|
||||
|
||||
|
||||
class ARPStress(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.adapter = None
|
||||
self.target_mode = "STA"
|
||||
# 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 cleanup(self):
|
||||
self.adapter.close()
|
||||
del self.adapter
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.result_cntx.start()
|
||||
|
||||
try:
|
||||
# configurable params
|
||||
test_time = self.test_time * 60
|
||||
# test frequency min should be 0.1s, otherwise reply could be missed
|
||||
test_freq = self.test_freq if self.test_freq > 0.1 else 0.1
|
||||
# test softAP or sta
|
||||
target_mode = self.target_mode
|
||||
# configurable params
|
||||
except StandardError, e:
|
||||
NativeLog.add_trace_critical("Error configuration for ARPStress script, error is %s" % e)
|
||||
raise StandardError("Error configuration")
|
||||
|
||||
# get parameters
|
||||
if target_mode == "STA":
|
||||
target_ip = self.get_parameter("target_ip")
|
||||
target_mac = self.get_parameter("target_mac")
|
||||
pc_mac = self.get_parameter("pc_nic_mac")
|
||||
pc_nic_name = self.get_parameter("pc_nic")
|
||||
elif target_mode == "SoftAP":
|
||||
target_ip = self.get_parameter("target_ap_ip")
|
||||
target_mac = self.get_parameter("target_ap_mac")
|
||||
pc_mac = self.get_parameter("pc_wifi_nic_mac")
|
||||
pc_nic_name = self.get_parameter("pc_wifi_nic")
|
||||
else:
|
||||
raise StandardError("Unsupported target mode: %s" % target_mode)
|
||||
|
||||
time_start = time.time()
|
||||
|
||||
# open device
|
||||
self.adapter = Adapter.Adapter(pc_nic_name, "capture+send")
|
||||
ret = self.adapter.set_filter("arp and ether src %s and ether dst %s" % (target_mac, pc_mac))
|
||||
if ret != "LIBPCAP_SUCCEED":
|
||||
NativeLog.add_trace_critical("ARP Stress test error: %s" % ret)
|
||||
return
|
||||
|
||||
ret = self.adapter.start_capture()
|
||||
if ret != "LIBPCAP_SUCCEED":
|
||||
NativeLog.add_trace_critical("ARP Stress test error: %s" % ret)
|
||||
return
|
||||
|
||||
arp_pdu = self.adapter.create_pdu("ARP", self.adapter.create_payload(),
|
||||
arp_op_code="request", arp_target_proto_addr=target_ip,
|
||||
ethernet_dst_addr="ff:ff:ff:ff:ff:ff")
|
||||
|
||||
data = arp_pdu.to_bytes()
|
||||
|
||||
total_test_count = total_fail_count = successive_fail_count = most_successive_fail_count = 0
|
||||
|
||||
while (time.time() - time_start) < test_time:
|
||||
# send arp req
|
||||
ret = self.adapter.ether_send(data)
|
||||
if ret != "LIBNET_SUCCEED":
|
||||
NativeLog.add_prompt_trace("libnet send fail, %s" % ret)
|
||||
continue
|
||||
total_test_count += 1
|
||||
# wait for reply
|
||||
time.sleep(test_freq)
|
||||
# should get one arp reply
|
||||
pdu_list = self.adapter.get_packets()
|
||||
|
||||
if len(pdu_list) == 0:
|
||||
# failed to get arp reply
|
||||
total_fail_count += 1
|
||||
successive_fail_count += 1
|
||||
if successive_fail_count > WARNING_COUNT:
|
||||
NativeLog.add_trace_critical("ARP Fail: successive fail %u times, total tested %u times"
|
||||
% (successive_fail_count, total_test_count))
|
||||
else:
|
||||
most_successive_fail_count = most_successive_fail_count \
|
||||
if most_successive_fail_count > successive_fail_count \
|
||||
else successive_fail_count
|
||||
successive_fail_count = 0
|
||||
pass
|
||||
NativeLog.add_trace_critical("ARP stress test, total %s times, failed %s times, most successive fail count %s"
|
||||
% (total_test_count, total_fail_count, most_successive_fail_count))
|
||||
self.result_cntx.set_result("Succeed")
|
||||
|
||||
# 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()
|
@ -1,122 +0,0 @@
|
||||
import time
|
||||
|
||||
from NativeLog import NativeLog
|
||||
from TCAction import TCActionBase
|
||||
from comm.NIC import Adapter
|
||||
|
||||
WARNING_COUNT = 2
|
||||
|
||||
|
||||
class PingStress(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.adapter = None
|
||||
self.target_mode = "STA"
|
||||
# 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 cleanup(self):
|
||||
self.adapter.close()
|
||||
del self.adapter
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.result_cntx.start()
|
||||
|
||||
try:
|
||||
# configurable params
|
||||
test_time = self.test_time * 60
|
||||
# ping data len
|
||||
ping_len = self.ping_len
|
||||
# test frequency min should be 0.1s, otherwise reply could be missed
|
||||
test_freq = self.test_freq if self.test_freq > 0.1 else 0.1
|
||||
# target mode
|
||||
target_mode = self.target_mode
|
||||
# configurable params
|
||||
except StandardError, e:
|
||||
NativeLog.add_trace_critical("Error configuration for PingStress script, error is %s" % e)
|
||||
raise StandardError("Error configuration")
|
||||
|
||||
if target_mode == "STA":
|
||||
target_ip = self.get_parameter("target_ip")
|
||||
target_mac = self.get_parameter("target_mac")
|
||||
pc_mac = self.get_parameter("pc_nic_mac")
|
||||
pc_nic_name = self.get_parameter("pc_nic")
|
||||
elif target_mode == "SoftAP":
|
||||
target_ip = self.get_parameter("target_ap_ip")
|
||||
target_mac = self.get_parameter("target_ap_mac")
|
||||
pc_mac = self.get_parameter("pc_wifi_nic_mac")
|
||||
pc_nic_name = self.get_parameter("pc_wifi_nic")
|
||||
else:
|
||||
raise StandardError("Unsupported target mode: %s" % target_mode)
|
||||
|
||||
time_start = time.time()
|
||||
# open device
|
||||
self.adapter = Adapter.Adapter(pc_nic_name, "capture+send")
|
||||
|
||||
ret = self.adapter.set_filter("icmp[icmpcode]=icmp-echoreply and ether src %s and ether dst %s"
|
||||
% (target_mac, pc_mac))
|
||||
if ret != "LIBPCAP_SUCCEED":
|
||||
NativeLog.add_trace_critical("PING Stress test error: %s" % ret)
|
||||
return
|
||||
|
||||
ret = self.adapter.start_capture()
|
||||
if ret != "LIBPCAP_SUCCEED":
|
||||
NativeLog.add_trace_critical("PING Stress test error: %s" % ret)
|
||||
return
|
||||
|
||||
total_test_count = total_fail_count = successive_fail_count = most_successive_fail_count = 0
|
||||
|
||||
while (time.time() - time_start) < test_time:
|
||||
|
||||
ping_pdu = self.adapter.create_pdu("ICMP", self.adapter.create_payload("A" * ping_len),
|
||||
icmp_type="echo-request", ipv4_protocol="ICMP",
|
||||
ipv4_dst_ip=target_ip, ethernet_dst_addr=target_mac)
|
||||
# send ping req
|
||||
ret = self.adapter.ether_send(ping_pdu.to_bytes())
|
||||
if ret != "LIBNET_SUCCEED":
|
||||
NativeLog.add_prompt_trace("libnet send fail, %s" % ret)
|
||||
continue
|
||||
total_test_count += 1
|
||||
# wait for reply
|
||||
time.sleep(test_freq)
|
||||
# should get one ping reply
|
||||
pdu_list = self.adapter.get_packets()
|
||||
|
||||
if len(pdu_list) == 0:
|
||||
# failed to get ping reply
|
||||
total_fail_count += 1
|
||||
successive_fail_count += 1
|
||||
if successive_fail_count > WARNING_COUNT:
|
||||
NativeLog.add_trace_critical("Ping Fail: successive fail %u times, total tested %u times"
|
||||
% (successive_fail_count, total_test_count))
|
||||
pass
|
||||
else:
|
||||
most_successive_fail_count = most_successive_fail_count \
|
||||
if most_successive_fail_count > successive_fail_count \
|
||||
else successive_fail_count
|
||||
successive_fail_count = 0
|
||||
pass
|
||||
pass
|
||||
NativeLog.add_trace_critical("Ping stress test, total %s times, failed %s times, most successive fail count %s"
|
||||
% (total_test_count, total_fail_count, most_successive_fail_count))
|
||||
self.result_cntx.set_result("Succeed")
|
||||
# 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()
|
@ -1 +0,0 @@
|
||||
__all__ = ["ARPStress", "PingStress"]
|
@ -1,168 +0,0 @@
|
||||
from TCAction import TCActionBase
|
||||
from NativeLog import NativeLog
|
||||
import copy
|
||||
import time
|
||||
import random
|
||||
import string
|
||||
|
||||
|
||||
class TCPAP4STAResultCheckCntx(TCActionBase.ResultCheckContext):
|
||||
|
||||
def __init__(self, test_action, test_env, name):
|
||||
TCActionBase.ResultCheckContext.__init__(self, test_action, test_env, name)
|
||||
self.failed_port = []
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
|
||||
while True:
|
||||
exit_flag = self.wait_exit_event(1)
|
||||
# force exit
|
||||
if exit_flag is True:
|
||||
break
|
||||
try:
|
||||
self.lock_data()
|
||||
temp_cache = copy.deepcopy(self.data_cache)
|
||||
self.data_cache = []
|
||||
finally:
|
||||
self.unlock_data()
|
||||
|
||||
for _cache in temp_cache:
|
||||
_data = _cache[1]
|
||||
if _data.find("user_test_tcpclient_recon_cb") != -1 or _data.find("discon") != -1 \
|
||||
or _data.find("No heap available") != -1:
|
||||
self.failed_port.append(_cache[0])
|
||||
NativeLog.add_trace_critical("TCPAP4STA failed, failed on %s" % _cache[0])
|
||||
pass
|
||||
if len(self.failed_port) != 0:
|
||||
# disconnect happen
|
||||
break
|
||||
|
||||
def get_test_results(self):
|
||||
return self.failed_port
|
||||
|
||||
|
||||
class TCPAP4STA(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
# 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
|
||||
send_len = self.send_len
|
||||
# test count
|
||||
test_count = self.test_count
|
||||
# server port
|
||||
server_port = self.server_port
|
||||
# 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+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
|
||||
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 dhcp%20server%20start"]
|
||||
test_action_string = ["SSCC SSC1 ap -S -s %s -p %s -n 10 -t 0 -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 C server%20starts%20at%20port"]
|
||||
if server_echo is True:
|
||||
test_action_string = ["SSCC SSC1 tcp -S -p %s -b 1" % server_port]
|
||||
else:
|
||||
test_action_string = ["SSCC SSC1 tcp -S -p %s" % server_port]
|
||||
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, 4 SSC target(SSC2 - SSC5) join SSC1 soft AP
|
||||
checker_stings = []
|
||||
test_action_string = []
|
||||
|
||||
for i in range(sta_number):
|
||||
checker_stings.append("P SSC%d C ip C mask C gw C get%%20ip%%20of" % (i+2))
|
||||
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
|
||||
|
||||
start_time = time.time()
|
||||
|
||||
# step 3, create client on SSC2 - SSC5
|
||||
checker_stings = []
|
||||
test_action_string = []
|
||||
|
||||
for i in range(sta_number):
|
||||
checker_stings.append("P SSC%d C tcp%%20client%%20connect%%20with%%20server" % (i+2))
|
||||
test_action_string.append("SSCC SSC%d tcp -W -i %s -p %s -c %s -n 1 -l %s -d %d"
|
||||
% ((i+2), ap_ip, server_port, test_count, send_len, send_delay))
|
||||
|
||||
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
|
||||
|
||||
# switch to new result context
|
||||
self.result_cntx.stop_thread()
|
||||
self.result_cntx.join()
|
||||
self.result_cntx = TCPAP4STAResultCheckCntx(self, self.test_env, self.tc_name)
|
||||
self.result_cntx.start()
|
||||
|
||||
self.result_cntx.join()
|
||||
|
||||
failed_port = self.result_cntx.get_test_results()
|
||||
if (time.time() - start_time) > pass_standard:
|
||||
self.result_cntx.set_result("Succeed")
|
||||
else:
|
||||
self.result_cntx.set_result("Failed")
|
||||
NativeLog.add_trace_critical("Failed port: %s" % failed_port)
|
||||
|
||||
# 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()
|
||||
|
@ -1,209 +0,0 @@
|
||||
from TCAction import TCActionBase
|
||||
from NativeLog import NativeLog
|
||||
import time
|
||||
import random
|
||||
import string
|
||||
|
||||
|
||||
TEST_COUNT_ONE_ROUND = 500
|
||||
|
||||
|
||||
class TCPAPNSTA(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
# 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
|
||||
send_len = self.send_len
|
||||
# test count
|
||||
test_count = self.test_count
|
||||
# server port
|
||||
server_port = self.server_port
|
||||
# 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+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)])
|
||||
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 set ap"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R SSC1 A <server_sock>:BIND:(\d+),OK"]
|
||||
test_action_string = ["SSCC SSC1 soc -B -t TCP -p %s" % server_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 <server_sock>"]
|
||||
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
|
||||
|
||||
start_time = time.time()
|
||||
|
||||
# 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 <client_sock%d>: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_sock%d>:ACCEPT:(\d+),.+" % (i+2)]
|
||||
test_action_string = ["SSCC SSC%d soc -C -s <client_sock%d> -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
|
||||
|
||||
# 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 <client_sock%d> -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 <accept_sock%d> -l %d -n %d -j %d" %
|
||||
(i+2, send_len, _tmp_count, send_delay))
|
||||
checker_stings.append("P SSC1 RE \"\+SEND:%%%%s,OK\"%%%%(<accept_sock%d>) 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
|
||||
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 + 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 <server_sock>: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 <server_sock>"]
|
||||
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 <client_sock%d>: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_sock%d>:ACCEPT:(\d+),.+" % (i + 2)]
|
||||
test_action_string = ["SSCC SSC%d soc -C -s <client_sock%d> -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()
|
||||
|
@ -1,363 +0,0 @@
|
||||
import random
|
||||
import re
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
|
||||
import TCPConnUtility
|
||||
from NativeLog import NativeLog
|
||||
from TCAction import TCActionBase
|
||||
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('iso-8859-1') # # use encoding that with 1 Byte length and contain 256 chars
|
||||
|
||||
|
||||
DEFAULT_MAX_CONN_ALLOWED = 5
|
||||
|
||||
|
||||
# complicated design because I want to make this script applied for all TCP connect/close test scenarios
|
||||
# basic flow: try to create max connections, send/recv data if possible, close all connections
|
||||
# connect:
|
||||
# 1. find available (target_link_id, socket_id) list,
|
||||
# notice that target_link_id maybe not correct if PC is client
|
||||
# (during that time, some link may timeout and got disconnected from FIN_WAIT or other state)
|
||||
# 2. choose one method from method set, try to connect
|
||||
# 3. update state table: a)check result and destination state, b)find real target_link_id, c)update
|
||||
# send/recv data:
|
||||
# 1. find channels that are possible to send data on all connections
|
||||
# 2. send data on possible channels
|
||||
# disconnect:
|
||||
# 1. find available connections
|
||||
# 2. choose one method from disconnect set, try to disconnect
|
||||
# 3. update state table (phase 1)
|
||||
# async process:
|
||||
# listen on AT UART port, record all "x,CONNECT" and "x,CLOSE" command
|
||||
# for "x,CONNECT", append them to self.target_link_id_list, used when need to find real target_link_id
|
||||
# for "x,CLOSE", update state table (phase 2), if matching connection is pending on wait state,
|
||||
# close them and remove from state table
|
||||
class TCPConnStressTC(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.__at1_buff = ""
|
||||
self.max_conn_allowed = test_env.get_variable_by_name("max_conn")
|
||||
self.enable_log = True
|
||||
# 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
|
||||
|
||||
# connection_state_dict: {target_link_id: [socket_id, target_state, socket_state, is_closed]}
|
||||
# is_closed: found "x,CLOSE" in AT UART port
|
||||
self.connection_state_dict = dict(zip(range(self.max_conn_allowed), [None] * self.max_conn_allowed))
|
||||
self.created_link_id_list = []
|
||||
|
||||
self.__available_soc_id = range(2, 2+self.max_conn_allowed)
|
||||
self.__available_link_id = range(self.max_conn_allowed)
|
||||
|
||||
self.result_cntx = TCActionBase.ResultCheckContext(self, test_env, self.tc_name)
|
||||
self.utility = TCPConnUtility.TCPConnUtility(self)
|
||||
self.state_lock = threading.Lock()
|
||||
self.link_id_lock = threading.Lock()
|
||||
self.available_id_lock = threading.Lock()
|
||||
pass
|
||||
|
||||
def __add_log(self, log_str):
|
||||
if self.enable_log is True:
|
||||
NativeLog.add_trace_info(log_str)
|
||||
|
||||
def __get_created_target_link_id(self):
|
||||
self.link_id_lock.acquire()
|
||||
try:
|
||||
link_id = self.created_link_id_list[-1]
|
||||
self.created_link_id_list = []
|
||||
finally:
|
||||
self.link_id_lock.release()
|
||||
return link_id
|
||||
pass
|
||||
|
||||
def __set_created_target_link_id(self, link_id):
|
||||
self.link_id_lock.acquire()
|
||||
try:
|
||||
self.created_link_id_list.append(link_id)
|
||||
finally:
|
||||
self.link_id_lock.release()
|
||||
pass
|
||||
|
||||
def __find_channel_list(self):
|
||||
channel_list = [] # # [(socket_id, able_to_send, link_id, able_to_send), ]
|
||||
self.state_lock.acquire()
|
||||
try:
|
||||
for link_id in self.connection_state_dict:
|
||||
state = self.connection_state_dict[link_id]
|
||||
if state is not None:
|
||||
channel_list.append([state[0], self.utility.is_able_to_send_data(state[2]),
|
||||
link_id, self.utility.is_able_to_send_data(state[1])])
|
||||
finally:
|
||||
self.state_lock.release()
|
||||
return channel_list
|
||||
pass
|
||||
|
||||
def __established_connection_list(self):
|
||||
conn_list = [] # # [(socket_id, link_id), ]
|
||||
self.state_lock.acquire()
|
||||
try:
|
||||
for link_id in self.connection_state_dict:
|
||||
state = self.connection_state_dict[link_id]
|
||||
if state is not None:
|
||||
if self.utility.is_established_connection([state[1], state[2]]) is True:
|
||||
conn_list.append([state[0], link_id])
|
||||
finally:
|
||||
self.state_lock.release()
|
||||
return conn_list
|
||||
pass
|
||||
|
||||
# find free socket_id, target_link_id pair
|
||||
def __get_available_id_list(self):
|
||||
self.available_id_lock.acquire()
|
||||
try:
|
||||
id_list = zip(self.__available_soc_id, self.__available_link_id)
|
||||
finally:
|
||||
self.available_id_lock.release()
|
||||
return id_list
|
||||
pass
|
||||
|
||||
def __update_available_id_list(self, soc_id, link_id, action="ADD"):
|
||||
self.available_id_lock.acquire()
|
||||
try:
|
||||
if action == "ADD":
|
||||
self.__available_link_id.append(link_id)
|
||||
self.__available_soc_id.append(soc_id)
|
||||
self.__add_log("[AVAILABLE ID]soc %d link %d is available" % (soc_id, link_id))
|
||||
elif action == "REMOVE":
|
||||
self.__available_link_id.remove(link_id)
|
||||
self.__available_soc_id.remove(soc_id)
|
||||
self.__add_log("[AVAILABLE ID]soc %d link %d is used" % (soc_id, link_id))
|
||||
finally:
|
||||
self.available_id_lock.release()
|
||||
|
||||
def __update_connection_state_item(self, target_link_id, socket_id=None,
|
||||
target_state=None, socket_state=None, is_closed=None):
|
||||
self.state_lock.acquire()
|
||||
try:
|
||||
state = self.connection_state_dict[target_link_id]
|
||||
if state is None:
|
||||
state = [None] * 4
|
||||
if socket_id is not None:
|
||||
state[0] = socket_id
|
||||
if target_state is not None:
|
||||
state[1] = target_state
|
||||
if socket_state is not None:
|
||||
state[2] = socket_state
|
||||
if is_closed is not None:
|
||||
state[3] = is_closed
|
||||
|
||||
# remove closed connections
|
||||
closed = self.utility.is_closed_state(state[1]) and (state[3] is True)
|
||||
if closed is True:
|
||||
self.__update_available_id_list(state[0], target_link_id)
|
||||
state = None
|
||||
# if new connection created
|
||||
if self.connection_state_dict[target_link_id] is None:
|
||||
created = self.utility.is_created_state(state[1])
|
||||
if created is True:
|
||||
self.__update_available_id_list(state[0], target_link_id, "REMOVE")
|
||||
else:
|
||||
# connection did not created, do not add them to connection state table
|
||||
state = None
|
||||
|
||||
# set new connection_state
|
||||
self.connection_state_dict[target_link_id] = state
|
||||
self.__add_log("[STATE] link id is %d, state is %s" % (target_link_id, state))
|
||||
except StandardError, e:
|
||||
pass
|
||||
finally:
|
||||
self.state_lock.release()
|
||||
pass
|
||||
|
||||
# update state table: if result is false, return, if result is true:
|
||||
# for connect, find real link id, update table according to destination state
|
||||
# for disconnect, if target in SOC_CLOSE_STATE && catch "x,CLOSE" from AT, remove the item
|
||||
def update_connection_state_table(self, conn_id, destination_state=None):
|
||||
if isinstance(conn_id, list) is True or isinstance(conn_id, tuple) is True:
|
||||
socket_id = conn_id[0]
|
||||
try:
|
||||
target_link_id = self.__get_created_target_link_id()
|
||||
except IndexError:
|
||||
target_link_id = conn_id[1]
|
||||
self.__add_log("[STATE]fail to get link id, state is %s, %s"
|
||||
% (destination_state[0], destination_state[1]))
|
||||
self.__update_connection_state_item(target_link_id, socket_id,
|
||||
destination_state[0], destination_state[1])
|
||||
pass
|
||||
else: # # called when recv CLOSED
|
||||
target_link_id = conn_id
|
||||
self.__update_connection_state_item(target_link_id, is_closed=True)
|
||||
pass
|
||||
pass
|
||||
|
||||
def process_at_data(self, data):
|
||||
pos1 = 0
|
||||
pos2 = 0
|
||||
connect = re.compile("\d,CONNECT\r\n")
|
||||
close = re.compile("\d,CLOSED\r\n")
|
||||
connect_match = connect.findall(data)
|
||||
close_match = close.findall(data)
|
||||
close = re.compile("\d,CONNECT FAIL\r\n")
|
||||
close_match += close.findall(data)
|
||||
if len(connect_match) != 0:
|
||||
pos1 = data.find(connect_match[-1]) + 9
|
||||
# append last connected link id
|
||||
self.__set_created_target_link_id(int(connect_match[-1][:1]))
|
||||
pass
|
||||
if len(close_match) != 0:
|
||||
pos2 = data.find(close_match[-1]) + 7
|
||||
# update for all closed links
|
||||
for close_str in close_match:
|
||||
self.update_connection_state_table(int(close_str[:1]))
|
||||
pass
|
||||
pos = pos1 if pos1 > pos2 else pos2
|
||||
|
||||
return data[pos:]
|
||||
|
||||
def execute(self):
|
||||
TCActionBase.TCActionBase.execute(self)
|
||||
self.result_cntx.start()
|
||||
|
||||
# configurable params
|
||||
# mandatory params
|
||||
try:
|
||||
connect_method_set = self.connect_method_set
|
||||
test_count = self.test_count
|
||||
except StandardError, e:
|
||||
NativeLog.add_trace_critical("Error configuration for TCPConnSingleMode script, error is %s" % e)
|
||||
raise StandardError("Error configuration")
|
||||
# optional params
|
||||
try:
|
||||
disconn_method_set = self.disconn_method_set
|
||||
except StandardError:
|
||||
disconn_method_set = ["D_05"]
|
||||
pass
|
||||
try:
|
||||
delay = self.delay
|
||||
except StandardError:
|
||||
delay = 0
|
||||
pass
|
||||
try:
|
||||
check_data_len = self.check_data_len
|
||||
except StandardError:
|
||||
check_data_len = [0, 0]
|
||||
pass
|
||||
if isinstance(check_data_len, list) is False:
|
||||
check_data_len = [check_data_len] * 2
|
||||
# configurable params
|
||||
|
||||
# step1 use <test_tcp_port1> to create server on both PC and target side
|
||||
checker_stings = ["SOCP SOC_COM L OK", "ATP AT1 L OK"]
|
||||
test_action_string = ["SOC SOC1 LISTEN <test_tcp_port1>", "ATC AT1 CIPSERVER 1 <test_tcp_port1>"]
|
||||
fail_string = "Fail, Fail on create server"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
for tested_count in xrange(test_count):
|
||||
# step2 do connect
|
||||
available_id_list = self.__get_available_id_list()
|
||||
|
||||
for conn_id in available_id_list:
|
||||
connect_method = random.choice(connect_method_set)
|
||||
# ret, destination_state = self.utility.execute_tcp_method(connect_method, conn_id)
|
||||
try:
|
||||
self.__add_log("[ACTION]connect method is %s, connect id is %s"
|
||||
% (connect_method, conn_id))
|
||||
ret, destination_state = self.utility.execute_tcp_method(connect_method, conn_id)
|
||||
except StandardError, e:
|
||||
NativeLog.add_trace_critical("Error in connect, error is %s" % e)
|
||||
raise StandardError("Exception happen when connect")
|
||||
if ret is False:
|
||||
# connect fail, should terminate TC and mark as fail
|
||||
return
|
||||
else:
|
||||
# succeed, append to table
|
||||
self.update_connection_state_table(conn_id, destination_state)
|
||||
if delay != 0:
|
||||
time.sleep(delay)
|
||||
|
||||
# step 3 send/recv test data
|
||||
# # [(socket_id, able_to_send, link_id, able_to_send)]
|
||||
self.__add_log("[ACTION]SEND/RECV data")
|
||||
channel_list = self.__find_channel_list()
|
||||
for channel in channel_list:
|
||||
_check_data_len = [0, 0]
|
||||
if channel[1] is True:
|
||||
_check_data_len[0] = check_data_len[0]
|
||||
if channel[3] is True:
|
||||
_check_data_len[1] = check_data_len[1]
|
||||
ret = self.utility.send_test_data(channel[0],
|
||||
channel[2],
|
||||
_check_data_len)
|
||||
if ret is False:
|
||||
# send/recv fail, should terminate TC and mark as fail
|
||||
return
|
||||
if delay != 0:
|
||||
time.sleep(delay)
|
||||
|
||||
# step 4 close all established connections
|
||||
# (socket_id, link_id)
|
||||
conn_list = self.__established_connection_list()
|
||||
for conn_id in conn_list:
|
||||
disconn_method = random.choice(disconn_method_set)
|
||||
try:
|
||||
self.__add_log("[ACTION]disconnect method is %s, connect id is %s"
|
||||
% (disconn_method, conn_id))
|
||||
ret, destination_state = self.utility.execute_tcp_method(disconn_method, conn_id)
|
||||
except StandardError, e:
|
||||
NativeLog.add_trace_critical("Error in disconnect, error is %s" % e)
|
||||
raise StandardError("Exception happen when disconnect")
|
||||
if ret is False:
|
||||
# connect fail, should terminate TC and mark as fail
|
||||
return
|
||||
else:
|
||||
# succeed, append to table
|
||||
self.update_connection_state_table(conn_id, destination_state)
|
||||
if delay != 0:
|
||||
time.sleep(delay)
|
||||
|
||||
# finally, execute done
|
||||
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)
|
||||
# find "x,CONNECT" and "x,CLOSE"
|
||||
if port_name.find("AT") != -1:
|
||||
self.__at1_buff += data
|
||||
self.__at1_buff = self.process_at_data(self.__at1_buff)
|
||||
|
||||
|
||||
def main():
|
||||
at1_buff = ""
|
||||
pos1 = 0
|
||||
pos2 = 0
|
||||
data = "dafgajglajdfg0,CLOSEjdalghalksdg1,CONNECT\r\n\r\n3,CONNECT4,CLOSEadfaasdf"
|
||||
at1_buff += data
|
||||
connect = re.compile("\d,CONNECT")
|
||||
close = re.compile("\d,CLOSE")
|
||||
connect_match = connect.findall(at1_buff)
|
||||
close_match = close.findall(at1_buff)
|
||||
if len(connect_match) != 0:
|
||||
pos1 = at1_buff.find(connect_match[-1]) + 9
|
||||
pass
|
||||
if len(close_match) != 0:
|
||||
pos2 = at1_buff.find(close_match[-1]) + 7
|
||||
pass
|
||||
pos = pos1 if pos1 > pos2 else pos2
|
||||
|
||||
at1_buff = at1_buff[pos:]
|
||||
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -1,273 +0,0 @@
|
||||
from NativeLog import NativeLog
|
||||
|
||||
# make sure target do not listen on this port
|
||||
ERROR_PORT = 23333
|
||||
|
||||
|
||||
def unused_param(param):
|
||||
return param
|
||||
|
||||
|
||||
class TCPUtilError(StandardError):
|
||||
pass
|
||||
|
||||
|
||||
class TCPConnUtility(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", "SYNC_SENT", "ESTABLISHED")
|
||||
SOC_SEND_DATA_STATE = ("ESTABLISHED", "CLOSE_WAIT")
|
||||
SOC_ESTABLISHED_STATE = ("ESTABLISHED", )
|
||||
|
||||
def __init__(self, tc_action):
|
||||
self.tc_action = tc_action
|
||||
self.pc_server_port = "<test_tcp_port1>"
|
||||
self.target_server_port = "<test_tcp_port1>"
|
||||
self.pc_ip = "<pc_ip>"
|
||||
self.target_ip = "<target_ip>"
|
||||
pass
|
||||
|
||||
def config_parameters(self, pc_server_port=None, target_server_port=None, pc_ip=None, target_ip=None):
|
||||
if pc_ip is not None:
|
||||
self.pc_ip = pc_ip
|
||||
if target_ip is not None:
|
||||
self.target_ip = target_ip
|
||||
if pc_server_port is not None:
|
||||
self.pc_server_port = pc_server_port
|
||||
if target_server_port is not None:
|
||||
self.target_server_port = target_server_port
|
||||
pass
|
||||
|
||||
def __connect_c_01(self, conn_id):
|
||||
checker_stings = ["SOCR SOC1 C +ACCEPT", "ATR AT1 NC CLOSE L OK"]
|
||||
test_action_strings = ["ATC AT1 CIPSTART %d \"TCP\" %s %s" %
|
||||
(conn_id[1], self.pc_ip, self.pc_server_port)]
|
||||
fail_string = "Fail, Target failed on connect to PC server"
|
||||
ret = self.tc_action.load_and_exe_one_step(checker_stings, test_action_strings, fail_string)
|
||||
if ret is False:
|
||||
return ret
|
||||
|
||||
checker_stings = ["SOCR SOC_COM L OK"]
|
||||
test_action_strings = ["SOC SOC1 ACCEPT SOC%d" % conn_id[0]]
|
||||
return self.tc_action.load_and_exe_one_step(checker_stings, test_action_strings, fail_string)
|
||||
pass
|
||||
|
||||
def __connect_c_02(self, conn_id):
|
||||
checker_stings = ["ATR AT1 C ERROR"]
|
||||
test_action_strings = ["ATC AT1 CIPSTART %d \"TCP\" %s %s" %
|
||||
(conn_id[1], self.pc_ip, ERROR_PORT)]
|
||||
fail_string = "Fail, Target fail on connect to port not listened"
|
||||
return self.tc_action.load_and_exe_one_step(checker_stings, test_action_strings, fail_string)
|
||||
pass
|
||||
|
||||
def __connect_c_03(self, conn_id):
|
||||
pass
|
||||
|
||||
def __connect_c_04(self, conn_id):
|
||||
pass
|
||||
|
||||
def __connect_c_05(self, conn_id):
|
||||
checker_stings = ["SOCP SOC_COM OK", "ATP AT1 C CONNECT"]
|
||||
test_action_strings = ["SOC SOC%d CONNECT %s %s" %
|
||||
(conn_id[0], self.target_server_port, self.target_ip)]
|
||||
fail_string = "Fail, PC fail on connect to target server"
|
||||
return self.tc_action.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=200, check_freq=0.01)
|
||||
pass
|
||||
|
||||
def __connect_c_06(self, conn_id):
|
||||
pass
|
||||
|
||||
def __connect_c_07(self, conn_id):
|
||||
# no checker strings, only try to create
|
||||
# while connect is a blocking function, will return till target reply RST
|
||||
checker_stings = ["SOCR SOC_COM C CLOSE"]
|
||||
test_action_strings = ["SOC SOC%d CONNECT %s %s" %
|
||||
(conn_id[0], ERROR_PORT, self.target_ip)]
|
||||
fail_string = "Fail, PC fail on connect to target server"
|
||||
return self.tc_action.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=2000, check_freq=0.01)
|
||||
pass
|
||||
|
||||
def __connect_c_08(self, conn_id):
|
||||
pass
|
||||
|
||||
def __close_d_01(self, conn_id):
|
||||
checker_stings = ["ATP AT1 C %d,CLOSED" % conn_id[1], "SOCP SOC_COM C CLOSE"]
|
||||
test_action_strings = ["SOC SOC%d SETOPT CLOSE_OPT IMM_SEND_FIN" % conn_id[0],
|
||||
"ATS AT1 AT+CIPCLOSE=%d" % conn_id[1]]
|
||||
fail_string = "Fail, Fail to close socket using D_01"
|
||||
return self.tc_action.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=200, check_freq=0.01)
|
||||
pass
|
||||
|
||||
def __close_d_02(self, conn_id):
|
||||
pass
|
||||
|
||||
def __close_d_03(self, conn_id):
|
||||
checker_stings = []
|
||||
test_action_strings = ["SOC SOC%d SETOPT CLOSE_OPT WAIT_TO" % conn_id[0],
|
||||
"ATS AT1 AT+CIPCLOSE=%d" % conn_id[1]]
|
||||
fail_string = "Fail, Fail to close socket using D_01"
|
||||
return self.tc_action.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=500, check_freq=0.01)
|
||||
pass
|
||||
|
||||
def __close_d_04(self, conn_id):
|
||||
pass
|
||||
|
||||
def __close_d_05(self, conn_id):
|
||||
checker_stings = ["ATP AT1 C %d,CLOSED" % conn_id[1]]
|
||||
test_action_strings = ["SOC SOC%d SETOPT CLOSE_OPT IMM_SEND_FIN" % conn_id[0],
|
||||
"SOC SOC%d CLOSE" % conn_id[0]]
|
||||
fail_string = "Fail, Fail to close socket using D_05"
|
||||
return self.tc_action.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=200, check_freq=0.01)
|
||||
pass
|
||||
|
||||
def __close_d_06(self, conn_id):
|
||||
# 1. set PC socket close option, stop calling recv; send in target
|
||||
checker_stings = ["ATP AT1 C >"]
|
||||
test_action_strings = ["SOC SOC%d STOPRECV" % conn_id[0],
|
||||
"SOC SOC%d SETOPT CLOSE_OPT IMM_SEND_RST" % conn_id[0],
|
||||
"ATS AT1 AT+CIPSEND=%d,5" % conn_id[1]]
|
||||
fail_string = "Fail, Fail to close socket using D_06"
|
||||
ret = self.tc_action.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=200, check_freq=0.01)
|
||||
if ret is False:
|
||||
return ret
|
||||
|
||||
# 2. send 5 bytes to socket
|
||||
checker_stings = ["ATP AT1 C OK"]
|
||||
test_action_strings = ["ATSN AT1 5"]
|
||||
fail_string = "Fail, Fail to close socket using D_06"
|
||||
ret = self.tc_action.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=200, check_freq=0.01)
|
||||
if ret is False:
|
||||
return ret
|
||||
|
||||
# 3. close socket
|
||||
checker_stings = ["ATP AT1 OR 2 C %d,CONNECT C %d,CLOSED" % (conn_id[1], conn_id[1])]
|
||||
test_action_strings = ["SOC SOC%d CLOSE" % conn_id[0]]
|
||||
fail_string = "Fail, Fail to close socket using D_06"
|
||||
return self.tc_action.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=200, check_freq=0.01)
|
||||
pass
|
||||
|
||||
def __close_d_07(self, conn_id):
|
||||
pass
|
||||
|
||||
def __close_d_08(self, conn_id):
|
||||
pass
|
||||
|
||||
def send_test_data(self, socket_id, target_link_id, check_data_len):
|
||||
# check_data_len[0] for socket data len, check_data_len[1] for target link data len
|
||||
fail_string = "Fail, Fail on send and recv data"
|
||||
|
||||
ret = True
|
||||
|
||||
for i in range(1):
|
||||
if check_data_len[1] != 0:
|
||||
checker_stings = ["ATP AT1 C >"]
|
||||
test_action_strings = ["ATS AT1 AT+CIPSEND=%d,%d" % (target_link_id, check_data_len[1])]
|
||||
if self.tc_action.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=20) is False:
|
||||
NativeLog.add_trace_critical("Fail on target send command for link %d" % target_link_id)
|
||||
ret = False
|
||||
break
|
||||
checker_stings = ["SOCP SOC%d RL %d" % (socket_id, check_data_len[1]), "ATP AT1 C OK"]
|
||||
test_action_strings = ["ATSN AT1 %d" % check_data_len[1]]
|
||||
if self.tc_action.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=20) is False:
|
||||
NativeLog.add_trace_critical("Fail on target send for link %d, send or recv error" % target_link_id)
|
||||
ret = False
|
||||
break
|
||||
|
||||
if check_data_len[0] != 0:
|
||||
checker_stings = ["ATP AT1 DL %d+%d" % (target_link_id, check_data_len[0])]
|
||||
test_action_strings = ["SOC SOC%d SEND %d" % (socket_id, check_data_len[0])]
|
||||
|
||||
if self.tc_action.load_and_exe_one_step(checker_stings, test_action_strings,
|
||||
fail_string, check_time=20) is False:
|
||||
NativeLog.add_trace_critical("Fail to receive PC SOC%d sent data" % socket_id)
|
||||
ret = False
|
||||
break
|
||||
|
||||
# return ret
|
||||
# for now do not validate data
|
||||
return True
|
||||
|
||||
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, conn_id):
|
||||
if method in self.METHOD_RESULT:
|
||||
return self.TCP_ACTION_DICT[method](self, conn_id), self.get_method_destination_state(method)
|
||||
else:
|
||||
raise TCPUtilError("Not TCP connection method")
|
||||
pass
|
||||
|
||||
def is_created_state(self, state):
|
||||
if state in self.SOC_CREATED_STATE:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def is_closed_state(self, state):
|
||||
if state in self.SOC_CLOSED_STATE:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def is_able_to_send_data(self, state):
|
||||
if state in self.SOC_SEND_DATA_STATE:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def is_established_connection(self, state):
|
||||
if state[0] in self.SOC_ESTABLISHED_STATE and state[1] in self.SOC_ESTABLISHED_STATE:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,321 +0,0 @@
|
||||
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")
|
||||
|
||||
|
||||
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):
|
||||
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
|
||||
pass
|
||||
|
||||
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)
|
||||
self.utility.execute_tcp_method(connect_method_choice, connection)
|
||||
# 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)
|
||||
self.utility.execute_tcp_method(disconnect_method_choice, connection)
|
||||
# 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 TCPConnection(PerformanceTCBase.PerformanceTCBase):
|
||||
def __init__(self, name, test_env, cmd_set, timeout=120, log_path=None):
|
||||
PerformanceTCBase.PerformanceTCBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
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"]
|
||||
# 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)
|
||||
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()
|
@ -1,251 +0,0 @@
|
||||
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()
|
@ -1,244 +0,0 @@
|
||||
import os
|
||||
import random
|
||||
import threading
|
||||
import socket
|
||||
import time
|
||||
import re
|
||||
|
||||
from TCAction import TCActionBase
|
||||
from TCAction import PerformanceTCBase
|
||||
from NativeLog import NativeLog
|
||||
|
||||
|
||||
LOG_FOLDER = os.path.join("AT_LOG", "Performance", "Throughput")
|
||||
|
||||
|
||||
AP_PROP_KEY = ("ssid", "password", "apc")
|
||||
|
||||
|
||||
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 TCPDataValidation(PerformanceTCBase.PerformanceTCBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
PerformanceTCBase.PerformanceTCBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.send_len = 1460
|
||||
self.tx_enable = True
|
||||
self.rx_enable = True
|
||||
self.conn_num = 1
|
||||
self.test_time = 300
|
||||
# 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
|
||||
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
|
||||
else:
|
||||
self.set_result("Succeed")
|
||||
|
||||
# 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()
|
@ -1,103 +0,0 @@
|
||||
import os
|
||||
import time
|
||||
import random
|
||||
import threading
|
||||
import socket
|
||||
from TCAction import TCActionBase
|
||||
from NativeLog import NativeLog
|
||||
from NativeLog import ThroughputResult
|
||||
|
||||
|
||||
class TCPRandomSend(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
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
|
||||
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.test_env.get_variable_by_name("pc_ip")[1]
|
||||
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 <client_sock>:\+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 <client_sock> -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)
|
||||
return
|
||||
pass
|
||||
time.sleep(delay)
|
||||
|
||||
self.result_cntx.set_result("Succeed")
|
||||
|
||||
# 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()
|
@ -1,143 +0,0 @@
|
||||
from TCAction import TCActionBase
|
||||
from NativeLog import NativeLog
|
||||
import time
|
||||
import random
|
||||
import string
|
||||
|
||||
TEST_COUNT_ONE_ROUND = 1000
|
||||
|
||||
|
||||
class TCPSendRecv(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
# 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 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)])
|
||||
|
||||
# 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 = ["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 server on AP
|
||||
checker_stings = ["R SSC1 A <server_sock>:\+BIND:(\d+),OK"]
|
||||
test_action_string = ["SSC SSC1 soc -B -t TCP -p <random_port>"]
|
||||
fail_string = "Fail, Fail to create server"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
checker_stings = ["R SSC1 A <server_sock>:\+LISTEN:(\d+),OK"]
|
||||
test_action_string = ["SSC SSC1 soc -L -s <server_sock>"]
|
||||
fail_string = "Fail, Fail to create server"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
return
|
||||
|
||||
# step 3 create conn_num tcp connections
|
||||
for i in range(conn_num):
|
||||
checker_stings = ["R SSC2 A <client_sock%s>:\+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:
|
||||
return
|
||||
|
||||
checker_stings = ["P SSC1 A <accept_sock%s>:\+ACCEPT:(\d+),\d+" % i,
|
||||
"P SSC2 RE \+CONNECT:\d+,OK"]
|
||||
test_action_string = ["SSC SSC2 soc -C -s <client_sock%s> -i <target_ap_ip> -p <random_port>" % i]
|
||||
fail_string = "Fail, Fail to connect"
|
||||
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 time.time()-start_time < test_time:
|
||||
|
||||
checker_stings = ["P SSC1 NC ERROR NC CLOSE"]
|
||||
for i in range(conn_num):
|
||||
test_action_string = ["SSC SSC2 soc -S -s <client_sock%d> -l %d -n %d -j %d" %
|
||||
(i, send_len, TEST_COUNT_ONE_ROUND, send_delay)]
|
||||
checker_stings.append("P SSC2 RE \"\+SEND:%%%%s,OK\"%%%%(<client_sock%d>) NC ERROR NC CLOSE" % i)
|
||||
|
||||
if duplex is True:
|
||||
checker_stings.append("P SSC1 RE \"\+SEND:%%%%s,OK\"%%%%(<accept_sock%d>)" % i)
|
||||
test_action_string.append("SSC SSC1 soc -S -s <accept_sock%d> -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:
|
||||
break
|
||||
# if self.load_and_exe_one_step([], ["SSC SSC1 ram -H", "SSC SSC2 ram -H"], fail_string) is False:
|
||||
# break
|
||||
# time.sleep(0.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))
|
||||
self.result_cntx.set_result("Succeed")
|
||||
|
||||
# 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()
|
||||
|
||||
|
@ -1,318 +0,0 @@
|
||||
from TCAction import TCActionBase
|
||||
from NativeLog import NativeLog
|
||||
import time
|
||||
import random
|
||||
import string
|
||||
|
||||
TEST_COUNT_ONE_ROUND = 500
|
||||
|
||||
|
||||
class TCPSoftAPSTASendRecv(TCActionBase.CommonTCActionBase):
|
||||
def __init__(self, name, test_env, cmd_set, timeout=45, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
# 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
|
||||
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 <server_sock>: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 <server_sock>"]
|
||||
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 <client_sock>: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_sock>:ACCEPT:(\d+),.+"]
|
||||
test_action_string = ["SSCC SSC2 soc -C -s <client_sock> -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 <server_sock_t>: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 <server_sock_t>"]
|
||||
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 <client_sock%d>: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_sock%d>:ACCEPT:(\d+),.+" % (i + 3)]
|
||||
test_action_string = ["SSCC SSC%d soc -C -s <client_sock%d> -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 <accept_sock> -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 <server_sock> -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 <client_sock%d> -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 <accept_sock%d> -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 <server_sock>: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 <server_sock>"]
|
||||
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 <client_sock>: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_sock>:ACCEPT:(\d+),.+"]
|
||||
test_action_string = ["SSCC SSC2 soc -C -s <client_sock> -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 <server_sock>: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 <server_sock>"]
|
||||
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 <client_sock%d>: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_sock%d>:ACCEPT:(\d+),.+" % (i + 3)]
|
||||
test_action_string = ["SSCC SSC%d soc -C -s <client_sock%d> -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()
|
@ -1,315 +0,0 @@
|
||||
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("AT_LOG", "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 TCPThroughput(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.att_test_list = range(60)
|
||||
# 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
|
||||
# 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_KEY, " + cmd_set[i][1][j] + ")))"
|
||||
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.ap_list
|
||||
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")
|
||||
|
||||
# find local ip and generate local port
|
||||
local_ip_list = socket.gethostbyname_ex(socket.gethostname())[2]
|
||||
for local_ip in local_ip_list:
|
||||
if local_ip.find("192.168.1.") != -1:
|
||||
pc_ip = local_ip
|
||||
break
|
||||
else:
|
||||
raise StandardError("Can't find local IP.")
|
||||
|
||||
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 = MakeFolder.make_folder(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:
|
||||
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:
|
||||
return
|
||||
|
||||
for ap_prop in ap_list:
|
||||
if ap_prop["password"] == "":
|
||||
# set a default string for open ap
|
||||
ap_prop["password"] = "1"
|
||||
|
||||
# switch off all outlet, switch on AP outlet
|
||||
outlet_config_dict = dict.fromkeys(range(1, 9), "OFF")
|
||||
outlet_config_dict[ap_prop["apc"]] = "ON"
|
||||
apc_cmd = "APC <APC1>"
|
||||
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 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(ap_prop["ssid"] + "_tx")
|
||||
if rx_enable is True:
|
||||
result.add_test_item(ap_prop["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 <att_port> %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 connect to AP
|
||||
checker_stings = ["R SSC1 C +JAP:CONNECTED"]
|
||||
test_action_string = ["SSC SSC1 sta -C -s %s -p %s" % (ap_prop["ssid"], ap_prop["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:
|
||||
continue
|
||||
# step 2 get AP RSSI
|
||||
checker_stings = ["R SSC1 A <rssi>:\+SCAN:%s,[:\d\w]+,\d+,\d+,([-\d]+)" % ap_prop["ssid"]]
|
||||
test_action_string = ["SSC SSC1 sta -S -s %s" % ap_prop["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 3 close all connections
|
||||
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:
|
||||
continue
|
||||
|
||||
# step 4 create tcp connection
|
||||
|
||||
checker_stings = ["R SSC1 A <client_sock>:\+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:
|
||||
continue
|
||||
|
||||
checker_stings = ["P SSC1 RE \+CONNECT:\d+,OK"]
|
||||
test_action_string = ["SSC SSC1 soc -C -s <client_sock> -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:
|
||||
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 <client_sock> -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(ap_prop["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(ap_prop["ssid"] + "_tx", rssi, att_value,
|
||||
float(recv_thread.get_bytes_recv() * 8) / (measure_period * 1000000))
|
||||
|
||||
result.output_to_file()
|
||||
pass
|
||||
|
||||
server_sock.close()
|
||||
|
||||
self.result_cntx.set_result("Succeed")
|
||||
|
||||
# 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()
|
@ -1 +0,0 @@
|
||||
__all__ = ["TCPConnUtility", "TCPConnSingleMode", "TCPConnMixedMode"]
|
@ -1,130 +0,0 @@
|
||||
from TCAction import TCActionBase
|
||||
from NativeLog import NativeLog
|
||||
import time
|
||||
import random
|
||||
import string
|
||||
|
||||
TEST_COUNT_ONE_ROUND = 1000
|
||||
|
||||
|
||||
class UDPSendRecv(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
# 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 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 <sta_ip>:\+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 <t1_sock%d>:\+BIND:(\d+),OK" % i,
|
||||
"R SSC2 A <t2_sock%d>:\+BIND:(\d+),OK" % i]
|
||||
test_action_string = ["SSC SSC1 soc -B -t UDP -p <test_udp_port%i>" % i,
|
||||
"SSC SSC2 soc -B -t UDP -p <test_udp_port%i>" % 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"]
|
||||
for i in range(1, conn_num+1):
|
||||
test_action_string = ["SSC SSC2 soc -S -s <t2_sock%d> -l %d -n %d -j %d "
|
||||
"-i <target_ap_ip> -p <test_udp_port%d>" %
|
||||
(i, send_len, TEST_COUNT_ONE_ROUND, send_delay, i)]
|
||||
checker_stings.append("P SSC2 RE \"\+SEND:%%%%s,OK\"%%%%(<t2_sock%d>) NC ERROR NC CLOSE" % i)
|
||||
if duplex is True:
|
||||
test_action_string.append("SSC SSC1 soc -S -s <t1_sock%d> -l %d -n %d -j %d"
|
||||
" -i <sta_ip> -p <test_udp_port%d>" %
|
||||
(i, send_len, TEST_COUNT_ONE_ROUND, send_delay, i))
|
||||
checker_stings.append("P SSC1 RE \"\+SEND:%%%%s,OK\"%%%%(<t1_sock%d>)" % 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))
|
||||
self.result_cntx.set_result("Succeed")
|
||||
|
||||
# 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()
|
||||
|
||||
|
@ -1,305 +0,0 @@
|
||||
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("AT_LOG", "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 UDPThroughput(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.att_test_list = range(60)
|
||||
# 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
|
||||
# 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_KEY, " + cmd_set[i][1][j] + ")))"
|
||||
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.ap_list
|
||||
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")
|
||||
|
||||
# find local ip and generate local port
|
||||
local_ip_list = socket.gethostbyname_ex(socket.gethostname())[2]
|
||||
for local_ip in local_ip_list:
|
||||
if local_ip.find("192.168.1.") != -1:
|
||||
pc_ip = local_ip
|
||||
break
|
||||
else:
|
||||
raise StandardError("Can't find local IP.")
|
||||
|
||||
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 = MakeFolder.make_folder(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:
|
||||
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:
|
||||
return
|
||||
|
||||
for ap_prop in ap_list:
|
||||
if ap_prop["password"] == "":
|
||||
# set a default string for open ap
|
||||
ap_prop["password"] = "1"
|
||||
|
||||
# switch off all outlet, switch on AP outlet
|
||||
outlet_config_dict = dict.fromkeys(range(1, 9), "OFF")
|
||||
outlet_config_dict[ap_prop["apc"]] = "ON"
|
||||
apc_cmd = "APC <APC1>"
|
||||
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 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(ap_prop["ssid"] + "_tx")
|
||||
if rx_enable is True:
|
||||
result.add_test_item(ap_prop["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 <att_port> %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 connect to AP
|
||||
checker_stings = ["R SSC1 C +JAP:CONNECTED"]
|
||||
test_action_string = ["SSC SSC1 sta -C -s %s -p %s" % (ap_prop["ssid"], ap_prop["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:
|
||||
continue
|
||||
checker_stings = ["R SSC1 A <target_ip>: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:
|
||||
continue
|
||||
target_ip = self.get_parameter("target_ip")
|
||||
# step 2 get AP RSSI
|
||||
checker_stings = ["R SSC1 A <rssi>:\+SCAN:%s,[:\d\w]+,\d+,\d+,([-\d]+)\r" % ap_prop["ssid"]]
|
||||
test_action_string = ["SSC SSC1 sta -S -s %s" % ap_prop["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 3 close all connections
|
||||
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:
|
||||
continue
|
||||
|
||||
# step 4 create UDP socket
|
||||
checker_stings = ["R SSC1 A <client_sock>:\+BIND:(\d+),OK"]
|
||||
test_action_string = ["SSC SSC1 soc -B -t UDP -i %s -p %s" % (target_ip, udp_port)]
|
||||
fail_string = "Fail, Fail bind"
|
||||
if self.load_and_exe_one_step(checker_stings, test_action_string, fail_string) is False:
|
||||
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 <client_sock> -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 <recv_len>:RECVLEN:(\d+)"],
|
||||
["SSC SSC1 soc -Q -s <client_sock> -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(ap_prop["ssid"] + "_rx", rssi, att_value,
|
||||
float(rx_data_len * 8) / (measure_period * 1000000))
|
||||
|
||||
if recv_thread.get_bytes_recv() > 0:
|
||||
result.log_throughput(ap_prop["ssid"] + "_tx", rssi, att_value,
|
||||
float(recv_thread.get_bytes_recv() * 8) / (measure_period * 1000000))
|
||||
|
||||
result.output_to_file()
|
||||
pass
|
||||
|
||||
udp_sock.close()
|
||||
|
||||
self.result_cntx.set_result("Succeed")
|
||||
|
||||
# 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()
|
@ -1 +0,0 @@
|
||||
__all__ = ["UDPSendRecv", ]
|
@ -1,178 +0,0 @@
|
||||
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 SoftAPNSTA(PerformanceTCBase.PerformanceTCBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
PerformanceTCBase.PerformanceTCBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
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
|
||||
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()
|
||||
|
@ -1,240 +0,0 @@
|
||||
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 <APC1>"
|
||||
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()
|
@ -1,218 +0,0 @@
|
||||
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("AT_LOG", "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 WifiJAP(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
# default value for optional configurable params
|
||||
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
|
||||
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(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()
|
@ -1,173 +0,0 @@
|
||||
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("AT_LOG", "Performance", "JAP")
|
||||
AP_PROP_KEY = ("ssid", "password", "apc")
|
||||
|
||||
|
||||
class Performance(object):
|
||||
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)
|
||||
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
|
||||
pass
|
||||
|
||||
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 WifiJAPAtt(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_path=log_path)
|
||||
self.att_test_list = range(60)
|
||||
# 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
|
||||
# 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_KEY, " + cmd_set[i][1][j] + ")))"
|
||||
exec cmd_string
|
||||
|
||||
self.performance = dict([(ap_prop["ssid"], Performance()) for ap_prop in self.ap_list])
|
||||
# create log file
|
||||
folder_path = MakeFolder.make_folder(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:
|
||||
if ap_prop["password"] == "":
|
||||
# set a default string for open ap
|
||||
ap_prop["password"] = "1"
|
||||
|
||||
# switch off all outlet, switch on AP outlet
|
||||
outlet_config_dict = dict.fromkeys(range(1, 9), "OFF")
|
||||
outlet_config_dict[ap_prop["apc"]] = "ON"
|
||||
apc_cmd = "APC <APC1>"
|
||||
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()
|
||||
|
||||
for att_value in att_test_list:
|
||||
# step 0 set att value
|
||||
checker_stings = ["R PC_COM L OK"]
|
||||
test_action_string = ["ATT <att_port> %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 <rssi>:\+SCAN:%s,[:\d\w]+,\d+,\d+,([-\d]+)" % ap_prop["ssid"]]
|
||||
test_action_string = ["SSC SSC1 sta -S -s %s" % ap_prop["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, ap_prop["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" % (ap_prop["ssid"], ap_prop["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, ap_prop["ssid"], "Failed to JAP")
|
||||
continue
|
||||
|
||||
self.log_performance(att_value, rssi, ap_prop["ssid"], "Succeed")
|
||||
|
||||
# finally, execute done
|
||||
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()
|
@ -1,273 +0,0 @@
|
||||
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("AT_LOG", "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 WifiSmartConfig(TCActionBase.CommonTCActionBase):
|
||||
|
||||
def __init__(self, name, test_env, cmd_set, timeout=30, log_path=TCActionBase.LOG_PATH):
|
||||
TCActionBase.CommonTCActionBase.__init__(self, name, test_env, cmd_set=cmd_set,
|
||||
timeout=timeout, log_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, [("<ht20_ap_ssid>", "<ht20_ap_password>"),
|
||||
("<ht40_ap_ssid>", "<ht40_ap_password>")]))
|
||||
self.ap_channel = {"ht20": 1, "ht40": 1}
|
||||
self.delay_time = 3 # default 3s, wait for scan done
|
||||
# load param from excel
|
||||
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(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 <pc_wifi_nic> CONN %s %s <pc_ip_sc>" % (_ht_ap[0], _ht_ap[1])]
|
||||
checker_stings = ["P AT1 L OK", "P PC_COM L OK"]
|
||||
else:
|
||||
cmd = ["SSC SSC1 smart -E", "WIFI <pc_wifi_nic> CONN %s %s <pc_ip_sc>" % (_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 <pc_ip_sc> %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()
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user