Skip to content

Commit

Permalink
Merge branch 'task/macos_hello_world_ci_test' into 'master'
Browse files Browse the repository at this point in the history
feat(ci): Fixed linux build on MacOS + Added host_test for the hello_world linux app for MacOS runners

Closes IDF-9208

See merge request espressif/esp-idf!30800
  • Loading branch information
sudeep-mohanty committed May 24, 2024
2 parents 13cfcc4 + 00efba0 commit 003f3bb
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 6 deletions.
32 changes: 32 additions & 0 deletions .gitlab/ci/host-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,38 @@ test_pytest_linux:
--ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME}
--app-info-filepattern \"list_job_*.txt\"

test_pytest_macos:
extends:
- .host_test_template
- .before_script:build:macos
tags:
- macos_shell
artifacts:
paths:
- XUNIT_RESULT.xml
- pytest-embedded/
- "**/build*/build_log.txt"
reports:
junit: XUNIT_RESULT.xml
variables:
PYTEST_IGNORE_COLLECT_IMPORT_ERROR: "1"
script:
- run_cmd python tools/ci/ci_build_apps.py components examples tools/test_apps -vv
--target linux
--pytest-apps
-m \"host_test and macos_shell\"
--collect-app-info "list_job_${CI_JOB_NAME_SLUG}.txt"
--modified-components ${MR_MODIFIED_COMPONENTS}
--modified-files ${MR_MODIFIED_FILES}
- python tools/ci/get_known_failure_cases_file.py
- run_cmd pytest
--target linux
-m \"host_test and macos_shell\"
--junitxml=XUNIT_RESULT.xml
--ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME}
--app-info-filepattern \"list_job_*.txt\"


test_idf_pytest_plugin:
extends:
- .host_test_template
Expand Down
2 changes: 1 addition & 1 deletion components/efuse/linux/esp_efuse_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ esp_err_t esp_efuse_utility_burn_chip_opt(bool ignore_coding_errors, bool verify
// This function reads EFUSE_BLKx_WDATAx_REG registers, and checks possible to write these data with RS coding scheme.
// The RS coding scheme does not require data changes for the encoded data. esp32s2 has special registers for this.
// They will be filled during the burn operation.
esp_err_t esp_efuse_utility_apply_new_coding_scheme()
esp_err_t esp_efuse_utility_apply_new_coding_scheme(void)
{
// start with EFUSE_BLK1. EFUSE_BLK0 - always uses EFUSE_CODING_SCHEME_NONE.
for (int num_block = EFUSE_BLK1; num_block < EFUSE_BLK_MAX; num_block++) {
Expand Down
8 changes: 7 additions & 1 deletion components/esp_app_format/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ idf_component_register(SRCS ${src}
if(NOT BOOTLOADER_BUILD)
# esp_app_desc structure is added as an undefined symbol because otherwise the
# linker will ignore this structure as it has no other files depending on it.
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u esp_app_desc")
if(CONFIG_IDF_TARGET_LINUX AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
# On MacOS, the linker expects the exact mangled symbol name (with leading underscore)
# to be present in the object file.
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u _esp_app_desc")
else()
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u esp_app_desc")
endif()

if(CONFIG_APP_PROJECT_VER_FROM_CONFIG)
# Ignore current PROJECT_VER (which was set in project.cmake)
Expand Down
4 changes: 4 additions & 0 deletions components/esp_app_format/esp_app_desc.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ static const char *TAG = "app_init";
#endif

// Application version info
#if defined(__APPLE__) && CONFIG_IDF_TARGET_LINUX
const __attribute__((weak)) __attribute__((section("__RODATA_DESC,.rodata_desc"))) esp_app_desc_t esp_app_desc = {
#else
const __attribute__((weak)) __attribute__((section(".rodata_desc"))) esp_app_desc_t esp_app_desc = {
#endif /* #if defined(__APPLE__) && CONFIG_IDF_TARGET_LINUX */
.magic_word = ESP_APP_DESC_MAGIC_WORD,
#ifdef CONFIG_APP_EXCLUDE_PROJECT_VER_VAR
.version = "",
Expand Down
6 changes: 5 additions & 1 deletion components/log/src/linux/log_timestamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ uint32_t esp_log_early_timestamp(void)
return milliseconds;
}

uint32_t esp_log_timestamp(void) __attribute__((alias("esp_log_early_timestamp")));
// Avoid using __attribute(alias) here since linux target builds on MacOS fail to compile.
uint32_t esp_log_timestamp(void)
{
return esp_log_early_timestamp();
}
10 changes: 8 additions & 2 deletions examples/get-started/hello_world/pytest_hello_world.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0

import hashlib
import logging
from typing import Callable
Expand All @@ -27,6 +26,13 @@ def test_hello_world_linux(dut: IdfDut) -> None:
dut.expect('Hello world!')


@pytest.mark.linux
@pytest.mark.host_test
@pytest.mark.macos_shell
def test_hello_world_macos(dut: IdfDut) -> None:
dut.expect('Hello world!')


def verify_elf_sha256_embedding(app: QemuApp, sha256_reported: str) -> None:
sha256 = hashlib.sha256()
with open(app.elf_file, 'rb') as f:
Expand Down
1 change: 1 addition & 0 deletions tools/ci/idf_pytest/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
ENV_MARKERS = {
# special markers
'qemu': 'build and test using qemu, not real target',
'macos_shell': 'tests should be run on macos hosts',
# single-dut markers
'generic': 'tests should be run on generic runners',
'flash_suspend': 'support flash suspend feature',
Expand Down
2 changes: 1 addition & 1 deletion tools/ci/idf_pytest/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def item_to_pytest_case(self, item: Function) -> t.Optional[PytestCase]:

def pytest_collectstart(self) -> None:
# mock the optional packages while collecting locally
if not os.getenv('CI_JOB_ID'):
if not os.getenv('CI_JOB_ID') or os.getenv('PYTEST_IGNORE_COLLECT_IMPORT_ERROR') == '1':
# optional packages required by test scripts
for p in [
'scapy',
Expand Down
2 changes: 2 additions & 0 deletions tools/ci/ignore_build_warnings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ warning: unknown kconfig symbol 'SPIRAM' assigned to 'y' in .*/examples/protocol
warning: unknown kconfig symbol 'SPIRAM' assigned to 'y' in .*/examples/protocols/https_request/sdkconfig.ci.ssldyn
warning: unknown kconfig symbol 'UNITY_FREERTOS_STACK_SIZE' assigned to '12288' in .*/components/bt/test_apps/sdkconfig.defaults
warning: unknown kconfig symbol 'WPA3_SAE' assigned to 'y' in .*/components/wpa_supplicant/test_apps/sdkconfig.defaults
ld: warning: ignoring duplicate libraries
archive library: .+ the table of contents is empty

0 comments on commit 003f3bb

Please sign in to comment.