mirror of
https://github.com/tezc/sc.git
synced 2025-02-04 07:13:10 +08:00
more tests
This commit is contained in:
parent
e5c549bd23
commit
1e6f2d3fa3
@ -55,11 +55,11 @@ endif ()
|
|||||||
add_custom_target(coverage)
|
add_custom_target(coverage)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage
|
TARGET coverage
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --exclude='*assert*' --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --exclude='*assert*' --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --exclude='*assert*' --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
# -------------------------- Code Coverage End ------------------------------ #
|
# -------------------------- Code Coverage End ------------------------------ #
|
||||||
|
@ -81,11 +81,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -4,14 +4,16 @@
|
|||||||
|
|
||||||
- Generic array which grows when you add elements.
|
- Generic array which grows when you add elements.
|
||||||
- Index access is possible (e.g float* arr; 'printf("%f", arr[i]')).
|
- Index access is possible (e.g float* arr; 'printf("%f", arr[i]')).
|
||||||
- Just copy <b>sc_array.h</b> and <b>sc_array.c</b> to your project.
|
- Copy <b>sc_array.h</b> and <b>sc_array.c</b> to your project.
|
||||||
|
|
||||||
|
|
||||||
##### Usage
|
##### Usage
|
||||||
|
|
||||||
|
|
||||||
```c
|
```c
|
||||||
|
|
||||||
int *p;
|
int *p;
|
||||||
|
int val;
|
||||||
|
|
||||||
sc_array_create(p, 0);
|
sc_array_create(p, 0);
|
||||||
|
|
||||||
@ -20,7 +22,7 @@
|
|||||||
sc_array_add(p, 3);
|
sc_array_add(p, 3);
|
||||||
|
|
||||||
printf("\nRemoving first element \n\n");
|
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("Capacity %zu \n", sc_array_cap(p));
|
||||||
printf("Element count %zu \n", sc_array_size(p));
|
printf("Element count %zu \n", sc_array_size(p));
|
||||||
@ -31,7 +33,13 @@
|
|||||||
printf("Elem = %d \n", p[i]);
|
printf("Elem = %d \n", p[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Foreach
|
||||||
|
sc_array_foreach(p, val) {
|
||||||
|
printf("Elem = %d \n", val);
|
||||||
|
}
|
||||||
|
|
||||||
sc_array_destroy(p);
|
sc_array_destroy(p);
|
||||||
|
|
||||||
```
|
```
|
||||||
#### Internals
|
#### Internals
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ int main(int argc, char *argv[])
|
|||||||
sc_array_add(p, 3);
|
sc_array_add(p, 3);
|
||||||
|
|
||||||
printf("\nRemoving first element \n\n");
|
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("Capacity %zu \n", sc_array_cap(p));
|
||||||
printf("Element count %zu \n", sc_array_size(p));
|
printf("Element count %zu \n", sc_array_size(p));
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
int example()
|
int example()
|
||||||
{
|
{
|
||||||
int *p;
|
int *p;
|
||||||
|
int val;
|
||||||
|
|
||||||
sc_array_create(p, 0);
|
sc_array_create(p, 0);
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ int example()
|
|||||||
sc_array_add(p, 3);
|
sc_array_add(p, 3);
|
||||||
|
|
||||||
printf("\nRemoving first element \n\n");
|
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("Capacity %zu \n", sc_array_cap(p));
|
||||||
printf("Element count %zu \n", sc_array_size(p));
|
printf("Element count %zu \n", sc_array_size(p));
|
||||||
@ -24,6 +25,10 @@ int example()
|
|||||||
printf("Elem = %d \n", p[i]);
|
printf("Elem = %d \n", p[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sc_array_foreach (p, val) {
|
||||||
|
printf("Elem = %d \n", val);
|
||||||
|
}
|
||||||
|
|
||||||
sc_array_destroy(p);
|
sc_array_destroy(p);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -48,9 +53,9 @@ static void test1(void)
|
|||||||
|
|
||||||
assert(sc_array_size(arr) == 3);
|
assert(sc_array_size(arr) == 3);
|
||||||
|
|
||||||
sc_array_remove(arr, 0);
|
sc_array_del(arr, 0);
|
||||||
assert(arr[0] == 4);
|
assert(arr[0] == 4);
|
||||||
sc_array_remove_last(arr);
|
sc_array_del_last(arr);
|
||||||
assert(arr[0] == 4);
|
assert(arr[0] == 4);
|
||||||
|
|
||||||
sc_array_add(arr, 1);
|
sc_array_add(arr, 1);
|
||||||
@ -75,6 +80,42 @@ static void test1(void)
|
|||||||
sc_array_destroy(arr);
|
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()
|
void bounds_test()
|
||||||
{
|
{
|
||||||
int *arr, total = 0;
|
int *arr, total = 0;
|
||||||
@ -172,9 +213,9 @@ void fail_test()
|
|||||||
|
|
||||||
assert(sc_array_size(arr) == 3);
|
assert(sc_array_size(arr) == 3);
|
||||||
|
|
||||||
sc_array_remove(arr, 0);
|
sc_array_del(arr, 0);
|
||||||
assert(arr[0] == 4);
|
assert(arr[0] == 4);
|
||||||
sc_array_remove_last(arr);
|
sc_array_del_last(arr);
|
||||||
assert(arr[0] == 4);
|
assert(arr[0] == 4);
|
||||||
|
|
||||||
sc_array_add(arr, 1);
|
sc_array_add(arr, 1);
|
||||||
@ -201,7 +242,7 @@ void fail_test()
|
|||||||
assert(total == 10);
|
assert(total == 10);
|
||||||
|
|
||||||
sc_array_sort(arr, compare);
|
sc_array_sort(arr, compare);
|
||||||
sc_array_remove_unordered(arr, 0);
|
sc_array_del_unordered(arr, 0);
|
||||||
assert(arr[0] == 4);
|
assert(arr[0] == 4);
|
||||||
assert(sc_array_size(arr) == 4);
|
assert(sc_array_size(arr) == 4);
|
||||||
sc_array_clear(arr);
|
sc_array_clear(arr);
|
||||||
@ -223,6 +264,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
example();
|
example();
|
||||||
test1();
|
test1();
|
||||||
|
test2();
|
||||||
fail_test();
|
fail_test();
|
||||||
bounds_test();
|
bounds_test();
|
||||||
|
|
||||||
|
@ -33,10 +33,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef SC_HAVE_CONFIG_H
|
#ifdef SC_HAVE_CONFIG_H
|
||||||
#include "sc_config.h"
|
#include "sc_config.h"
|
||||||
#else
|
#else
|
||||||
#define sc_array_realloc realloc
|
#define sc_array_realloc realloc
|
||||||
#define sc_array_free free
|
#define sc_array_free free
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,62 +61,61 @@ bool sc_array_expand(void **arr, size_t elem_size);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param arr Array pointer
|
* @param arr Array
|
||||||
* @param cap Initial capacity, '0' is accepted, then no memory allocation
|
* @param cap Initial capacity. '0' is a valid initial capacity, then no
|
||||||
* will be made until first 'add' operation.
|
* memory allocation will be made until first 'add' operation.
|
||||||
* @return 'true' on success, 'false' on out of memory
|
* @return 'true' on success, 'false' on out of memory
|
||||||
*/
|
*/
|
||||||
#define sc_array_create(arr, cap) \
|
#define sc_array_create(arr, cap) \
|
||||||
sc_array_init((void **) &(arr), sizeof(*(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));
|
#define sc_array_destroy(arr) sc_array_term((void **) &(arr));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param arr Array pointer
|
* @param arr Array
|
||||||
* @return Current allocated capacity
|
* @return Current allocated capacity
|
||||||
*/
|
*/
|
||||||
#define sc_array_cap(arr) (sc_array_meta((arr))->cap)
|
#define sc_array_cap(arr) (sc_array_meta((arr))->cap)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param arr Array pointer
|
* @param arr Array
|
||||||
* @return Current element count
|
* @return Current element count
|
||||||
*/
|
*/
|
||||||
#define sc_array_size(arr) (sc_array_meta((arr))->size)
|
#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
|
* @param arr Array pointer
|
||||||
*/
|
*/
|
||||||
#define sc_array_clear(arr) (sc_array_meta((arr))->size = 0)
|
#define sc_array_clear(arr) (sc_array_meta((arr))->size = 0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param v Array pointer
|
* @param v Array
|
||||||
* @param elem Element to be appended
|
* @param elem Element to be appended
|
||||||
* @return 'true' on success, 'false' if memory allocation fails if we try
|
* @return 'true' on success, 'false' if memory allocation fails if we try
|
||||||
* to expand underlying memory.
|
* to expand underlying memory.
|
||||||
*/
|
*/
|
||||||
#define sc_array_add(arr, elem) \
|
#define sc_array_add(arr, elem) \
|
||||||
sc_array_expand((void **) &((arr)), sizeof(*(arr))) == true ? \
|
sc_array_expand((void **) &((arr)), sizeof(*(arr))) == true ? \
|
||||||
(arr)[sc_array_meta(arr)->size++] = (elem), \
|
(arr)[sc_array_meta(arr)->size++] = (elem), true : false
|
||||||
true : false
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the element at index i, moves elements to fill the space
|
* Deletes the element at index i, moves elements to fill the space
|
||||||
* unless removed element is the last element
|
* 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 arr Array pointer
|
||||||
* @param i Element index to be removed
|
* @param i Element index
|
||||||
*
|
*
|
||||||
* If 'i' is out of the range, result is undefined.
|
* If 'i' is out of the range, result is undefined.
|
||||||
*/
|
*/
|
||||||
#define sc_array_remove(arr, i) \
|
#define sc_array_del(arr, i) \
|
||||||
do { \
|
do { \
|
||||||
assert((i) < sc_array_meta(arr)->size); \
|
assert((i) < sc_array_meta(arr)->size); \
|
||||||
const size_t to_move = sc_array_size(arr) - (i) -1; \
|
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)
|
} while (0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes an element at index i, replaces last element with removed element
|
* Deletes the element at index i, replaces last element with the deleted
|
||||||
* unless removed element is the last element. This is faster than moving
|
* element unless deleted element is the last element. This is faster than
|
||||||
* elements but elements will no longer be in the push order
|
* 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 arr Array pointer
|
||||||
* @param i Element index to be removed
|
* @param i Element index
|
||||||
*
|
*
|
||||||
* If 'i' is out of the range, result is undefined.
|
* 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 { \
|
do { \
|
||||||
assert((i) < sc_array_meta(arr)->size); \
|
assert((i) < sc_array_meta(arr)->size); \
|
||||||
(arr)[i] = (arr)[(--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
|
* @param arr Array pointer
|
||||||
*/
|
*/
|
||||||
#define sc_array_remove_last(arr) \
|
#define sc_array_del_last(arr) \
|
||||||
do { \
|
do { \
|
||||||
assert(sc_array_meta(arr)->size != 0); \
|
assert(sc_array_meta(arr)->size != 0); \
|
||||||
sc_array_meta(arr)->size--; \
|
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)
|
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]
|
#define sc_array_last(arr) (arr)[sc_array_size(arr) - 1]
|
||||||
|
|
||||||
|
@ -78,11 +78,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -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 sc_buf_wrap(void *data, uint32_t len, int flags)
|
||||||
{
|
{
|
||||||
struct sc_buf buf = {.mem = data,
|
struct sc_buf buf = {.mem = data,
|
||||||
.cap = len,
|
.cap = len,
|
||||||
.limit = flags & SC_BUF_REF ? len : UINT32_MAX,
|
.limit = flags & SC_BUF_REF ? len : UINT32_MAX,
|
||||||
.wpos = flags & SC_BUF_DATA ? len : 0,
|
.wpos = flags & SC_BUF_DATA ? len : 0,
|
||||||
.rpos = 0,
|
.rpos = 0,
|
||||||
.ref = (bool) (flags & SC_BUF_REF),
|
.ref = (bool) (flags & SC_BUF_REF),
|
||||||
.error = 0};
|
.error = 0};
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@ -204,7 +204,8 @@ void sc_buf_move(struct sc_buf *dest, struct sc_buf *src)
|
|||||||
src->rpos += size;
|
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) {
|
if (pos + sizeof(*val) > buf->wpos) {
|
||||||
buf->error |= SC_BUF_CORRUPT;
|
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);
|
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) {
|
if (pos + sizeof(*val) > buf->wpos) {
|
||||||
buf->error |= SC_BUF_CORRUPT;
|
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];
|
p = &buf->mem[pos];
|
||||||
|
|
||||||
*val = (uint16_t) p[0] << 0 |
|
*val = (uint16_t) p[0] << 0 | (uint16_t) p[1] << 8;
|
||||||
(uint16_t) p[1] << 8;
|
|
||||||
|
|
||||||
return sizeof(*val);
|
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) {
|
if (pos + sizeof(*val) > buf->wpos) {
|
||||||
buf->error |= SC_BUF_CORRUPT;
|
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];
|
p = &buf->mem[pos];
|
||||||
|
|
||||||
*val = (uint32_t) p[0] << 0 |
|
*val = (uint32_t) p[0] << 0 | (uint32_t) p[1] << 8 | (uint32_t) p[2] << 16 |
|
||||||
(uint32_t) p[1] << 8 |
|
|
||||||
(uint32_t) p[2] << 16 |
|
|
||||||
(uint32_t) p[3] << 24;
|
(uint32_t) p[3] << 24;
|
||||||
|
|
||||||
return sizeof(*val);
|
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) {
|
if (pos + sizeof(*val) > buf->wpos) {
|
||||||
buf->error |= SC_BUF_CORRUPT;
|
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];
|
p = &buf->mem[pos];
|
||||||
|
|
||||||
*val = (uint64_t) p[0] << 0 |
|
*val = (uint64_t) p[0] << 0 | (uint64_t) p[1] << 8 | (uint64_t) p[2] << 16 |
|
||||||
(uint64_t) p[1] << 8 |
|
(uint64_t) p[3] << 24 | (uint64_t) p[4] << 32 |
|
||||||
(uint64_t) p[2] << 16 |
|
(uint64_t) p[5] << 40 | (uint64_t) p[6] << 48 |
|
||||||
(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;
|
(uint64_t) p[7] << 56;
|
||||||
|
|
||||||
return sizeof(*val);
|
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)) {
|
if (buf->error != 0 || (pos + sizeof(*val) > buf->cap)) {
|
||||||
buf->error |= SC_BUF_CORRUPT;
|
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);
|
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)) {
|
if (buf->error != 0 || (pos + sizeof(*val) > buf->cap)) {
|
||||||
buf->error |= SC_BUF_CORRUPT;
|
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);
|
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)) {
|
if (buf->error != 0 || (pos + sizeof(*val) > buf->cap)) {
|
||||||
buf->error |= SC_BUF_CORRUPT;
|
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);
|
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)) {
|
if (buf->error != 0 || (pos + sizeof(*val) > buf->cap)) {
|
||||||
buf->error |= SC_BUF_CORRUPT;
|
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)
|
void sc_buf_put_64(struct sc_buf *buf, uint64_t val)
|
||||||
{
|
{
|
||||||
if (!sc_buf_reserve(buf, sizeof(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;
|
int rc;
|
||||||
va_list args;
|
va_list args;
|
||||||
uint32_t pos = 0;
|
|
||||||
int offset = sc_buf_size(buf) > 0 ? 1 : 0;
|
int offset = sc_buf_size(buf) > 0 ? 1 : 0;
|
||||||
uint32_t quota = sc_buf_quota(buf);
|
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) {
|
if (rc < 0) {
|
||||||
buf->error |= SC_BUF_CORRUPT;
|
buf->error |= SC_BUF_CORRUPT;
|
||||||
sc_buf_set_wpos(buf, pos);
|
sc_buf_set_wpos(buf, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc >= quota) {
|
if (rc >= quota) {
|
||||||
if (!sc_buf_reserve(buf, (uint32_t) rc)) {
|
if (!sc_buf_reserve(buf, (uint32_t) rc)) {
|
||||||
sc_buf_set_wpos(buf, pos);
|
sc_buf_set_wpos(buf, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -734,7 +733,7 @@ void sc_buf_put_text(struct sc_buf *buf, const char *fmt, ...)
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if (rc < 0 || rc >= quota) {
|
if (rc < 0 || rc >= quota) {
|
||||||
sc_buf_set_wpos(buf, pos);
|
sc_buf_set_wpos(buf, 0);
|
||||||
buf->error = SC_BUF_OOM;
|
buf->error = SC_BUF_OOM;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -32,11 +32,11 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef SC_HAVE_CONFIG_H
|
#ifdef SC_HAVE_CONFIG_H
|
||||||
#include "sc_config.h"
|
#include "sc_config.h"
|
||||||
#else
|
#else
|
||||||
#define sc_buf_malloc malloc
|
#define sc_buf_malloc malloc
|
||||||
#define sc_buf_realloc realloc
|
#define sc_buf_realloc realloc
|
||||||
#define sc_buf_free free
|
#define sc_buf_free free
|
||||||
#endif
|
#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
|
* @param flags if set 'SC_BUF_REF', buffer will not try to expand itself and
|
||||||
* 'sc_buf_term' will not try to 'free()' buffer.
|
* 'sc_buf_term' will not try to 'free()' buffer.
|
||||||
* if set 'SC_BUF_DATA', buffer wpos will be 'len'.
|
* 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
|
* @return
|
||||||
*/
|
*/
|
||||||
struct sc_buf sc_buf_wrap(void *data, uint32_t len, int flags);
|
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);
|
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
|
* Put functions, 'val' will be copied to the buffer and write position will
|
||||||
* be advanced.
|
* be advanced.
|
||||||
|
@ -80,11 +80,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -67,11 +67,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -78,11 +78,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -68,11 +68,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --ini coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -67,11 +67,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -80,11 +80,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -87,11 +87,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -80,11 +80,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -80,11 +80,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -80,11 +80,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -80,11 +80,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -81,11 +81,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -77,11 +77,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -100,11 +100,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -81,11 +81,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -504,7 +504,6 @@ void* server(void* arg)
|
|||||||
printf("Received :%d \n", received);
|
printf("Received :%d \n", received);
|
||||||
assert(received == 10000);
|
assert(received == 10000);
|
||||||
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,7 +535,6 @@ void* client(void* arg)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void test_poll()
|
void test_poll()
|
||||||
{
|
{
|
||||||
struct sc_thread thread1;
|
struct sc_thread thread1;
|
||||||
@ -552,7 +550,6 @@ void test_poll()
|
|||||||
assert(sc_thread_term(&thread2) == 0);
|
assert(sc_thread_term(&thread2) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
@ -79,11 +79,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -79,11 +79,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -67,11 +67,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -80,11 +80,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
@ -77,11 +77,11 @@ endif ()
|
|||||||
add_custom_target(coverage_${PROJECT_NAME})
|
add_custom_target(coverage_${PROJECT_NAME})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET coverage_${PROJECT_NAME}
|
TARGET coverage_${PROJECT_NAME}
|
||||||
COMMAND lcov --capture --directory ..
|
COMMAND lcov --capture --directory .
|
||||||
--output-file coverage.info --rc lcov_branch_coverage=1
|
--output-file coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
COMMAND lcov --remove coverage.info '/usr/*' '*example*' '*test*'
|
||||||
--output-file 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
|
COMMAND lcov --list coverage.info --rc lcov_branch_coverage=1 --rc lcov_excl_br_line='assert'
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
add_dependencies(coverage_${PROJECT_NAME} check_${PROJECT_NAME})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user