From patchwork Tue Dec 15 12:29:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 58435 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3766lbb; Tue, 15 Dec 2015 04:32:29 -0800 (PST) X-Received: by 10.140.138.69 with SMTP id 66mr45457951qhk.18.1450182749868; Tue, 15 Dec 2015 04:32:29 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id j64si945794qgj.115.2015.12.15.04.32.29; Tue, 15 Dec 2015 04:32:29 -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 703F86195E; Tue, 15 Dec 2015 12:32:29 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=amjep448; 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 6874D619CF; Tue, 15 Dec 2015 12:30:28 +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 0C2CB61941; Tue, 15 Dec 2015 12:30:24 +0000 (UTC) Received: from mail-lf0-f53.google.com (mail-lf0-f53.google.com [209.85.215.53]) by lists.linaro.org (Postfix) with ESMTPS id 574D361941 for ; Tue, 15 Dec 2015 12:29:43 +0000 (UTC) Received: by mail-lf0-f53.google.com with SMTP id l133so5161247lfd.2 for ; Tue, 15 Dec 2015 04:29:43 -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=amjep448isGyeDRMpA+FFIXCxxCUYgsiWqT8+jGV8+45sFjubSZi6qikiFGjR0/Xdh Xx4hT8X5ykW1Zk3/zkEDsbhDaLYrhQ6zoZu2tSU70prREvYe4aR0dRAMGslQpB2zZEah o/fyfFsWtyBN//TKgLmntkprtxzBgq644nKaQ= 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=bi4Q/wlDO6pre77L2UnSWRcUelVBwkNOh+gGqsp4KVNuKsvDN1V2OtgzCFWrtw2Cdm of+a27FH4DzLCjRgAm8eoYcFapy1NZt6fAtr4dKo/uUHTnoHyt0e0kdaWjJZ7qSPq8ps pnWnQQlO54UXR1tPOfWGubu6JgTnJbmpXyoq6gIwZ5sH+DlIgBUnqUhjqHQ4Yt4nVwO3 oyQzlRv8l8ghuCE0m7ZujyVbPjAJGs1t9K1Xm/D1DuUC3Y7oFHA160G8eb1bFFIQbceV ryt77PEp3bZ5QxlkIky/4nYBtGLA6f2jT8+Wu7nTW6TDUrhPJgGCV60RwMBzjEb/EB41 ee2w== X-Gm-Message-State: ALoCoQkRR6ujDdOlwy6hgMXy99PBUVxBCFrNHoJQ32Pt4LboACPUgAhp8qb7+QyjfS/JAFhKXW37tjaFTASMDcfOUUMVRAYugg== X-Received: by 10.25.160.213 with SMTP id j204mr16553258lfe.85.1450182582169; Tue, 15 Dec 2015 04:29:42 -0800 (PST) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id h8sm15103lbd.5.2015.12.15.04.29.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Dec 2015 04:29:41 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Tue, 15 Dec 2015 14:29:26 +0200 Message-Id: <1450182567-7646-6-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450182567-7646-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1450182567-7646-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v2 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);