mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/esp_http_client_read' into 'master'
Fix esp_http_client_read for file size aligned to 289 bytes Closes IDFGH-4981 See merge request espressif/esp-idf!13193
This commit is contained in:
commit
a82466674a
@ -121,6 +121,7 @@ example_test_001D:
|
||||
|
||||
example_test_OTA:
|
||||
extends: .example_test_esp32_template
|
||||
parallel: 2
|
||||
tags:
|
||||
- ESP32
|
||||
- Example_WIFI_OTA
|
||||
|
@ -991,7 +991,7 @@ int esp_http_client_read(esp_http_client_handle_t client, char *buffer, int len)
|
||||
}
|
||||
ESP_LOG_LEVEL(sev, TAG, "esp_transport_read returned:%d and errno:%d ", rlen, errno);
|
||||
}
|
||||
if (rlen < 0 && ridx == 0) {
|
||||
if (rlen < 0 && ridx == 0 && !esp_http_client_is_complete_data_received(client)) {
|
||||
return ESP_FAIL;
|
||||
} else {
|
||||
return ridx;
|
||||
|
@ -641,6 +641,55 @@ def test_examples_protocol_advanced_https_ota_example_bluedroid_gatts(env, extra
|
||||
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__':
|
||||
test_examples_protocol_advanced_https_ota_example()
|
||||
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_nimble_gatts()
|
||||
test_examples_protocol_advanced_https_ota_example_bluedroid_gatts()
|
||||
test_examples_protocol_advanced_https_ota_example_openssl_aligned_bin()
|
||||
|
Loading…
Reference in New Issue
Block a user