#include <stdio.h>
#include <string.h>
+#include <ecoli_log.h>
#include <ecoli_malloc.h>
#include <ecoli_test.h>
#include <ecoli_tk.h>
ret = 0;
if (expected == NULL && ret != 0)
- printf("tk should not match but matches <%s>\n", s);
+ ec_log(EC_LOG_ERR, "tk should not match but matches <%s>\n", s);
if (expected != NULL && ret != 0)
- printf("tk should match <%s> but matches <%s>\n",
+ ec_log(EC_LOG_ERR, "tk should match <%s> but matches <%s>\n",
expected, s);
ec_parsed_tk_free(p);
ret = 0;
if (expected == NULL && ret != 0)
- printf("tk should not complete but completes with <%s>\n", s);
+ ec_log(EC_LOG_ERR,
+ "tk should not complete but completes with <%s>\n", s);
if (expected != NULL && ret != 0)
- printf("tk should complete with <%s> but completes with <%s>\n",
+ ec_log(EC_LOG_ERR,
+ "tk should complete with <%s> but completes with <%s>\n",
expected, s);
ec_completed_tk_free(p);
ret = hdr + 1;
}
- printf("%s:%d: info: malloc(%zd) -> %p\n", file, line, size, ret);
+ ec_log(EC_LOG_INFO, "%s:%d: info: malloc(%zd) -> %p\n",
+ file, line, size, ret);
return ret;
}
(void)file;
(void)line;
- printf("%s:%d: info: free(%p)\n", file, line, ptr);
+ ec_log(EC_LOG_INFO, "%s:%d: info: free(%p)\n", file, line, ptr);
if (ptr == NULL)
return;
hdr = (ptr - sizeof(*hdr));
if (hdr->cookie != 0x12345678) {
- printf("%s:%d: error: free(%p): bad start cookie\n",
+ ec_log(EC_LOG_ERR, "%s:%d: error: free(%p): bad start cookie\n",
file, line, ptr);
abort();
}
}
if (h == NULL) {
- printf("%s:%d: error: free(%p): bad ptr\n",
+ ec_log(EC_LOG_ERR, "%s:%d: error: free(%p): bad ptr\n",
file, line, ptr);
abort();
}
if (ptr != NULL) {
if (hdr->cookie != 0x12345678) {
- printf("%s:%d: error: realloc(%p): bad start cookie\n",
+ ec_log(EC_LOG_ERR, "%s:%d: error: realloc(%p): bad start cookie\n",
file, line, ptr);
abort();
}
}
if (h == NULL) {
- printf("%s:%d: error: realloc(%p): bad ptr\n",
+ ec_log(EC_LOG_ERR, "%s:%d: error: realloc(%p): bad ptr\n",
file, line, ptr);
abort();
}
TAILQ_INSERT_TAIL(&debug_alloc_hdr_list, hdr, next);
}
- printf("%s:%d: info: realloc(%p, %zd) -> %p\n",
+ ec_log(EC_LOG_INFO, "%s:%d: info: realloc(%p, %zd) -> %p\n",
file, line, ptr, size, ret);
return ret;
struct debug_alloc_hdr *hdr;
TAILQ_FOREACH(hdr, &debug_alloc_hdr_list, next) {
- printf("%s:%d: error: memory leak size=%zd ptr=%p\n",
+ ec_log(EC_LOG_ERR, "%s:%d: error: memory leak size=%zd ptr=%p\n",
hdr->file, hdr->line, hdr->size, hdr + 1);
}
}
+/* XXX todo */
/* int ec_test_check_tk_complete_list(const struct ec_tk *tk, */
/* const char *input, ...) */
/* register a new malloc to trac memleaks */
if (ec_malloc_register(debug_malloc, debug_free, debug_realloc) < 0) {
- printf("cannot register new malloc\n");
+ ec_log(EC_LOG_ERR, "cannot register new malloc\n");
return -1;
}
TAILQ_FOREACH(test, &test_list, next) {
if (test->test() == 0) {
- printf("== test %-20s success\n", test->name);
+ ec_log(EC_LOG_INFO, "== test %-20s success\n",
+ test->name);
} else {
- printf("== test %-20s failed\n", test->name);
+ ec_log(EC_LOG_INFO, "== test %-20s failed\n",
+ test->name);
ret = -1;
}
}