diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 000000000..b05b57634 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,4 @@ +coverage: + ignore: + - "tests/*" + - "third_party/*" diff --git a/.travis.yml b/.travis.yml index d79c02f93..86f7f056b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,6 +37,9 @@ before_install: script: - .travis/script.sh +after_success: + - bash <(curl -s https://codecov.io/bash) + matrix: include: - env: BUILD_TARGET="pretty-check" diff --git a/.travis/script.sh b/.travis/script.sh index adcb1d0cb..4583d9731 100755 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -63,7 +63,7 @@ set -x } [ $BUILD_TARGET != posix-32-bit ] || { - CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 BuildJobs=10 make -f examples/Makefile-posix check || die + COVERAGE=1 CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 BuildJobs=10 make -f examples/Makefile-posix check || die } [ $BUILD_TARGET != posix-ncp ] || { diff --git a/README.md b/README.md index e5289a036..6d0a5158a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![OpenThread][ot-logo]][ot-repo] [![Build Status][ot-travis-svg]][ot-travis] +[![Coverage Status][ot-codecov-svg]][ot-codecov] --- @@ -18,7 +19,8 @@ applications. More information about Thread can be found on [ot-logo]: doc/images/openthread_logo.png [ot-travis]: https://travis-ci.org/openthread/openthread [ot-travis-svg]: https://travis-ci.org/openthread/openthread.svg?branch=master - +[ot-codecov]: https://codecov.io/gh/openthread/openthread +[ot-codecov-svg]: https://codecov.io/gh/openthread/openthread/branch/master/graph/badge.svg ## Features ## diff --git a/examples/apps/cli/Makefile.am b/examples/apps/cli/Makefile.am index 6003f4211..2be23d400 100644 --- a/examples/apps/cli/Makefile.am +++ b/examples/apps/cli/Makefile.am @@ -73,4 +73,8 @@ ot_cli_SOURCES = \ main.c \ $(NULL) +if OPENTHREAD_BUILD_COVERAGE +CLEANFILES = $(wildcard *.gcda *.gcno) +endif # OPENTHREAD_BUILD_COVERAGE + include $(abs_top_nlbuild_autotools_dir)/automake/post.am diff --git a/examples/apps/ncp/Makefile.am b/examples/apps/ncp/Makefile.am index 117d5a8a0..e37d035b1 100644 --- a/examples/apps/ncp/Makefile.am +++ b/examples/apps/ncp/Makefile.am @@ -73,4 +73,8 @@ ot_ncp_SOURCES = \ main.c \ $(NULL) +if OPENTHREAD_BUILD_COVERAGE +CLEANFILES = $(wildcard *.gcda *.gcno) +endif # OPENTHREAD_BUILD_COVERAGE + include $(abs_top_nlbuild_autotools_dir)/automake/post.am diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 8b00ecdc2..3dc440518 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -76,6 +76,9 @@ const struct Command Interpreter::sCommands[] = #endif { "discover", &ProcessDiscover }, { "eidcache", &ProcessEidCache }, +#ifdef OPENTHREAD_EXAMPLES_POSIX + { "exit", &ProcessExit }, +#endif { "extaddr", &ProcessExtAddress }, { "extpanid", &ProcessExtPanId }, { "ifconfig", &ProcessIfconfig }, @@ -568,6 +571,15 @@ exit: AppendResult(error); } +#ifdef OPENTHREAD_EXAMPLES_POSIX +void Interpreter::ProcessExit(int argc, char *argv[]) +{ + exit(0); + (void)argc; + (void)argv; +} +#endif + void Interpreter::ProcessExtPanId(int argc, char *argv[]) { ThreadError error = kThreadError_None; diff --git a/src/cli/cli.hpp b/src/cli/cli.hpp index 9606096a5..5888b957d 100644 --- a/src/cli/cli.hpp +++ b/src/cli/cli.hpp @@ -147,6 +147,9 @@ private: #endif // OPENTHREAD_ENABLE_DIAG static void ProcessDiscover(int argc, char *argv[]); static void ProcessEidCache(int argc, char *argv[]); +#ifdef OPENTHREAD_EXAMPLES_POSIX + static void ProcessExit(int argc, char *argv[]); +#endif static void ProcessExtAddress(int argc, char *argv[]); static void ProcessExtPanId(int argc, char *argv[]); static void ProcessIfconfig(int argc, char *argv[]); diff --git a/src/core/Makefile.am b/src/core/Makefile.am index e64112857..697fe32fe 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -160,7 +160,8 @@ noinst_HEADERS = \ $(NULL) if OPENTHREAD_BUILD_COVERAGE -CLEANFILES = $(wildcard *.gcda *.gcno) +Dash = - +CLEANFILES = $(shell find $(top_builddir)/src/core $(Dash)name "*.gcda" $(Dash)o $(Dash)name "*.gcno") endif # OPENTHREAD_BUILD_COVERAGE include $(abs_top_nlbuild_autotools_dir)/automake/post.am diff --git a/tests/scripts/thread-cert/node.py b/tests/scripts/thread-cert/node.py index b6991250c..e11df7c85 100755 --- a/tests/scripts/thread-cert/node.py +++ b/tests/scripts/thread-cert/node.py @@ -98,7 +98,10 @@ class Node: def __del__(self): if self.pexpect.isalive(): - if self.node_type == 'ncp-sim': + if self.node_type == 'sim': + self.send_command('exit') + self.pexpect.expect('Done') + elif self.node_type == 'ncp-sim': self.pexpect.sendcontrol('c'); self.pexpect.terminate() self.pexpect.close(force=True) diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index b71d304b5..9a4154582 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -142,6 +142,10 @@ test_diag_LDADD = $(top_builddir)/src/diag/libopenthread-diag.a test_diag_SOURCES = test_diag.cpp endif +if OPENTHREAD_BUILD_COVERAGE +CLEANFILES = $(wildcard *.gcda *.gcno) +endif # OPENTHREAD_BUILD_COVERAGE + endif # OPENTHREAD_BUILD_TESTS include $(abs_top_nlbuild_autotools_dir)/automake/post.am diff --git a/third_party/mbedtls/Makefile.am b/third_party/mbedtls/Makefile.am index 96f15f588..2790c3d6e 100644 --- a/third_party/mbedtls/Makefile.am +++ b/third_party/mbedtls/Makefile.am @@ -73,7 +73,8 @@ libmbedcrypto_a_SOURCES += \ endif # OPENTHREAD_ENABLE_DTLS if OPENTHREAD_BUILD_COVERAGE -CLEANFILES = $(wildcard *.gcda *.gcno) +Dash = - +CLEANFILES = $(shell find $(top_builddir)/third_party/mbedtls $(Dash)name "*.gcda" $(Dash)o $(Dash)name "*.gcno") endif # OPENTHREAD_BUILD_COVERAGE include $(abs_top_nlbuild_autotools_dir)/automake/post.am diff --git a/tools/spi-hdlc-adapter/Makefile.am b/tools/spi-hdlc-adapter/Makefile.am index b6bf8c71f..54f92f50a 100644 --- a/tools/spi-hdlc-adapter/Makefile.am +++ b/tools/spi-hdlc-adapter/Makefile.am @@ -47,4 +47,8 @@ spi_hdlc_adapter_SOURCES = \ spi-hdlc-adapter.c \ $(NULL) +if OPENTHREAD_BUILD_COVERAGE +CLEANFILES = $(wildcard *.gcda *.gcno) +endif # OPENTHREAD_BUILD_COVERAGE + include $(abs_top_nlbuild_autotools_dir)/automake/post.am