From patchwork Mon Dec 14 18:58:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 58362 Delivered-To: patch@linaro.org Received: by 10.112.73.68 with SMTP id j4csp1667391lbv; Mon, 14 Dec 2015 11:01:14 -0800 (PST) X-Received: by 10.140.216.14 with SMTP id m14mr37636198qhb.90.1450119674021; Mon, 14 Dec 2015 11:01:14 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p15si36097774qkl.19.2015.12.14.11.01.13; Mon, 14 Dec 2015 11:01:13 -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 8F2F961CC7; Mon, 14 Dec 2015 19:01:13 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=NqLxllZT; 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 90915610AD; Mon, 14 Dec 2015 18:59:06 +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 D731761CC7; Mon, 14 Dec 2015 18:58:57 +0000 (UTC) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com [209.85.217.170]) by lists.linaro.org (Postfix) with ESMTPS id C512761D07 for ; Mon, 14 Dec 2015 18:58:31 +0000 (UTC) Received: by lbpu9 with SMTP id u9so105919495lbp.2 for ; Mon, 14 Dec 2015 10:58:30 -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=AscQZyOClqiUXlp9aiqcnJ9gLtdXP6ZJXUamQfX/seI=; b=NqLxllZT/u6u9ubLD130Yzx5rLATXDP0VT7T4QDoI3tffNY2FiLhUstd67nCwgmwpo +CuN5fdin5UGlCkY+3VjAmudYiPDJh2ukIqNfR/pE8g5+oCn0MK/FvMdrAkKBnc71PiU o9YY3WXvASbU9cGpIS8IW1R1+tPtmRimqtnAQ= 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=AscQZyOClqiUXlp9aiqcnJ9gLtdXP6ZJXUamQfX/seI=; b=SJxtHo4IKydNsa5zaHTbwSiqUHqBIRHoWlS3lKjoGN6v/udLvFBnmSkCRmRVY+9uMR 8AgorvqkFTLvmss0JM+U2fbEjchnYLA1LdYhhe5JbwuZvl0Izn+yrteumWNz7AWUHvGg o3WJPsW66/+56zFtGb3kN1aPlsmsbKd9ZR3FsAj2iB+XbkrB7BbQvO1t02MgVx2uBErz sTTWFZSEBrLqzCyCPZlqN/MIet/jwEi7A8kyl2XiKSNRkGhB92Ca2vNU8qdq7T4Jt6s8 CTW3s/Q1+v651MTnSi18+Pcw+fZSP69LEefAjpJ/NbDBYY/wybcsgG10/7h8iBs1A5js BhGg== X-Gm-Message-State: ALoCoQnQOrRMhj+7+ZZpPFrInr7WFDWuLVs3UCHz5lllJrXo+xhw4A0GXmSeYku3i9spX1ADZLvRTraFM/2ZOcRunbfc30gnuA== X-Received: by 10.112.63.233 with SMTP id j9mr6679645lbs.47.1450119510732; Mon, 14 Dec 2015 10:58:30 -0800 (PST) Received: from localhost.localdomain ([212.90.60.8]) by smtp.gmail.com with ESMTPSA id o5sm5609246lbw.16.2015.12.14.10.58.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Dec 2015 10:58:29 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Mon, 14 Dec 2015 20:58:16 +0200 Message-Id: <1450119496-21604-7-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 6/6] validation: time: add test for odp_time_delay() 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_delay(). Also it visually demonstrates 5 second count. Signed-off-by: Ivan Khoronzhuk --- test/validation/time/time.c | 26 ++++++++++++++++++++++++++ test/validation/time/time.h | 1 + 2 files changed, 27 insertions(+) diff --git a/test/validation/time/time.c b/test/validation/time/time.c index 8b77fea..8d9fe5c 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,30 @@ void time_test_odp_sum(void) CU_ASSERT(odp_time_cmp(t2, sum) == 0); } +void time_test_delay(void) +{ + int i; + odp_time_t start_time, end_time, diff; + 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(); + for (i = 1; i < 6; i++) { + odp_time_delay(second); + 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 +302,7 @@ 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_delay), 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 c275b39..72eea1b 100644 --- a/test/validation/time/time.h +++ b/test/validation/time/time.h @@ -17,6 +17,7 @@ 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_delay(void); void time_test_odp_to_u64(void); /* test arrays: */