mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
advanced_https_ota: Add example test for OTA with OpenSSL server with binary file aligned to 289 byte boundary
This commit is contained in:
parent
b148433fbd
commit
691e30e659
@ -121,6 +121,7 @@ example_test_001D:
|
|||||||
|
|
||||||
example_test_OTA:
|
example_test_OTA:
|
||||||
extends: .example_test_esp32_template
|
extends: .example_test_esp32_template
|
||||||
|
parallel: 2
|
||||||
tags:
|
tags:
|
||||||
- ESP32
|
- ESP32
|
||||||
- Example_WIFI_OTA
|
- Example_WIFI_OTA
|
||||||
|
@ -641,6 +641,55 @@ def test_examples_protocol_advanced_https_ota_example_bluedroid_gatts(env, extra
|
|||||||
dut1.reset()
|
dut1.reset()
|
||||||
|
|
||||||
|
|
||||||
|
@ttfw_idf.idf_example_test(env_tag='Example_WIFI_OTA')
|
||||||
|
def test_examples_protocol_advanced_https_ota_example_openssl_aligned_bin(env, extra_data):
|
||||||
|
"""
|
||||||
|
This is a test case for esp_http_client_read with binary size multiple of 289 bytes
|
||||||
|
steps: |
|
||||||
|
1. join AP
|
||||||
|
2. Fetch OTA image over HTTPS
|
||||||
|
3. Reboot with the new OTA image
|
||||||
|
"""
|
||||||
|
dut1 = env.get_dut('advanced_https_ota_example', 'examples/system/ota/advanced_https_ota', dut_class=ttfw_idf.ESP32DUT)
|
||||||
|
# Original binary file generated after compilation
|
||||||
|
bin_name = 'advanced_https_ota.bin'
|
||||||
|
# Binary file aligned to DEFAULT_OTA_BUF_SIZE(289 bytes) boundary
|
||||||
|
aligned_bin_name = 'aligned.bin'
|
||||||
|
# check and log bin size
|
||||||
|
binary_file = os.path.join(dut1.app.binary_path, bin_name)
|
||||||
|
# Original binary size
|
||||||
|
bin_size = os.path.getsize(binary_file)
|
||||||
|
# Dummy data required to align binary size to 289 bytes boundary
|
||||||
|
dummy_data_size = 289 - (bin_size % 289)
|
||||||
|
f = open(binary_file, 'rb+')
|
||||||
|
fo = open(os.path.join(dut1.app.binary_path, aligned_bin_name), 'wb+')
|
||||||
|
fo.write(f.read(bin_size))
|
||||||
|
for _ in range(dummy_data_size):
|
||||||
|
fo.write(struct.pack('B', random.randrange(0,255,1)))
|
||||||
|
fo.close()
|
||||||
|
f.close()
|
||||||
|
# start test
|
||||||
|
host_ip = get_my_ip()
|
||||||
|
chunked_server = start_chunked_server(dut1.app.binary_path, 8070)
|
||||||
|
dut1.start_app()
|
||||||
|
dut1.expect('Loaded app from partition at offset', timeout=30)
|
||||||
|
try:
|
||||||
|
ip_address = dut1.expect(re.compile(r' sta ip: ([^,]+),'), timeout=30)
|
||||||
|
print('Connected to AP with IP: {}'.format(ip_address))
|
||||||
|
except DUT.ExpectTimeout:
|
||||||
|
raise ValueError('ENV_TEST_FAILURE: Cannot connect to AP')
|
||||||
|
dut1.expect('Starting Advanced OTA example', timeout=30)
|
||||||
|
|
||||||
|
print('writing to device: {}'.format('https://' + host_ip + ':8070/' + aligned_bin_name))
|
||||||
|
dut1.write('https://' + host_ip + ':8070/' + aligned_bin_name)
|
||||||
|
dut1.expect('Loaded app from partition at offset', timeout=60)
|
||||||
|
dut1.expect('Starting Advanced OTA example', timeout=30)
|
||||||
|
chunked_server.kill()
|
||||||
|
os.remove(os.path.join(dut1.app.binary_path, 'server_cert.pem'))
|
||||||
|
os.remove(os.path.join(dut1.app.binary_path, 'server_key.pem'))
|
||||||
|
os.remove(aligned_bin_name)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
test_examples_protocol_advanced_https_ota_example()
|
test_examples_protocol_advanced_https_ota_example()
|
||||||
test_examples_protocol_advanced_https_ota_example_chunked()
|
test_examples_protocol_advanced_https_ota_example_chunked()
|
||||||
@ -652,3 +701,4 @@ if __name__ == '__main__':
|
|||||||
test_examples_protocol_advanced_https_ota_example_partial_request()
|
test_examples_protocol_advanced_https_ota_example_partial_request()
|
||||||
test_examples_protocol_advanced_https_ota_example_nimble_gatts()
|
test_examples_protocol_advanced_https_ota_example_nimble_gatts()
|
||||||
test_examples_protocol_advanced_https_ota_example_bluedroid_gatts()
|
test_examples_protocol_advanced_https_ota_example_bluedroid_gatts()
|
||||||
|
test_examples_protocol_advanced_https_ota_example_openssl_aligned_bin()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user