From patchwork Thu Dec 17 16:31:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 58608 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp475451lbb; Thu, 17 Dec 2015 08:35:00 -0800 (PST) X-Received: by 10.140.106.201 with SMTP id e67mr69148900qgf.80.1450370100570; Thu, 17 Dec 2015 08:35:00 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id c129si11974553qha.15.2015.12.17.08.35.00; Thu, 17 Dec 2015 08:35:00 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 0C9986161C; Thu, 17 Dec 2015 16:35:00 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=asaMf4Cq; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,T_DKIM_INVALID,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 174D261636; Thu, 17 Dec 2015 16:32:25 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id B6CE361636; Thu, 17 Dec 2015 16:32:20 +0000 (UTC) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com [209.85.217.171]) by lists.linaro.org (Postfix) with ESMTPS id BF6A06161C for ; Thu, 17 Dec 2015 16:31:45 +0000 (UTC) Received: by mail-lb0-f171.google.com with SMTP id u9so48202456lbp.2 for ; Thu, 17 Dec 2015 08:31:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=upbXqBMTNqum3/USv87hpMweid+94PKgnlXgQiaM0JA=; b=asaMf4Cq3EJJUeM2wRhM5rNhEtMcqORWlyanc+1b8x/2/Vz8f5h0mU1TDm/oJs/8YI G4iqbN3wEbIVAulrQVKONXBTZR/4dUfOSETT1QKJkHm6DAFSpxqAiXYty7gLwUZbbPxr sMLgjk5Aa0fqVHTwRe47Y2pwvQWxCZ6MPTdwg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=upbXqBMTNqum3/USv87hpMweid+94PKgnlXgQiaM0JA=; b=PS6BkHwu+m5MS8Hm2wMJYyjrbV/0Hprg9fMaews09TghGEQKK3scBoOcEQJbq8dGbS j4vnVBGvPTSPvW/vHLmPnKLNsEWzNkTTSki/K1aQv5TeeBMAqjjUeC7Skku6DyOxSMtv ORmaFi5onM6Tv3h3fZS5pU/pGshZyDIOiDbsGBE0/sGpoIO+BiFAyXrkgOQWUQMpXEUK cF+mY9WMRG89A7p/zCsBspvvm717tVvkBK2SrBpl/8zYMq35Re3i///QtMozHEtY15LF iLJbWQJ1oXpxJQydtHdfA9VTy8qCNwJC7Zfx4eoLFcQxlnhvEChjerOZnE7e4dhdSIEf m8Og== X-Gm-Message-State: ALoCoQm1ApkkaKRTlCx+cS3jVCyFdidQhL9e6QxrHN0TfX6cr9SEBKWreJjaJwVmgdKzSp6LCaKncqVXfUkcy3jxs28r7KJzaw== X-Received: by 10.112.167.131 with SMTP id zo3mr21968974lbb.91.1450369904618; Thu, 17 Dec 2015 08:31:44 -0800 (PST) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id u12sm2030563lbk.45.2015.12.17.08.31.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Dec 2015 08:31:43 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Thu, 17 Dec 2015 18:31:28 +0200 Message-Id: <1450369889-4310-6-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450369889-4310-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1450369889-4310-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v4 5/6] validation: time: add test for odp_time_local_res() and use resolution X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" 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" This function is used to get resolution, test uses it to check other APIs. Signed-off-by: Ivan Khoronzhuk --- test/validation/time/time.c | 46 ++++++++++++++++++++++++++++++--------------- test/validation/time/time.h | 1 + 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/test/validation/time/time.c b/test/validation/time/time.c index ce6666f..0fe8c5a 100644 --- a/test/validation/time/time.c +++ b/test/validation/time/time.c @@ -8,9 +8,12 @@ #include "odp_cunit_common.h" #include "time.h" -#define TOLERANCE 1 #define BUSY_LOOP_CNT 30000000 /* used for t > min resolution */ #define BUSY_LOOP_CNT_LONG 12000000000 /* used for t > 4 sec */ +#define MIN_TIME_RATE 32000 +#define MAX_TIME_RATE 15000000000 + +static uint64_t res; void time_test_odp_constants(void) { @@ -22,6 +25,18 @@ void time_test_odp_constants(void) CU_ASSERT(ns == ODP_TIME_USEC_IN_NS); } +void time_test_res(void) +{ + uint64_t rate; + + rate = odp_time_local_res(); + CU_ASSERT(rate > MIN_TIME_RATE); + CU_ASSERT(rate < MAX_TIME_RATE); + + res = ODP_TIME_SEC_IN_NS / rate; + res = res ? res : 1; +} + /* check that related conversions come back to the same value */ void time_test_odp_conversion(void) { @@ -36,8 +51,8 @@ void time_test_odp_conversion(void) /* need to check within arithmetic tolerance that the same * value in ns is returned after conversions */ - upper_limit = ns1 + TOLERANCE; - lower_limit = ns1 - TOLERANCE; + upper_limit = ns1 + res; + lower_limit = ns1 - res; CU_ASSERT((ns2 <= upper_limit) && (ns2 >= lower_limit)); ns1 = 60 * 11 * ODP_TIME_SEC_IN_NS; @@ -47,8 +62,8 @@ void time_test_odp_conversion(void) /* need to check within arithmetic tolerance that the same * value in ns is returned after conversions */ - upper_limit = ns1 + TOLERANCE; - lower_limit = ns1 - TOLERANCE; + upper_limit = ns1 + res; + lower_limit = ns1 - res; CU_ASSERT((ns2 <= upper_limit) && (ns2 >= lower_limit)); /* test on 0 */ @@ -151,8 +166,8 @@ void time_test_odp_diff(void) ns = ns2 - ns1; nsdiff = odp_time_to_ns(diff); - upper_limit = ns + TOLERANCE; - lower_limit = ns - TOLERANCE; + upper_limit = ns + res; + lower_limit = ns - res; CU_ASSERT((nsdiff <= upper_limit) && (nsdiff >= lower_limit)); /* test timestamp and interval diff */ @@ -164,8 +179,8 @@ void time_test_odp_diff(void) CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL) > 0); nsdiff = odp_time_to_ns(diff); - upper_limit = ns + TOLERANCE; - lower_limit = ns - TOLERANCE; + upper_limit = ns + res; + lower_limit = ns - res; CU_ASSERT((nsdiff <= upper_limit) && (nsdiff >= lower_limit)); /* test interval diff */ @@ -177,8 +192,8 @@ void time_test_odp_diff(void) CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL) > 0); nsdiff = odp_time_to_ns(diff); - upper_limit = ns + TOLERANCE; - lower_limit = ns - TOLERANCE; + upper_limit = ns + res; + lower_limit = ns - res; CU_ASSERT((nsdiff <= upper_limit) && (nsdiff >= lower_limit)); /* same time has to diff to 0 */ @@ -207,8 +222,8 @@ void time_test_odp_sum(void) CU_ASSERT(odp_time_cmp(sum, ODP_TIME_NULL) > 0); nssum = odp_time_to_ns(sum); - upper_limit = ns + TOLERANCE; - lower_limit = ns - TOLERANCE; + upper_limit = ns + res; + lower_limit = ns - res; CU_ASSERT((nssum <= upper_limit) && (nssum >= lower_limit)); /* sum intervals */ @@ -220,8 +235,8 @@ void time_test_odp_sum(void) CU_ASSERT(odp_time_cmp(sum, ODP_TIME_NULL) > 0); nssum = odp_time_to_ns(sum); - upper_limit = ns + TOLERANCE; - lower_limit = ns - TOLERANCE; + upper_limit = ns + res; + lower_limit = ns - res; CU_ASSERT((nssum <= upper_limit) && (nssum >= lower_limit)); /* test on 0 */ @@ -256,6 +271,7 @@ void time_test_odp_to_u64(void) odp_testinfo_t time_suite_time[] = { ODP_TEST_INFO(time_test_odp_constants), + ODP_TEST_INFO(time_test_res), ODP_TEST_INFO(time_test_odp_conversion), ODP_TEST_INFO(time_test_monotony), ODP_TEST_INFO(time_test_odp_cmp), diff --git a/test/validation/time/time.h b/test/validation/time/time.h index 3407138..cf9495b 100644 --- a/test/validation/time/time.h +++ b/test/validation/time/time.h @@ -11,6 +11,7 @@ /* test functions: */ void time_test_odp_constants(void); +void time_test_res(void); void time_test_odp_conversion(void); void time_test_monotony(void); void time_test_odp_cmp(void);