From patchwork Mon Dec 14 18:58:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 58363 Delivered-To: patch@linaro.org Received: by 10.112.73.68 with SMTP id j4csp1667727lbv; Mon, 14 Dec 2015 11:01:49 -0800 (PST) X-Received: by 10.140.202.132 with SMTP id x126mr37897087qha.1.1450119709179; Mon, 14 Dec 2015 11:01:49 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 16si36041594qhm.48.2015.12.14.11.01.48; Mon, 14 Dec 2015 11:01:49 -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 AB1C761C9E; Mon, 14 Dec 2015 19:01:48 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=ju0q5Kjn; 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 391FE61D10; Mon, 14 Dec 2015 18:59:09 +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 EB0ED61C9E; Mon, 14 Dec 2015 18:58:57 +0000 (UTC) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com [209.85.217.177]) by lists.linaro.org (Postfix) with ESMTPS id 629EA61D20 for ; Mon, 14 Dec 2015 18:58:30 +0000 (UTC) Received: by lbbkw15 with SMTP id kw15so112605006lbb.0 for ; Mon, 14 Dec 2015 10:58:29 -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=v6GvEy1n2Oe3aQFcokQkdpUM1GG49tSjuxq99cbdEM4=; b=ju0q5KjnCP5jRIjA2s09ce8Buh/JQsk+hyGQgfL5xKXCOm/1OSTx6khk3uzbtqzWwv aLAHuA+bGAZFtNu86Fpjrtl5shI8O+WQ28d1Qyqkqoc2cYWz5YrJzwdKo2TbIGdpqswG eOqmOXAqlD0tewGeXdj8t5Sj9P+ma2k6lb3eA= 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=v6GvEy1n2Oe3aQFcokQkdpUM1GG49tSjuxq99cbdEM4=; b=Ou07i6yQEXMfdj22uW6zZc5zeHhCjrVURHEIQODs1pXBLjzVG9crpcBaSv/UW3F3nB h3iXm7sEHfkI9yNXlRreQG6aCKLF+2Li51fOGd4RzorSbdU6bTcHOhrHdHLszEZc1Im8 zaSNUHv+NPjm4EizOkcvq3b5DcyelbmdbWsPttESv6rd0z3w8lZn/i9ydNRmg2Af7bAq YPw/NTxYpDCYhYMJQpnTPZGKI/MiNuICUc8Xk9eUMeG+L8qcjUcZ3Hiu6oIVss/C0hno ReWZotQ5lRNqE4XJuSMgj/4D+zww5X8fIUgdh9vT7agFJnRkzPVYOrEHsX72fYW7p9+u RNgQ== X-Gm-Message-State: ALoCoQlSIUuTyKJ5T1Y+75MRD+/FBzyW1JeQSYPjqQ5I3CdfwDHBiclm0GZxit0N0Jci7SKIXulsdUzQ6moVAnTTkNMcS3ao8Q== X-Received: by 10.112.137.5 with SMTP id qe5mr5880718lbb.33.1450119509353; Mon, 14 Dec 2015 10:58:29 -0800 (PST) Received: from localhost.localdomain ([212.90.60.8]) by smtp.gmail.com with ESMTPSA id o5sm5609246lbw.16.2015.12.14.10.58.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Dec 2015 10:58:28 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Mon, 14 Dec 2015 20:58:15 +0200 Message-Id: <1450119496-21604-6-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450119496-21604-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1450119496-21604-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 5/6] validation: time: add test for odp_time_local_rate() 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, that test uses 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..8b77fea 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_rate(void) +{ + uint64_t rate; + + rate = odp_time_local_rate(); + 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_rate), 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..c275b39 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_rate(void); void time_test_odp_conversion(void); void time_test_monotony(void); void time_test_odp_cmp(void);