simple_ota_example: Adds configs to test on_update_no_secure_boot option (RSA&ECDSA)

This commit is contained in:
KonstantinKondrashov
2021-04-19 21:33:06 +08:00
committed by bot
parent a67793e9fc
commit 6e06d323b1
6 changed files with 176 additions and 0 deletions

View File

@@ -200,7 +200,88 @@ def test_examples_protocol_simple_ota_example_with_flash_encryption(env, extra_d
dut1.expect('Starting OTA example', timeout=30)
@ttfw_idf.idf_example_test(env_tag='Example_EthKitV1')
def test_examples_protocol_simple_ota_example_with_verify_app_signature_on_update_no_secure_boot_ecdsa(env, extra_data):
"""
steps: |
1. join AP
2. Fetch OTA image over HTTPS
3. Reboot with the new OTA image
"""
dut1 = env.get_dut('simple_ota_example', 'examples/system/ota/simple_ota_example', dut_class=ttfw_idf.ESP32DUT,
app_config_name='on_update_no_sb_ecdsa')
# check and log bin size
binary_file = os.path.join(dut1.app.binary_path, 'simple_ota.bin')
bin_size = os.path.getsize(binary_file)
ttfw_idf.log_performance('simple_ota_bin_size', '{}KB'.format(bin_size // 1024))
# start test
host_ip = get_my_ip()
thread1 = Thread(target=start_https_server, args=(dut1.app.binary_path, host_ip, 8000))
thread1.daemon = True
thread1.start()
dut1.start_app()
dut1.expect('Loaded app from partition at offset 0x20000', timeout=30)
try:
ip_address = dut1.expect(re.compile(r' eth 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 OTA example', timeout=30)
print('writing to device: {}'.format('https://' + host_ip + ':8000/simple_ota.bin'))
dut1.write('https://' + host_ip + ':8000/simple_ota.bin')
dut1.expect('Writing to partition subtype 16 at offset 0x120000', timeout=20)
dut1.expect('Verifying image signature...', timeout=60)
dut1.expect('Loaded app from partition at offset 0x120000', timeout=20)
dut1.expect('Starting OTA example', timeout=30)
@ttfw_idf.idf_example_test(env_tag='Example_EthKitV12')
def test_examples_protocol_simple_ota_example_with_verify_app_signature_on_update_no_secure_boot_rsa(env, extra_data):
"""
steps: |
1. join AP
2. Fetch OTA image over HTTPS
3. Reboot with the new OTA image
"""
dut1 = env.get_dut('simple_ota_example', 'examples/system/ota/simple_ota_example', dut_class=ttfw_idf.ESP32DUT,
app_config_name='on_update_no_sb_rsa')
# check and log bin size
binary_file = os.path.join(dut1.app.binary_path, 'simple_ota.bin')
bin_size = os.path.getsize(binary_file)
ttfw_idf.log_performance('simple_ota_bin_size', '{}KB'.format(bin_size // 1024))
# start test
host_ip = get_my_ip()
thread1 = Thread(target=start_https_server, args=(dut1.app.binary_path, host_ip, 8000))
thread1.daemon = True
thread1.start()
dut1.start_app()
dut1.expect('Loaded app from partition at offset 0x20000', timeout=30)
try:
ip_address = dut1.expect(re.compile(r' eth 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 OTA example', timeout=30)
print('writing to device: {}'.format('https://' + host_ip + ':8000/simple_ota.bin'))
dut1.write('https://' + host_ip + ':8000/simple_ota.bin')
dut1.expect('Writing to partition subtype 16 at offset 0x120000', timeout=20)
dut1.expect('Verifying image signature...', timeout=60)
dut1.expect('#0 app key digest == #0 trusted key digest', timeout=10)
dut1.expect('Verifying with RSA-PSS...', timeout=10)
dut1.expect('Signature verified successfully!', timeout=10)
dut1.expect('Loaded app from partition at offset 0x120000', timeout=20)
dut1.expect('Starting OTA example', timeout=30)
if __name__ == '__main__':
test_examples_protocol_simple_ota_example()
test_examples_protocol_simple_ota_example_ethernet_with_spiram_config()
test_examples_protocol_simple_ota_example_with_flash_encryption()
test_examples_protocol_simple_ota_example_with_verify_app_signature_on_update_no_secure_boot_ecdsa()
test_examples_protocol_simple_ota_example_with_verify_app_signature_on_update_no_secure_boot_rsa()