flash_encryption_example: Update example test to use pytest framework

pull/8089/merge
Aditya Patwardhan 2022-04-14 10:24:04 +05:30
rodzic c3bac72cbb
commit 600272bc5d
3 zmienionych plików z 31 dodań i 21 usunięć

Wyświetl plik

@ -91,6 +91,26 @@ example_test_pytest_esp32_ethernet_ip101:
TARGET: ESP32
ENV_MARKER: ip101
example_test_pytest_esp32_flash_encryption:
extends:
- .pytest_examples_dir_template
- .rules:test:example_test-esp32
needs:
- build_pytest_examples_esp32
variables:
TARGET: ESP32
ENV_MARKER: flash_encryption
example_test_pytest_esp32c3_flash_encryption:
extends:
- .pytest_examples_dir_template
- .rules:test:example_test-esp32c3
needs:
- build_pytest_examples_esp32c3
variables:
TARGET: ESP32C3
ENV_MARKER: flash_encryption
.pytest_components_dir_template:
extends: .pytest_template
variables:
@ -413,12 +433,6 @@ example_test_007:
- ESP32
- Example_I2C_CCS811_SENSOR
example_test_008A:
extends: .example_test_esp32_template
tags:
- ESP32
- Example_Flash_Encryption
example_test_008B:
extends: .example_test_esp32_template
tags:
@ -491,12 +505,6 @@ example_test_C3_GENERIC:
- ESP32C3
- Example_GENERIC
example_test_C3_FLASH_ENC:
extends: .example_test_esp32c3_template
tags:
- ESP32C3
- Example_Flash_Encryption
example_test_C3_FLASH_ENC_OTA:
extends: .example_test_esp32c3_template
tags:

Wyświetl plik

@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
from __future__ import print_function
import binascii
@ -6,7 +9,8 @@ import sys
from collections import namedtuple
from io import BytesIO
import ttfw_idf
import pytest
from pytest_embedded import Dut
try:
import espsecure
@ -25,13 +29,10 @@ except ImportError:
# espefuse.py --do-not-confirm -p $ESPPORT burn_efuse FLASH_CRYPT_CONFIG 0xf
# espefuse.py --do-not-confirm -p $ESPPORT burn_efuse FLASH_CRYPT_CNT 0x1
# espefuse.py --do-not-confirm -p $ESPPORT burn_key flash_encryption key.bin
@ttfw_idf.idf_example_test(env_tag='Example_Flash_Encryption', target=['esp32', 'esp32c3'])
def test_examples_security_flash_encryption(env, extra_data):
dut = env.get_dut('flash_encryption', 'examples/security/flash_encryption')
dut.erase_flash()
# start test
dut.start_app()
@pytest.mark.esp32
@pytest.mark.esp32c3
@pytest.mark.flash_encryption
def test_examples_security_flash_encryption(dut: Dut) -> None:
# calculate the expected ciphertext
flash_addr = dut.app.partition_table['storage']['offset']
plain_hex_str = '00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f'
@ -40,7 +41,7 @@ def test_examples_security_flash_encryption(env, extra_data):
# espsecure uses the cryptography package for encrypting
# with aes-xts, but does not allow for a symmetric key
# so the key for later chips are not all zeros
if dut.TARGET == 'esp32':
if dut.target == 'esp32':
key_bytes = b'\x00' * 32
aes_xts = False
else:

Wyświetl plik

@ -32,6 +32,7 @@ markers =
octal_psram: runners with octal psram
usb_host: usb host runners
ethernet_ota: ethernet OTA runners
flash_encryption: Flash Encryption runners
# log related
log_cli = True