From patchwork Thu Dec 17 16:38:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 58611 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp477865lbb; Thu, 17 Dec 2015 08:39:11 -0800 (PST) X-Received: by 10.55.26.204 with SMTP id l73mr69185612qkh.78.1450370351067; Thu, 17 Dec 2015 08:39:11 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id q68si11986911qgq.99.2015.12.17.08.39.10; Thu, 17 Dec 2015 08:39:11 -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 7DB0A6161C; Thu, 17 Dec 2015 16:39:10 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=efBIIeBo; 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 85A86615F3; Thu, 17 Dec 2015 16:39: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 40AE4615CA; Thu, 17 Dec 2015 16:39:04 +0000 (UTC) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by lists.linaro.org (Postfix) with ESMTPS id 49CAB6161C for ; Thu, 17 Dec 2015 16:39:03 +0000 (UTC) Received: by mail-lb0-f182.google.com with SMTP id cs9so48341677lbb.1 for ; Thu, 17 Dec 2015 08:39:03 -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=iSx/9KamNNG6QTTKoooBT+geyR/nCTzpJPfivtNJCrQ=; b=efBIIeBosaZxMqwVf7S9XDh063j4jYSRiKgKBKy9NtnIfVx2KqVGu/+VN/IDITHmRI GtqgGH3oJQWvSpCcZgxu3XEbmeWIvAKFhaWXe0kCjHFJuzdD4cC5RPjvqwb7C31+lnAU 6GBoVhNm0V+1HdYeiG6wUJBXw7zduOcYcuK/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; bh=iSx/9KamNNG6QTTKoooBT+geyR/nCTzpJPfivtNJCrQ=; b=G/MyuVDTAxhBJSJE2TBnentD/Q5cfJ7o0IQKtNZZ2VR0jakz+n4JZ7+sEDaXSpnxo7 pKhujds8vVeSNTCgO4wCupE4u5XxcSRotMK3pBRmerFnoMazuD3L6XOg9/h8YgEtQP9L v4Lf+wCePdhwCUeD8t8UU2TXgH6UqaaHGYKJDJnFXOsPQp2vVWE06SnvrekHgfhFCgU5 DJh3OC/GyGsUMuRNPpwAXVaYjkFeF2G00LOJ62OqtCGfgnFFea4iin72M/D5Oiw0kaPM dfaTga+kyTEyt1CeNMvseKV1lyhH7tydezBn8+26xQk/T8BQn62ieoriqM8w6DNZMIDV gyaw== X-Gm-Message-State: ALoCoQmrEN2WOz+i1tBc/0S9GW34O8URP2kCJ1zwVZ9J9aKH2Ju3xzVl1fk2XTl4AoeXQHKO+l2kkK3gmxlmCvj70d8/o3xZog== X-Received: by 10.112.147.167 with SMTP id tl7mr22045139lbb.100.1450370342178; Thu, 17 Dec 2015 08:39:02 -0800 (PST) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id pl2sm2035460lbc.8.2015.12.17.08.39.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Dec 2015 08:39:01 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Thu, 17 Dec 2015 18:38:56 +0200 Message-Id: <1450370336-15445-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 v2] 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 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..daed8cb 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,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)