From patchwork Thu Dec 17 15:29:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 58598 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp437589lbb; Thu, 17 Dec 2015 07:32:37 -0800 (PST) X-Received: by 10.141.7.69 with SMTP id j66mr65750581qhd.2.1450366357053; Thu, 17 Dec 2015 07:32:37 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 197si11737532qha.88.2015.12.17.07.32.34; Thu, 17 Dec 2015 07:32:37 -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 81D9661630; Thu, 17 Dec 2015 15:32:34 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=droildxz; 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_H3, RCVD_IN_MSPIKE_WL, 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 0210161623; Thu, 17 Dec 2015 15:30:20 +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 8F64161673; Thu, 17 Dec 2015 15:30:15 +0000 (UTC) Received: from mail-lf0-f42.google.com (mail-lf0-f42.google.com [209.85.215.42]) by lists.linaro.org (Postfix) with ESMTPS id C330061623 for ; Thu, 17 Dec 2015 15:29:38 +0000 (UTC) Received: by mail-lf0-f42.google.com with SMTP id y184so54110586lfc.1 for ; Thu, 17 Dec 2015 07:29:38 -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=droildxzC5qzg+/MXC81jPQVEqOzv0hRbRKPXiiik7wpRJvQqWpV6OQ/pYbkMkrA2O S3tbjxDb+yFBENrryvQObEq7MDEXfsGAOC2sQRbu3I9YMlSy2UzeIpBE/G9wwgPKQfo6 +3LF8GJIV2LF2QhYeZpjpSXLZcGDJ6vXOPhOI= 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=TgLv/6qIclj905tATGidILDBbNniAM0USCeJ3a5YlXBoMAozJlxqXQu/6NCXQHg6pa 5c0vp9lWY/txyh9d0Dedvl5OvdJBb6fvBIJCxuntAG02mxMuDKJ/MPi1jzpkDHPHdKYp CgSiu7Ys/ybOpWQc1etW8FhG9YqUcB6P/IfZpS+C8+UdPpVqoZZQxIXTRoN54nLk6xwG 8TomC3Q0jFSeY4i8RA/lfTxEVX1o7sEopEqwPlO0ZxP1XxhQwSHsglvUJeaxMr/F+Z5Y gtqCaMR4M/1JmFc3r4zLUPOnpAL51tgH1XNn/rID8b2JD4s/4fxRpALP8MxMUT+i0W6C /UdA== X-Gm-Message-State: ALoCoQkK5SwNhFf1QuybxJjwMqMfA2dAxS8y26SExzSOl51bQekUuLCJSK3t5CrdRGD//zH+FSToEOI3fNHcGjdCHjkAQ/MmVA== X-Received: by 10.25.23.15 with SMTP id n15mr8239041lfi.44.1450366177637; Thu, 17 Dec 2015 07:29:37 -0800 (PST) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id kz5sm801302lbc.7.2015.12.17.07.29.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Dec 2015 07:29:36 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Thu, 17 Dec 2015 17:29:23 +0200 Message-Id: <1450366164-19537-6-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450366164-19537-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1450366164-19537-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v3 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);