Skip to content

Commit

Permalink
Added coverall statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
CurlyMoo committed Jul 21, 2017
1 parent cf23f0d commit 885fd6a
Show file tree
Hide file tree
Showing 93 changed files with 754 additions and 548 deletions.
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ addons:
packages:
- libpcap-dev
- libunwind8-dev
- lcov

install:
- curl https://apt.pilight.org/pilight.key | sudo apt-key add - && echo "deb http://apt.pilight.org/ stable main" | sudo tee -a /etc/apt/sources.list
Expand All @@ -32,4 +33,11 @@ before_script:
- if [[ $CONFIG == "ALL_ON" ]]; then sed "s/\(set(.*\) OFF/\1 ON/" -i CMakeConfig.txt; fi

script:
- mkdir build && pushd build && cmake .. && make && sudo ./pilight-unittest && sudo make install
- mkdir build && pushd build && cmake .. -DCOVERALLS=ON -DCMAKE_BUILD_TYPE=Debug && make && sudo ./pilight-unittest && sudo make install

after_success:
- gem install coveralls-lcov
- lcov -c -d CMakeFiles/pilight.dir/libs/pilight/events/ -d CMakeFiles/pilight.dir/libs/pilight/core/ -d CMakeFiles/pilight.dir/libs/pilight/psutil/ -d CMakeFiles/pilight.dir/libs/pilight/protocols/API/ -d CMakeFiles/pilight.dir/libs/pilight/protocols/core/ -d CMakeFiles/pilight.dir/libs/pilight/protocols/generic/ -d CMakeFiles/pilight.dir/libs/pilight/protocols/network/ -d CMakeFiles/pilight.dir/libs/pilight/protocols/GPIO -d CMakeFiles/pilight-unittest.dir/ -o coverage.info
- lcov -r coverage.info '*proc.c' '*adhoc.c' '*gc.c' '*generic_webcam.c' '*mem.c' '*CuTest.c' '*firmware.c' '*gpio_switch.c' '*relay.c' '*pushover.c' '*pushbullet.c' '*dht11.c' '*dht22.c' '*arping.c' -o coverage-filtered.info
- lcov --list coverage-filtered.info
- coveralls-lcov --repo-token ${COVERALLS_TOKEN} coverage-filtered.info
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ endif()
set(CMAKE_SKIP_RULE_DEPENDENCY TRUE)
set(CPACK_DEB_COMPONENT_INSTALL TRUE)

