From patchwork Fri Nov 24 13:00:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 119580 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2137513edl; Fri, 24 Nov 2017 05:03:37 -0800 (PST) X-Google-Smtp-Source: AGs4zMaG5yAuV3kmFjz2MG7C6vtT+iaiFt8vwtqdr9XuuRJMX+RCQui+gtPESwxDyqs7yJhBcAvn X-Received: by 10.233.223.2 with SMTP id t2mr42701663qkf.331.1511528616884; Fri, 24 Nov 2017 05:03:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511528616; cv=none; d=google.com; s=arc-20160816; b=VH7BZoiVbZwDcJaMK1EoMV0vtVIcKUvQYhlFVKe4KCUtcxjy6AMDbd8sGijDyePeeH ZFQSKltynUT7vV9zI1hSnspiJrLvrIG5dg9m1hkJqwaExP3+0UxChPj30BuHxKO0INg2 x9EGQtxDL0SHUuUkZmu4IxMRNwaRG6BQ3GznYQSbCMaK/mLwnz/ov3wlLGj7ER1PYI0u dgLIPpY8CrZiKR3TuP/wKPllLyJ3d2QS5dw+BIpVsZ/tBrjwdO50BSzpqR8eE/pYQGBb +fS9wtvnpssesgkkDnU52RAlj/Y4VlXm+s7yZ9y1J58bK43XZOBsFPWTjExSpuq6+dgN BBpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=oLw4M7GoXmXjmkWfGO7a+7gkVBlFy5UTFTx4Q5JttaQ=; b=WOWqUEUn8Z3OU/eyMwO6nRATqhINLu1YpYGcm0audrupzTerXrJ7CWeUr6v1eEU+EJ ouQgaVWOrWz2NyKAjjsAGr083+UXy+Mi8d9QLHGUiyStAGqCQXNchqXhlYqXq5GWiua6 kP6NoHmqDCWgSXa43V0EhjO6f6EmAdHOaI3qAw+fP5rua1JFUBODw6OOqnMRkVpWUqJJ xWNfA0uaTUuQC2SpZbE/8Rj+c6aRgFPu/21B2QXMn2JRWe1usmbeMvOIBiLigBkwk3If JvP+gfN0+4NStQRYp7ubUgmc/kEqSeHGuRVLtx347KjqZmU/gMc4NbOSMhETW8igd9Ag d3HQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id q32si2036269qkq.242.2017.11.24.05.03.36; Fri, 24 Nov 2017 05:03:36 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 67FF2608DF; Fri, 24 Nov 2017 13:03:36 +0000 (UTC) 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.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,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 3354960833; Fri, 24 Nov 2017 13:02:14 +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 82BAD608A7; Fri, 24 Nov 2017 13:02:04 +0000 (UTC) Received: from forward104o.mail.yandex.net (forward104o.mail.yandex.net [37.140.190.179]) by lists.linaro.org (Postfix) with ESMTPS id 0E26C60726 for ; Fri, 24 Nov 2017 13:00:36 +0000 (UTC) Received: from mxback5o.mail.yandex.net (mxback5o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1f]) by forward104o.mail.yandex.net (Yandex) with ESMTP id 7B38A702149 for ; Fri, 24 Nov 2017 16:00:34 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback5o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id xgwIQiBdXo-09GGkDeR; Fri, 24 Nov 2017 16:00:10 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id N2PeGhXtlr-09ouiL3t; Fri, 24 Nov 2017 16:00:09 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Fri, 24 Nov 2017 16:00:06 +0300 Message-Id: <1511528406-25262-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511528406-25262-1-git-send-email-odpbot@yandex.ru> References: <1511528406-25262-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 310 Subject: [lng-odp] [PATCH API-NEXT v1 3/3] validation: time: test odp_time_diff_ns 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Petri Savolainen Added tests for the new time difference in nsec function. Signed-off-by: Petri Savolainen --- /** Email created from pull request 310 (psavol:next-time-convert) ** https://github.com/Linaro/odp/pull/310 ** Patch: https://github.com/Linaro/odp/pull/310.patch ** Base sha: b95e7d08043ba45d12635c5afaa3fbf3a07ecc90 ** Merge commit sha: 7700d0dab4af4db47973c2a88e5a6d6765bf979e **/ test/validation/api/time/time.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/validation/api/time/time.c b/test/validation/api/time/time.c index ef1372578..c8f90dbac 100644 --- a/test/validation/api/time/time.c +++ b/test/validation/api/time/time.c @@ -201,7 +201,8 @@ static void time_test_diff(time_cb time_cur, /* volatile to stop optimization of busy loop */ volatile int count = 0; odp_time_t diff, t1, t2; - uint64_t nsdiff, ns1, ns2, ns; + uint64_t ns1, ns2, ns; + uint64_t nsdiff, diff_ns; uint64_t upper_limit, lower_limit; /* test timestamp diff */ @@ -217,6 +218,9 @@ static void time_test_diff(time_cb time_cur, diff = odp_time_diff(t2, t1); CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL) > 0); + diff_ns = odp_time_diff_ns(t2, t1); + CU_ASSERT(diff_ns > 0); + ns1 = odp_time_to_ns(t1); ns2 = odp_time_to_ns(t2); ns = ns2 - ns1; @@ -225,6 +229,7 @@ static void time_test_diff(time_cb time_cur, upper_limit = ns + 2 * res; lower_limit = ns - 2 * res; CU_ASSERT((nsdiff <= upper_limit) && (nsdiff >= lower_limit)); + CU_ASSERT((diff_ns <= upper_limit) && (diff_ns >= lower_limit)); /* test timestamp and interval diff */ ns1 = 54; @@ -233,11 +238,16 @@ static void time_test_diff(time_cb time_cur, diff = odp_time_diff(t2, t1); CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL) > 0); + + diff_ns = odp_time_diff_ns(t2, t1); + CU_ASSERT(diff_ns > 0); + nsdiff = odp_time_to_ns(diff); upper_limit = ns + 2 * res; lower_limit = ns - 2 * res; CU_ASSERT((nsdiff <= upper_limit) && (nsdiff >= lower_limit)); + CU_ASSERT((diff_ns <= upper_limit) && (diff_ns >= lower_limit)); /* test interval diff */ ns2 = 60 * 10 * ODP_TIME_SEC_IN_NS; @@ -246,11 +256,16 @@ static void time_test_diff(time_cb time_cur, t2 = time_from_ns(ns2); diff = odp_time_diff(t2, t1); CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL) > 0); + + diff_ns = odp_time_diff_ns(t2, t1); + CU_ASSERT(diff_ns > 0); + nsdiff = odp_time_to_ns(diff); upper_limit = ns + 2 * res; lower_limit = ns - 2 * res; CU_ASSERT((nsdiff <= upper_limit) && (nsdiff >= lower_limit)); + CU_ASSERT((diff_ns <= upper_limit) && (diff_ns >= lower_limit)); /* same time has to diff to 0 */ diff = odp_time_diff(t2, t2); @@ -258,6 +273,9 @@ static void time_test_diff(time_cb time_cur, diff = odp_time_diff(t2, ODP_TIME_NULL); CU_ASSERT(odp_time_cmp(t2, diff) == 0); + + diff_ns = odp_time_diff_ns(t2, t2); + CU_ASSERT(diff_ns == 0); } void time_test_local_diff(void)