diff options
author | Yakun Xu <xyk@google.com> | 2018-08-23 04:43:11 +0800 |
---|---|---|
committer | Jonathan Hui <jonhui@nestlabs.com> | 2018-08-22 13:43:11 -0700 |
commit | a33725e472bf5fc867a2dc904c6684b0c3b0ddce (patch) | |
tree | 68d57cadd546614afd4a80bd965c0a6f022ad87c | |
parent | 194741b70f2bf3958d525956b6474d39927a782e (diff) | |
download | ot-br-posix-a33725e472bf5fc867a2dc904c6684b0c3b0ddce.tar.gz |
[codecov] enable code coverage (#173)
-rw-r--r-- | .codecov.yml | 2 | ||||
-rw-r--r-- | .travis.yml | 4 | ||||
-rwxr-xr-x | .travis/script.sh | 8 | ||||
-rw-r--r-- | README.md | 11 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/agent/main.cpp | 11 | ||||
-rw-r--r-- | tests/mdns/main.cpp | 58 | ||||
-rw-r--r-- | tests/meshcop/Makefile.am | 3 |
8 files changed, 61 insertions, 38 deletions
diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 00000000..7e99d406 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,2 @@ +ignore: + - "third_party/*" diff --git a/.travis.yml b/.travis.yml index c41727fb..7f7fed71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,8 @@ cache: before_install: .travis/before_install.sh script: .travis/script.sh +after_success: bash <(curl -s https://codecov.io/bash) + matrix: include: - env: BUILD_TARGET="pretty-check" @@ -28,7 +30,7 @@ matrix: - env: BUILD_TARGET="posix-check" VERBOSE=1 compiler: gcc os: linux - - env: BUILD_TARGET="posix-check" VERBOSE=1 WITH_MDNS=mdnssd + - env: BUILD_TARGET="posix-check" VERBOSE=1 WITH_MDNS=mDNSResponder compiler: gcc os: linux - env: BUILD_TARGET="raspbian-gcc" VERBOSE=1 IMAGE_NAME=2017-04-10-raspbian-jessie-lite IMAGE_URL=http://director.downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-04-10/2017-04-10-raspbian-jessie-lite.zip diff --git a/.travis/script.sh b/.travis/script.sh index 94a724bc..795d01d4 100755 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -51,13 +51,15 @@ pretty-check) posix-check) export CPPFLAGS="$CFLAGS -I$TOOLS_HOME/usr/include" export LDFLAGS="$LDFLAGS -L$TOOLS_HOME/usr/lib" - ./bootstrap || die + ./bootstrap + ./configure + distcleancheck_listfiles="find . -type f \\( -name '*.gcda' -o -name '*.gcno' \\) -exec mv '{}' '$(pwd)/{}' \\;;find . -type f" if [ "$WITH_MDNS" = 'mDNSResponder' ]; then sudo service avahi-daemon stop sudo mdnsd - ./configure && make distcheck DISTCHECK_CONFIGURE_FLAGS='--with-mdns=mDNSResponder' + make distcheck DISTCHECK_CONFIGURE_FLAGS='--enable-coverage --with-mdns=mDNSResponder' distcleancheck_listfiles="${distcleancheck_listfiles}" else - ./configure && make distcheck + make distcheck DISTCHECK_CONFIGURE_FLAGS='--enable-coverage' distcleancheck_listfiles="${distcleancheck_listfiles}" fi ;; @@ -1,4 +1,5 @@ -[![Build Status][ot-travis-svg]][ot-travis] +[![Build Status][otbr-travis-svg]][otbr-travis] +[![Coverage Status][otbr-codecov-svg]][otbr-codecov] --- @@ -22,8 +23,10 @@ OpenThread's implementation of a Border Router is called OpenThread Border Route More information about Thread can be found at [threadgroup.org](http://threadgroup.org/). Thread is a registered trademark of the Thread Group, Inc. -[ot-travis]: https://travis-ci.org/openthread/borderrouter -[ot-travis-svg]: https://travis-ci.org/openthread/borderrouter.svg?branch=master +[otbr-travis]: https://travis-ci.org/openthread/borderrouter +[otbr-travis-svg]: https://travis-ci.org/openthread/borderrouter.svg?branch=master +[otbr-codecov]: https://codecov.io/gh/openthread/borderrouter +[otbr-codecov-svg]: https://codecov.io/gh/openthread/borderrouter/branch/master/graph/badge.svg ## Getting started @@ -67,4 +70,4 @@ The openthread-users Google Group is the recommended place for users to discuss ## OpenThread -To learn more about OpenThread, see the [OpenThread repository](https://github.com/openthread/openthread).
\ No newline at end of file +To learn more about OpenThread, see the [OpenThread repository](https://github.com/openthread/openthread). diff --git a/configure.ac b/configure.ac index 58aab8e4..1965fe48 100644 --- a/configure.ac +++ b/configure.ac @@ -416,7 +416,7 @@ fi # Add any code coverage CPPFLAGS and LDFLAGS CPPFLAGS="${CPPFLAGS} ${NL_COVERAGE_CPPFLAGS}" -LDFLAGS="${LDFLAGS} ${NL_COVERAGE_LDFLAGS}" +LIBS="${LIBS} ${NL_COVERAGE_LIBS}" # At this point, we can restore the compiler flags to whatever the # user passed in, now that we're clear of an -Werror issues by diff --git a/src/agent/main.cpp b/src/agent/main.cpp index 00888c52..75f4fbdf 100644 --- a/src/agent/main.cpp +++ b/src/agent/main.cpp @@ -31,6 +31,7 @@ #endif #include <errno.h> +#include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -47,6 +48,11 @@ static const char kDefaultInterfaceName[] = "wpan0"; // Default poll timeout. static const struct timeval kPollTimeout = {10, 0}; +static void HandleSignal(int aSignal) +{ + signal(aSignal, SIG_DFL); +} + int Mainloop(const char *aInterfaceName) { int rval = EXIT_FAILURE; @@ -56,6 +62,9 @@ int Mainloop(const char *aInterfaceName) otbrLog(OTBR_LOG_INFO, "Border router agent started."); + // allow quitting elegantly + signal(SIGTERM, HandleSignal); + while (true) { fd_set readFdSet; @@ -71,7 +80,7 @@ int Mainloop(const char *aInterfaceName) instance.UpdateFdSet(readFdSet, writeFdSet, errorFdSet, maxFd, timeout); rval = select(maxFd + 1, &readFdSet, &writeFdSet, &errorFdSet, &timeout); - if ((rval < 0) && (errno != EINTR)) + if (rval < 0) { rval = OTBR_ERROR_ERRNO; otbrLog(OTBR_LOG_ERR, "select() failed", strerror(errno)); diff --git a/tests/mdns/main.cpp b/tests/mdns/main.cpp index 3a18d2cd..72e0a98f 100644 --- a/tests/mdns/main.cpp +++ b/tests/mdns/main.cpp @@ -44,7 +44,7 @@ static struct Context { Mdns::Publisher *mPublisher; bool mUpdate; -} context; +} sContext; int Mainloop(Mdns::Publisher &aPublisher) { @@ -79,43 +79,43 @@ int Mainloop(Mdns::Publisher &aPublisher) void PublishSingleService(void *aContext, Mdns::State aState) { - assert(aContext == &context); + assert(aContext == &sContext); if (aState == Mdns::kStateReady) { - assert(OTBR_ERROR_NONE == context.mPublisher->PublishService(12345, "SingleService", "_meshcop._udp", "nn", - "cool", "xp", "1122334455667788", NULL)); + assert(OTBR_ERROR_NONE == sContext.mPublisher->PublishService(12345, "SingleService", "_meshcop._udp", "nn", + "cool", "xp", "1122334455667788", NULL)); } } void PublishMultipleServices(void *aContext, Mdns::State aState) { - assert(aContext == &context); + assert(aContext == &sContext); if (aState == Mdns::kStateReady) { - assert(OTBR_ERROR_NONE == context.mPublisher->PublishService(12345, "MultipleService1", "_meshcop._udp", "nn", - "cool1", "xp", "1122334455667788", NULL)); - assert(OTBR_ERROR_NONE == context.mPublisher->PublishService(12346, "MultipleService2", "_meshcop._udp", "nn", - "cool2", "xp", "1122334455667788", NULL)); + assert(OTBR_ERROR_NONE == sContext.mPublisher->PublishService(12345, "MultipleService1", "_meshcop._udp", "nn", + "cool1", "xp", "1122334455667788", NULL)); + assert(OTBR_ERROR_NONE == sContext.mPublisher->PublishService(12346, "MultipleService2", "_meshcop._udp", "nn", + "cool2", "xp", "1122334455667788", NULL)); } } void PublishUpdateServices(void *aContext, Mdns::State aState) { - assert(aContext == &context); + assert(aContext == &sContext); if (aState == Mdns::kStateReady) { - if (!context.mUpdate) + if (!sContext.mUpdate) { - assert(OTBR_ERROR_NONE == context.mPublisher->PublishService(12345, "UpdateService", "_meshcop._udp", "nn", - "cool", "xp", "1122334455667788", NULL)); + assert(OTBR_ERROR_NONE == sContext.mPublisher->PublishService(12345, "UpdateService", "_meshcop._udp", "nn", + "cool", "xp", "1122334455667788", NULL)); } else { - assert(OTBR_ERROR_NONE == context.mPublisher->PublishService(12345, "UpdateService", "_meshcop._udp", "nn", - "coolcool", "xp", "8877665544332211", NULL)); + assert(OTBR_ERROR_NONE == sContext.mPublisher->PublishService(12345, "UpdateService", "_meshcop._udp", "nn", + "coolcool", "xp", "8877665544332211", NULL)); } } } @@ -124,8 +124,8 @@ otbrError TestSingleService(void) { otbrError ret = OTBR_ERROR_NONE; - Mdns::Publisher *pub = Mdns::Publisher::Create(AF_UNSPEC, NULL, NULL, PublishSingleService, &context); - context.mPublisher = pub; + Mdns::Publisher *pub = Mdns::Publisher::Create(AF_UNSPEC, NULL, NULL, PublishSingleService, &sContext); + sContext.mPublisher = pub; SuccessOrExit(ret = pub->Start()); Mainloop(*pub); @@ -138,8 +138,8 @@ otbrError TestMultipleServices(void) { otbrError ret = OTBR_ERROR_NONE; - Mdns::Publisher *pub = Mdns::Publisher::Create(AF_UNSPEC, NULL, NULL, PublishMultipleServices, &context); - context.mPublisher = pub; + Mdns::Publisher *pub = Mdns::Publisher::Create(AF_UNSPEC, NULL, NULL, PublishMultipleServices, &sContext); + sContext.mPublisher = pub; SuccessOrExit(ret = pub->Start()); Mainloop(*pub); @@ -152,12 +152,12 @@ otbrError TestUpdateService(void) { otbrError ret = OTBR_ERROR_NONE; - Mdns::Publisher *pub = Mdns::Publisher::Create(AF_UNSPEC, NULL, NULL, PublishUpdateServices, &context); - context.mPublisher = pub; - context.mUpdate = false; + Mdns::Publisher *pub = Mdns::Publisher::Create(AF_UNSPEC, NULL, NULL, PublishUpdateServices, &sContext); + sContext.mPublisher = pub; + sContext.mUpdate = false; SuccessOrExit(ret = pub->Start()); - context.mUpdate = true; - PublishUpdateServices(&context, Mdns::kStateReady); + sContext.mUpdate = true; + PublishUpdateServices(&sContext, Mdns::kStateReady); Mainloop(*pub); exit: @@ -181,15 +181,15 @@ otbrError TestStopService(void) { otbrError ret = OTBR_ERROR_NONE; - Mdns::Publisher *pub = Mdns::Publisher::Create(AF_UNSPEC, NULL, NULL, PublishSingleService, &context); - context.mPublisher = pub; + Mdns::Publisher *pub = Mdns::Publisher::Create(AF_UNSPEC, NULL, NULL, PublishSingleService, &sContext); + sContext.mPublisher = pub; SuccessOrExit(ret = pub->Start()); signal(SIGUSR1, RecoverSignal); signal(SIGUSR2, RecoverSignal); Mainloop(*pub); - context.mPublisher->Stop(); + sContext.mPublisher->Stop(); Mainloop(*pub); - SuccessOrExit(ret = context.mPublisher->Start()); + SuccessOrExit(ret = sContext.mPublisher->Start()); Mainloop(*pub); exit: @@ -207,6 +207,8 @@ int main(int argc, char *argv[]) } otbrLogInit("otbr-mdns", OTBR_LOG_DEBUG); + // allow quitting elegantly + signal(SIGTERM, RecoverSignal); switch (argv[1][0]) { case 's': diff --git a/tests/meshcop/Makefile.am b/tests/meshcop/Makefile.am index 547aa0d8..1788527e 100644 --- a/tests/meshcop/Makefile.am +++ b/tests/meshcop/Makefile.am @@ -71,6 +71,9 @@ dist_check_SCRIPTS = \ TESTS_ENVIRONMENT = \ export \ + CFLAGS='' \ + CPPFLAGS='' \ + LDFLAGS='' \ MAKE=$(MAKE) \ top_builddir='$(top_builddir)' \ top_srcdir='$(top_srcdir)' \ |