[posix] enhance reset implementation to support code coverage (#3071)

This commit is contained in:
Yakun Xu
2018-09-14 10:59:07 -10:00
committed by Jonathan Hui
parent a23f778e11
commit ed794337e7
10 changed files with 78 additions and 43 deletions
+4
View File
@@ -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
+20
View File
@@ -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;