From patchwork Sat Nov 15 16:19:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 40875 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C1347244FC for ; Sat, 15 Nov 2014 16:19:54 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id l15sf161874wiw.4 for ; Sat, 15 Nov 2014 08:19:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=3odx1Mh8qJT8kDyoTjhvDJvOGxAbvUUPp6Hm+cOtFLE=; b=AM00bwSnHxOg8ZPUKlZHRWs0ZAE8ZODnu92LUtnW8p/hLgfAOax0TX6lJuUDKKLGuh FSwlS+r/lwbSXcSMOSIx0NhhCU1fO27K/l4Wc3fKXABzc3vUw21JoyqDgKdtXWyWVMSS 9dIoITiN7V8fs7+rCDHbFF0ZUge/qb2qeM/Ewb6hLEtLWWVf478dPaI13u2pLWWfO4nh i0rlGzd1tYTGR+Cftdz2fj/eGMA+Y1FuEvczruSyG4KBy27vNs83tP0wdOOXafUNIMlX 6cA+VLqOAiGzlJUAEwLZbm8qjdxodr70Z3nIWfLOBkwE3BEzuMaPjbMvrZ1EQIzHuLbj R+SA== X-Gm-Message-State: ALoCoQmkIDQJzORq13bDoa6mCd1yzJB7+DNtLiP2jntGKXn6onHRjv/1DWWxICahqsBA1fNZH0R7 X-Received: by 10.152.7.73 with SMTP id h9mr231714laa.6.1416068393948; Sat, 15 Nov 2014 08:19:53 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.7 with SMTP id o7ls587163lao.55.gmail; Sat, 15 Nov 2014 08:19:53 -0800 (PST) X-Received: by 10.153.6.9 with SMTP id cq9mr2529712lad.79.1416068393788; Sat, 15 Nov 2014 08:19:53 -0800 (PST) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id s6si45266011laj.90.2014.11.15.08.19.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 15 Nov 2014 08:19:53 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by mail-lb0-f173.google.com with SMTP id n15so14303629lbi.32 for ; Sat, 15 Nov 2014 08:19:53 -0800 (PST) X-Received: by 10.152.37.69 with SMTP id w5mr14336403laj.67.1416068393351; Sat, 15 Nov 2014 08:19:53 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp943598lbc; Sat, 15 Nov 2014 08:19:52 -0800 (PST) X-Received: by 10.224.74.135 with SMTP id u7mr19248793qaj.67.1416068391550; Sat, 15 Nov 2014 08:19:51 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id 69si56067540qgd.50.2014.11.15.08.19.49 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 15 Nov 2014 08:19:50 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xpg4i-0002WD-Gl; Sat, 15 Nov 2014 16:19:48 +0000 Received: from mail-qa0-f42.google.com ([209.85.216.42]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xpg4c-0002W8-Gl for lng-odp@lists.linaro.org; Sat, 15 Nov 2014 16:19:42 +0000 Received: by mail-qa0-f42.google.com with SMTP id j7so1982417qaq.15 for ; Sat, 15 Nov 2014 08:19:37 -0800 (PST) X-Received: by 10.140.104.169 with SMTP id a38mr14252110qgf.35.1416068377246; Sat, 15 Nov 2014 08:19:37 -0800 (PST) Received: from fedora1.holmesfamily.ws ([98.221.136.245]) by mx.google.com with ESMTPSA id u8sm29986648qat.27.2014.11.15.08.19.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 15 Nov 2014 08:19:36 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Sat, 15 Nov 2014 11:19:24 -0500 Message-Id: <1416068364-37527-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 X-Topics: patch Subject: [lng-odp] [PATCH] test: remove use of odp api logging X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mike.holmes@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Free the tests of their dependence on the ODP logging functions. This enables the migration of the ODP logging functions from the ODP public API to the ODP internal API. Signed-off-by: Mike Holmes Reviewed-by: Ciprian Barbu --- test/api_test/Makefile.am | 6 +++ test/api_test/odp_atomic_test.c | 10 ++--- test/api_test/odp_common.c | 3 +- test/api_test/odp_ring_test.c | 62 ++++++++++++++--------------- test/api_test/odp_shm_test.c | 3 +- test/api_test/odp_timer_ping.c | 27 +++++++------ test/test_debug.h | 88 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 148 insertions(+), 51 deletions(-) create mode 100644 test/test_debug.h diff --git a/test/api_test/Makefile.am b/test/api_test/Makefile.am index 5104454..bad7132 100644 --- a/test/api_test/Makefile.am +++ b/test/api_test/Makefile.am @@ -1,6 +1,12 @@ include $(top_srcdir)/test/Makefile.inc bin_PROGRAMS = odp_atomic odp_shm odp_ring odp_timer_ping + +odp_atomic_CFLAGS = $(AM_CFLAGS) -I $(top_srcdir)/test +odp_shm_CFLAGS = $(AM_CFLAGS) -I $(top_srcdir)/test +odp_ring_CFLAGS = $(AM_CFLAGS) -I $(top_srcdir)/test +odp_timer_ping_CFLAGS = $(AM_CFLAGS) -I $(top_srcdir)/test + odp_atomic_LDFLAGS = $(AM_LDFLAGS) -static odp_shm_LDFLAGS = $(AM_LDFLAGS) -static odp_ring_LDFLAGS = $(AM_LDFLAGS) -static diff --git a/test/api_test/odp_atomic_test.c b/test/api_test/odp_atomic_test.c index 3ca7674..f07c962 100644 --- a/test/api_test/odp_atomic_test.c +++ b/test/api_test/odp_atomic_test.c @@ -6,9 +6,9 @@ #include #include -#include #include #include +#include static odp_atomic_u32_t a32u; static odp_atomic_u64_t a64u; @@ -166,12 +166,12 @@ void test_atomic_store(void) int test_atomic_validate(void) { if (odp_atomic_load_u32(&a32u) != U32_INIT_VAL) { - ODP_ERR("Atomic u32 usual functions failed\n"); + LOG_ERR("Atomic u32 usual functions failed\n"); return -1; } if (odp_atomic_load_u64(&a64u) != U64_INIT_VAL) { - ODP_ERR("Atomic u64 usual functions failed\n"); + LOG_ERR("Atomic u64 usual functions failed\n"); return -1; } @@ -247,7 +247,7 @@ int main(int argc, char *argv[]) sscanf(argv[++i], "%d", &pthrdnum); break; default: - ODP_ERR("Invalid option %c\n", c); + LOG_ERR("Invalid option %c\n", c); usage(); goto err_exit; } @@ -273,7 +273,7 @@ int main(int argc, char *argv[]) if ((test_type > 0) && (test_type < TEST_MAX)) { printf("%s\n", test_name[test_type]); } else { - ODP_ERR("Invalid test case [%d]\n", test_type); + LOG_ERR("Invalid test case [%d]\n", test_type); usage(); goto err_exit; } diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c index ed1fc97..329d4d4 100644 --- a/test/api_test/odp_common.c +++ b/test/api_test/odp_common.c @@ -16,6 +16,7 @@ #include #include #include +#include /* Globals */ @@ -57,7 +58,7 @@ int odp_test_global_init(void) memset(thread_tbl, 0, sizeof(thread_tbl)); if (odp_init_global(NULL, NULL)) { - ODP_ERR("ODP global init failed.\n"); + LOG_ERR("ODP global init failed.\n"); return -1; } diff --git a/test/api_test/odp_ring_test.c b/test/api_test/odp_ring_test.c index eb1f301..a55a0cd 100644 --- a/test/api_test/odp_ring_test.c +++ b/test/api_test/odp_ring_test.c @@ -48,9 +48,9 @@ #include #include #include -#include #include #include +#include #define RING_SIZE 4096 #define MAX_BULK 32 @@ -66,7 +66,7 @@ static int test_ring_basic(odph_ring_t *r) /* alloc dummy object pointers */ src = malloc(RING_SIZE*2*sizeof(void *)); if (src == NULL) { - ODP_ERR("failed to allocate test ring src memory\n"); + LOG_ERR("failed to allocate test ring src memory\n"); goto fail; } for (i = 0; i < RING_SIZE*2; i++) @@ -77,7 +77,7 @@ static int test_ring_basic(odph_ring_t *r) /* alloc some room for copied objects */ dst = malloc(RING_SIZE*2*sizeof(void *)); if (dst == NULL) { - ODP_ERR("failed to allocate test ring dst memory\n"); + LOG_ERR("failed to allocate test ring dst memory\n"); goto fail; } @@ -89,7 +89,7 @@ static int test_ring_basic(odph_ring_t *r) ret = odph_ring_sp_enqueue_burst(r, cur_src, 1); cur_src += 1; if ((ret & ODPH_RING_SZ_MASK) != 1) { - ODP_ERR("sp_enq for 1 obj failed\n"); + LOG_ERR("sp_enq for 1 obj failed\n"); goto fail; } @@ -97,14 +97,14 @@ static int test_ring_basic(odph_ring_t *r) ret = odph_ring_sp_enqueue_burst(r, cur_src, 2); cur_src += 2; if ((ret & ODPH_RING_SZ_MASK) != 2) { - ODP_ERR("sp_enq for 2 obj failed\n"); + LOG_ERR("sp_enq for 2 obj failed\n"); goto fail; } printf("enqueue MAX_BULK objs\n"); ret = odph_ring_sp_enqueue_burst(r, cur_src, MAX_BULK); if ((ret & ODPH_RING_SZ_MASK) != MAX_BULK) { - ODP_ERR("sp_enq for %d obj failed\n", MAX_BULK); + LOG_ERR("sp_enq for %d obj failed\n", MAX_BULK); goto fail; } @@ -112,7 +112,7 @@ static int test_ring_basic(odph_ring_t *r) ret = odph_ring_sc_dequeue_burst(r, cur_dst, 1); cur_dst += 1; if ((ret & ODPH_RING_SZ_MASK) != 1) { - ODP_ERR("sc_deq for 1 obj failed\n"); + LOG_ERR("sc_deq for 1 obj failed\n"); goto fail; } @@ -120,7 +120,7 @@ static int test_ring_basic(odph_ring_t *r) ret = odph_ring_sc_dequeue_burst(r, cur_dst, 2); cur_dst += 2; if ((ret & ODPH_RING_SZ_MASK) != 2) { - ODP_ERR("sc_deq for 2 obj failed\n"); + LOG_ERR("sc_deq for 2 obj failed\n"); goto fail; } @@ -128,13 +128,13 @@ static int test_ring_basic(odph_ring_t *r) ret = odph_ring_sc_dequeue_burst(r, cur_dst, MAX_BULK); cur_dst += MAX_BULK; if ((ret & ODPH_RING_SZ_MASK) != MAX_BULK) { - ODP_ERR("sc_deq for %d obj failed\n", MAX_BULK); + LOG_ERR("sc_deq for %d obj failed\n", MAX_BULK); goto fail; } /* check data */ if (memcmp(src, dst, cur_dst - dst)) { - ODP_ERR("data after dequeue is not the same\n"); + LOG_ERR("data after dequeue is not the same\n"); goto fail; } @@ -147,46 +147,46 @@ static int test_ring_basic(odph_ring_t *r) ret = odph_ring_mp_enqueue_bulk(r, cur_src, 1); cur_src += 1; if (ret != 0) { - ODP_ERR("mp_enq for 1 obj failed\n"); + LOG_ERR("mp_enq for 1 obj failed\n"); goto fail; } printf("enqueue 2 objs\n"); ret = odph_ring_mp_enqueue_bulk(r, cur_src, 2); cur_src += 2; if (ret != 0) { - ODP_ERR("mp_enq for 2 obj failed\n"); + LOG_ERR("mp_enq for 2 obj failed\n"); goto fail; } printf("enqueue MAX_BULK objs\n"); ret = odph_ring_mp_enqueue_bulk(r, cur_src, MAX_BULK); if (ret != 0) { - ODP_ERR("mp_enq for %d obj failed\n", MAX_BULK); + LOG_ERR("mp_enq for %d obj failed\n", MAX_BULK); goto fail; } printf("dequeue 1 obj\n"); ret = odph_ring_mc_dequeue_bulk(r, cur_dst, 1); cur_dst += 1; if (ret != 0) { - ODP_ERR("mc_deq for 1 obj failed\n"); + LOG_ERR("mc_deq for 1 obj failed\n"); goto fail; } printf("dequeue 2 objs\n"); ret = odph_ring_mc_dequeue_bulk(r, cur_dst, 2); cur_dst += 2; if (ret != 0) { - ODP_ERR("mc_deq for 2 obj failed\n"); + LOG_ERR("mc_deq for 2 obj failed\n"); goto fail; } printf("dequeue MAX_BULK objs\n"); ret = odph_ring_mc_dequeue_bulk(r, cur_dst, MAX_BULK); cur_dst += MAX_BULK; if (ret != 0) { - ODP_ERR("mc_deq for %d obj failed\n", MAX_BULK); + LOG_ERR("mc_deq for %d obj failed\n", MAX_BULK); goto fail; } /* check data */ if (memcmp(src, dst, cur_dst - dst)) { - ODP_ERR("data after dequeue is not the same\n"); + LOG_ERR("data after dequeue is not the same\n"); goto fail; } @@ -200,30 +200,30 @@ static int test_ring_basic(odph_ring_t *r) ret = odph_ring_mp_enqueue_bulk(r, cur_src, num_elems); cur_src += num_elems; if (ret != 0) { - ODP_ERR("Cannot enqueue\n"); + LOG_ERR("Cannot enqueue\n"); goto fail; } ret = odph_ring_mp_enqueue_bulk(r, cur_src, num_elems); if (ret != -EDQUOT) { - ODP_ERR("Watermark not exceeded\n"); + LOG_ERR("Watermark not exceeded\n"); goto fail; } ret = odph_ring_mc_dequeue_bulk(r, cur_dst, num_elems); cur_dst += num_elems; if (ret != 0) { - ODP_ERR("Cannot dequeue\n"); + LOG_ERR("Cannot dequeue\n"); goto fail; } ret = odph_ring_mc_dequeue_bulk(r, cur_dst, num_elems); cur_dst += num_elems; if (ret != 0) { - ODP_ERR("Cannot dequeue2\n"); + LOG_ERR("Cannot dequeue2\n"); goto fail; } /* check data */ if (memcmp(src, dst, cur_dst - dst)) { - ODP_ERR("data after dequeue is not the same\n"); + LOG_ERR("data after dequeue is not the same\n"); goto fail; } @@ -253,7 +253,7 @@ static int producer_fn(void) /* alloc dummy object pointers */ src = malloc(MAX_BULK*2*sizeof(void *)); if (src == NULL) { - ODP_ERR("failed to allocate producer memory.\n"); + LOG_ERR("failed to allocate producer memory.\n"); return -1; } for (i = 0; i < MAX_BULK; i++) @@ -277,7 +277,7 @@ static int consumer_fn(void) /* alloc dummy object pointers */ src = malloc(MAX_BULK*2*sizeof(void *)); if (src == NULL) { - ODP_ERR("failed to allocate consumer memory.\n"); + LOG_ERR("failed to allocate consumer memory.\n"); return -1; } @@ -340,7 +340,7 @@ static void test_ring_stress(stress_type_t type) case one_deq_rest_enq: case one_enq_rest_deq:/*TBD*/ default: - ODP_ERR("Invalid stress type or test case yet not supported\n"); + LOG_ERR("Invalid stress type or test case yet not supported\n"); } } @@ -371,20 +371,20 @@ static void *test_ring(void *arg) 0 /* not used, alignement taken care inside func : todo */); if (r == NULL) { - ODP_ERR("ring create failed\n"); + LOG_ERR("ring create failed\n"); result = -1; break; } /* lookup ring from its name */ if (odph_ring_lookup(ring_name) != r) { - ODP_ERR("ring lookup failed\n"); + LOG_ERR("ring lookup failed\n"); result = -1; break; } /* basic operations */ if (test_ring_basic(r) < 0) { - ODP_ERR("ring basic enqueue/dequeu ops failed\n"); + LOG_ERR("ring basic enqueue/dequeu ops failed\n"); result = -1; } @@ -401,7 +401,7 @@ static void *test_ring(void *arg) break; default: - ODP_ERR("Invalid test case [%d]\n", parg->thrdarg.testcase); + LOG_ERR("Invalid test case [%d]\n", parg->thrdarg.testcase); result = -1; break; } @@ -447,12 +447,12 @@ int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED) 0 /* not used, alignement taken care inside func : todo */); if (r_stress == NULL) { - ODP_ERR("ring create failed\n"); + LOG_ERR("ring create failed\n"); goto fail; } /* lookup ring from its name */ if (odph_ring_lookup(ring_name) != r_stress) { - ODP_ERR("ring lookup failed\n"); + LOG_ERR("ring lookup failed\n"); goto fail; } #endif diff --git a/test/api_test/odp_shm_test.c b/test/api_test/odp_shm_test.c index 6208e78..5cfde7d 100644 --- a/test/api_test/odp_shm_test.c +++ b/test/api_test/odp_shm_test.c @@ -14,6 +14,7 @@ #include #include #include +#include static void *run_thread(void *arg) { @@ -32,7 +33,7 @@ static void *run_thread(void *arg) printf(" [%i] shared data at %p\n", thr, test_shared_data); break; default: - ODP_ERR("Invalid test case [%d]\n", parg->testcase); + LOG_ERR("Invalid test case [%d]\n", parg->testcase); } fflush(stdout); diff --git a/test/api_test/odp_timer_ping.c b/test/api_test/odp_timer_ping.c index 65e3834..7704181 100644 --- a/test/api_test/odp_timer_ping.c +++ b/test/api_test/odp_timer_ping.c @@ -37,6 +37,7 @@ #include #include #include +#include #define MSG_POOL_SIZE (4*1024*1024) #define BUF_SIZE 8 @@ -98,7 +99,7 @@ static int listen_to_pingack(void) sd = socket(PF_INET, SOCK_RAW, proto->p_proto); if (sd < 0) { - ODP_ERR("Listener socket open failed\n"); + LOG_ERR("Listener socket open failed\n"); err = -1; goto err; } @@ -116,7 +117,7 @@ static int listen_to_pingack(void) ODP_DBG(" Rx timeout msg cnt [%d]\n", i); err = -1; } else if (res == -1) { - ODP_ERR("recvfrom error"); + LOG_ERR("recvfrom error"); err = -1; goto err; } else { @@ -130,7 +131,7 @@ static int listen_to_pingack(void) /* pkt rxvd therefore cancel the timeout */ if (odp_timer_cancel_tmo(test_timer_ping, test_ping_tmo) != 0) { - ODP_ERR("cancel_tmo failed ..exiting listner thread\n"); + LOG_ERR("cancel_tmo failed ..exiting listner thread\n"); /* avoid exiting from here even if tmo * failed for current ping, * allow subsequent ping_rx request */ @@ -166,17 +167,17 @@ static int send_ping_request(struct sockaddr_in *addr) sd = socket(PF_INET, SOCK_RAW, proto->p_proto); if (sd < 0) { - ODP_ERR("Sender socket open failed\n"); + LOG_ERR("Sender socket open failed\n"); return -1; } if (setsockopt(sd, SOL_IP, IP_TTL, &val, sizeof(val)) != 0) { - ODP_ERR("Error setting TTL option\n"); + LOG_ERR("Error setting TTL option\n"); err = -1; goto err; } if (fcntl(sd, F_SETFL, O_NONBLOCK) != 0) { - ODP_ERR("Request for nonblocking I/O failed\n"); + LOG_ERR("Request for nonblocking I/O failed\n"); err = -1; goto err; } @@ -201,7 +202,7 @@ static int send_ping_request(struct sockaddr_in *addr) /* txmit the pkt */ if (sendto(sd, &pckt, sizeof(pckt), 0, (struct sockaddr *)addr, sizeof(*addr)) <= 0) { - ODP_ERR("sendto operation failed msg_cnt [%d]..exiting sender thread\n", i); + LOG_ERR("sendto operation failed msg_cnt [%d]..exiting sender thread\n", i); err = -1; goto err; } @@ -258,7 +259,7 @@ static void *send_ping(void *arg) parg->result = -1; break; default: - ODP_ERR("Invalid test case [%d]\n", parg->thrdarg.testcase); + LOG_ERR("Invalid test case [%d]\n", parg->thrdarg.testcase); } fflush(stdout); @@ -281,7 +282,7 @@ static void *rx_ping(void *arg) parg->result = -1; break; default: - ODP_ERR("Invalid test case [%d]\n", parg->thrdarg.testcase); + LOG_ERR("Invalid test case [%d]\n", parg->thrdarg.testcase); } fflush(stdout); @@ -294,7 +295,7 @@ static int ping_init(int count, char *name[]) { struct hostent *hname; if (count != 2) { - ODP_ERR("usage: %s \n", name[0]); + LOG_ERR("usage: %s \n", name[0]); return -1; } @@ -342,7 +343,7 @@ int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED) ODP_CACHE_LINE_SIZE, ODP_BUFFER_TYPE_RAW); if (pool == ODP_BUFFER_POOL_INVALID) { - ODP_ERR("Pool create failed.\n"); + LOG_ERR("Pool create failed.\n"); return -1; } @@ -353,7 +354,7 @@ int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED) NULL); if (queue == ODP_QUEUE_INVALID) { - ODP_ERR("Timer queue create failed.\n"); + LOG_ERR("Timer queue create failed.\n"); return -1; } @@ -363,7 +364,7 @@ int main(int argc ODP_UNUSED, char *argv[] ODP_UNUSED) MAXUS*ODP_TIME_USEC); if (test_timer_ping == ODP_TIMER_INVALID) { - ODP_ERR("Timer create failed.\n"); + LOG_ERR("Timer create failed.\n"); return -1; } diff --git a/test/test_debug.h b/test/test_debug.h new file mode 100644 index 0000000..35e21d9 --- /dev/null +++ b/test/test_debug.h @@ -0,0 +1,88 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +/** + * @file + * + * example debug + */ + +#ifndef TEST_DEBUG_H_ +#define TEST_DEBUG_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef TEST_DEBUG_PRINT +#define TEST_DEBUG_PRINT 1 +#endif + +/** + * log level. + */ +typedef enum example_log_level { + TEST_LOG_DBG, + TEST_LOG_ERR, + TEST_LOG_ABORT +} example_log_level_e; + +/** + * default LOG macro. + */ +#define TEST_LOG(level, fmt, ...) \ +do { \ + switch (level) { \ + case TEST_LOG_ERR: \ + fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \ + __LINE__, __func__, ##__VA_ARGS__); \ + break; \ + case TEST_LOG_DBG: \ + if (TEST_DEBUG_PRINT == 1) \ + fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \ + __LINE__, __func__, ##__VA_ARGS__); \ + break; \ + case TEST_LOG_ABORT: \ + fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \ + __LINE__, __func__, ##__VA_ARGS__); \ + abort(); \ + break; \ + default: \ + fprintf(stderr, "Unknown LOG level"); \ + break;\ + } \ +} while (0) + +/** + * Debug printing macro, which prints output when DEBUG flag is set. + */ +#define LOG_DBG(fmt, ...) \ + TEST_LOG(TEST_LOG_DBG, fmt, ##__VA_ARGS__) + +/** + * Print output to stderr (file, line and function). + */ +#define LOG_ERR(fmt, ...) \ + TEST_LOG(TEST_LOG_ERR, fmt, ##__VA_ARGS__) + +/** + * Print output to stderr (file, line and function), + * then abort. + */ +#define LOG_ABORT(fmt, ...) \ + TEST_LOG(TEST_LOG_ABORT, fmt, ##__VA_ARGS__) + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif