[travis] add code coverage flag (#3037)

This commit is contained in:
Yakun Xu
2018-09-10 14:40:23 -10:00
committed by Jonathan Hui
parent c573dafe8e
commit afb4d2e72a
6 changed files with 36 additions and 16 deletions
+11 -9
View File
@@ -548,15 +548,16 @@ set -x
[ $BUILD_TARGET != posix-app-cli ] || { [ $BUILD_TARGET != posix-app-cli ] || {
./bootstrap || die ./bootstrap || die
VIRTUAL_TIME_UART=1 make -f examples/Makefile-posix || die # enable code coverage for OpenThread transceiver only
make -f src/posix/Makefile-posix || die COVERAGE=1 VIRTUAL_TIME_UART=1 make -f examples/Makefile-posix || die
PYTHONUNBUFFERED=1 OT_CLI_PATH="$(pwd)/$(ls output/posix/*/bin/ot-cli)" RADIO_DEVICE="$(pwd)/$(ls output/*/bin/ot-ncp-radio)" COVERAGE=1 make -f src/posix/Makefile-posix check || die COVERAGE=1 make -f src/posix/Makefile-posix || die
COVERAGE=1 PYTHONUNBUFFERED=1 OT_CLI_PATH="$(pwd)/$(ls output/posix/*/bin/ot-cli)" RADIO_DEVICE="$(pwd)/$(ls output/*/bin/ot-ncp-radio)" make -f src/posix/Makefile-posix check || die
} }
[ $BUILD_TARGET != posix-app-pty ] || { [ $BUILD_TARGET != posix-app-pty ] || {
./bootstrap ./bootstrap
make -f examples/Makefile-posix COVERAGE=1 make -f examples/Makefile-posix
make -f src/posix/Makefile-posix COVERAGE=1 make -f src/posix/Makefile-posix
SOCAT_OUTPUT=/tmp/ot-socat SOCAT_OUTPUT=/tmp/ot-socat
socat -d -d pty,raw,echo=0 pty,raw,echo=0 > /dev/null 2> $SOCAT_OUTPUT & socat -d -d pty,raw,echo=0 pty,raw,echo=0 > /dev/null 2> $SOCAT_OUTPUT &
@@ -611,14 +612,15 @@ EOF
[ $BUILD_TARGET != posix-app-ncp ] || { [ $BUILD_TARGET != posix-app-ncp ] || {
./bootstrap || die ./bootstrap || die
VIRTUAL_TIME_UART=1 make -f examples/Makefile-posix || die COVERAGE=1 VIRTUAL_TIME_UART=1 make -f examples/Makefile-posix || die
make -f src/posix/Makefile-posix || die # enable code coverage for OpenThread posix radio
PYTHONUNBUFFERED=1 OT_NCP_PATH="$(pwd)/$(ls output/posix/*/bin/ot-ncp)" RADIO_DEVICE="$(pwd)/$(ls output/*/bin/ot-ncp-radio)" COVERAGE=1 NODE_TYPE=ncp-sim make -f src/posix/Makefile-posix check || die COVERAGE=1 make -f src/posix/Makefile-posix || die
COVERAGE=1 PYTHONUNBUFFERED=1 OT_NCP_PATH="$(pwd)/$(ls output/posix/*/bin/ot-ncp)" RADIO_DEVICE="$(pwd)/$(ls output/*/bin/ot-ncp-radio)" NODE_TYPE=ncp-sim make -f src/posix/Makefile-posix check || die
} }
[ $BUILD_TARGET != posix-ncp ] || { [ $BUILD_TARGET != posix-ncp ] || {
./bootstrap || die ./bootstrap || die
PYTHONUNBUFFERED=1 NODE_TYPE=ncp-sim make -f examples/Makefile-posix check || die COVERAGE=1 PYTHONUNBUFFERED=1 NODE_TYPE=ncp-sim make -f examples/Makefile-posix check || die
} }
[ $BUILD_TARGET != toranj-test-framework ] || { [ $BUILD_TARGET != toranj-test-framework ] || {
+17 -2
View File
@@ -53,7 +53,8 @@
uint32_t NODE_ID = 1; uint32_t NODE_ID = 1;
uint32_t WELLKNOWN_NODE_ID = 34; uint32_t WELLKNOWN_NODE_ID = 34;
extern bool gPlatformPseudoResetWasRequested; extern bool gPlatformPseudoResetWasRequested;
static volatile bool gTerminate = false;
int gArgumentsCount = 0; int gArgumentsCount = 0;
char **gArguments = NULL; char **gArguments = NULL;
@@ -62,6 +63,12 @@ uint64_t sNow = 0; // microseconds
int sSockFd; int sSockFd;
uint16_t sPortOffset; uint16_t sPortOffset;
static void handleSignal(int aSignal)
{
(void)aSignal;
gTerminate = true;
}
void otSimSendEvent(const struct Event *aEvent) void otSimSendEvent(const struct Event *aEvent)
{ {
ssize_t rval; ssize_t rval;
@@ -236,6 +243,9 @@ void otSysInit(int argc, char *argv[])
platformAlarmInit(1); platformAlarmInit(1);
platformRadioInit(); platformRadioInit();
platformRandomInit(); platformRandomInit();
signal(SIGTERM, &handleSignal);
signal(SIGHUP, &handleSignal);
} }
bool otSysPseudoResetWasRequested(void) bool otSysPseudoResetWasRequested(void)
@@ -256,6 +266,11 @@ void otSysProcessDrivers(otInstance *aInstance)
int max_fd = -1; int max_fd = -1;
int rval; int rval;
if (gTerminate)
{
exit(0);
}
FD_ZERO(&read_fds); FD_ZERO(&read_fds);
FD_ZERO(&write_fds); FD_ZERO(&write_fds);
FD_ZERO(&error_fds); FD_ZERO(&error_fds);
@@ -279,7 +294,7 @@ void otSysProcessDrivers(otInstance *aInstance)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (FD_ISSET(sSockFd, &read_fds)) if (rval > 0 && FD_ISSET(sSockFd, &read_fds))
{ {
receiveEvent(aInstance); receiveEvent(aInstance);
} }
+5
View File
@@ -46,6 +46,7 @@ BuildJobs ?= 10
configure_OPTIONS = \ configure_OPTIONS = \
--enable-application-coap \ --enable-application-coap \
--enable-border-agent \
--enable-border-router \ --enable-border-router \
--enable-cert-log \ --enable-cert-log \
--enable-child-supervision \ --enable-child-supervision \
@@ -67,6 +68,10 @@ configure_OPTIONS = \
--with-ncp-bus=uart \ --with-ncp-bus=uart \
$(NULL) $(NULL)
ifeq ($(COVERAGE),1)
configure_OPTIONS += --enable-coverage
endif
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))../.. TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))../..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))../.. AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))../..
+1 -1
View File
@@ -272,7 +272,7 @@ static int OpenPty(const char *aFile, const char *aConfig)
close(static_cast<int>(i)); close(static_cast<int>(i));
} }
rval = snprintf(cmd, sizeof(cmd), "%s %s", aFile, aConfig); rval = snprintf(cmd, sizeof(cmd), "exec %s %s", aFile, aConfig);
VerifyOrExit(rval > 0 && static_cast<size_t>(rval) < sizeof(cmd), VerifyOrExit(rval > 0 && static_cast<size_t>(rval) < sizeof(cmd),
otLogCritPlat(mInstance, "NCP file and configuration is too long!")); otLogCritPlat(mInstance, "NCP file and configuration is too long!"));
+1 -3
View File
@@ -141,11 +141,9 @@ class otCli:
if self.pexpect and self.pexpect.isalive(): if self.pexpect and self.pexpect.isalive():
print("%d: exit" % self.nodeid) print("%d: exit" % self.nodeid)
self.pexpect.send('exit\n') self.pexpect.send('exit\n')
self.pexpect.expect(pexpect.EOF)
self.pexpect.terminate() self.pexpect.terminate()
self._expect(pexpect.EOF)
self.pexpect.wait()
self.pexpect = None self.pexpect = None
sys.stdout.flush()
def send_command(self, cmd, go=True): def send_command(self, cmd, go=True):
print("%d: %s" % (self.nodeid, cmd)) print("%d: %s" % (self.nodeid, cmd))
+1 -1
View File
@@ -58,7 +58,7 @@ class RealTime:
def get_messages_sent_by(self, nodeid): def get_messages_sent_by(self, nodeid):
return self._sniffer.get_messages_sent_by(nodeid) return self._sniffer.get_messages_sent_by(nodeid)
def go(self, duration): def go(self, duration, nodeid=None):
time.sleep(duration) time.sleep(duration)
def stop(self): def stop(self):