From patchwork Thu Dec 17 16:31:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 58609 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp475869lbb; Thu, 17 Dec 2015 08:35:43 -0800 (PST) X-Received: by 10.140.242.216 with SMTP id n207mr18690024qhc.37.1450370143706; Thu, 17 Dec 2015 08:35:43 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id g131si11943844qkb.102.2015.12.17.08.35.43; Thu, 17 Dec 2015 08:35:43 -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 3DB3461662; Thu, 17 Dec 2015 16:35:43 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=dEQYN/2U; 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 F33FD61670; Thu, 17 Dec 2015 16:32:46 +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 4AB326165F; Thu, 17 Dec 2015 16:32:43 +0000 (UTC) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com [209.85.217.178]) by lists.linaro.org (Postfix) with ESMTPS id 3CA936165F for ; Thu, 17 Dec 2015 16:31:47 +0000 (UTC) Received: by mail-lb0-f178.google.com with SMTP id kw15so48689289lbb.0 for ; Thu, 17 Dec 2015 08:31:47 -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=dEQYN/2U9Y2gr5XJzOjnnq5AviOKUvETxDXtPs6LiXOn6cVDiwbLIyslRTJ7Wkasyj FOI+5mhz8pSEeAQB6xPDG9zOBdyERAYK5jlV/L8G4n3Oh4KVScPe1Ec0l5V/D0WTWWsZ CcFVLkkI9IReUDQPBdSabJ7zIvrUKPgaSb6fc= 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=WhizDxsAi+nywzg6PWe5ms0ECUjNxOduMb73OcDUx/tzekDYnu+bHxXNyM1rX9VXcf IDWqV2ns3hpAjI467KLiwAVpuGcLcYYxb4Yf9TOiOjqMLbq24I5TW89G0/0W+jiQ4jCO cFBkMZZ36++d08KtiChkIB4I/pLtMeka/LQr6LQPcMGUdna18PdE0HSehC7Rz5r7KHBy 1b+YB+0MQ6Nj87ppoEy4xhMzMqNZUbEUqkr9dTRJEsIqs3Ce8SfsXUsWHcaz2U8hmbmg clINpkVYw9dmJqULO0niK6miI89nqRSd+crL6xhlA50F6BqWxlTRMPHl6ztNr4MnaEXF oifQ== X-Gm-Message-State: ALoCoQmik8nA9AHHo4KjFSyd59mp+tsVmv8W4C7AkklWqvaNGPLEuGN4NCQRCHww3HQgUfLu4ObFMAYqyvvfPZSGnS4Q7jkiCQ== X-Received: by 10.112.161.228 with SMTP id xv4mr23297293lbb.60.1450369906113; Thu, 17 Dec 2015 08:31:46 -0800 (PST) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id u12sm2030563lbk.45.2015.12.17.08.31.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Dec 2015 08:31:44 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Thu, 17 Dec 2015 18:31:29 +0200 Message-Id: <1450369889-4310-7-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450369889-4310-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1450369889-4310-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v4 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: */