From patchwork Tue Dec 22 10:50:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 58871 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3154166lbb; Tue, 22 Dec 2015 02:51:00 -0800 (PST) X-Received: by 10.140.249.2 with SMTP id u2mr33099311qhc.53.1450781460578; Tue, 22 Dec 2015 02:51:00 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id m84si7211780qhb.18.2015.12.22.02.51.00; Tue, 22 Dec 2015 02:51:00 -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 EA03461617; Tue, 22 Dec 2015 10:50:59 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=Wyyn0G+0; 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 F058A615F1; Tue, 22 Dec 2015 10:50:55 +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 A1074615C8; Tue, 22 Dec 2015 10:50:43 +0000 (UTC) Received: from mail-lf0-f50.google.com (mail-lf0-f50.google.com [209.85.215.50]) by lists.linaro.org (Postfix) with ESMTPS id 1A0D2615C8 for ; Tue, 22 Dec 2015 10:50:42 +0000 (UTC) Received: by mail-lf0-f50.google.com with SMTP id p203so128265267lfa.0 for ; Tue, 22 Dec 2015 02:50:42 -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; bh=NmCkI+Z3UCpJ9v5RBsbun3BeqJoIU2wR7AXUvMeUDdU=; b=Wyyn0G+0Ftm+AMLzWo6LRdw+eTP9YWOi80CsXWgFtHK1VYhU3NGsXZwyKj8SkmBLSk Yr6Rutp3meKDlrIwpuoIPVI/JUcRj7BabG3+UglsxyNAmcg2TkVqkIR8zXbvURlgbwQA SicgW6RYxyZI4z35JeVspx512x7R3expcAWj4= 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; bh=NmCkI+Z3UCpJ9v5RBsbun3BeqJoIU2wR7AXUvMeUDdU=; b=IgZSYIqCxdJqyKpnvsYnYUMBgWYVzWwV0/TeikrJsAznO1qmf785OudggH5OQbJCld 3OMojh9mLjbaH8tqTItSUsFhmAIkzpwhnO7SjB7NboqK+NU1gIjp6ru3KH6AY4No94nU VxJEi0z1wNQ+/Tmujj6F8XJ31qNiUynHL4Ic+b2rzjKRAiJn5AClzApLp800HzZfdAW/ Fwl9+b5c6j9QPhHH4zqAX5nk5fBjy/+8YApfaiXZm3wLON23yBgn+y6wq5QEqFlMQYLk ts3QQDBJexAWejgn7bVpuEWcRpbzKMFWKeDfrxQyxwh2IJvUx4V6l1W5XmsBurygYM9r a0Sw== X-Gm-Message-State: ALoCoQk4moLM0zxNAg8tELeY4QmXvdl/gI191ncLdkXRrCE9rrTjyu0FjqQzEQlUitYqkzAFFYDzNPARhKZPlDf3PhPeuij2iQ== X-Received: by 10.25.218.9 with SMTP id r9mr8277494lfg.138.1450781440883; Tue, 22 Dec 2015 02:50:40 -0800 (PST) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id qb3sm5518156lbb.39.2015.12.22.02.50.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Dec 2015 02:50:37 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Tue, 22 Dec 2015 12:50:28 +0200 Message-Id: <1450781428-16505-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Cc: petri.savolainen@nokia.com Subject: [lng-odp] [API-NEXT PATCH v3] validation: sched: Improve scheduler validation test to check sched time correctly 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" Test checks scheduler time correctness using time API. Signed-off-by: Ivan Khoronzhuk --- Based on api-next as it uses new time API. Since v2: - replaced 200000000 on (20 * ODP_TIME_MSEC_IN_NS) Since v1: - improved a little test/validation/scheduler/scheduler.c | 45 +++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/test/validation/scheduler/scheduler.c b/test/validation/scheduler/scheduler.c index 2e157a5..7ba6a06 100644 --- a/test/validation/scheduler/scheduler.c +++ b/test/validation/scheduler/scheduler.c @@ -48,6 +48,8 @@ #define CHAOS_NDX_TO_PTR(n) ((void *)(uintptr_t)n) #define CHAOS_WAIT_FAIL (5 * ODP_TIME_SEC_IN_NS) +#define ODP_WAIT_TOLERANCE (20 * ODP_TIME_MSEC_IN_NS) + /* Test global variables */ typedef struct { int num_workers; @@ -114,13 +116,52 @@ static int exit_schedule_loop(void) void scheduler_test_wait_time(void) { + int i; + odp_queue_t queue; uint64_t wait_time; + odp_queue_param_t qp; + odp_time_t lower_limit, upper_limit; + odp_time_t start_time, end_time, diff; + /* check on read */ wait_time = odp_schedule_wait_time(0); wait_time = odp_schedule_wait_time(1); - wait_time = odp_schedule_wait_time((uint64_t)-1LL); - CU_ASSERT(wait_time > 0); + /* check ODP_SCHED_NO_WAIT */ + odp_queue_param_init(&qp); + queue = odp_queue_create("dummy_queue", ODP_QUEUE_TYPE_SCHED, &qp); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + + wait_time = odp_schedule_wait_time(ODP_TIME_SEC_IN_NS); + start_time = odp_time_local(); + odp_schedule(&queue, ODP_SCHED_NO_WAIT); + end_time = odp_time_local(); + + diff = odp_time_diff(end_time, start_time); + lower_limit = ODP_TIME_NULL; + upper_limit = odp_time_local_from_ns(ODP_WAIT_TOLERANCE); + + CU_ASSERT(odp_time_cmp(diff, lower_limit) >= 0); + CU_ASSERT(odp_time_cmp(diff, upper_limit) <= 0); + + /* check time correctness */ + start_time = odp_time_local(); + for (i = 1; i < 6; i++) { + odp_schedule(&queue, wait_time); + 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 - + ODP_WAIT_TOLERANCE); + upper_limit = odp_time_local_from_ns(5 * ODP_TIME_SEC_IN_NS + + ODP_WAIT_TOLERANCE); + + CU_ASSERT(odp_time_cmp(diff, lower_limit) >= 0); + CU_ASSERT(odp_time_cmp(diff, upper_limit) <= 0); + + CU_ASSERT_FATAL(odp_queue_destroy(queue) == 0); } void scheduler_test_num_prio(void)