| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | """
 | 
					
						
							|  |  |  | Test case for iperf example. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This test case might have problem running on windows: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 1. direct use of `make` | 
					
						
							|  |  |  | 2. use `sudo killall iperf` to force kill iperf, didn't implement windows version | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The test env Example_ShieldBox do need the following config:: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Example_ShieldBox: | 
					
						
							|  |  |  |     ap_list: | 
					
						
							|  |  |  |       - ssid: "ssid" | 
					
						
							|  |  |  |         password: "password" | 
					
						
							|  |  |  |         outlet: 1 | 
					
						
							|  |  |  |     apc_ip: "192.168.1.88" | 
					
						
							|  |  |  |     attenuator_port: "/dev/ttyUSB0" | 
					
						
							|  |  |  |     iperf: "/dev/ttyUSB1" | 
					
						
							|  |  |  |     apc_ip: "192.168.1.88" | 
					
						
							|  |  |  |     pc_nic: "eth0" | 
					
						
							|  |  |  | """
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  | from __future__ import division, unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | import os | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  | import re | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | import subprocess | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  | import time | 
					
						
							|  |  |  | from builtins import object, range, str | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-27 11:58:07 +08:00
										 |  |  | import ttfw_idf | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  | from idf_iperf_test_util import Attenuator, LineChart, PowerControl, TestReport | 
					
						
							|  |  |  | from tiny_test_fw import DUT, TinyFW, Utility | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # configurations | 
					
						
							|  |  |  | TEST_TIME = TEST_TIMEOUT = 60 | 
					
						
							|  |  |  | WAIT_AP_POWER_ON_TIMEOUT = 90 | 
					
						
							|  |  |  | SCAN_TIMEOUT = 3 | 
					
						
							|  |  |  | SCAN_RETRY_COUNT = 3 | 
					
						
							|  |  |  | RETRY_COUNT_FOR_BEST_PERFORMANCE = 2 | 
					
						
							|  |  |  | ATTEN_VALUE_LIST = range(0, 60, 2) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # constants | 
					
						
							|  |  |  | FAILED_TO_SCAN_RSSI = -97 | 
					
						
							|  |  |  | INVALID_HEAP_SIZE = 0xFFFFFFFF | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  | PC_IPERF_TEMP_LOG_FILE = '.tmp_iperf.log' | 
					
						
							|  |  |  | CONFIG_NAME_PATTERN = re.compile(r'sdkconfig\.ci\.(.+)') | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # We need to auto compare the difference between adjacent configs (01 -> 00, 02 -> 01, ...) and put them to reports. | 
					
						
							|  |  |  | # Using numbers for config will make this easy. | 
					
						
							|  |  |  | # Use default value `99` for config with best performance. | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  | BEST_PERFORMANCE_CONFIG = '99' | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class TestResult(object): | 
					
						
							|  |  |  |     """ record, analysis test result and convert data to output format """ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |     PC_BANDWIDTH_LOG_PATTERN = re.compile(r'(\d+).0\s*-\s*(\d+).0\s+sec\s+[\d.]+\s+MBytes\s+([\d.]+)\s+Mbits/sec') | 
					
						
							|  |  |  |     DUT_BANDWIDTH_LOG_PATTERN = re.compile(r'(\d+)-\s+(\d+)\s+sec\s+([\d.]+)\s+Mbits/sec') | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ZERO_POINT_THRESHOLD = -88  # RSSI, dbm | 
					
						
							|  |  |  |     ZERO_THROUGHPUT_THRESHOLD = -92  # RSSI, dbm | 
					
						
							| 
									
										
										
										
											2020-11-13 09:46:32 +08:00
										 |  |  |     BAD_POINT_RSSI_THRESHOLD = -75  # RSSI, dbm | 
					
						
							|  |  |  |     BAD_POINT_MIN_THRESHOLD = 10  # Mbps | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |     BAD_POINT_PERCENTAGE_THRESHOLD = 0.3 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # we need at least 1/2 valid points to qualify the test result | 
					
						
							| 
									
										
										
										
											2018-12-04 08:32:48 +01:00
										 |  |  |     THROUGHPUT_QUALIFY_COUNT = TEST_TIME // 2 | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-18 16:55:26 +08:00
										 |  |  |     RSSI_RANGE = [-x for x in range(10, 100)] | 
					
						
							|  |  |  |     ATT_RANGE = [x for x in range(0, 64)] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |     def __init__(self, proto, direction, config_name): | 
					
						
							|  |  |  |         self.proto = proto | 
					
						
							|  |  |  |         self.direction = direction | 
					
						
							|  |  |  |         self.config_name = config_name | 
					
						
							|  |  |  |         self.throughput_by_rssi = dict() | 
					
						
							|  |  |  |         self.throughput_by_att = dict() | 
					
						
							|  |  |  |         self.att_rssi_map = dict() | 
					
						
							|  |  |  |         self.heap_size = INVALID_HEAP_SIZE | 
					
						
							|  |  |  |         self.error_list = [] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _save_result(self, throughput, ap_ssid, att, rssi, heap_size): | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         save the test results: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         * record the better throughput if att/rssi is the same. | 
					
						
							|  |  |  |         * record the min heap size. | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         if ap_ssid not in self.att_rssi_map: | 
					
						
							|  |  |  |             # for new ap, create empty dict() | 
					
						
							|  |  |  |             self.throughput_by_att[ap_ssid] = dict() | 
					
						
							|  |  |  |             self.throughput_by_rssi[ap_ssid] = dict() | 
					
						
							|  |  |  |             self.att_rssi_map[ap_ssid] = dict() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         self.att_rssi_map[ap_ssid][att] = rssi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         def record_throughput(database, key_value): | 
					
						
							|  |  |  |             try: | 
					
						
							|  |  |  |                 # we save the larger value for same att | 
					
						
							|  |  |  |                 if throughput > database[ap_ssid][key_value]: | 
					
						
							|  |  |  |                     database[ap_ssid][key_value] = throughput | 
					
						
							|  |  |  |             except KeyError: | 
					
						
							|  |  |  |                 database[ap_ssid][key_value] = throughput | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         record_throughput(self.throughput_by_att, att) | 
					
						
							|  |  |  |         record_throughput(self.throughput_by_rssi, rssi) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if int(heap_size) < self.heap_size: | 
					
						
							|  |  |  |             self.heap_size = int(heap_size) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def add_result(self, raw_data, ap_ssid, att, rssi, heap_size): | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         add result for one test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         :param raw_data: iperf raw data | 
					
						
							|  |  |  |         :param ap_ssid: ap ssid that tested | 
					
						
							|  |  |  |         :param att: attenuate value | 
					
						
							|  |  |  |         :param rssi: AP RSSI | 
					
						
							|  |  |  |         :param heap_size: min heap size during test | 
					
						
							|  |  |  |         :return: throughput | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         fall_to_0_recorded = 0 | 
					
						
							|  |  |  |         throughput_list = [] | 
					
						
							|  |  |  |         result_list = self.PC_BANDWIDTH_LOG_PATTERN.findall(raw_data) | 
					
						
							|  |  |  |         if not result_list: | 
					
						
							|  |  |  |             # failed to find raw data by PC pattern, it might be DUT pattern | 
					
						
							|  |  |  |             result_list = self.DUT_BANDWIDTH_LOG_PATTERN.findall(raw_data) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for result in result_list: | 
					
						
							|  |  |  |             if int(result[1]) - int(result[0]) != 1: | 
					
						
							|  |  |  |                 # this could be summary, ignore this | 
					
						
							|  |  |  |                 continue | 
					
						
							|  |  |  |             throughput_list.append(float(result[2])) | 
					
						
							|  |  |  |             if float(result[2]) == 0 and rssi > self.ZERO_POINT_THRESHOLD \ | 
					
						
							|  |  |  |                     and fall_to_0_recorded < 1: | 
					
						
							|  |  |  |                 # throughput fall to 0 error. we only record 1 records for one test | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                 self.error_list.append('[Error][fall to 0][{}][att: {}][rssi: {}]: 0 throughput interval: {}-{}' | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |                                        .format(ap_ssid, att, rssi, result[0], result[1])) | 
					
						
							|  |  |  |                 fall_to_0_recorded += 1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if len(throughput_list) > self.THROUGHPUT_QUALIFY_COUNT: | 
					
						
							|  |  |  |             throughput = sum(throughput_list) / len(throughput_list) | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             throughput = 0.0 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if throughput == 0 and rssi > self.ZERO_THROUGHPUT_THRESHOLD: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             self.error_list.append('[Error][Fatal][{}][att: {}][rssi: {}]: No throughput data found' | 
					
						
							| 
									
										
										
										
											2019-11-27 11:58:07 +08:00
										 |  |  |                                    .format(ap_ssid, att, rssi)) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         self._save_result(throughput, ap_ssid, att, rssi, heap_size) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return throughput | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def post_analysis(self): | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         some rules need to be checked after we collected all test raw data: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         1. throughput value 30% worse than the next point with lower RSSI | 
					
						
							|  |  |  |         2. throughput value 30% worse than the next point with larger attenuate | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         def analysis_bad_point(data, index_type): | 
					
						
							|  |  |  |             for ap_ssid in data: | 
					
						
							|  |  |  |                 result_dict = data[ap_ssid] | 
					
						
							| 
									
										
										
										
											2018-09-10 15:13:47 +02:00
										 |  |  |                 index_list = list(result_dict.keys()) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |                 index_list.sort() | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                 if index_type == 'att': | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |                     index_list.reverse() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 for i, index_value in enumerate(index_list[1:]): | 
					
						
							|  |  |  |                     if index_value < self.BAD_POINT_RSSI_THRESHOLD or \ | 
					
						
							|  |  |  |                             result_dict[index_list[i]] < self.BAD_POINT_MIN_THRESHOLD: | 
					
						
							|  |  |  |                         continue | 
					
						
							|  |  |  |                     _percentage = result_dict[index_value] / result_dict[index_list[i]] | 
					
						
							|  |  |  |                     if _percentage < 1 - self.BAD_POINT_PERCENTAGE_THRESHOLD: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                         self.error_list.append('[Error][Bad point][{}][{}: {}]: drop {:.02f}%' | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |                                                .format(ap_ssid, index_type, index_value, | 
					
						
							|  |  |  |                                                        (1 - _percentage) * 100)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         analysis_bad_point(self.throughput_by_rssi, 'rssi') | 
					
						
							|  |  |  |         analysis_bad_point(self.throughput_by_att, 'att') | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def draw_throughput_figure(self, path, ap_ssid, draw_type): | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         :param path: folder to save figure. make sure the folder is already created. | 
					
						
							|  |  |  |         :param ap_ssid: ap ssid string or a list of ap ssid string | 
					
						
							|  |  |  |         :param draw_type: "att" or "rssi" | 
					
						
							|  |  |  |         :return: file_name | 
					
						
							|  |  |  |         """
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         if draw_type == 'rssi': | 
					
						
							|  |  |  |             type_name = 'RSSI' | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |             data = self.throughput_by_rssi | 
					
						
							| 
									
										
										
										
											2020-12-18 16:55:26 +08:00
										 |  |  |             range_list = self.RSSI_RANGE | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         elif draw_type == 'att': | 
					
						
							|  |  |  |             type_name = 'Att' | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |             data = self.throughput_by_att | 
					
						
							| 
									
										
										
										
											2020-12-18 16:55:26 +08:00
										 |  |  |             range_list = self.ATT_RANGE | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |         else: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             raise AssertionError('draw type not supported') | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |         if isinstance(ap_ssid, list): | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             file_name = 'ThroughputVs{}_{}_{}_{}.html'.format(type_name, self.proto, self.direction, | 
					
						
							| 
									
										
										
										
											2020-12-18 16:55:26 +08:00
										 |  |  |                                                               hash(ap_ssid)[:6]) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |         else: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             file_name = 'ThroughputVs{}_{}_{}_{}.html'.format(type_name, self.proto, self.direction, ap_ssid) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         LineChart.draw_line_chart(os.path.join(path, file_name), | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                                   'Throughput Vs {} ({} {})'.format(type_name, self.proto, self.direction), | 
					
						
							|  |  |  |                                   '{} (dbm)'.format(type_name), | 
					
						
							|  |  |  |                                   'Throughput (Mbps)', | 
					
						
							| 
									
										
										
										
											2020-12-18 16:55:26 +08:00
										 |  |  |                                   data, range_list) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |         return file_name | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def draw_rssi_vs_att_figure(self, path, ap_ssid): | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         :param path: folder to save figure. make sure the folder is already created. | 
					
						
							|  |  |  |         :param ap_ssid: ap to use | 
					
						
							|  |  |  |         :return: file_name | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         if isinstance(ap_ssid, list): | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             file_name = 'AttVsRSSI_{}.html'.format(hash(ap_ssid)[:6]) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |         else: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             file_name = 'AttVsRSSI_{}.html'.format(ap_ssid) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |         LineChart.draw_line_chart(os.path.join(path, file_name), | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                                   'Att Vs RSSI', | 
					
						
							|  |  |  |                                   'Att (dbm)', | 
					
						
							|  |  |  |                                   'RSSI (dbm)', | 
					
						
							| 
									
										
										
										
											2020-12-18 16:55:26 +08:00
										 |  |  |                                   self.att_rssi_map, | 
					
						
							|  |  |  |                                   self.ATT_RANGE) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |         return file_name | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def get_best_throughput(self): | 
					
						
							|  |  |  |         """  get the best throughput during test """ | 
					
						
							|  |  |  |         best_for_aps = [max(self.throughput_by_att[ap_ssid].values()) | 
					
						
							|  |  |  |                         for ap_ssid in self.throughput_by_att] | 
					
						
							|  |  |  |         return max(best_for_aps) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def __str__(self): | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         returns summary for this test: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         1. test result (success or fail) | 
					
						
							|  |  |  |         2. best performance for each AP | 
					
						
							|  |  |  |         3. min free heap size during test | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         if self.throughput_by_att: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             ret = '[{}_{}][{}]: {}\r\n\r\n'.format(self.proto, self.direction, self.config_name, | 
					
						
							|  |  |  |                                                    'Fail' if self.error_list else 'Success') | 
					
						
							|  |  |  |             ret += 'Performance for each AP:\r\n' | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |             for ap_ssid in self.throughput_by_att: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                 ret += '[{}]: {:.02f} Mbps\r\n'.format(ap_ssid, max(self.throughput_by_att[ap_ssid].values())) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |             if self.heap_size != INVALID_HEAP_SIZE: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                 ret += 'Minimum heap size: {}'.format(self.heap_size) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |         else: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             ret = '' | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |         return ret | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class IperfTestUtility(object): | 
					
						
							|  |  |  |     """ iperf test implementation """ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def __init__(self, dut, config_name, ap_ssid, ap_password, | 
					
						
							|  |  |  |                  pc_nic_ip, pc_iperf_log_file, test_result=None): | 
					
						
							|  |  |  |         self.config_name = config_name | 
					
						
							|  |  |  |         self.dut = dut | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         self.pc_iperf_log_file = pc_iperf_log_file | 
					
						
							|  |  |  |         self.ap_ssid = ap_ssid | 
					
						
							|  |  |  |         self.ap_password = ap_password | 
					
						
							|  |  |  |         self.pc_nic_ip = pc_nic_ip | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if test_result: | 
					
						
							|  |  |  |             self.test_result = test_result | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             self.test_result = { | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                 'tcp_tx': TestResult('tcp', 'tx', config_name), | 
					
						
							|  |  |  |                 'tcp_rx': TestResult('tcp', 'rx', config_name), | 
					
						
							|  |  |  |                 'udp_tx': TestResult('udp', 'tx', config_name), | 
					
						
							|  |  |  |                 'udp_rx': TestResult('udp', 'rx', config_name), | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def setup(self): | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         setup iperf test: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         1. kill current iperf process | 
					
						
							|  |  |  |         2. reboot DUT (currently iperf is not very robust, need to reboot DUT) | 
					
						
							|  |  |  |         3. scan to get AP RSSI | 
					
						
							|  |  |  |         4. connect to AP | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         try: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             subprocess.check_output('sudo killall iperf 2>&1 > /dev/null', shell=True) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |         except subprocess.CalledProcessError: | 
					
						
							|  |  |  |             pass | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         self.dut.write('restart') | 
					
						
							|  |  |  |         self.dut.expect_any('iperf>', 'esp32>') | 
					
						
							|  |  |  |         self.dut.write('scan {}'.format(self.ap_ssid)) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |         for _ in range(SCAN_RETRY_COUNT): | 
					
						
							|  |  |  |             try: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                 rssi = int(self.dut.expect(re.compile(r'\[{}]\[rssi=(-\d+)]'.format(self.ap_ssid)), | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |                                            timeout=SCAN_TIMEOUT)[0]) | 
					
						
							|  |  |  |                 break | 
					
						
							|  |  |  |             except DUT.ExpectTimeout: | 
					
						
							|  |  |  |                 continue | 
					
						
							|  |  |  |         else: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             raise AssertionError('Failed to scan AP') | 
					
						
							|  |  |  |         self.dut.write('sta {} {}'.format(self.ap_ssid, self.ap_password)) | 
					
						
							|  |  |  |         dut_ip = self.dut.expect(re.compile(r'sta ip: ([\d.]+), mask: ([\d.]+), gw: ([\d.]+)'))[0] | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |         return dut_ip, rssi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _save_test_result(self, test_case, raw_data, att, rssi, heap_size): | 
					
						
							|  |  |  |         return self.test_result[test_case].add_result(raw_data, self.ap_ssid, att, rssi, heap_size) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _test_once(self, proto, direction): | 
					
						
							|  |  |  |         """ do measure once for one type """ | 
					
						
							|  |  |  |         # connect and scan to get RSSI | 
					
						
							|  |  |  |         dut_ip, rssi = self.setup() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         assert direction in ['rx', 'tx'] | 
					
						
							|  |  |  |         assert proto in ['tcp', 'udp'] | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # run iperf test | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         if direction == 'tx': | 
					
						
							|  |  |  |             with open(PC_IPERF_TEMP_LOG_FILE, 'w') as f: | 
					
						
							|  |  |  |                 if proto == 'tcp': | 
					
						
							|  |  |  |                     process = subprocess.Popen(['iperf', '-s', '-B', self.pc_nic_ip, | 
					
						
							|  |  |  |                                                 '-t', str(TEST_TIME), '-i', '1', '-f', 'm'], | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |                                                stdout=f, stderr=f) | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                     self.dut.write('iperf -c {} -i 1 -t {}'.format(self.pc_nic_ip, TEST_TIME)) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |                 else: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                     process = subprocess.Popen(['iperf', '-s', '-u', '-B', self.pc_nic_ip, | 
					
						
							|  |  |  |                                                 '-t', str(TEST_TIME), '-i', '1', '-f', 'm'], | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |                                                stdout=f, stderr=f) | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                     self.dut.write('iperf -c {} -u -i 1 -t {}'.format(self.pc_nic_ip, TEST_TIME)) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 for _ in range(TEST_TIMEOUT): | 
					
						
							|  |  |  |                     if process.poll() is not None: | 
					
						
							|  |  |  |                         break | 
					
						
							|  |  |  |                     time.sleep(1) | 
					
						
							|  |  |  |                 else: | 
					
						
							|  |  |  |                     process.terminate() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             with open(PC_IPERF_TEMP_LOG_FILE, 'r') as f: | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |                 pc_raw_data = server_raw_data = f.read() | 
					
						
							|  |  |  |         else: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             with open(PC_IPERF_TEMP_LOG_FILE, 'w') as f: | 
					
						
							|  |  |  |                 if proto == 'tcp': | 
					
						
							|  |  |  |                     self.dut.write('iperf -s -i 1 -t {}'.format(TEST_TIME)) | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  |                     # wait until DUT TCP server created | 
					
						
							|  |  |  |                     try: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                         self.dut.expect('iperf tcp server create successfully', timeout=1) | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  |                     except DUT.ExpectTimeout: | 
					
						
							|  |  |  |                         # compatible with old iperf example binary | 
					
						
							|  |  |  |                         pass | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                     process = subprocess.Popen(['iperf', '-c', dut_ip, | 
					
						
							|  |  |  |                                                 '-t', str(TEST_TIME), '-f', 'm'], | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |                                                stdout=f, stderr=f) | 
					
						
							|  |  |  |                 else: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                     self.dut.write('iperf -s -u -i 1 -t {}'.format(TEST_TIME)) | 
					
						
							|  |  |  |                     process = subprocess.Popen(['iperf', '-c', dut_ip, '-u', '-b', '100M', | 
					
						
							|  |  |  |                                                 '-t', str(TEST_TIME), '-f', 'm'], | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |                                                stdout=f, stderr=f) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 for _ in range(TEST_TIMEOUT): | 
					
						
							|  |  |  |                     if process.poll() is not None: | 
					
						
							|  |  |  |                         break | 
					
						
							|  |  |  |                     time.sleep(1) | 
					
						
							|  |  |  |                 else: | 
					
						
							|  |  |  |                     process.terminate() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             server_raw_data = self.dut.read() | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             with open(PC_IPERF_TEMP_LOG_FILE, 'r') as f: | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |                 pc_raw_data = f.read() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # save PC iperf logs to console | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         with open(self.pc_iperf_log_file, 'a+') as f: | 
					
						
							|  |  |  |             f.write('## [{}] `{}`\r\n##### {}' | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |                     .format(self.config_name, | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                             '{}_{}'.format(proto, direction), | 
					
						
							|  |  |  |                             time.strftime('%m-%d %H:%M:%S', time.localtime(time.time())))) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |             f.write('\r\n```\r\n\r\n' + pc_raw_data + '\r\n```\r\n') | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         self.dut.write('heap') | 
					
						
							|  |  |  |         heap_size = self.dut.expect(re.compile(r'min heap size: (\d+)\D'))[0] | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # return server raw data (for parsing test results) and RSSI | 
					
						
							|  |  |  |         return server_raw_data, rssi, heap_size | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def run_test(self, proto, direction, atten_val): | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         run test for one type, with specified atten_value and save the test result | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         :param proto: tcp or udp | 
					
						
							|  |  |  |         :param direction: tx or rx | 
					
						
							|  |  |  |         :param atten_val: attenuate value | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         rssi = FAILED_TO_SCAN_RSSI | 
					
						
							|  |  |  |         heap_size = INVALID_HEAP_SIZE | 
					
						
							|  |  |  |         try: | 
					
						
							|  |  |  |             server_raw_data, rssi, heap_size = self._test_once(proto, direction) | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             throughput = self._save_test_result('{}_{}'.format(proto, direction), | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |                                                 server_raw_data, atten_val, | 
					
						
							|  |  |  |                                                 rssi, heap_size) | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             Utility.console_log('[{}][{}_{}][{}][{}]: {:.02f}' | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |                                 .format(self.config_name, proto, direction, rssi, self.ap_ssid, throughput)) | 
					
						
							|  |  |  |         except Exception as e: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             self._save_test_result('{}_{}'.format(proto, direction), '', atten_val, rssi, heap_size) | 
					
						
							|  |  |  |             Utility.console_log('Failed during test: {}'.format(e)) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def run_all_cases(self, atten_val): | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         run test for all types (udp_tx, udp_rx, tcp_tx, tcp_rx). | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         :param atten_val: attenuate value | 
					
						
							|  |  |  |         """
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         self.run_test('tcp', 'tx', atten_val) | 
					
						
							|  |  |  |         self.run_test('tcp', 'rx', atten_val) | 
					
						
							|  |  |  |         self.run_test('udp', 'tx', atten_val) | 
					
						
							|  |  |  |         self.run_test('udp', 'rx', atten_val) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def wait_ap_power_on(self): | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         AP need to take sometime to power on. It changes for different APs. | 
					
						
							|  |  |  |         This method will scan to check if the AP powers on. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         :return: True or False | 
					
						
							|  |  |  |         """
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         self.dut.write('restart') | 
					
						
							|  |  |  |         self.dut.expect_any('iperf>', 'esp32>') | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |         for _ in range(WAIT_AP_POWER_ON_TIMEOUT // SCAN_TIMEOUT): | 
					
						
							|  |  |  |             try: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                 self.dut.write('scan {}'.format(self.ap_ssid)) | 
					
						
							|  |  |  |                 self.dut.expect(re.compile(r'\[{}]\[rssi=(-\d+)]'.format(self.ap_ssid)), | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |                                 timeout=SCAN_TIMEOUT) | 
					
						
							|  |  |  |                 ret = True | 
					
						
							|  |  |  |                 break | 
					
						
							|  |  |  |             except DUT.ExpectTimeout: | 
					
						
							|  |  |  |                 pass | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             ret = False | 
					
						
							|  |  |  |         return ret | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  | class IperfTestUtilitySoftap(IperfTestUtility): | 
					
						
							|  |  |  |     """ iperf test implementation """ | 
					
						
							|  |  |  |     def __init__(self, dut, softap_dut, config_name, test_result=None): | 
					
						
							|  |  |  |         super(IperfTestUtility, self).__init__(dut, config_name, 'softap', '1234567890', None, None, test_result=None) | 
					
						
							|  |  |  |         self.softap_dut = softap_dut | 
					
						
							|  |  |  |         self.softap_ip = '192.168.4.1' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def setup(self): | 
					
						
							|  |  |  |         """
 | 
					
						
							|  |  |  |         setup iperf test: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         1. kill current iperf process | 
					
						
							|  |  |  |         2. reboot DUT (currently iperf is not very robust, need to reboot DUT) | 
					
						
							|  |  |  |         3. scan to get AP RSSI | 
					
						
							|  |  |  |         4. connect to AP | 
					
						
							|  |  |  |         """
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         self.softap_dut.write('restart') | 
					
						
							|  |  |  |         self.softap_dut.expect_any('iperf>', 'esp32>', timeout=30) | 
					
						
							|  |  |  |         self.softap_dut.write('ap {} {}'.format(self.ap_ssid, self.ap_password)) | 
					
						
							|  |  |  |         self.dut.write('restart') | 
					
						
							|  |  |  |         self.dut.expect_any('iperf>', 'esp32>', timeout=30) | 
					
						
							|  |  |  |         self.dut.write('scan {}'.format(self.ap_ssid)) | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  |         for _ in range(SCAN_RETRY_COUNT): | 
					
						
							|  |  |  |             try: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                 rssi = int(self.dut.expect(re.compile(r'\[{}]\[rssi=(-\d+)]'.format(self.ap_ssid)), | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  |                                            timeout=SCAN_TIMEOUT)[0]) | 
					
						
							|  |  |  |                 break | 
					
						
							|  |  |  |             except DUT.ExpectTimeout: | 
					
						
							|  |  |  |                 continue | 
					
						
							|  |  |  |         else: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             raise AssertionError('Failed to scan AP') | 
					
						
							|  |  |  |         self.dut.write('sta {} {}'.format(self.ap_ssid, self.ap_password)) | 
					
						
							|  |  |  |         dut_ip = self.dut.expect(re.compile(r'sta ip: ([\d.]+), mask: ([\d.]+), gw: ([\d.]+)'))[0] | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  |         return dut_ip, rssi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _test_once(self, proto, direction): | 
					
						
							|  |  |  |         """ do measure once for one type """ | 
					
						
							|  |  |  |         # connect and scan to get RSSI | 
					
						
							|  |  |  |         dut_ip, rssi = self.setup() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         assert direction in ['rx', 'tx'] | 
					
						
							|  |  |  |         assert proto in ['tcp', 'udp'] | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # run iperf test | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         if direction == 'tx': | 
					
						
							|  |  |  |             if proto == 'tcp': | 
					
						
							|  |  |  |                 self.softap_dut.write('iperf -s -i 1 -t {}'.format(TEST_TIME)) | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  |                 # wait until DUT TCP server created | 
					
						
							|  |  |  |                 try: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                     self.softap_dut.expect('iperf tcp server create successfully', timeout=1) | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  |                 except DUT.ExpectTimeout: | 
					
						
							|  |  |  |                     # compatible with old iperf example binary | 
					
						
							|  |  |  |                     pass | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                 self.dut.write('iperf -c {} -i 1 -t {}'.format(self.softap_ip, TEST_TIME)) | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  |             else: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                 self.softap_dut.write('iperf -s -u -i 1 -t {}'.format(TEST_TIME)) | 
					
						
							|  |  |  |                 self.dut.write('iperf -c {} -u -i 1 -t {}'.format(self.softap_ip, TEST_TIME)) | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  |         else: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             if proto == 'tcp': | 
					
						
							|  |  |  |                 self.dut.write('iperf -s -i 1 -t {}'.format(TEST_TIME)) | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  |                 # wait until DUT TCP server created | 
					
						
							|  |  |  |                 try: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                     self.dut.expect('iperf tcp server create successfully', timeout=1) | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  |                 except DUT.ExpectTimeout: | 
					
						
							|  |  |  |                     # compatible with old iperf example binary | 
					
						
							|  |  |  |                     pass | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                 self.softap_dut.write('iperf -c {} -i 1 -t {}'.format(dut_ip, TEST_TIME)) | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  |             else: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                 self.dut.write('iperf -s -u -i 1 -t {}'.format(TEST_TIME)) | 
					
						
							|  |  |  |                 self.softap_dut.write('iperf -c {} -u -i 1 -t {}'.format(dut_ip, TEST_TIME)) | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  |         time.sleep(60) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         if direction == 'tx': | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  |             server_raw_data = self.dut.read() | 
					
						
							|  |  |  |         else: | 
					
						
							|  |  |  |             server_raw_data = self.softap_dut.read() | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         self.dut.write('iperf -a') | 
					
						
							|  |  |  |         self.softap_dut.write('iperf -a') | 
					
						
							|  |  |  |         self.dut.write('heap') | 
					
						
							|  |  |  |         heap_size = self.dut.expect(re.compile(r'min heap size: (\d+)\D'))[0] | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # return server raw data (for parsing test results) and RSSI | 
					
						
							|  |  |  |         return server_raw_data, rssi, heap_size | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-12 10:16:20 +08:00
										 |  |  | @ttfw_idf.idf_example_test(env_tag='Example_ShieldBox_Basic', target=['ESP32', 'ESP32S2', 'ESP32C3'], category='stress') | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | def test_wifi_throughput_with_different_configs(env, extra_data): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     steps: | | 
					
						
							|  |  |  |       1. build iperf with specified configs | 
					
						
							|  |  |  |       2. test throughput for all routers | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |     pc_nic_ip = env.get_pc_nic_info('pc_nic', 'ipv4')['addr'] | 
					
						
							|  |  |  |     pc_iperf_log_file = os.path.join(env.log_path, 'pc_iperf_log.md') | 
					
						
							| 
									
										
										
										
											2018-10-24 13:34:05 +08:00
										 |  |  |     ap_info = { | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         'ssid': env.get_variable('ap_ssid'), | 
					
						
							|  |  |  |         'password': env.get_variable('ap_password'), | 
					
						
							| 
									
										
										
										
											2018-10-24 13:34:05 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |     config_names_raw = subprocess.check_output(['ls', os.path.dirname(os.path.abspath(__file__))]) | 
					
						
							| 
									
										
										
										
											2019-11-24 23:51:39 +01:00
										 |  |  |     config_names = CONFIG_NAME_PATTERN.findall(config_names_raw) | 
					
						
							|  |  |  |     if not config_names: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         raise ValueError('no configs found in {}'.format(os.path.dirname(__file__))) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     test_result = dict() | 
					
						
							|  |  |  |     sdkconfig_files = dict() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-24 23:51:39 +01:00
										 |  |  |     for config_name in config_names: | 
					
						
							| 
									
										
										
										
											2019-10-17 16:16:33 +02:00
										 |  |  |         # 1. get the config | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |         sdkconfig_files[config_name] = os.path.join(os.path.dirname(__file__), | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                                                     'sdkconfig.ci.{}'.format(config_name)) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # 2. get DUT and download | 
					
						
							| 
									
										
										
										
											2021-05-12 10:16:20 +08:00
										 |  |  |         dut = env.get_dut('iperf', 'examples/wifi/iperf', app_config_name=config_name) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |         dut.start_app() | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         dut.expect_any('iperf>', 'esp32>') | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # 3. run test for each required att value | 
					
						
							|  |  |  |         test_result[config_name] = { | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             'tcp_tx': TestResult('tcp', 'tx', config_name), | 
					
						
							|  |  |  |             'tcp_rx': TestResult('tcp', 'rx', config_name), | 
					
						
							|  |  |  |             'udp_tx': TestResult('udp', 'tx', config_name), | 
					
						
							|  |  |  |             'udp_rx': TestResult('udp', 'rx', config_name), | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         test_utility = IperfTestUtility(dut, config_name, ap_info['ssid'], | 
					
						
							|  |  |  |                                         ap_info['password'], pc_nic_ip, pc_iperf_log_file, test_result[config_name]) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         for _ in range(RETRY_COUNT_FOR_BEST_PERFORMANCE): | 
					
						
							|  |  |  |             test_utility.run_all_cases(0) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for result_type in test_result[config_name]: | 
					
						
							|  |  |  |             summary = str(test_result[config_name][result_type]) | 
					
						
							|  |  |  |             if summary: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |                 Utility.console_log(summary, color='orange') | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # 4. check test results | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         env.close_dut('iperf') | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # 5. generate report | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |     report = TestReport.ThroughputForConfigsReport(os.path.join(env.log_path, 'ThroughputForConfigsReport'), | 
					
						
							|  |  |  |                                                    ap_info['ssid'], test_result, sdkconfig_files) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |     report.generate_report() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-12 10:16:20 +08:00
										 |  |  | @ttfw_idf.idf_example_test(env_tag='Example_ShieldBox', target=['ESP32', 'ESP32S2', 'ESP32C3'], category='stress') | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | def test_wifi_throughput_vs_rssi(env, extra_data): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     steps: | | 
					
						
							|  |  |  |       1. build with best performance config | 
					
						
							|  |  |  |       2. switch on one router | 
					
						
							|  |  |  |       3. set attenuator value from 0-60 for each router | 
					
						
							|  |  |  |       4. test TCP tx rx and UDP tx rx throughput | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |     att_port = env.get_variable('attenuator_port') | 
					
						
							|  |  |  |     ap_list = env.get_variable('ap_list') | 
					
						
							|  |  |  |     pc_nic_ip = env.get_pc_nic_info('pc_nic', 'ipv4')['addr'] | 
					
						
							|  |  |  |     apc_ip = env.get_variable('apc_ip') | 
					
						
							|  |  |  |     pc_iperf_log_file = os.path.join(env.log_path, 'pc_iperf_log.md') | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     test_result = { | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         'tcp_tx': TestResult('tcp', 'tx', BEST_PERFORMANCE_CONFIG), | 
					
						
							|  |  |  |         'tcp_rx': TestResult('tcp', 'rx', BEST_PERFORMANCE_CONFIG), | 
					
						
							|  |  |  |         'udp_tx': TestResult('udp', 'tx', BEST_PERFORMANCE_CONFIG), | 
					
						
							|  |  |  |         'udp_rx': TestResult('udp', 'rx', BEST_PERFORMANCE_CONFIG), | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-17 16:16:33 +02:00
										 |  |  |     # 1. get DUT and download | 
					
						
							| 
									
										
										
										
											2021-05-12 10:16:20 +08:00
										 |  |  |     dut = env.get_dut('iperf', 'examples/wifi/iperf', app_config_name=BEST_PERFORMANCE_CONFIG) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |     dut.start_app() | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |     dut.expect_any('iperf>', 'esp32>') | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-17 16:16:33 +02:00
										 |  |  |     # 2. run test for each required att value | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |     for ap_info in ap_list: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         test_utility = IperfTestUtility(dut, BEST_PERFORMANCE_CONFIG, ap_info['ssid'], ap_info['password'], | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |                                         pc_nic_ip, pc_iperf_log_file, test_result) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         PowerControl.Control.control_rest(apc_ip, ap_info['outlet'], 'OFF') | 
					
						
							|  |  |  |         PowerControl.Control.control(apc_ip, {ap_info['outlet']: 'ON'}) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |         Attenuator.set_att(att_port, 0) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if not test_utility.wait_ap_power_on(): | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |             Utility.console_log('[{}] failed to power on, skip testing this AP' | 
					
						
							|  |  |  |                                 .format(ap_info['ssid']), color='red') | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |             continue | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for atten_val in ATTEN_VALUE_LIST: | 
					
						
							|  |  |  |             assert Attenuator.set_att(att_port, atten_val) is True | 
					
						
							|  |  |  |             test_utility.run_all_cases(atten_val) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-17 16:16:33 +02:00
										 |  |  |     # 3. check test results | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |     env.close_dut('iperf') | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-17 16:16:33 +02:00
										 |  |  |     # 4. generate report | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |     report = TestReport.ThroughputVsRssiReport(os.path.join(env.log_path, 'STAThroughputVsRssiReport'), | 
					
						
							| 
									
										
										
										
											2019-11-27 11:58:07 +08:00
										 |  |  |                                                test_result) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |     report.generate_report() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-12 10:16:20 +08:00
										 |  |  | @ttfw_idf.idf_example_test(env_tag='Example_ShieldBox_Basic', | 
					
						
							|  |  |  |                            target=['ESP32', 'ESP32S2', 'ESP32C3'], ci_target=['ESP32']) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | def test_wifi_throughput_basic(env, extra_data): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     steps: | | 
					
						
							|  |  |  |       1. test TCP tx rx and UDP tx rx throughput | 
					
						
							|  |  |  |       2. compare with the pre-defined pass standard | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |     pc_nic_ip = env.get_pc_nic_info('pc_nic', 'ipv4')['addr'] | 
					
						
							|  |  |  |     pc_iperf_log_file = os.path.join(env.log_path, 'pc_iperf_log.md') | 
					
						
							| 
									
										
										
										
											2018-10-24 13:34:05 +08:00
										 |  |  |     ap_info = { | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         'ssid': env.get_variable('ap_ssid'), | 
					
						
							|  |  |  |         'password': env.get_variable('ap_password'), | 
					
						
							| 
									
										
										
										
											2018-10-24 13:34:05 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-17 16:16:33 +02:00
										 |  |  |     # 1. get DUT | 
					
						
							| 
									
										
										
										
											2021-05-12 10:16:20 +08:00
										 |  |  |     dut = env.get_dut('iperf', 'examples/wifi/iperf', app_config_name=BEST_PERFORMANCE_CONFIG) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |     dut.start_app() | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |     dut.expect_any('iperf>', 'esp32>') | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-17 16:16:33 +02:00
										 |  |  |     # 2. preparing | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |     test_result = { | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         'tcp_tx': TestResult('tcp', 'tx', BEST_PERFORMANCE_CONFIG), | 
					
						
							|  |  |  |         'tcp_rx': TestResult('tcp', 'rx', BEST_PERFORMANCE_CONFIG), | 
					
						
							|  |  |  |         'udp_tx': TestResult('udp', 'tx', BEST_PERFORMANCE_CONFIG), | 
					
						
							|  |  |  |         'udp_rx': TestResult('udp', 'rx', BEST_PERFORMANCE_CONFIG), | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |     test_utility = IperfTestUtility(dut, BEST_PERFORMANCE_CONFIG, ap_info['ssid'], | 
					
						
							|  |  |  |                                     ap_info['password'], pc_nic_ip, pc_iperf_log_file, test_result) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-17 16:16:33 +02:00
										 |  |  |     # 3. run test for TCP Tx, Rx and UDP Tx, Rx | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |     for _ in range(RETRY_COUNT_FOR_BEST_PERFORMANCE): | 
					
						
							|  |  |  |         test_utility.run_all_cases(0) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-17 16:16:33 +02:00
										 |  |  |     # 4. log performance and compare with pass standard | 
					
						
							| 
									
										
										
										
											2019-03-07 20:24:12 +08:00
										 |  |  |     performance_items = [] | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |     for throughput_type in test_result: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         ttfw_idf.log_performance('{}_throughput'.format(throughput_type), | 
					
						
							|  |  |  |                                  '{:.02f} Mbps'.format(test_result[throughput_type].get_best_throughput())) | 
					
						
							|  |  |  |         performance_items.append(['{}_throughput'.format(throughput_type), | 
					
						
							|  |  |  |                                   '{:.02f} Mbps'.format(test_result[throughput_type].get_best_throughput())]) | 
					
						
							| 
									
										
										
										
											2019-03-07 20:24:12 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-17 16:16:33 +02:00
										 |  |  |     # 5. save to report | 
					
						
							| 
									
										
										
										
											2019-03-07 20:24:12 +08:00
										 |  |  |     TinyFW.JunitReport.update_performance(performance_items) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  |     # do check after logging, otherwise test will exit immediately if check fail, some performance can't be logged. | 
					
						
							|  |  |  |     for throughput_type in test_result: | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         ttfw_idf.check_performance('{}_throughput'.format(throughput_type), | 
					
						
							| 
									
										
										
										
											2020-02-28 16:12:11 +01:00
										 |  |  |                                    test_result[throughput_type].get_best_throughput(), dut.TARGET) | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |     env.close_dut('iperf') | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-12 10:16:20 +08:00
										 |  |  | @ttfw_idf.idf_example_test(env_tag='Example_ShieldBox2', target=['ESP32', 'ESP32S2', 'ESP32C3'], category='stress') | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  | def test_softap_throughput_vs_rssi(env, extra_data): | 
					
						
							|  |  |  |     """
 | 
					
						
							|  |  |  |     steps: | | 
					
						
							|  |  |  |       1. build with best performance config | 
					
						
							|  |  |  |       2. switch on one router | 
					
						
							|  |  |  |       3. set attenuator value from 0-60 for each router | 
					
						
							|  |  |  |       4. test TCP tx rx and UDP tx rx throughput | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |     att_port = env.get_variable('attenuator_port') | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     test_result = { | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |         'tcp_tx': TestResult('tcp', 'tx', BEST_PERFORMANCE_CONFIG), | 
					
						
							|  |  |  |         'tcp_rx': TestResult('tcp', 'rx', BEST_PERFORMANCE_CONFIG), | 
					
						
							|  |  |  |         'udp_tx': TestResult('udp', 'tx', BEST_PERFORMANCE_CONFIG), | 
					
						
							|  |  |  |         'udp_rx': TestResult('udp', 'rx', BEST_PERFORMANCE_CONFIG), | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # 1. get DUT and download | 
					
						
							| 
									
										
										
										
											2021-05-12 10:16:20 +08:00
										 |  |  |     softap_dut = env.get_dut('softap_iperf', 'examples/wifi/iperf') | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  |     softap_dut.start_app() | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |     softap_dut.expect_any('iperf>', 'esp32>') | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-12 10:16:20 +08:00
										 |  |  |     sta_dut = env.get_dut('sta_iperf', 'examples/wifi/iperf', app_config_name=BEST_PERFORMANCE_CONFIG) | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  |     sta_dut.start_app() | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |     sta_dut.expect_any('iperf>', 'esp32>') | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # 2. run test for each required att value | 
					
						
							|  |  |  |     test_utility = IperfTestUtilitySoftap(sta_dut, softap_dut, BEST_PERFORMANCE_CONFIG, test_result) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Attenuator.set_att(att_port, 0) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for atten_val in ATTEN_VALUE_LIST: | 
					
						
							|  |  |  |         assert Attenuator.set_att(att_port, atten_val) is True | 
					
						
							|  |  |  |         test_utility.run_all_cases(atten_val) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |     env.close_dut('softap_iperf') | 
					
						
							|  |  |  |     env.close_dut('sta_iperf') | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # 3. generate report | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |     report = TestReport.ThroughputVsRssiReport(os.path.join(env.log_path, 'SoftAPThroughputVsRssiReport'), | 
					
						
							| 
									
										
										
										
											2020-12-10 20:33:11 +08:00
										 |  |  |                                                test_result) | 
					
						
							|  |  |  |     report.generate_report() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-07 20:28:09 +08:00
										 |  |  | if __name__ == '__main__': | 
					
						
							| 
									
										
										
										
											2021-05-12 10:16:20 +08:00
										 |  |  |     # test_wifi_throughput_basic(env_config_file='EnvConfig.yml') | 
					
						
							|  |  |  |     # test_wifi_throughput_with_different_configs(env_config_file='EnvConfig.yml') | 
					
						
							|  |  |  |     test_wifi_throughput_vs_rssi(env_config_file='EnvConfig.yml', target='ESP32C3') | 
					
						
							| 
									
										
										
										
											2021-01-26 10:49:01 +08:00
										 |  |  |     test_softap_throughput_vs_rssi(env_config_file='EnvConfig.yml') |