diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c472c3..d8d2300 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,11 +55,11 @@ endif () add_custom_target(coverage) add_custom_command( TARGET coverage - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --exclude='*assert*' --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --exclude='*assert*' --remove coverage.info '/usr/*' '*example*' '*test*' + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --exclude='*assert*' --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) # -------------------------- Code Coverage End ------------------------------ # diff --git a/array/CMakeLists.txt b/array/CMakeLists.txt index 24428ef..8d670f8 100644 --- a/array/CMakeLists.txt +++ b/array/CMakeLists.txt @@ -81,11 +81,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/array/README.md b/array/README.md index 3ab17ae..afd8108 100644 --- a/array/README.md +++ b/array/README.md @@ -4,14 +4,16 @@ - Generic array which grows when you add elements. - Index access is possible (e.g float* arr; 'printf("%f", arr[i]')). -- Just copy sc_array.h and sc_array.c to your project. +- Copy sc_array.h and sc_array.c to your project. ##### Usage ```c + int *p; + int val; sc_array_create(p, 0); @@ -20,7 +22,7 @@ sc_array_add(p, 3); printf("\nRemoving first element \n\n"); - sc_array_remove(p, 0); + sc_array_del(p, 0); printf("Capacity %zu \n", sc_array_cap(p)); printf("Element count %zu \n", sc_array_size(p)); @@ -30,8 +32,14 @@ for (int i = 0; i < sc_array_size(p); i++) { printf("Elem = %d \n", p[i]); } + + // Foreach + sc_array_foreach(p, val) { + printf("Elem = %d \n", val); + } sc_array_destroy(p); + ``` #### Internals diff --git a/array/array_example.c b/array/array_example.c index 7bad9d9..a1889d5 100644 --- a/array/array_example.c +++ b/array/array_example.c @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) sc_array_add(p, 3); printf("\nRemoving first element \n\n"); - sc_array_remove(p, 0); + sc_array_del(p, 0); printf("Capacity %zu \n", sc_array_cap(p)); printf("Element count %zu \n", sc_array_size(p)); diff --git a/array/array_test.c b/array/array_test.c index d082173..c888ff2 100644 --- a/array/array_test.c +++ b/array/array_test.c @@ -7,6 +7,7 @@ int example() { int *p; + int val; sc_array_create(p, 0); @@ -15,7 +16,7 @@ int example() sc_array_add(p, 3); printf("\nRemoving first element \n\n"); - sc_array_remove(p, 0); + sc_array_del(p, 0); printf("Capacity %zu \n", sc_array_cap(p)); printf("Element count %zu \n", sc_array_size(p)); @@ -24,6 +25,10 @@ int example() printf("Elem = %d \n", p[i]); } + sc_array_foreach (p, val) { + printf("Elem = %d \n", val); + } + sc_array_destroy(p); return 0; @@ -48,9 +53,9 @@ static void test1(void) assert(sc_array_size(arr) == 3); - sc_array_remove(arr, 0); + sc_array_del(arr, 0); assert(arr[0] == 4); - sc_array_remove_last(arr); + sc_array_del_last(arr); assert(arr[0] == 4); sc_array_add(arr, 1); @@ -75,6 +80,42 @@ static void test1(void) sc_array_destroy(arr); } +void test2() +{ + int *arr; + int val; + + assert(sc_array_create(arr, 0) == true); + sc_array_foreach (arr, val) { + assert(true); + } + sc_array_destroy(arr); + + assert(sc_array_create(arr, 2) == true); + sc_array_foreach (arr, val) { + assert(true); + } + sc_array_destroy(arr); + + assert(sc_array_create(arr, 2) == true); + assert(sc_array_add(arr, 1) == true); + sc_array_foreach (arr, val) { + assert(val == 1); + } + sc_array_del_last(arr); + sc_array_foreach (arr, val) { + assert(true); + } + + assert(sc_array_add(arr, 1) == true); + sc_array_del_unordered(arr, 0); + sc_array_foreach (arr, val) { + assert(true); + } + + sc_array_destroy(arr); +} + void bounds_test() { int *arr, total = 0; @@ -172,9 +213,9 @@ void fail_test() assert(sc_array_size(arr) == 3); - sc_array_remove(arr, 0); + sc_array_del(arr, 0); assert(arr[0] == 4); - sc_array_remove_last(arr); + sc_array_del_last(arr); assert(arr[0] == 4); sc_array_add(arr, 1); @@ -201,7 +242,7 @@ void fail_test() assert(total == 10); sc_array_sort(arr, compare); - sc_array_remove_unordered(arr, 0); + sc_array_del_unordered(arr, 0); assert(arr[0] == 4); assert(sc_array_size(arr) == 4); sc_array_clear(arr); @@ -223,6 +264,7 @@ int main(int argc, char *argv[]) { example(); test1(); + test2(); fail_test(); bounds_test(); diff --git a/array/sc_array.h b/array/sc_array.h index bef1e0d..b79dfd9 100644 --- a/array/sc_array.h +++ b/array/sc_array.h @@ -33,10 +33,10 @@ #include #ifdef SC_HAVE_CONFIG_H -#include "sc_config.h" + #include "sc_config.h" #else -#define sc_array_realloc realloc -#define sc_array_free free + #define sc_array_realloc realloc + #define sc_array_free free #endif /** @@ -61,62 +61,61 @@ bool sc_array_expand(void **arr, size_t elem_size); */ /** - * @param arr Array pointer - * @param cap Initial capacity, '0' is accepted, then no memory allocation - * will be made until first 'add' operation. + * @param arr Array + * @param cap Initial capacity. '0' is a valid initial capacity, then no + * memory allocation will be made until first 'add' operation. * @return 'true' on success, 'false' on out of memory */ #define sc_array_create(arr, cap) \ sc_array_init((void **) &(arr), sizeof(*(arr)), cap) /** - * @param arr Array pointer + * @param arr Array */ #define sc_array_destroy(arr) sc_array_term((void **) &(arr)); /** - * @param arr Array pointer + * @param arr Array * @return Current allocated capacity */ #define sc_array_cap(arr) (sc_array_meta((arr))->cap) /** - * @param arr Array pointer + * @param arr Array * @return Current element count */ #define sc_array_size(arr) (sc_array_meta((arr))->size) /** - * Removes items from the list without deallocating underlying memory + * Deletes items from the array without deallocating underlying memory * * @param arr Array pointer */ #define sc_array_clear(arr) (sc_array_meta((arr))->size = 0) /** - * @param v Array pointer + * @param v Array * @param elem Element to be appended * @return 'true' on success, 'false' if memory allocation fails if we try * to expand underlying memory. */ #define sc_array_add(arr, elem) \ sc_array_expand((void **) &((arr)), sizeof(*(arr))) == true ? \ - (arr)[sc_array_meta(arr)->size++] = (elem), \ - true : false + (arr)[sc_array_meta(arr)->size++] = (elem), true : false /** - * Removes the element at index i, moves elements to fill the space - * unless removed element is the last element + * Deletes the element at index i, moves elements to fill the space + * unless deleted element is the last element * - * vec[a,b,c,d,e,f] -> sc_array_remove(vec, 2) - > vec[a,b,d,f,e] + * vec[a,b,c,d,e,f] -> sc_array_del(vec, 2) - > vec[a,b,d,f,e] * * @param arr Array pointer - * @param i Element index to be removed + * @param i Element index * * If 'i' is out of the range, result is undefined. */ -#define sc_array_remove(arr, i) \ +#define sc_array_del(arr, i) \ do { \ assert((i) < sc_array_meta(arr)->size); \ const size_t to_move = sc_array_size(arr) - (i) -1; \ @@ -127,18 +126,18 @@ bool sc_array_expand(void **arr, size_t elem_size); } while (0) /** - * Removes an element at index i, replaces last element with removed element - * unless removed element is the last element. This is faster than moving - * elements but elements will no longer be in the push order + * Deletes the element at index i, replaces last element with the deleted + * element unless deleted element is the last element. This is faster than + * moving elements but elements will no longer be in the 'add order' * - * arr[a,b,c,d,e,f] -> sc_array_remove_unordered(vec, 2) - > arr[a,b,f,d,e] + * arr[a,b,c,d,e,f] -> sc_array_del_unordered(vec, 2) - > arr[a,b,f,d,e] * * @param arr Array pointer - * @param i Element index to be removed + * @param i Element index * * If 'i' is out of the range, result is undefined. */ -#define sc_array_remove_unordered(arr, i) \ +#define sc_array_del_unordered(arr, i) \ do { \ assert((i) < sc_array_meta(arr)->size); \ (arr)[i] = (arr)[(--sc_array_meta((arr))->size)]; \ @@ -146,10 +145,11 @@ bool sc_array_expand(void **arr, size_t elem_size); /** - * Remove the last element. If there is no element, result is undefined. + * Deletes the last element. If there is no element in the array, result is + * undefined. * @param arr Array pointer */ -#define sc_array_remove_last(arr) \ +#define sc_array_del_last(arr) \ do { \ assert(sc_array_meta(arr)->size != 0); \ sc_array_meta(arr)->size--; \ @@ -172,7 +172,7 @@ bool sc_array_expand(void **arr, size_t elem_size); for ((value) = (arr)[_i]; _k; _k = !_k) /** - * Return last element. If array is empty, result is undefined. + * Returns last element. If array is empty, result is undefined. */ #define sc_array_last(arr) (arr)[sc_array_size(arr) - 1] diff --git a/buffer/CMakeLists.txt b/buffer/CMakeLists.txt index 094d226..c122cff 100644 --- a/buffer/CMakeLists.txt +++ b/buffer/CMakeLists.txt @@ -78,11 +78,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/buffer/sc_buf.c b/buffer/sc_buf.c index da3b3f2..1eff742 100644 --- a/buffer/sc_buf.c +++ b/buffer/sc_buf.c @@ -50,12 +50,12 @@ bool sc_buf_init(struct sc_buf *buf, uint32_t cap) struct sc_buf sc_buf_wrap(void *data, uint32_t len, int flags) { struct sc_buf buf = {.mem = data, - .cap = len, - .limit = flags & SC_BUF_REF ? len : UINT32_MAX, - .wpos = flags & SC_BUF_DATA ? len : 0, - .rpos = 0, - .ref = (bool) (flags & SC_BUF_REF), - .error = 0}; + .cap = len, + .limit = flags & SC_BUF_REF ? len : UINT32_MAX, + .wpos = flags & SC_BUF_DATA ? len : 0, + .rpos = 0, + .ref = (bool) (flags & SC_BUF_REF), + .error = 0}; return buf; } @@ -204,7 +204,8 @@ void sc_buf_move(struct sc_buf *dest, struct sc_buf *src) src->rpos += size; } -static uint16_t sc_buf_peek_8_pos(struct sc_buf *buf, uint32_t pos, uint8_t *val) +static uint16_t sc_buf_peek_8_pos(struct sc_buf *buf, uint32_t pos, + uint8_t *val) { if (pos + sizeof(*val) > buf->wpos) { buf->error |= SC_BUF_CORRUPT; @@ -217,9 +218,10 @@ static uint16_t sc_buf_peek_8_pos(struct sc_buf *buf, uint32_t pos, uint8_t *val return sizeof(*val); } -static uint16_t sc_buf_peek_16_pos(struct sc_buf *buf, uint32_t pos, uint16_t *val) +static uint16_t sc_buf_peek_16_pos(struct sc_buf *buf, uint32_t pos, + uint16_t *val) { - unsigned char* p; + unsigned char *p; if (pos + sizeof(*val) > buf->wpos) { buf->error |= SC_BUF_CORRUPT; @@ -229,15 +231,15 @@ static uint16_t sc_buf_peek_16_pos(struct sc_buf *buf, uint32_t pos, uint16_t *v p = &buf->mem[pos]; - *val = (uint16_t) p[0] << 0 | - (uint16_t) p[1] << 8; + *val = (uint16_t) p[0] << 0 | (uint16_t) p[1] << 8; return sizeof(*val); } -static uint32_t sc_buf_peek_32_pos(struct sc_buf *buf, uint32_t pos, uint32_t *val) +static uint32_t sc_buf_peek_32_pos(struct sc_buf *buf, uint32_t pos, + uint32_t *val) { - unsigned char* p; + unsigned char *p; if (pos + sizeof(*val) > buf->wpos) { buf->error |= SC_BUF_CORRUPT; @@ -247,17 +249,16 @@ static uint32_t sc_buf_peek_32_pos(struct sc_buf *buf, uint32_t pos, uint32_t *v p = &buf->mem[pos]; - *val = (uint32_t) p[0] << 0 | - (uint32_t) p[1] << 8 | - (uint32_t) p[2] << 16 | + *val = (uint32_t) p[0] << 0 | (uint32_t) p[1] << 8 | (uint32_t) p[2] << 16 | (uint32_t) p[3] << 24; return sizeof(*val); } -static uint32_t sc_buf_peek_64_pos(struct sc_buf *buf, uint32_t pos, uint64_t *val) +static uint32_t sc_buf_peek_64_pos(struct sc_buf *buf, uint32_t pos, + uint64_t *val) { - unsigned char* p; + unsigned char *p; if (pos + sizeof(*val) > buf->wpos) { buf->error |= SC_BUF_CORRUPT; @@ -267,19 +268,16 @@ static uint32_t sc_buf_peek_64_pos(struct sc_buf *buf, uint32_t pos, uint64_t *v p = &buf->mem[pos]; - *val = (uint64_t) p[0] << 0 | - (uint64_t) p[1] << 8 | - (uint64_t) p[2] << 16 | - (uint64_t) p[3] << 24 | - (uint64_t) p[4] << 32 | - (uint64_t) p[5] << 40 | - (uint64_t) p[6] << 48 | + *val = (uint64_t) p[0] << 0 | (uint64_t) p[1] << 8 | (uint64_t) p[2] << 16 | + (uint64_t) p[3] << 24 | (uint64_t) p[4] << 32 | + (uint64_t) p[5] << 40 | (uint64_t) p[6] << 48 | (uint64_t) p[7] << 56; return sizeof(*val); } -static uint32_t sc_buf_set_8_pos(struct sc_buf *buf, uint32_t pos, const uint8_t *val) +static uint32_t sc_buf_set_8_pos(struct sc_buf *buf, uint32_t pos, + const uint8_t *val) { if (buf->error != 0 || (pos + sizeof(*val) > buf->cap)) { buf->error |= SC_BUF_CORRUPT; @@ -291,9 +289,10 @@ static uint32_t sc_buf_set_8_pos(struct sc_buf *buf, uint32_t pos, const uint8_t return sizeof(*val); } -static uint32_t sc_buf_set_16_pos(struct sc_buf *buf, uint32_t pos, const uint16_t *val) +static uint32_t sc_buf_set_16_pos(struct sc_buf *buf, uint32_t pos, + const uint16_t *val) { - unsigned char* p; + unsigned char *p; if (buf->error != 0 || (pos + sizeof(*val) > buf->cap)) { buf->error |= SC_BUF_CORRUPT; @@ -308,9 +307,10 @@ static uint32_t sc_buf_set_16_pos(struct sc_buf *buf, uint32_t pos, const uint16 return sizeof(*val); } -static uint32_t sc_buf_set_32_pos(struct sc_buf *buf, uint32_t pos, const uint32_t *val) +static uint32_t sc_buf_set_32_pos(struct sc_buf *buf, uint32_t pos, + const uint32_t *val) { - unsigned char* p; + unsigned char *p; if (buf->error != 0 || (pos + sizeof(*val) > buf->cap)) { buf->error |= SC_BUF_CORRUPT; @@ -327,9 +327,10 @@ static uint32_t sc_buf_set_32_pos(struct sc_buf *buf, uint32_t pos, const uint32 return sizeof(*val); } -static uint32_t sc_buf_set_64_pos(struct sc_buf *buf, uint32_t pos, const uint64_t *val) +static uint32_t sc_buf_set_64_pos(struct sc_buf *buf, uint32_t pos, + const uint64_t *val) { - unsigned char* p; + unsigned char *p; if (buf->error != 0 || (pos + sizeof(*val) > buf->cap)) { buf->error |= SC_BUF_CORRUPT; @@ -608,7 +609,6 @@ void sc_buf_put_32(struct sc_buf *buf, uint32_t val) } - void sc_buf_put_64(struct sc_buf *buf, uint64_t val) { if (!sc_buf_reserve(buf, sizeof(val))) { @@ -709,7 +709,6 @@ void sc_buf_put_text(struct sc_buf *buf, const char *fmt, ...) { int rc; va_list args; - uint32_t pos = 0; int offset = sc_buf_size(buf) > 0 ? 1 : 0; uint32_t quota = sc_buf_quota(buf); @@ -719,13 +718,13 @@ void sc_buf_put_text(struct sc_buf *buf, const char *fmt, ...) if (rc < 0) { buf->error |= SC_BUF_CORRUPT; - sc_buf_set_wpos(buf, pos); + sc_buf_set_wpos(buf, 0); return; } if (rc >= quota) { if (!sc_buf_reserve(buf, (uint32_t) rc)) { - sc_buf_set_wpos(buf, pos); + sc_buf_set_wpos(buf, 0); return; } @@ -734,7 +733,7 @@ void sc_buf_put_text(struct sc_buf *buf, const char *fmt, ...) va_end(args); if (rc < 0 || rc >= quota) { - sc_buf_set_wpos(buf, pos); + sc_buf_set_wpos(buf, 0); buf->error = SC_BUF_OOM; return; } diff --git a/buffer/sc_buf.h b/buffer/sc_buf.h index d170836..db0c609 100644 --- a/buffer/sc_buf.h +++ b/buffer/sc_buf.h @@ -32,11 +32,11 @@ #include #ifdef SC_HAVE_CONFIG_H -#include "sc_config.h" + #include "sc_config.h" #else -#define sc_buf_malloc malloc -#define sc_buf_realloc realloc -#define sc_buf_free free + #define sc_buf_malloc malloc + #define sc_buf_realloc realloc + #define sc_buf_free free #endif @@ -83,7 +83,7 @@ void sc_buf_term(struct sc_buf *buf); * @param flags if set 'SC_BUF_REF', buffer will not try to expand itself and * 'sc_buf_term' will not try to 'free()' buffer. * if set 'SC_BUF_DATA', buffer wpos will be 'len'. - * flags can be combined : SC_BUF_REF | SC_BUF_REF + * flags can be combined : SC_BUF_REF | SC_BUF_DATA * @return */ struct sc_buf sc_buf_wrap(void *data, uint32_t len, int flags); @@ -288,7 +288,6 @@ void *sc_buf_get_blob(struct sc_buf *buf, uint32_t len); */ void sc_buf_get_data(struct sc_buf *buf, void *dest, uint32_t len); - /** * Put functions, 'val' will be copied to the buffer and write position will * be advanced. diff --git a/condition/CMakeLists.txt b/condition/CMakeLists.txt index 2ed2982..cd78533 100644 --- a/condition/CMakeLists.txt +++ b/condition/CMakeLists.txt @@ -80,11 +80,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/crc32/CMakeLists.txt b/crc32/CMakeLists.txt index 6ec8a86..00767e3 100644 --- a/crc32/CMakeLists.txt +++ b/crc32/CMakeLists.txt @@ -67,11 +67,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/heap/CMakeLists.txt b/heap/CMakeLists.txt index 2b9477f..aff8cde 100644 --- a/heap/CMakeLists.txt +++ b/heap/CMakeLists.txt @@ -78,11 +78,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/ini/CMakeLists.txt b/ini/CMakeLists.txt index 905a20e..9d39e06 100644 --- a/ini/CMakeLists.txt +++ b/ini/CMakeLists.txt @@ -68,11 +68,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --ini coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --ini coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/linked-list/CMakeLists.txt b/linked-list/CMakeLists.txt index 8f0dc67..b455a4b 100644 --- a/linked-list/CMakeLists.txt +++ b/linked-list/CMakeLists.txt @@ -67,11 +67,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/logger/CMakeLists.txt b/logger/CMakeLists.txt index e0e8b82..45bcf77 100644 --- a/logger/CMakeLists.txt +++ b/logger/CMakeLists.txt @@ -80,11 +80,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/map/CMakeLists.txt b/map/CMakeLists.txt index 60799b9..848fab9 100644 --- a/map/CMakeLists.txt +++ b/map/CMakeLists.txt @@ -87,11 +87,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/math/CMakeLists.txt b/math/CMakeLists.txt index 0216713..2f5989e 100644 --- a/math/CMakeLists.txt +++ b/math/CMakeLists.txt @@ -80,11 +80,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/memory-map/CMakeLists.txt b/memory-map/CMakeLists.txt index 3c74402..16aa2cf 100644 --- a/memory-map/CMakeLists.txt +++ b/memory-map/CMakeLists.txt @@ -80,11 +80,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/mutex/CMakeLists.txt b/mutex/CMakeLists.txt index fcfdebe..374a708 100644 --- a/mutex/CMakeLists.txt +++ b/mutex/CMakeLists.txt @@ -80,11 +80,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/option/CMakeLists.txt b/option/CMakeLists.txt index 46043b7..febb9aa 100644 --- a/option/CMakeLists.txt +++ b/option/CMakeLists.txt @@ -80,11 +80,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/queue/CMakeLists.txt b/queue/CMakeLists.txt index 0bebb72..fb9ee38 100644 --- a/queue/CMakeLists.txt +++ b/queue/CMakeLists.txt @@ -81,11 +81,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/rc4/CMakeLists.txt b/rc4/CMakeLists.txt index ab82d94..b657f20 100644 --- a/rc4/CMakeLists.txt +++ b/rc4/CMakeLists.txt @@ -77,11 +77,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/signal/CMakeLists.txt b/signal/CMakeLists.txt index 6a8418b..63c09cd 100644 --- a/signal/CMakeLists.txt +++ b/signal/CMakeLists.txt @@ -100,11 +100,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/socket/CMakeLists.txt b/socket/CMakeLists.txt index 56c9b83..d616bd8 100644 --- a/socket/CMakeLists.txt +++ b/socket/CMakeLists.txt @@ -81,11 +81,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/socket/sock_test.c b/socket/sock_test.c index 7a67d22..e5d2a62 100644 --- a/socket/sock_test.c +++ b/socket/sock_test.c @@ -504,7 +504,6 @@ void* server(void* arg) printf("Received :%d \n", received); assert(received == 10000); - return NULL; } @@ -536,7 +535,6 @@ void* client(void* arg) return NULL; } - void test_poll() { struct sc_thread thread1; @@ -552,7 +550,6 @@ void test_poll() assert(sc_thread_term(&thread2) == 0); } - int main() { #if defined(_WIN32) || defined(_WIN64) diff --git a/string/CMakeLists.txt b/string/CMakeLists.txt index 02e1679..63e9a4e 100644 --- a/string/CMakeLists.txt +++ b/string/CMakeLists.txt @@ -79,11 +79,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/thread/CMakeLists.txt b/thread/CMakeLists.txt index c5e9cd0..260351b 100644 --- a/thread/CMakeLists.txt +++ b/thread/CMakeLists.txt @@ -79,11 +79,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/time/CMakeLists.txt b/time/CMakeLists.txt index 936a780..deb360a 100644 --- a/time/CMakeLists.txt +++ b/time/CMakeLists.txt @@ -67,11 +67,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/timer/CMakeLists.txt b/timer/CMakeLists.txt index d21b742..a901f1d 100644 --- a/timer/CMakeLists.txt +++ b/timer/CMakeLists.txt @@ -80,11 +80,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME}) diff --git a/url/CMakeLists.txt b/url/CMakeLists.txt index 1699386..1843f9b 100644 --- a/url/CMakeLists.txt +++ b/url/CMakeLists.txt @@ -77,11 +77,11 @@ endif () add_custom_target(coverage_${PROJECT_NAME}) add_custom_command( TARGET coverage_${PROJECT_NAME} - COMMAND lcov --capture --directory .. - --output-file coverage.info --rc lcov_branch_coverage=1 + COMMAND lcov --capture --directory . + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*' - --output-file coverage.info --rc lcov_branch_coverage=1 - COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 + --output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' + COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert' ) add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})