From patchwork Thu Dec 17 15:29:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 58599 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp438215lbb; Thu, 17 Dec 2015 07:33:35 -0800 (PST) X-Received: by 10.140.101.130 with SMTP id u2mr23639845qge.71.1450366413566; Thu, 17 Dec 2015 07:33:33 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id m84si11717645qhb.110.2015.12.17.07.33.33; Thu, 17 Dec 2015 07:33:33 -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 263F361636; Thu, 17 Dec 2015 15:33:33 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=LTMC6nBC; 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 7047661674; Thu, 17 Dec 2015 15: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 0304961630; Thu, 17 Dec 2015 15:30:21 +0000 (UTC) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) by lists.linaro.org (Postfix) with ESMTPS id 8AABD61630 for ; Thu, 17 Dec 2015 15:29:40 +0000 (UTC) Received: by mail-lf0-f51.google.com with SMTP id z124so49336024lfa.3 for ; Thu, 17 Dec 2015 07:29:40 -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=xfVgCwdNbsTpCGPGvrksiotG7hmQk3FGzYVzig/wL9A=; b=LTMC6nBCYG4Zvwjuma0hdp4iQ3LdkMEATOby4TNaKhaIGWpP5BPEL0nP76Joh8hvM9 w0HMXkMdR1YhmeYD/rURwNPfPJ1YmL/XI1G51d8l0u8rgaz0xlak1vqQItl9/Te852V6 c7leexAh6EjpYp6MQUZfWhbzXkDhXKdxftqhY= 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=xfVgCwdNbsTpCGPGvrksiotG7hmQk3FGzYVzig/wL9A=; b=mX5n4/WKfkJdveR+/HRDGp1xSoqak7czGe6ir8+6IfmENSu0ZVGea6MLiwBW4gl23q KhAeJnYkV02DulDspDOsl85DOLnlKXMj4xyBc1v9NLqq59/WP0Sg52rxBuhdEwFKH7sY 44X4GAYeB/sVnShywq/SlFQd+tQxu9rDo0U0dPMC6DBQG4lme9shOtRg80P9pLciqkPq apct9RAWVkUvgv7KF4h7YoCNwuMxhtllKTIzHyTLH6ktbnH+CrjmmvF5h0GDYn4FuTqu ajwcTucIjVTANALHEZUC3dUMQylWuTV9tR/2MayHeZ8wMOVMrIWCqJ38HDNXpBuN1Quh iFEA== X-Gm-Message-State: ALoCoQlpT1PMgKu1EBjvfzCjSAiti8F03IkKCeh5jgRP5uqB5uleopcGl0OsGzAMdBraRe0pyeJIuD7vQ7o//R0GlfAvKKWL+w== X-Received: by 10.25.207.205 with SMTP id f196mr22006543lfg.124.1450366179138; Thu, 17 Dec 2015 07:29:39 -0800 (PST) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id kz5sm801302lbc.7.2015.12.17.07.29.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Dec 2015 07:29:37 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Thu, 17 Dec 2015 17:29:24 +0200 Message-Id: <1450366164-19537-7-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 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 | 52 +++++++++++++++++++++++++++++++++++++++++++++ test/validation/time/time.h | 2 ++ 2 files changed, 54 insertions(+) diff --git a/test/validation/time/time.c b/test/validation/time/time.c index 0fe8c5a..ea07f2a 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 50 /* deviation for delay */ static uint64_t res; @@ -244,6 +245,55 @@ 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 start_time, end_time, wait; + odp_time_t lower_limit, upper_limit, tolerance; + 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); + tolerance = odp_time_local_from_ns(DELAY_TOLERANCE); + + lower_limit = odp_time_diff(wait, tolerance); + upper_limit = odp_time_sum(wait, 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 start_time, end_time, diff; + odp_time_t lower_limit, upper_limit, tolerance; + + 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); + tolerance = odp_time_local_from_ns(DELAY_TOLERANCE); + + lower_limit = odp_time_diff(diff, tolerance); + upper_limit = odp_time_sum(diff, 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 +327,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: */