From patchwork Tue Dec 15 12:29:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 58437 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp4561lbb; Tue, 15 Dec 2015 04:33:52 -0800 (PST) X-Received: by 10.55.72.143 with SMTP id v137mr50257806qka.73.1450182832202; Tue, 15 Dec 2015 04:33:52 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 23si78400qgb.90.2015.12.15.04.33.51; Tue, 15 Dec 2015 04:33:52 -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 8F9C7619B8; Tue, 15 Dec 2015 12:33:51 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=XoBPudYL; 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 DC32761B50; Tue, 15 Dec 2015 12:30:34 +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 39F5A61B54; Tue, 15 Dec 2015 12:30:29 +0000 (UTC) Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com [209.85.215.54]) by lists.linaro.org (Postfix) with ESMTPS id 91DCE619B8 for ; Tue, 15 Dec 2015 12:29:44 +0000 (UTC) Received: by mail-lf0-f54.google.com with SMTP id p203so5270485lfa.0 for ; Tue, 15 Dec 2015 04:29:44 -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=Sw6WlliMwE8pZOmuyh+A081TUn8bVNvNQybxKTfSuyM=; b=XoBPudYLBwt9lDQyv6/OvkW213Cfx/DDjvs9d+Ejg+SVvaAulJzCgIlWJqtEy7goaC oJODggJTiqlw3c9XdLucfuHgRycnqBH1IyVZI6itlNnugvu/W6S/V+b4WwVhZ/Zl+STX Uf9Zwj16LdBeR7vsgIIC2T6XvhZowHMYkuR/o= 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=Sw6WlliMwE8pZOmuyh+A081TUn8bVNvNQybxKTfSuyM=; b=Dyjnc+uzVEwTJl+7qxciq5No17tHRWycmqy/RHms2kCEe/XOz7YG8Z0ZxldH15dSiT SK8/0P2/tQR09hut9oqKmAPkWuTYAQsqT6JDu5HyP9GVunlzyiRRjUsPLbO0K/ZIscFN 6Y8JhNd1JmHAFJiNq0iO31Ij4XDhXDbpbOgSiInadoK5FAlX9egnpXxHCTdpOfB0X6gS FTmsuwyGEQLLeuhiW/W6bcim2ylSzMjejoHTlYStGeWneIQ9uUSIY+X7axGVosw4d/7y RDSpRRnpTQiWUaisGG7G4wsP6HW96H33AmDz6o2whPnPRDdFkiIYCGe4nG3yAWuJHcUM HGxA== X-Gm-Message-State: ALoCoQmKhBXtYr+9/lwYVOB/1FKvS0ZIDNNezNb4qx7Mp0iqwRGxD0akokSgqKKrr83ri6eqvuWIaYl2oN9Muc+PNtOlkd/vAg== X-Received: by 10.25.218.9 with SMTP id r9mr15648547lfg.138.1450182583540; Tue, 15 Dec 2015 04:29:43 -0800 (PST) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id h8sm15103lbd.5.2015.12.15.04.29.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Dec 2015 04:29:42 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Tue, 15 Dec 2015 14:29:27 +0200 Message-Id: <1450182567-7646-7-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450182567-7646-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1450182567-7646-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v2 6/6] validation: time: add test for odp_time_wait() 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(). 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 0fe8c5a..482a91d 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_wait(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_wait(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_wait), 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..a97a3f3 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_wait(void); void time_test_odp_to_u64(void); /* test arrays: */