if(COVERALLS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0") # debug, no optimisation
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") # enabling coverage
endif()

if(WIN32)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
else()
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pilight version 7.0
=======
[![Build Status](https://travis-ci.org/pilight/pilight.svg?branch=rewrite)](https://travis-ci.org/pilight/pilight)
[![Build Status](https://travis-ci.org/pilight/pilight.svg?branch=rewrite)](https://travis-ci.org/pilight/pilight)[![Coverage Status](https://coveralls.io/repos/github/pilight/pilight/badge.svg?branch=rewrite)](https://coveralls.io/github/pilight/pilight?branch=rewrite)
<a class="donate" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=curlymoo1%40gmail%2ecom&lc=US&item_name=curlymoo&no_note=0&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHostedGuest" target="_blank">
<img alt="PayPal" title="PayPal" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" style="max-width:100%;"></a>
<a href="https://flattr.com/submit/auto?user_id=pilight&url=http%3A%2F%2Fwww.pilight.org" target="_blank"><img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0"></a>
Expand Down
38 changes: 19 additions & 19 deletions control.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static void ssdp_not_found(uv_timer_t *param) {
static void alloc_cb(uv_handle_t *handle, size_t len, uv_buf_t *buf) {
buf->len = len;
if((buf->base = malloc(len)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
memset(buf->base, 0, len);
}
Expand Down Expand Up @@ -189,7 +189,7 @@ static void on_read(int fd, char *buf, ssize_t len, char **buf1, ssize_t *len1)
for(q=0;q<n;q+=2) {
char *name = MALLOC(strlen(array[q])+1);
if(name == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(name, array[q]);
if(q+1 == n) {
Expand All @@ -200,7 +200,7 @@ static void on_read(int fd, char *buf, ssize_t len, char **buf1, ssize_t *len1)
} else {
char *val = MALLOC(strlen(array[q+1])+1);
if(val == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(val, array[q+1]);
struct JsonNode *jvalue = NULL;
Expand All @@ -216,7 +216,7 @@ static void on_read(int fd, char *buf, ssize_t len, char **buf1, ssize_t *len1)
jvalue->decimals_ = nrDecimals(val);
} else {
if((jvalue->string_ = REALLOC(jvalue->string_, strlen(val)+1)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(jvalue->string_, val);
}
Expand Down Expand Up @@ -247,7 +247,7 @@ static void on_read(int fd, char *buf, ssize_t len, char **buf1, ssize_t *len1)
struct JsonNode *jstate = json_find_member(tmp, "state");
if(jstate != NULL && jstate->tag == JSON_STRING) {
if((jstate->string_ = REALLOC(jstate->string_, strlen(state)+1)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(jstate->string_, state);
}
Expand Down Expand Up @@ -341,7 +341,7 @@ static void connect_to_server(char *server, int port) {
uv_timer_t *socket_timeout_req = NULL;

if((socket_timeout_req = MALLOC(sizeof(uv_timer_t))) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}

uv_timer_init(uv_default_loop(), socket_timeout_req);
Expand Down Expand Up @@ -379,7 +379,7 @@ static void *ssdp_found(int reason, void *param) {
}
if(match == 0) {
if((node = MALLOC(sizeof(struct ssdp_list_t))) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strncpy(node->server, data->ip, INET_ADDRSTRLEN);
node->port = data->port;
Expand Down Expand Up @@ -468,7 +468,7 @@ int main(int argc, char **argv) {
pilight.process = PROCESS_CLIENT;

if((fconfig = MALLOC(strlen(CONFIG_FILE)+1)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(fconfig, CONFIG_FILE);

Expand All @@ -478,12 +478,12 @@ int main(int argc, char **argv) {
log_level_set(LOG_NOTICE);

if((progname = MALLOC(16)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(progname, "pilight-control");

if((signal_req = MALLOC(sizeof(uv_signal_t))) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}

uv_signal_init(uv_default_loop(), signal_req);
Expand Down Expand Up @@ -522,37 +522,37 @@ int main(int argc, char **argv) {
break;
case 'd':
if((device = REALLOC(device, strlen(optarg)+1)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(device, optarg);
break;
case 's':
if((state = REALLOC(state, strlen(optarg)+1)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(state, optarg);
break;
case 'v':
if((values = REALLOC(values, strlen(optarg)+1)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(values, optarg);
break;
case 'C':
if((fconfig = REALLOC(fconfig, strlen(optarg)+1)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(fconfig, optarg);
break;
case 'I':
if((instance = MALLOC(strlen(optarg)+1)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(instance, optarg);
break;
case 'S':
if((server = REALLOC(server, strlen(optarg)+1)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(server, optarg);
break;
Expand Down Expand Up @@ -611,7 +611,7 @@ int main(int argc, char **argv) {
} else {
ssdp_seek();
if((ssdp_reseek_req = MALLOC(sizeof(uv_timer_t))) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}

uv_timer_init(uv_default_loop(), ssdp_reseek_req);
Expand All @@ -622,15 +622,15 @@ int main(int argc, char **argv) {
fflush(stdout);

if((tty_req = MALLOC(sizeof(uv_tty_t))) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}

uv_tty_init(uv_default_loop(), tty_req, 0, 1);
uv_read_start((uv_stream_t *)tty_req, alloc_cb, read_cb);
} else {
uv_timer_t *ssdp_not_found_req = NULL;
if((ssdp_not_found_req = MALLOC(sizeof(uv_timer_t))) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}

uv_timer_init(uv_default_loop(), ssdp_not_found_req);
Expand Down
8 changes: 4 additions & 4 deletions debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,12 @@ int main(int argc, char **argv) {
uv_replace_allocator(_MALLOC, _REALLOC, _CALLOC, _FREE);

if((progname = MALLOC(15)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(progname, "pilight-debug");

if((signal_req = MALLOC(sizeof(uv_signal_t))) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}

uv_signal_init(uv_default_loop(), signal_req);
Expand All @@ -361,7 +361,7 @@ int main(int argc, char **argv) {

char *fconfig = NULL;
if((fconfig = MALLOC(strlen(CONFIG_FILE)+1)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(fconfig, CONFIG_FILE);

Expand Down Expand Up @@ -390,7 +390,7 @@ int main(int argc, char **argv) {
break;
case 'C':
if((fconfig = REALLOC(fconfig, strlen(args)+1)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(fconfig, args);
break;
Expand Down
6 changes: 3 additions & 3 deletions flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ int main(int argc, char **argv) {
memset(&comport, '\0', 255);

if((fconfig = MALLOC(strlen(CONFIG_FILE)+1)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(fconfig, CONFIG_FILE);

if((progname = MALLOC(15)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(progname, "pilight-flash");

Expand Down Expand Up @@ -90,7 +90,7 @@ int main(int argc, char **argv) {
break;
case 'C':
if((fconfig = REALLOC(fconfig, strlen(args)+1)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(fconfig, args);
break;
Expand Down
4 changes: 2 additions & 2 deletions libs/avrdude/avrconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ TOKEN * new_token(int primary)

tkn = (TOKEN *)MALLOC(sizeof(TOKEN));
if (tkn == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}

memset(tkn, 0, sizeof(TOKEN));
Expand Down Expand Up @@ -100,7 +100,7 @@ TOKEN * string(char * text)
tkn->value.type = V_STR;
tkn->value.string = (char *) MALLOC(len+1);
if (tkn->value.string == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(tkn->value.string, text);

Expand Down
8 changes: 4 additions & 4 deletions libs/avrdude/avrpart.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ OPCODE * avr_new_opcode(void)

m = (OPCODE *)MALLOC(sizeof(*m));
if (m == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}

memset(m, 0, sizeof(*m));
Expand Down Expand Up @@ -173,7 +173,7 @@ AVRMEM * avr_new_memtype(void)

m = (AVRMEM *)MALLOC(sizeof(*m));
if (m == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}

memset(m, 0, sizeof(*m));
Expand All @@ -192,7 +192,7 @@ AVRMEM * avr_dup_mem(AVRMEM * m)

n->buf = (unsigned char *)MALLOC(n->size);
if (n->buf == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
memset(n->buf, 0, n->size);

Expand All @@ -212,7 +212,7 @@ AVRPART * avr_new_part(void)

p = (AVRPART *)MALLOC(sizeof(AVRPART));
if (p == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}

memset(p, 0, sizeof(*p));
Expand Down
16 changes: 8 additions & 8 deletions libs/avrdude/avrupd.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ AVRUPD * parse_op(char * s)

upd = (AVRUPD *)MALLOC(sizeof(AVRUPD));
if (upd == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}

i = 0;
Expand All @@ -75,7 +75,7 @@ AVRUPD * parse_op(char * s)
upd->memtype = (char *)MALLOC(strlen("flash")+1);
if (upd->memtype == NULL) {
outofmem:
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(upd->memtype, "flash");
upd->op = DEVICE_WRITE;
Expand All @@ -89,7 +89,7 @@ AVRUPD * parse_op(char * s)

upd->memtype = (char *)MALLOC(strlen(buf)+1);
if (upd->memtype == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(upd->memtype, buf);

Expand Down Expand Up @@ -167,7 +167,7 @@ AVRUPD * parse_op(char * s)
}

if (upd->filename == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
memcpy(upd->filename, cp, fnlen);
upd->filename[fnlen] = 0;
Expand All @@ -181,17 +181,17 @@ AVRUPD * dup_AVRUPD(AVRUPD * upd)

u = (AVRUPD *)MALLOC(sizeof(AVRUPD));
if(u == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}

memcpy(u, upd, sizeof(AVRUPD));

if((u->memtype = MALLOC(strlen(upd->memtype)+1)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(u->memtype, upd->memtype);
if((u->filename = MALLOC(strlen(upd->filename)+1)) == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(u->filename, upd->filename);

Expand All @@ -204,7 +204,7 @@ AVRUPD * new_AVRUPD(int op, char * memtype, int filefmt, char * filename)

u = (AVRUPD *)MALLOC(sizeof(AVRUPD));
if (u == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}

u->memtype = MALLOC(strlen(memtype)+1);
Expand Down
2 changes: 1 addition & 1 deletion libs/avrdude/pgm.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ PROGRAMMER * pgm_new(void)

pgm = (PROGRAMMER *)MALLOC(sizeof(*pgm));
if (pgm == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}

memset(pgm, 0, sizeof(*pgm));
Expand Down
2 changes: 1 addition & 1 deletion libs/avrdude/ser_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp) {
newname = MALLOC(strlen("\\\\.\\") + strlen(port) + 1);

if(newname == NULL) {
OUT_OF_MEMORY
OUT_OF_MEMORY /*LCOV_EXCL_LINE*/
}
strcpy(newname, "\\\\.\\");
strcat(newname, port);
Expand Down

0 comments on commit 885fd6a

Please sign in to comment.