diff --git a/c/brlib/src/debug.c b/c/brlib/src/debug.c index ad7d665..164a04b 100644 --- a/c/brlib/src/debug.c +++ b/c/brlib/src/debug.c @@ -124,22 +124,3 @@ void debug(int lev, bool timestamp, int indent, const char *src, if (flush) fflush(stream); } - -#ifdef BIN_debug -#include - -int main() -{ - int foo=1; - debug_init(5); - - log(0, "log0=%d\n", foo++); - log(1, "log1=%d\n", foo++); - log(2, "log2=%d\n", foo++); - log_i(2, "log_i 2=%d\n", foo++); - log_i(5, "log_i 5=%d\n", foo++); - log_i(6, "log_i 6=%d\n", foo++); - log_it(4, "log_it 4=%d\n", foo++); - log_f(1, "log_f 5=%d\n", foo++); -} -#endif diff --git a/c/brlib/src/pool.c b/c/brlib/src/pool.c index d1653f1..a423141 100644 --- a/c/brlib/src/pool.c +++ b/c/brlib/src/pool.c @@ -161,59 +161,3 @@ void pool_destroy(pool_t *pool) # endif free(pool); } - -#ifdef BIN_pool -struct d { - u16 data1; - char c; - struct list_head list; -}; - -static LIST_HEAD (head); - -int main(int ac, char**av) -{ - pool_t *pool; - int total; - int action=0; - u16 icur=0; - char ccur='z'; - struct d *elt; - - debug_init(3); - log_f(1, "%s: sizeof(d)=%lu sizeof(*d)=%lu off=%lu\n", *av, sizeof(elt), - sizeof(*elt), offsetof(struct d, list)); - - if ((pool = pool_create("dummy", 3, sizeof(*elt)))) { - pool_stats(pool); - for (int cur=1; curdata1 = icur++; - elt->c = ccur--; - list_add(&elt->list, &head); - } - pool_stats(pool); - action = 1; - } else { /* remove one elt from list */ - log_f(2, "deleting %d elements\n", total); - for (int i = 0; i < total; ++i) { - if (!list_empty(&head)) { - elt = list_last_entry(&head, struct d, list); - printf("elt=[%d, %c]\n", elt->data1, elt->c); - list_del(&elt->list); - pool_add(pool, elt); - } - } - pool_stats(pool); - action = 0; - } - } - } - pool_stats(pool); - pool_destroy(pool); -} -#endif diff --git a/c/brlib/test/test/tst-debug.c b/c/brlib/test/test/tst-debug.c new file mode 100644 index 0000000..f294c89 --- /dev/null +++ b/c/brlib/test/test/tst-debug.c @@ -0,0 +1,17 @@ +#include +#include "debug.h" + +int main() +{ + int foo=1; + debug_init(5); + + log(0, "log0=%d\n", foo++); + log(1, "log1=%d\n", foo++); + log(2, "log2=%d\n", foo++); + log_i(2, "log_i 2=%d\n", foo++); + log_i(5, "log_i 5=%d\n", foo++); + log_i(6, "log_i 6=%d\n", foo++); + log_it(4, "log_it 4=%d\n", foo++); + log_f(1, "log_f 5=%d\n", foo++); +} diff --git a/c/brlib/test/tst-pool.c b/c/brlib/test/tst-pool.c new file mode 100644 index 0000000..14ce9f7 --- /dev/null +++ b/c/brlib/test/tst-pool.c @@ -0,0 +1,57 @@ +#include +#include "bits.h" +#include "pool.h" + +struct d { + u16 data1; + char c; + struct list_head list; +}; + +static LIST_HEAD (head); + +int main(int ac, char**av) +{ + pool_t *pool; + int total; + int action=0; + u16 icur=0; + char ccur='z'; + struct d *elt; + + debug_init(3); + log_f(1, "%s: sizeof(d)=%lu sizeof(*d)=%lu off=%lu\n", *av, sizeof(elt), + sizeof(*elt), offsetof(struct d, list)); + + if ((pool = pool_create("dummy", 3, sizeof(*elt)))) { + pool_stats(pool); + for (int cur=1; curdata1 = icur++; + elt->c = ccur--; + list_add(&elt->list, &head); + } + pool_stats(pool); + action = 1; + } else { /* remove one elt from list */ + log_f(2, "deleting %d elements\n", total); + for (int i = 0; i < total; ++i) { + if (!list_empty(&head)) { + elt = list_last_entry(&head, struct d, list); + printf("elt=[%d, %c]\n", elt->data1, elt->c); + list_del(&elt->list); + pool_add(pool, elt); + } + } + pool_stats(pool); + action = 0; + } + } + } + pool_stats(pool); + pool_destroy(pool); +}