mirror of
https://github.com/espressif/openthread.git
synced 2026-08-11 13:17:48 +00:00
[posix] enhance reset implementation to support code coverage (#3071)
This commit is contained in:
@@ -129,6 +129,10 @@ ot_cli_mtd_LDFLAGS += -Wl,-Ma
|
||||
endif
|
||||
|
||||
if OPENTHREAD_BUILD_COVERAGE
|
||||
CPPFLAGS_COMMON += \
|
||||
-DOPENTHREAD_ENABLE_COVERAGE \
|
||||
$(NULL)
|
||||
|
||||
CLEANFILES = $(wildcard *.gcda *.gcno)
|
||||
endif # OPENTHREAD_BUILD_COVERAGE
|
||||
|
||||
|
||||
@@ -37,6 +37,15 @@
|
||||
|
||||
#include "openthread-system.h"
|
||||
|
||||
#if OPENTHREAD_EXAMPLES_POSIX
|
||||
#include <setjmp.h>
|
||||
#include <unistd.h>
|
||||
|
||||
jmp_buf gResetJump;
|
||||
|
||||
void __gcov_flush();
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
void *otPlatCAlloc(size_t aNum, size_t aSize)
|
||||
{
|
||||
@@ -58,6 +67,17 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
otInstance *sInstance;
|
||||
|
||||
#if OPENTHREAD_EXAMPLES_POSIX
|
||||
if (setjmp(gResetJump))
|
||||
{
|
||||
alarm(0);
|
||||
#if OPENTHREAD_ENABLE_COVERAGE
|
||||
__gcov_flush();
|
||||
#endif
|
||||
execvp(argv[0], argv);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES
|
||||
size_t otInstanceBufferLength = 0;
|
||||
uint8_t *otInstanceBuffer = NULL;
|
||||
|
||||
Reference in New Issue
Block a user