Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: direct support for __dump_gcov #1005

Merged
merged 4 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/ev-project-bootstrap.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set_property(
GLOBAL
PROPERTY EVEREST_REQUIRED_EV_CLI_VERSION "0.4.0"
PROPERTY EVEREST_REQUIRED_EV_CLI_VERSION "0.4.5"
)

# FIXME (aw): clean up this inclusion chain
Expand Down
2 changes: 1 addition & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ext-mbedtls:
# everest-testing and ev-dev-tools
everest-utils:
git: https://github.com/EVerest/everest-utils.git
git_tag: v0.4.4
git_tag: 165f2c8acd7819e2c788f438d4f00a56dd030be0
# linux_libnfc-nci for RFID
libnfc-nci:
git: https://github.com/EVerest/linux_libnfc-nci.git
Expand Down
9 changes: 9 additions & 0 deletions lib/staging/helpers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ target_sources(everest_staging_helpers
lib/helpers.cpp
)

if (EVEREST_CORE_BUILD_TESTING)
target_compile_definitions(everest_staging_helpers PUBLIC EVEREST_COVERAGE_ENABLED)

target_sources(everest_staging_helpers
PRIVATE
lib/coverage.cpp
)
endif()

target_include_directories(everest_staging_helpers
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

namespace everest::helpers {

void install_signal_handlers_for_gcov();

}
38 changes: 38 additions & 0 deletions lib/staging/helpers/lib/coverage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <everest/staging/helpers/coverage.hpp>

#include <atomic>

#include <signal.h>
#include <stdlib.h>
#include <unistd.h>

extern "C" void __gcov_dump();

namespace {

static std::atomic_flag going_to_terminate = ATOMIC_FLAG_INIT;

void terminate_handler(int signal) {
if (going_to_terminate.test_and_set()) {
return;
}

__gcov_dump();

_exit(EXIT_FAILURE);
};

} // namespace

namespace everest::helpers {

void install_signal_handlers_for_gcov() {
struct sigaction action {};
action.sa_handler = &terminate_handler;
// action.sa_mask should be zero, so no blocked signals within the signal handler
// action.sa_flags should be fine with being zero
sigaction(SIGINT, &action, nullptr);
sigaction(SIGTERM, &action, nullptr);
}

} // namespace everest::helpers
4 changes: 4 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ foreach(type MODULES LIBRARIES)

foreach(target ${targets})
append_coverage_compiler_flags_to_target(${target})

if (type STREQUAL "MODULES")
target_link_libraries(${target} PRIVATE everest::staging::helpers)
endif()
endforeach()
endforeach()

Expand Down