mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
test: remove elf sha256 check from pytest_blink to qemu test
not upload elf file
This commit is contained in:
parent
62c6a1d8b7
commit
1ed5bf0bff
@ -1,7 +1,6 @@
|
|||||||
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
# SPDX-License-Identifier: CC0-1.0
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
import hashlib
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@ -9,21 +8,6 @@ import pytest
|
|||||||
from pytest_embedded_idf.dut import IdfDut
|
from pytest_embedded_idf.dut import IdfDut
|
||||||
|
|
||||||
|
|
||||||
def verify_elf_sha256_embedding(bin_path: str, sha256_reported: str) -> None:
|
|
||||||
elf_file = os.path.join(bin_path, 'blink.elf')
|
|
||||||
sha256 = hashlib.sha256()
|
|
||||||
with open(elf_file, 'rb') as f:
|
|
||||||
sha256.update(f.read())
|
|
||||||
sha256_expected = sha256.hexdigest()
|
|
||||||
|
|
||||||
logging.info(f'ELF file SHA256: {sha256_expected}')
|
|
||||||
logging.info(f'ELF file SHA256 (reported by the app): {sha256_reported}')
|
|
||||||
|
|
||||||
# the app reports only the first several hex characters of the SHA256, check that they match
|
|
||||||
if not sha256_expected.startswith(sha256_reported):
|
|
||||||
raise ValueError('ELF file SHA256 mismatch')
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.supported_targets
|
@pytest.mark.supported_targets
|
||||||
@pytest.mark.generic
|
@pytest.mark.generic
|
||||||
def test_blink(dut: IdfDut) -> None:
|
def test_blink(dut: IdfDut) -> None:
|
||||||
@ -31,7 +15,3 @@ def test_blink(dut: IdfDut) -> None:
|
|||||||
binary_file = os.path.join(dut.app.binary_path, 'blink.bin')
|
binary_file = os.path.join(dut.app.binary_path, 'blink.bin')
|
||||||
bin_size = os.path.getsize(binary_file)
|
bin_size = os.path.getsize(binary_file)
|
||||||
logging.info('blink_bin_size : {}KB'.format(bin_size // 1024))
|
logging.info('blink_bin_size : {}KB'.format(bin_size // 1024))
|
||||||
|
|
||||||
sha256_reported = dut.expect(r'ELF file SHA256:\s+([a-f0-9]+)').group(1).decode('utf-8')
|
|
||||||
|
|
||||||
verify_elf_sha256_embedding(dut.app.binary_path, sha256_reported)
|
|
||||||
|
@ -1,22 +1,46 @@
|
|||||||
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
# SPDX-License-Identifier: CC0-1.0
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
import logging
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_embedded_idf.dut import IdfDut
|
from pytest_embedded_idf.dut import IdfDut
|
||||||
|
from pytest_embedded_qemu.app import QemuApp
|
||||||
from pytest_embedded_qemu.dut import QemuDut
|
from pytest_embedded_qemu.dut import QemuDut
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.supported_targets
|
@pytest.mark.supported_targets
|
||||||
@pytest.mark.generic
|
@pytest.mark.generic
|
||||||
def test_hello_world(dut: IdfDut, log_minimum_free_heap_size: Callable[..., None]) -> None:
|
def test_hello_world(
|
||||||
|
dut: IdfDut, log_minimum_free_heap_size: Callable[..., None]
|
||||||
|
) -> None:
|
||||||
dut.expect('Hello world!')
|
dut.expect('Hello world!')
|
||||||
log_minimum_free_heap_size()
|
log_minimum_free_heap_size()
|
||||||
|
|
||||||
|
|
||||||
|
def verify_elf_sha256_embedding(app: QemuApp, sha256_reported: str) -> None:
|
||||||
|
sha256 = hashlib.sha256()
|
||||||
|
with open(app.elf_file, 'rb') as f:
|
||||||
|
sha256.update(f.read())
|
||||||
|
sha256_expected = sha256.hexdigest()
|
||||||
|
|
||||||
|
logging.info(f'ELF file SHA256: {sha256_expected}')
|
||||||
|
logging.info(f'ELF file SHA256 (reported by the app): {sha256_reported}')
|
||||||
|
|
||||||
|
# the app reports only the first several hex characters of the SHA256, check that they match
|
||||||
|
if not sha256_expected.startswith(sha256_reported):
|
||||||
|
raise ValueError('ELF file SHA256 mismatch')
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.esp32 # we only support qemu on esp32 for now
|
@pytest.mark.esp32 # we only support qemu on esp32 for now
|
||||||
@pytest.mark.host_test
|
@pytest.mark.host_test
|
||||||
@pytest.mark.qemu
|
@pytest.mark.qemu
|
||||||
def test_hello_world_host(dut: QemuDut) -> None:
|
def test_hello_world_host(app: QemuApp, dut: QemuDut) -> None:
|
||||||
|
sha256_reported = (
|
||||||
|
dut.expect(r'ELF file SHA256:\s+([a-f0-9]+)').group(1).decode('utf-8')
|
||||||
|
)
|
||||||
|
verify_elf_sha256_embedding(app, sha256_reported)
|
||||||
|
|
||||||
dut.expect('Hello world!')
|
dut.expect('Hello world!')
|
||||||
|
Loading…
Reference in New Issue
Block a user