2018-01-07 07:28:09 -05: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-25 21:49:01 -05:00
|
|
|
from __future__ import division, unicode_literals
|
|
|
|
|
2018-01-07 07:28:09 -05:00
|
|
|
import os
|
2021-01-25 21:49:01 -05:00
|
|
|
import re
|
2018-01-07 07:28:09 -05:00
|
|
|
import subprocess
|
2021-01-25 21:49:01 -05:00
|
|
|
import time
|
2021-07-27 21:39:02 -04:00
|
|
|
from builtins import range, str
|
2018-01-07 07:28:09 -05:00
|
|
|
|
2019-11-26 22:58:07 -05:00
|
|
|
import ttfw_idf
|
2021-07-27 21:39:02 -04:00
|
|
|
from idf_iperf_test_util import Attenuator, IperfUtility, PowerControl, TestReport
|
|
|
|
from idf_iperf_test_util.IperfUtility import SCAN_RETRY_COUNT, SCAN_TIMEOUT, TEST_TIME
|
2021-01-25 21:49:01 -05:00
|
|
|
from tiny_test_fw import DUT, TinyFW, Utility
|
2018-01-07 07:28:09 -05:00
|
|
|
|
|
|
|
# configurations
|
|
|
|
RETRY_COUNT_FOR_BEST_PERFORMANCE = 2
|
|
|
|
ATTEN_VALUE_LIST = range(0, 60, 2)
|
2022-03-25 09:45:56 -04:00
|
|
|
NO_BANDWIDTH_LIMIT = -1 # iperf send bandwith is not limited
|
2018-01-07 07:28:09 -05:00
|
|
|
|
2021-01-25 21:49:01 -05:00
|
|
|
CONFIG_NAME_PATTERN = re.compile(r'sdkconfig\.ci\.(.+)')
|
2018-01-07 07:28:09 -05: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-25 21:49:01 -05:00
|
|
|
BEST_PERFORMANCE_CONFIG = '99'
|
2018-01-07 07:28:09 -05:00
|
|
|
|
|
|
|
|
2021-07-27 21:39:02 -04:00
|
|
|
class IperfTestUtilitySoftap(IperfUtility.IperfTestUtility):
|
2020-12-10 07:33:11 -05:00
|
|
|
""" iperf test implementation """
|
|
|
|
def __init__(self, dut, softap_dut, config_name, test_result=None):
|
2021-07-27 21:39:02 -04:00
|
|
|
IperfUtility.IperfTestUtility.__init__(self, dut, config_name, 'softap', '1234567890', None, None, test_result)
|
2020-12-10 07:33:11 -05:00
|
|
|
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-25 21:49:01 -05: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 07:33:11 -05:00
|
|
|
for _ in range(SCAN_RETRY_COUNT):
|
|
|
|
try:
|
2021-01-25 21:49:01 -05:00
|
|
|
rssi = int(self.dut.expect(re.compile(r'\[{}]\[rssi=(-\d+)]'.format(self.ap_ssid)),
|
2020-12-10 07:33:11 -05:00
|
|
|
timeout=SCAN_TIMEOUT)[0])
|
|
|
|
break
|
|
|
|
except DUT.ExpectTimeout:
|
|
|
|
continue
|
|
|
|
else:
|
2021-01-25 21:49:01 -05: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 07:33:11 -05: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-25 21:49:01 -05:00
|
|
|
assert direction in ['rx', 'tx']
|
|
|
|
assert proto in ['tcp', 'udp']
|
2020-12-10 07:33:11 -05:00
|
|
|
|
|
|
|
# run iperf test
|
2021-01-25 21:49:01 -05:00
|
|
|
if direction == 'tx':
|
|
|
|
if proto == 'tcp':
|
|
|
|
self.softap_dut.write('iperf -s -i 1 -t {}'.format(TEST_TIME))
|
2020-12-10 07:33:11 -05:00
|
|
|
# wait until DUT TCP server created
|
|
|
|
try:
|
2021-01-25 21:49:01 -05:00
|
|
|
self.softap_dut.expect('iperf tcp server create successfully', timeout=1)
|
2020-12-10 07:33:11 -05:00
|
|
|
except DUT.ExpectTimeout:
|
|
|
|
# compatible with old iperf example binary
|
|
|
|
pass
|
2021-01-25 21:49:01 -05:00
|
|
|
self.dut.write('iperf -c {} -i 1 -t {}'.format(self.softap_ip, TEST_TIME))
|
2020-12-10 07:33:11 -05:00
|
|
|
else:
|
2021-01-25 21:49:01 -05: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 07:33:11 -05:00
|
|
|
else:
|
2021-01-25 21:49:01 -05:00
|
|
|
if proto == 'tcp':
|
|
|
|
self.dut.write('iperf -s -i 1 -t {}'.format(TEST_TIME))
|
2020-12-10 07:33:11 -05:00
|
|
|
# wait until DUT TCP server created
|
|
|
|
try:
|
2021-01-25 21:49:01 -05:00
|
|
|
self.dut.expect('iperf tcp server create successfully', timeout=1)
|
2020-12-10 07:33:11 -05:00
|
|
|
except DUT.ExpectTimeout:
|
|
|
|
# compatible with old iperf example binary
|
|
|
|
pass
|
2021-01-25 21:49:01 -05:00
|
|
|
self.softap_dut.write('iperf -c {} -i 1 -t {}'.format(dut_ip, TEST_TIME))
|
2020-12-10 07:33:11 -05:00
|
|
|
else:
|
2021-01-25 21:49:01 -05: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 07:33:11 -05:00
|
|
|
time.sleep(60)
|
|
|
|
|
2021-01-25 21:49:01 -05:00
|
|
|
if direction == 'tx':
|
2020-12-10 07:33:11 -05:00
|
|
|
server_raw_data = self.dut.read()
|
|
|
|
else:
|
|
|
|
server_raw_data = self.softap_dut.read()
|
2021-01-25 21:49:01 -05: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 07:33:11 -05:00
|
|
|
|
|
|
|
# return server raw data (for parsing test results) and RSSI
|
|
|
|
return server_raw_data, rssi, heap_size
|
|
|
|
|
|
|
|
|
2021-07-27 21:39:02 -04:00
|
|
|
@ttfw_idf.idf_example_test(env_tag='Example_ShieldBox_Basic', target=['ESP32', 'ESP32S2', 'ESP32C3', 'ESP32S3'], category='stress')
|
2018-01-07 07:28:09 -05: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-25 21:49:01 -05: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 01:34:05 -04:00
|
|
|
ap_info = {
|
2021-01-25 21:49:01 -05:00
|
|
|
'ssid': env.get_variable('ap_ssid'),
|
|
|
|
'password': env.get_variable('ap_password'),
|
2018-10-24 01:34:05 -04:00
|
|
|
}
|
2018-01-07 07:28:09 -05:00
|
|
|
|
2021-01-25 21:49:01 -05:00
|
|
|
config_names_raw = subprocess.check_output(['ls', os.path.dirname(os.path.abspath(__file__))])
|
2019-11-24 17:51:39 -05:00
|
|
|
config_names = CONFIG_NAME_PATTERN.findall(config_names_raw)
|
|
|
|
if not config_names:
|
2021-01-25 21:49:01 -05:00
|
|
|
raise ValueError('no configs found in {}'.format(os.path.dirname(__file__)))
|
2018-01-07 07:28:09 -05:00
|
|
|
|
|
|
|
test_result = dict()
|
|
|
|
sdkconfig_files = dict()
|
|
|
|
|
2019-11-24 17:51:39 -05:00
|
|
|
for config_name in config_names:
|
2019-10-17 10:16:33 -04:00
|
|
|
# 1. get the config
|
2018-01-07 07:28:09 -05:00
|
|
|
sdkconfig_files[config_name] = os.path.join(os.path.dirname(__file__),
|
2021-01-25 21:49:01 -05:00
|
|
|
'sdkconfig.ci.{}'.format(config_name))
|
2018-01-07 07:28:09 -05:00
|
|
|
|
|
|
|
# 2. get DUT and download
|
2021-05-11 22:16:20 -04:00
|
|
|
dut = env.get_dut('iperf', 'examples/wifi/iperf', app_config_name=config_name)
|
2018-01-07 07:28:09 -05:00
|
|
|
dut.start_app()
|
2021-01-25 21:49:01 -05:00
|
|
|
dut.expect_any('iperf>', 'esp32>')
|
2018-01-07 07:28:09 -05:00
|
|
|
|
|
|
|
# 3. run test for each required att value
|
|
|
|
test_result[config_name] = {
|
2021-07-27 21:39:02 -04:00
|
|
|
'tcp_tx': IperfUtility.TestResult('tcp', 'tx', config_name),
|
|
|
|
'tcp_rx': IperfUtility.TestResult('tcp', 'rx', config_name),
|
|
|
|
'udp_tx': IperfUtility.TestResult('udp', 'tx', config_name),
|
|
|
|
'udp_rx': IperfUtility.TestResult('udp', 'rx', config_name),
|
2018-01-07 07:28:09 -05:00
|
|
|
}
|
|
|
|
|
2021-07-27 21:39:02 -04:00
|
|
|
test_utility = IperfUtility.IperfTestUtility(dut, config_name, ap_info['ssid'], ap_info['password'], pc_nic_ip,
|
|
|
|
pc_iperf_log_file, test_result[config_name])
|
2018-01-07 07:28:09 -05:00
|
|
|
|
|
|
|
for _ in range(RETRY_COUNT_FOR_BEST_PERFORMANCE):
|
2022-03-25 09:45:56 -04:00
|
|
|
test_utility.run_all_cases(0, NO_BANDWIDTH_LIMIT)
|
2018-01-07 07:28:09 -05:00
|
|
|
|
|
|
|
for result_type in test_result[config_name]:
|
|
|
|
summary = str(test_result[config_name][result_type])
|
|
|
|
if summary:
|
2021-01-25 21:49:01 -05:00
|
|
|
Utility.console_log(summary, color='orange')
|
2018-01-07 07:28:09 -05:00
|
|
|
|
|
|
|
# 4. check test results
|
2021-01-25 21:49:01 -05:00
|
|
|
env.close_dut('iperf')
|
2018-01-07 07:28:09 -05:00
|
|
|
|
|
|
|
# 5. generate report
|
2021-07-27 21:39:02 -04:00
|
|
|
report = TestReport.ThroughputForConfigsReport(os.path.join(env.log_path, 'Performance',
|
|
|
|
'ThroughputForConfigsReport'),
|
2021-01-25 21:49:01 -05:00
|
|
|
ap_info['ssid'], test_result, sdkconfig_files)
|
2018-01-07 07:28:09 -05:00
|
|
|
report.generate_report()
|
|
|
|
|
|
|
|
|
2021-07-27 21:39:02 -04:00
|
|
|
@ttfw_idf.idf_example_test(env_tag='Example_ShieldBox', target=['ESP32', 'ESP32S2', 'ESP32C3', 'ESP32S3'], category='stress')
|
2018-01-07 07:28:09 -05: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-25 21:49:01 -05: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 07:28:09 -05:00
|
|
|
|
|
|
|
test_result = {
|
2021-07-27 21:39:02 -04:00
|
|
|
'tcp_tx': IperfUtility.TestResult('tcp', 'tx', BEST_PERFORMANCE_CONFIG),
|
|
|
|
'tcp_rx': IperfUtility.TestResult('tcp', 'rx', BEST_PERFORMANCE_CONFIG),
|
|
|
|
'udp_tx': IperfUtility.TestResult('udp', 'tx', BEST_PERFORMANCE_CONFIG),
|
|
|
|
'udp_rx': IperfUtility.TestResult('udp', 'rx', BEST_PERFORMANCE_CONFIG),
|
2018-01-07 07:28:09 -05:00
|
|
|
}
|
|
|
|
|
2019-10-17 10:16:33 -04:00
|
|
|
# 1. get DUT and download
|
2021-05-11 22:16:20 -04:00
|
|
|
dut = env.get_dut('iperf', 'examples/wifi/iperf', app_config_name=BEST_PERFORMANCE_CONFIG)
|
2018-01-07 07:28:09 -05:00
|
|
|
dut.start_app()
|
2021-01-25 21:49:01 -05:00
|
|
|
dut.expect_any('iperf>', 'esp32>')
|
2018-01-07 07:28:09 -05:00
|
|
|
|
2019-10-17 10:16:33 -04:00
|
|
|
# 2. run test for each required att value
|
2018-01-07 07:28:09 -05:00
|
|
|
for ap_info in ap_list:
|
2021-07-27 21:39:02 -04:00
|
|
|
test_utility = IperfUtility.IperfTestUtility(dut, BEST_PERFORMANCE_CONFIG, ap_info['ssid'],
|
|
|
|
ap_info['password'], pc_nic_ip, pc_iperf_log_file, test_result)
|
2018-01-07 07:28:09 -05:00
|
|
|
|
2021-01-25 21:49:01 -05:00
|
|
|
PowerControl.Control.control_rest(apc_ip, ap_info['outlet'], 'OFF')
|
|
|
|
PowerControl.Control.control(apc_ip, {ap_info['outlet']: 'ON'})
|
2018-01-07 07:28:09 -05:00
|
|
|
Attenuator.set_att(att_port, 0)
|
|
|
|
|
|
|
|
if not test_utility.wait_ap_power_on():
|
2021-01-25 21:49:01 -05:00
|
|
|
Utility.console_log('[{}] failed to power on, skip testing this AP'
|
|
|
|
.format(ap_info['ssid']), color='red')
|
2018-01-07 07:28:09 -05:00
|
|
|
continue
|
|
|
|
|
|
|
|
for atten_val in ATTEN_VALUE_LIST:
|
|
|
|
assert Attenuator.set_att(att_port, atten_val) is True
|
2021-07-27 21:39:02 -04:00
|
|
|
try:
|
2022-03-25 09:45:56 -04:00
|
|
|
test_utility.run_all_cases(atten_val, NO_BANDWIDTH_LIMIT)
|
2021-07-27 21:39:02 -04:00
|
|
|
except AssertionError:
|
|
|
|
break
|
2018-01-07 07:28:09 -05:00
|
|
|
|
2019-10-17 10:16:33 -04:00
|
|
|
# 3. check test results
|
2021-01-25 21:49:01 -05:00
|
|
|
env.close_dut('iperf')
|
2018-01-07 07:28:09 -05:00
|
|
|
|
2019-10-17 10:16:33 -04:00
|
|
|
# 4. generate report
|
2021-07-27 21:39:02 -04:00
|
|
|
report = TestReport.ThroughputVsRssiReport(os.path.join(env.log_path, 'Performance', 'STAThroughputVsRssiReport'),
|
2019-11-26 22:58:07 -05:00
|
|
|
test_result)
|
2018-01-07 07:28:09 -05:00
|
|
|
report.generate_report()
|
|
|
|
|
|
|
|
|
2021-05-11 22:16:20 -04:00
|
|
|
@ttfw_idf.idf_example_test(env_tag='Example_ShieldBox_Basic',
|
2021-07-27 21:39:02 -04:00
|
|
|
target=['ESP32', 'ESP32S2', 'ESP32C3', 'ESP32S3'], ci_target=['ESP32'])
|
2018-01-07 07:28:09 -05: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-25 21:49:01 -05: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 01:34:05 -04:00
|
|
|
ap_info = {
|
2021-01-25 21:49:01 -05:00
|
|
|
'ssid': env.get_variable('ap_ssid'),
|
|
|
|
'password': env.get_variable('ap_password'),
|
2018-10-24 01:34:05 -04:00
|
|
|
}
|
2018-01-07 07:28:09 -05:00
|
|
|
|
2019-10-17 10:16:33 -04:00
|
|
|
# 1. get DUT
|
2021-05-11 22:16:20 -04:00
|
|
|
dut = env.get_dut('iperf', 'examples/wifi/iperf', app_config_name=BEST_PERFORMANCE_CONFIG)
|
2018-01-07 07:28:09 -05:00
|
|
|
dut.start_app()
|
2021-01-25 21:49:01 -05:00
|
|
|
dut.expect_any('iperf>', 'esp32>')
|
2018-01-07 07:28:09 -05:00
|
|
|
|
2019-10-17 10:16:33 -04:00
|
|
|
# 2. preparing
|
2018-01-07 07:28:09 -05:00
|
|
|
test_result = {
|
2021-07-27 21:39:02 -04:00
|
|
|
'tcp_tx': IperfUtility.TestResult('tcp', 'tx', BEST_PERFORMANCE_CONFIG),
|
|
|
|
'tcp_rx': IperfUtility.TestResult('tcp', 'rx', BEST_PERFORMANCE_CONFIG),
|
|
|
|
'udp_tx': IperfUtility.TestResult('udp', 'tx', BEST_PERFORMANCE_CONFIG),
|
|
|
|
'udp_rx': IperfUtility.TestResult('udp', 'rx', BEST_PERFORMANCE_CONFIG),
|
2018-01-07 07:28:09 -05:00
|
|
|
}
|
|
|
|
|
2021-07-27 21:39:02 -04:00
|
|
|
test_utility = IperfUtility.IperfTestUtility(dut, BEST_PERFORMANCE_CONFIG, ap_info['ssid'], ap_info['password'],
|
|
|
|
pc_nic_ip, pc_iperf_log_file, test_result)
|
2018-01-07 07:28:09 -05:00
|
|
|
|
2019-10-17 10:16:33 -04:00
|
|
|
# 3. run test for TCP Tx, Rx and UDP Tx, Rx
|
2018-01-07 07:28:09 -05:00
|
|
|
for _ in range(RETRY_COUNT_FOR_BEST_PERFORMANCE):
|
2022-03-25 09:45:56 -04:00
|
|
|
test_utility.run_all_cases(0, NO_BANDWIDTH_LIMIT)
|
2018-01-07 07:28:09 -05:00
|
|
|
|
2019-10-17 10:16:33 -04:00
|
|
|
# 4. log performance and compare with pass standard
|
2019-03-07 07:24:12 -05:00
|
|
|
performance_items = []
|
2018-01-07 07:28:09 -05:00
|
|
|
for throughput_type in test_result:
|
2021-01-25 21:49:01 -05: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 07:24:12 -05:00
|
|
|
|
2019-10-17 10:16:33 -04:00
|
|
|
# 5. save to report
|
2019-03-07 07:24:12 -05:00
|
|
|
TinyFW.JunitReport.update_performance(performance_items)
|
2018-01-07 07:28:09 -05: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-25 21:49:01 -05:00
|
|
|
ttfw_idf.check_performance('{}_throughput'.format(throughput_type),
|
2020-02-28 10:12:11 -05:00
|
|
|
test_result[throughput_type].get_best_throughput(), dut.TARGET)
|
2018-01-07 07:28:09 -05:00
|
|
|
|
2021-01-25 21:49:01 -05:00
|
|
|
env.close_dut('iperf')
|
2018-01-07 07:28:09 -05:00
|
|
|
|
|
|
|
|
2021-07-27 21:39:02 -04:00
|
|
|
@ttfw_idf.idf_example_test(env_tag='Example_ShieldBox2', target=['ESP32', 'ESP32S2', 'ESP32C3', 'ESP32S3'], category='stress')
|
2020-12-10 07:33:11 -05: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-25 21:49:01 -05:00
|
|
|
att_port = env.get_variable('attenuator_port')
|
2020-12-10 07:33:11 -05:00
|
|
|
|
|
|
|
test_result = {
|
2021-07-27 21:39:02 -04:00
|
|
|
'tcp_tx': IperfUtility.TestResult('tcp', 'tx', BEST_PERFORMANCE_CONFIG),
|
|
|
|
'tcp_rx': IperfUtility.TestResult('tcp', 'rx', BEST_PERFORMANCE_CONFIG),
|
|
|
|
'udp_tx': IperfUtility.TestResult('udp', 'tx', BEST_PERFORMANCE_CONFIG),
|
|
|
|
'udp_rx': IperfUtility.TestResult('udp', 'rx', BEST_PERFORMANCE_CONFIG),
|
2020-12-10 07:33:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
# 1. get DUT and download
|
2021-05-11 22:16:20 -04:00
|
|
|
softap_dut = env.get_dut('softap_iperf', 'examples/wifi/iperf')
|
2020-12-10 07:33:11 -05:00
|
|
|
softap_dut.start_app()
|
2021-01-25 21:49:01 -05:00
|
|
|
softap_dut.expect_any('iperf>', 'esp32>')
|
2020-12-10 07:33:11 -05:00
|
|
|
|
2021-05-11 22:16:20 -04:00
|
|
|
sta_dut = env.get_dut('sta_iperf', 'examples/wifi/iperf', app_config_name=BEST_PERFORMANCE_CONFIG)
|
2020-12-10 07:33:11 -05:00
|
|
|
sta_dut.start_app()
|
2021-01-25 21:49:01 -05:00
|
|
|
sta_dut.expect_any('iperf>', 'esp32>')
|
2020-12-10 07:33:11 -05: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
|
2021-07-27 21:39:02 -04:00
|
|
|
try:
|
2022-03-25 09:45:56 -04:00
|
|
|
test_utility.run_all_cases(atten_val, NO_BANDWIDTH_LIMIT)
|
2021-07-27 21:39:02 -04:00
|
|
|
except AssertionError:
|
|
|
|
break
|
2020-12-10 07:33:11 -05:00
|
|
|
|
2021-01-25 21:49:01 -05:00
|
|
|
env.close_dut('softap_iperf')
|
|
|
|
env.close_dut('sta_iperf')
|
2020-12-10 07:33:11 -05:00
|
|
|
|
|
|
|
# 3. generate report
|
2021-07-27 21:39:02 -04:00
|
|
|
report = TestReport.ThroughputVsRssiReport(os.path.join(env.log_path, 'Performance',
|
|
|
|
'SoftAPThroughputVsRssiReport'),test_result)
|
2020-12-10 07:33:11 -05:00
|
|
|
report.generate_report()
|
|
|
|
|
|
|
|
|
2018-01-07 07:28:09 -05:00
|
|
|
if __name__ == '__main__':
|
2021-05-11 22:16:20 -04: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-25 21:49:01 -05:00
|
|
|
test_softap_throughput_vs_rssi(env_config_file='EnvConfig.yml')
|