From patchwork Fri Dec 18 12:01:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 58651 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp981222lbb; Fri, 18 Dec 2015 04:08:07 -0800 (PST) X-Received: by 10.140.161.137 with SMTP id h131mr4519603qhh.57.1450440486917; Fri, 18 Dec 2015 04:08:06 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id q186si15907172qha.42.2015.12.18.04.08.06; Fri, 18 Dec 2015 04:08:06 -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 79C866168E; Fri, 18 Dec 2015 12:08:06 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=T7xKZw8d; 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 E632A61684; Fri, 18 Dec 2015 12:03:53 +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 4FB77616B0; Fri, 18 Dec 2015 12:03:45 +0000 (UTC) Received: from mail-lf0-f43.google.com (mail-lf0-f43.google.com [209.85.215.43]) by lists.linaro.org (Postfix) with ESMTPS id 5F82861684 for ; Fri, 18 Dec 2015 12:02:16 +0000 (UTC) Received: by mail-lf0-f43.google.com with SMTP id l133so70833010lfd.2 for ; Fri, 18 Dec 2015 04:02:16 -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=I8DWVKtxxznv+DrYNWO+gUnJNPbRA1+uUf4P790kylw=; b=T7xKZw8dNq6wYMS8TfhDF2RIWjqC1J9JYVbKnG+pHQeXffZeSWbaPzGQ3AoohDReJ1 4nxiGBJxRPhIdqRiGOkArhj+FdourXJ+Q8Gs2GSQwiIe1Rw4pM7Vpka2PuZ5PFHrVioe noC6/J1YhFyWBTWF3M/GIiemxQWdVd+2Cmc0M= 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=I8DWVKtxxznv+DrYNWO+gUnJNPbRA1+uUf4P790kylw=; b=Upn7orwWX1zg1Bqtzh6q9y4rTYvJ3y3zyeSJS9ZxDocNkxMqLKb+kgbrza44U77/+I j6eyH35WLmV1QjZ1cH8Qgpp2qusRNvDYjCJk762SyBBGmosf7Ap3HxL8ExAj1ch0cMFR bm1N0AekqdjnPjWsb3vJmp4rrff1k/pI6CUkyAGRvdxBE7ukJT2ses8yY3UQSOxJZak/ C1QRWzNz+k1obSoxsLr9ilXoDhZQPLj6N4I287XqfR7HrNawLk8FNEESKodFsgpoRfv5 joBYVQlwpYKxGODR/8dq0KOc3Sqgua/QaL+B0p2m1J0Xb5Zx1YbnV523uG9fzR3dnly/ 0P/Q== X-Gm-Message-State: ALoCoQlet34VIfHIbYqec1nRfOXfAGxeZqNBSNVtFOXGsR4L5V1A3cb4JtxIhkdlVma26nrgUon8qKcL0MyYqNMLvaQQPU1GmA== X-Received: by 10.25.167.197 with SMTP id q188mr1212810lfe.129.1450440135321; Fri, 18 Dec 2015 04:02:15 -0800 (PST) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id e63sm2731250lfe.5.2015.12.18.04.02.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Dec 2015 04:02:14 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Fri, 18 Dec 2015 14:01:57 +0200 Message-Id: <1450440117-5588-7-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450440117-5588-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1450440117-5588-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Cc: petri.savolainen@nokia.com Subject: [lng-odp] [API-NEXT PATCH v5 6/6] validation: time: add test for odp_time_wait_ns() and odp_time_wait_until() 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 patch adds validation test for odp_time_wait_ns/until(). Also it visually demonstrates 5 second count. Signed-off-by: Ivan Khoronzhuk --- test/validation/time/time.c | 53 +++++++++++++++++++++++++++++++++++++++++++++ test/validation/time/time.h | 2 ++ 2 files changed, 55 insertions(+) diff --git a/test/validation/time/time.c b/test/validation/time/time.c index 0fe8c5a..add1be8 100644 --- a/test/validation/time/time.c +++ b/test/validation/time/time.c @@ -12,6 +12,7 @@ #define BUSY_LOOP_CNT_LONG 12000000000 /* used for t > 4 sec */ #define MIN_TIME_RATE 32000 #define MAX_TIME_RATE 15000000000 +#define DELAY_TOLERANCE 20000000 /* deviation for delay */ static uint64_t res; @@ -244,6 +245,56 @@ void time_test_odp_sum(void) CU_ASSERT(odp_time_cmp(t2, sum) == 0); } +void time_test_wait_until(void) +{ + int i; + odp_time_t lower_limit, upper_limit; + odp_time_t start_time, end_time, wait; + odp_time_t second = odp_time_local_from_ns(ODP_TIME_SEC_IN_NS); + + start_time = odp_time_local(); + wait = start_time; + for (i = 1; i < 6; i++) { + wait = odp_time_sum(wait, second); + odp_time_wait_until(wait); + printf("%d..", i); + } + end_time = odp_time_local(); + + wait = odp_time_diff(end_time, start_time); + lower_limit = odp_time_local_from_ns(5 * ODP_TIME_SEC_IN_NS - + DELAY_TOLERANCE); + upper_limit = odp_time_local_from_ns(5 * ODP_TIME_SEC_IN_NS + + DELAY_TOLERANCE); + + CU_ASSERT(odp_time_cmp(wait, lower_limit) >= 0); + CU_ASSERT(odp_time_cmp(wait, upper_limit) <= 0); +} + +void time_test_wait_ns(void) +{ + int i; + odp_time_t lower_limit, upper_limit; + odp_time_t start_time, end_time, diff; + + start_time = odp_time_local(); + for (i = 1; i < 6; i++) { + odp_time_wait_ns(ODP_TIME_SEC_IN_NS); + printf("%d..", i); + } + end_time = odp_time_local(); + + diff = odp_time_diff(end_time, start_time); + + lower_limit = odp_time_local_from_ns(5 * ODP_TIME_SEC_IN_NS - + DELAY_TOLERANCE); + upper_limit = odp_time_local_from_ns(5 * ODP_TIME_SEC_IN_NS + + DELAY_TOLERANCE); + + CU_ASSERT(odp_time_cmp(diff, lower_limit) >= 0); + CU_ASSERT(odp_time_cmp(diff, upper_limit) <= 0); +} + void time_test_odp_to_u64(void) { volatile int count = 0; @@ -277,6 +328,8 @@ odp_testinfo_t time_suite_time[] = { ODP_TEST_INFO(time_test_odp_cmp), ODP_TEST_INFO(time_test_odp_diff), ODP_TEST_INFO(time_test_odp_sum), + ODP_TEST_INFO(time_test_wait_until), + ODP_TEST_INFO(time_test_wait_ns), ODP_TEST_INFO(time_test_odp_to_u64), ODP_TEST_INFO_NULL }; diff --git a/test/validation/time/time.h b/test/validation/time/time.h index cf9495b..c2330f8 100644 --- a/test/validation/time/time.h +++ b/test/validation/time/time.h @@ -17,6 +17,8 @@ void time_test_monotony(void); void time_test_odp_cmp(void); void time_test_odp_diff(void); void time_test_odp_sum(void); +void time_test_wait_until(void); +void time_test_wait_ns(void); void time_test_odp_to_u64(void); /* test arrays: */