From patchwork Thu Dec 17 16:20:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 58603 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp466794lbb; Thu, 17 Dec 2015 08:20:35 -0800 (PST) X-Received: by 10.140.236.87 with SMTP id h84mr14348326qhc.25.1450369235609; Thu, 17 Dec 2015 08:20:35 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id z6si11950276qgz.8.2015.12.17.08.20.34; Thu, 17 Dec 2015 08:20:35 -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 AF22861633; Thu, 17 Dec 2015 16:20:34 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=faIyAn34; 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 419EF61624; Thu, 17 Dec 2015 16:20:30 +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 2120D6162F; Thu, 17 Dec 2015 16:20:28 +0000 (UTC) Received: from mail-lf0-f48.google.com (mail-lf0-f48.google.com [209.85.215.48]) by lists.linaro.org (Postfix) with ESMTPS id 252B76161C for ; Thu, 17 Dec 2015 16:20:27 +0000 (UTC) Received: by mail-lf0-f48.google.com with SMTP id z124so50394776lfa.3 for ; Thu, 17 Dec 2015 08:20:27 -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=zZFhkx7XWxf6Vn6zSlrTVNOdcMwgUJvJdHQC5tEKBLo=; b=faIyAn34O431QJ0Cr9IePwWugvSa4xYsE6eoZvoVeyU088KHG+WOTHlpOGJAqQGu88 O9aEV5xfajMV/gbYtO5YOZvK0N55xnMrFmbQYwajU31bORXjamMnqbWzDfmbh0jfvtFx zS52mZXGFBP2/HLgEGZ5ewdWoFZa2RdijeIC4= 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=zZFhkx7XWxf6Vn6zSlrTVNOdcMwgUJvJdHQC5tEKBLo=; b=j3lbTRtRfE8wWYDMxS0DXaVN6U79OQU3xPKkMF6JzQxTk8P9ZN7Lg70KaFwaxn0wBU gaagepA2X6EaDSexPG3aYWucOLqnpkUuzUXTow1w/N3cN3nOhWtpgaT+8gutwgaHDjS3 tK8hU4AMYlDae0LlpsivnmO/5ZNRzZJgPd4uMtMY9u0UIG0v9go7z9BaZmedaX4Ovsef xmQj+rgaew4bQNzpEbcgLMv8UI+gmJshDZVNk9wm1C8N2mum00igIWU8146OPVVEqUYD bhQbU1MJCOU17t73H1z1R7H9nrxl11hrwoSjhWEl8PduNuPhGHptUuOBWrtxCaZhMSKy FoWA== X-Gm-Message-State: ALoCoQlliD4DdBYEWD1nqf6ePy4O7/fWJUMiSFFhXwwnJ6fousZAZsjhfxa+AqF49Z342iiTInT0KZZq5ty60J31O9/eDA3/yg== X-Received: by 10.25.83.193 with SMTP id h184mr21414942lfb.155.1450369226000; Thu, 17 Dec 2015 08:20:26 -0800 (PST) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id au8sm1994058lbc.31.2015.12.17.08.20.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Dec 2015 08:20:24 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Thu, 17 Dec 2015 18:20:19 +0200 Message-Id: <1450369219-25331-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH] 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 --- Patch is based on api-next, as it uses new time API. test/validation/scheduler/scheduler.c | 47 +++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/test/validation/scheduler/scheduler.c b/test/validation/scheduler/scheduler.c index 2e157a5..5aa3818 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 20000000 + /* Test global variables */ typedef struct { int num_workers; @@ -114,13 +116,54 @@ 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, tolerance; + odp_time_t start_time, end_time, diff, etalon_time; + /* 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); + tolerance = odp_time_local_from_ns(ODP_WAIT_TOLERANCE); + lower_limit = ODP_TIME_NULL; + upper_limit = 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); + tolerance = odp_time_local_from_ns(ODP_WAIT_TOLERANCE); + + etalon_time = odp_time_local_from_ns(5 * ODP_TIME_SEC_IN_NS); + lower_limit = odp_time_diff(etalon_time, tolerance); + upper_limit = odp_time_sum(etalon_time, 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)