From patchwork Thu Jan 29 11:01:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 43921 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7A80324119 for ; Thu, 29 Jan 2015 11:01:56 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id b6sf18354800lbj.0 for ; Thu, 29 Jan 2015 03:01:55 -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:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=nahs7qy/rZPTu3T0Gn/MnuhygednEUlEZbNoVlYueFk=; b=NgposUhmezcH8PMPyvlH/VX45Vajxy7GS9bAx0N9ELqE73aCT7B1wCTe5TJilmmVAJ d3SK1VDXNjNc2aW8m9S37exmh6jDZXMcVtH+mpR0nwfNhO9GACB2Ra2HW68c90Q8ms7Z iiBIdwCtTjsTghm3gnmY/2+5jZLZxNV3Ap0zVk1jqNepCYKaP45M9/bEf/vMZcxx9NZ4 7ndibvfhuNxz4fljoEf8HOn9UTbhH+z2f6mFR0wBB4WNG5sfSVFy3KxoaxM2cvREec6G GmFlxe7UDphRWdOIeUcBQoQ2CWVMso0JyzFNBOEZno/It6xAQt0JNnESItSxqDHnMXxH BiaA== X-Gm-Message-State: ALoCoQkWvtSiHbHEljFZEki7MeplENVJfPGuGte5kpAhgrXAF1nxzgUg9n5SwNzqwnasQ58lwgWP X-Received: by 10.112.154.233 with SMTP id vr9mr1720288lbb.9.1422529315422; Thu, 29 Jan 2015 03:01:55 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.73 with SMTP id c9ls285588lae.74.gmail; Thu, 29 Jan 2015 03:01:55 -0800 (PST) X-Received: by 10.112.171.168 with SMTP id av8mr13549690lbc.88.1422529315275; Thu, 29 Jan 2015 03:01:55 -0800 (PST) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id xp1si5433272lbb.14.2015.01.29.03.01.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 Jan 2015 03:01:55 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by mail-lb0-f182.google.com with SMTP id l4so26688124lbv.13 for ; Thu, 29 Jan 2015 03:01:55 -0800 (PST) X-Received: by 10.112.135.196 with SMTP id pu4mr13562819lbb.41.1422529315133; Thu, 29 Jan 2015 03:01:55 -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.35.133 with SMTP id h5csp1724133lbj; Thu, 29 Jan 2015 03:01:54 -0800 (PST) X-Received: by 10.140.85.9 with SMTP id m9mr26843qgd.7.1422529313468; Thu, 29 Jan 2015 03:01:53 -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 e7si9709474qaw.116.2015.01.29.03.01.51 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 29 Jan 2015 03:01:53 -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 1YGmr7-0007xG-AB; Thu, 29 Jan 2015 11:01:49 +0000 Received: from mail-lb0-f180.google.com ([209.85.217.180]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YGmqk-0007sn-OH for lng-odp@lists.linaro.org; Thu, 29 Jan 2015 11:01:26 +0000 Received: by mail-lb0-f180.google.com with SMTP id b6so26663880lbj.11 for ; Thu, 29 Jan 2015 03:01:21 -0800 (PST) X-Received: by 10.112.37.161 with SMTP id z1mr13456745lbj.87.1422529280940; Thu, 29 Jan 2015 03:01:20 -0800 (PST) Received: from macmini.lan (78-82-118-111.tn.glocalnet.net. [78.82.118.111]) by mx.google.com with ESMTPSA id s7sm2045761las.17.2015.01.29.03.01.19 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jan 2015 03:01:19 -0800 (PST) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Thu, 29 Jan 2015 12:01:12 +0100 Message-Id: <1422529273-31282-5-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1422529273-31282-1-git-send-email-ola.liljedahl@linaro.org> References: <1422529273-31282-1-git-send-email-ola.liljedahl@linaro.org> X-Topics: timers patch Subject: [lng-odp] [PATCHv3 4/5] validation: odp_timer.c: cunit cleanup 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: ola.liljedahl@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.182 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 Use CU_ASSERT_FATAL instead of plain assert so to work better with the cunit test framework. Use LOG_DBG instead of printf. Remove some unnecessary printouts. Ensure we run at least one worker thread. Signed-off-by: Ola Liljedahl --- (This document/code contribution attached is provided under the terms of agreement LES-LTM-21309) test/validation/odp_timer.c | 50 ++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/test/validation/odp_timer.c b/test/validation/odp_timer.c index ce5ffb1..d78f6b6 100644 --- a/test/validation/odp_timer.c +++ b/test/validation/odp_timer.c @@ -10,7 +10,6 @@ /* For rand_r and nanosleep */ #define _POSIX_C_SOURCE 200112L -#include #include #include #include @@ -54,8 +53,7 @@ struct test_timer { /* @private Handle a received (timeout) event */ static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick) { - /* Use assert() for internal correctness checks of test program */ - assert(ev != ODP_EVENT_INVALID); + CU_ASSERT_FATAL(ev != ODP_EVENT_INVALID); /* Internal error */ if (odp_event_type(ev) != ODP_EVENT_TIMEOUT) { /* Not a timeout event */ CU_FAIL("Unexpected event type received"); @@ -233,14 +231,14 @@ static void *worker_entrypoint(void *arg) CU_FAIL("odp_timer_free"); } - printf("Thread %u: %u timers set\n", thr, nset); - printf("Thread %u: %u timers reset\n", thr, nreset); - printf("Thread %u: %u timers cancelled\n", thr, ncancel); - printf("Thread %u: %u timers reset/cancelled too late\n", - thr, ntoolate); - printf("Thread %u: %u timeouts received\n", thr, nrcv); - printf("Thread %u: %u stale timeout(s) after odp_timer_free()\n", - thr, nstale); + LOG_DBG("Thread %u: %u timers set\n", thr, nset); + LOG_DBG("Thread %u: %u timers reset\n", thr, nreset); + LOG_DBG("Thread %u: %u timers cancelled\n", thr, ncancel); + LOG_DBG("Thread %u: %u timers reset/cancelled too late\n", + thr, ntoolate); + LOG_DBG("Thread %u: %u timeouts received\n", thr, nrcv); + LOG_DBG("Thread %u: %u stale timeout(s) after odp_timer_free()\n", + thr, nstale); /* Delay some more to ensure timeouts for expired timers can be * received */ @@ -264,7 +262,7 @@ static void *worker_entrypoint(void *arg) if (ev != ODP_EVENT_INVALID) CU_FAIL("Unexpected event received"); - printf("Thread %u: exiting\n", thr); + LOG_DBG("Thread %u: exiting\n", thr); return NULL; } @@ -273,9 +271,13 @@ static void test_odp_timer_all(void) { odp_pool_param_t params; odp_timer_pool_param_t tparam; - /* This is a stressfull test - need to reserve some cpu cycles - * @TODO move to test/performance */ - int num_workers = min(odp_sys_cpu_count()-1, MAX_WORKERS); + /* Reserve at least one core for running other processes so the timer + * test hopefully can run undisturbed and thus get better timing + * results. */ + int num_workers = min(odp_sys_cpu_count() - 1, MAX_WORKERS); + /* On a single-CPU machine run at least one thread */ + if (num_workers < 1) + num_workers = 1; /* Create timeout pools */ params.tmo.num = (NTIMERS + 1) * num_workers; @@ -309,19 +311,11 @@ static void test_odp_timer_all(void) CU_ASSERT(tpinfo.param.res_ns == RES); CU_ASSERT(tpinfo.param.min_tmo == MIN); CU_ASSERT(tpinfo.param.max_tmo == MAX); - printf("Timer pool\n"); - printf("----------\n"); - printf(" name: %s\n", tpinfo.name); - printf(" resolution: %"PRIu64" ns (%"PRIu64" us)\n", - tpinfo.param.res_ns, tpinfo.param.res_ns / 1000); - printf(" min tmo: %"PRIu64" ns\n", tpinfo.param.min_tmo); - printf(" max tmo: %"PRIu64" ns\n", tpinfo.param.max_tmo); - printf("\n"); - - printf("#timers..: %u\n", NTIMERS); - printf("Tmo range: %u ms (%"PRIu64" ticks)\n", RANGE_MS, - odp_timer_ns_to_tick(tp, 1000000ULL * RANGE_MS)); - printf("\n"); + CU_ASSERT(strcmp(tpinfo.name, NAME) == 0); + + LOG_DBG("#timers..: %u\n", NTIMERS); + LOG_DBG("Tmo range: %u ms (%"PRIu64" ticks)\n", RANGE_MS, + odp_timer_ns_to_tick(tp, 1000000ULL * RANGE_MS)); uint64_t tick; for (tick = 0; tick < 1000000000000ULL; tick += 1000000ULL) {