From patchwork Fri Dec 18 12:14: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: 58656 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp985555lbb; Fri, 18 Dec 2015 04:15:49 -0800 (PST) X-Received: by 10.140.22.212 with SMTP id 78mr4325802qgn.17.1450440949245; Fri, 18 Dec 2015 04:15:49 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id l104si15982776qgl.57.2015.12.18.04.15.48; Fri, 18 Dec 2015 04:15:49 -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 CCA00615D5; Fri, 18 Dec 2015 12:15:48 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=XB+yXfnL; 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 9DE9A615CB; Fri, 18 Dec 2015 12:15:12 +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 9D5486109A; Fri, 18 Dec 2015 12:15:06 +0000 (UTC) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com [209.85.217.169]) by lists.linaro.org (Postfix) with ESMTPS id 082826109A for ; Fri, 18 Dec 2015 12:14:39 +0000 (UTC) Received: by mail-lb0-f169.google.com with SMTP id kw15so62642057lbb.0 for ; Fri, 18 Dec 2015 04:14:38 -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=eFzq7Irb+tWikYRQk2RERZIYOsT7UHrOMv7b59UPvSQ=; b=XB+yXfnL7uLjQEXlrfEoW28F/FXyC/GmKTKmJV5QATo5ePuOq9ulQ9/7E1YRS9BpHO YfO8hvVr+alSsMeuPzh6qJBB7rBFgP5HSrZC+B0DGU+nGP79B30FCnKFPEXMsf72i4ga fhc7SJPuNEV0eHu/S1RVGt7KBcJ8h9C3wwyqE= 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=eFzq7Irb+tWikYRQk2RERZIYOsT7UHrOMv7b59UPvSQ=; b=ic4tzxSH467ms+g41KEUDDxWHiOUFp5gxRcl+fzx1Or8/2g3pGULPPodpiZe26rWhI 3586jnRU+Qa7elTRbhSqeUowU5LSe0KJxn37wn8+Nu7+QaRLlkKuC6/z+GtmT6Rg+Z/C MfWM6I8ybByCLQmWccVPar/MiYSR3u//TFPXKQGhrWsDslYEhKt0qdwuZH9Dc9IYX6Lk hThAwyQ7frVuU5JpdRa7P81QNGCq3/7zyWVAO9xWJW4JwnJZ0V7uKy2vKvPWFW+w/aHH exymCe1Ps2juZTNarRjDbVUTEJPGPLwV1GFYKQAiOqgFmd4MouYwNT3cE7Q5uI7puEfL eYcw== X-Gm-Message-State: ALoCoQnXroLRG2SdAM0du2ivkkz4r+F7005DMrs6gpMcDy6InLEbu/B7/TdrQsLAO4ML/CUGvnOxjBHygZVIA0YnvvBcZP+3Hw== X-Received: by 10.112.141.131 with SMTP id ro3mr1286143lbb.106.1450440877763; Fri, 18 Dec 2015 04:14:37 -0800 (PST) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id g193sm2778743lfb.6.2015.12.18.04.14.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Dec 2015 04:14:36 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Fri, 18 Dec 2015 14:14:27 +0200 Message-Id: <1450440867-5891-3-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450440867-5891-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1450440867-5891-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Cc: petri.savolainen@nokia.com Subject: [lng-odp] [API-NEXT PATCH 2/2] validation: time: update to tes global time API also 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" Mostly global time API is tested in the same way, so reuse existent functions. Signed-off-by: Ivan Khoronzhuk --- test/validation/time/time.c | 160 +++++++++++++++++++++++++++++++++----------- test/validation/time/time.h | 23 ++++--- 2 files changed, 137 insertions(+), 46 deletions(-) diff --git a/test/validation/time/time.c b/test/validation/time/time.c index add1be8..8ef095e 100644 --- a/test/validation/time/time.c +++ b/test/validation/time/time.c @@ -14,9 +14,10 @@ #define MAX_TIME_RATE 15000000000 #define DELAY_TOLERANCE 20000000 /* deviation for delay */ -static uint64_t res; +static uint64_t local_res; +static uint64_t global_res; -void time_test_odp_constants(void) +void time_test_constants(void) { uint64_t ns; @@ -26,11 +27,11 @@ void time_test_odp_constants(void) CU_ASSERT(ns == ODP_TIME_USEC_IN_NS); } -void time_test_res(void) +static void time_test_res(uint64_t time_res(void), uint64_t res) { uint64_t rate; - rate = odp_time_local_res(); + rate = time_res(); CU_ASSERT(rate > MIN_TIME_RATE); CU_ASSERT(rate < MAX_TIME_RATE); @@ -38,15 +39,26 @@ void time_test_res(void) res = res ? res : 1; } +void time_test_local_res(void) +{ + time_test_res(odp_time_local_res, local_res); +} + +void time_test_global_res(void) +{ + time_test_res(odp_time_global_res, global_res); +} + /* check that related conversions come back to the same value */ -void time_test_odp_conversion(void) +static +void time_test_conversion(odp_time_t time_from_ns(uint64_t ns), uint64_t res) { uint64_t ns1, ns2; odp_time_t time; uint64_t upper_limit, lower_limit; ns1 = 100; - time = odp_time_local_from_ns(ns1); + time = time_from_ns(ns1); ns2 = odp_time_to_ns(time); @@ -57,7 +69,7 @@ void time_test_odp_conversion(void) CU_ASSERT((ns2 <= upper_limit) && (ns2 >= lower_limit)); ns1 = 60 * 11 * ODP_TIME_SEC_IN_NS; - time = odp_time_local_from_ns(ns1); + time = time_from_ns(ns1); ns2 = odp_time_to_ns(time); @@ -72,25 +84,35 @@ void time_test_odp_conversion(void) CU_ASSERT(ns1 == 0); } -void time_test_monotony(void) +void time_test_local_conversion(void) +{ + time_test_conversion(odp_time_local_from_ns, local_res); +} + +void time_test_global_conversion(void) +{ + time_test_conversion(odp_time_global_from_ns, global_res); +} + +static void time_test_monotony(odp_time_t time(void)) { volatile uint64_t count = 0; odp_time_t t1, t2, t3; uint64_t ns1, ns2, ns3; - t1 = odp_time_local(); + t1 = time(); while (count < BUSY_LOOP_CNT) { count++; }; - t2 = odp_time_local(); + t2 = time(); while (count < BUSY_LOOP_CNT_LONG) { count++; }; - t3 = odp_time_local(); + t3 = time(); ns1 = odp_time_to_ns(t1); ns2 = odp_time_to_ns(t2); @@ -100,25 +122,36 @@ void time_test_monotony(void) CU_ASSERT(ns3 > ns2); } -void time_test_odp_cmp(void) +void time_test_local_monotony(void) +{ + time_test_monotony(odp_time_local); +} + +void time_test_global_monotony(void) +{ + time_test_monotony(odp_time_global); +} + +static void time_test_cmp(odp_time_t time(void), + odp_time_t time_from_ns(uint64_t ns)) { /* volatile to stop optimization of busy loop */ volatile int count = 0; odp_time_t t1, t2, t3; - t1 = odp_time_local(); + t1 = time(); while (count < BUSY_LOOP_CNT) { count++; }; - t2 = odp_time_local(); + t2 = time(); while (count < BUSY_LOOP_CNT * 2) { count++; }; - t3 = odp_time_local(); + t3 = time(); CU_ASSERT(odp_time_cmp(t2, t1) > 0); CU_ASSERT(odp_time_cmp(t3, t2) > 0); @@ -130,18 +163,30 @@ void time_test_odp_cmp(void) CU_ASSERT(odp_time_cmp(t2, t2) == 0); CU_ASSERT(odp_time_cmp(t3, t3) == 0); - t2 = odp_time_local_from_ns(60 * 10 * ODP_TIME_SEC_IN_NS); - t1 = odp_time_local_from_ns(3); + t2 = time_from_ns(60 * 10 * ODP_TIME_SEC_IN_NS); + t1 = time_from_ns(3); CU_ASSERT(odp_time_cmp(t2, t1) > 0); CU_ASSERT(odp_time_cmp(t1, t2) < 0); - t1 = odp_time_local_from_ns(0); + t1 = time_from_ns(0); CU_ASSERT(odp_time_cmp(t1, ODP_TIME_NULL) == 0); } +void time_test_local_cmp(void) +{ + time_test_cmp(odp_time_local, odp_time_local_from_ns); +} + +void time_test_global_cmp(void) +{ + time_test_cmp(odp_time_global, odp_time_global_from_ns); +} + /* check that a time difference gives a reasonable result */ -void time_test_odp_diff(void) +static void time_test_diff(odp_time_t time(void), + odp_time_t time_from_ns(uint64_t ns), + uint64_t res) { /* volatile to stop optimization of busy loop */ volatile int count = 0; @@ -150,13 +195,13 @@ void time_test_odp_diff(void) uint64_t upper_limit, lower_limit; /* test timestamp diff */ - t1 = odp_time_local(); + t1 = time(); while (count < BUSY_LOOP_CNT) { count++; }; - t2 = odp_time_local(); + t2 = time(); CU_ASSERT(odp_time_cmp(t2, t1) > 0); diff = odp_time_diff(t2, t1); @@ -173,7 +218,7 @@ void time_test_odp_diff(void) /* test timestamp and interval diff */ ns1 = 54; - t1 = odp_time_local_from_ns(ns1); + t1 = time_from_ns(ns1); ns = ns2 - ns1; diff = odp_time_diff(t2, t1); @@ -188,7 +233,7 @@ void time_test_odp_diff(void) ns2 = 60 * 10 * ODP_TIME_SEC_IN_NS; ns = ns2 - ns1; - t2 = odp_time_local_from_ns(ns2); + t2 = time_from_ns(ns2); diff = odp_time_diff(t2, t1); CU_ASSERT(odp_time_cmp(diff, ODP_TIME_NULL) > 0); nsdiff = odp_time_to_ns(diff); @@ -205,17 +250,29 @@ void time_test_odp_diff(void) CU_ASSERT(odp_time_cmp(t2, diff) == 0); } +void time_test_local_diff(void) +{ + time_test_diff(odp_time_local, odp_time_local_from_ns, local_res); +} + +void time_test_global_diff(void) +{ + time_test_diff(odp_time_global, odp_time_global_from_ns, global_res); +} + /* check that a time sum gives a reasonable result */ -void time_test_odp_sum(void) +static void time_test_sum(odp_time_t time(void), + odp_time_t time_from_ns(uint64_t ns), + uint64_t res) { odp_time_t sum, t1, t2; uint64_t nssum, ns1, ns2, ns; uint64_t upper_limit, lower_limit; /* sum timestamp and interval */ - t1 = odp_time_local(); + t1 = time(); ns2 = 103; - t2 = odp_time_local_from_ns(ns2); + t2 = time_from_ns(ns2); ns1 = odp_time_to_ns(t1); ns = ns1 + ns2; @@ -229,7 +286,7 @@ void time_test_odp_sum(void) /* sum intervals */ ns1 = 60 * 13 * ODP_TIME_SEC_IN_NS; - t1 = odp_time_local_from_ns(ns1); + t1 = time_from_ns(ns1); ns = ns1 + ns2; sum = odp_time_sum(t2, t1); @@ -245,6 +302,16 @@ void time_test_odp_sum(void) CU_ASSERT(odp_time_cmp(t2, sum) == 0); } +void time_test_local_sum(void) +{ + time_test_sum(odp_time_local, odp_time_local_from_ns, local_res); +} + +void time_test_global_sum(void) +{ + time_test_sum(odp_time_global, odp_time_global_from_ns, global_res); +} + void time_test_wait_until(void) { int i; @@ -295,13 +362,13 @@ void time_test_wait_ns(void) CU_ASSERT(odp_time_cmp(diff, upper_limit) <= 0); } -void time_test_odp_to_u64(void) +static void time_test_to_u64(odp_time_t time(void)) { volatile int count = 0; uint64_t val1, val2; odp_time_t t1, t2; - t1 = odp_time_local(); + t1 = time(); val1 = odp_time_to_u64(t1); CU_ASSERT(val1 > 0); @@ -310,7 +377,7 @@ void time_test_odp_to_u64(void) count++; }; - t2 = odp_time_local(); + t2 = time(); val2 = odp_time_to_u64(t2); CU_ASSERT(val2 > 0); @@ -320,17 +387,34 @@ void time_test_odp_to_u64(void) CU_ASSERT(val1 == 0); } +void time_test_local_to_u64(void) +{ + time_test_to_u64(odp_time_local); +} + +void time_test_global_to_u64(void) +{ + time_test_to_u64(odp_time_global); +} + odp_testinfo_t time_suite_time[] = { - ODP_TEST_INFO(time_test_odp_constants), - ODP_TEST_INFO(time_test_res), - ODP_TEST_INFO(time_test_odp_conversion), - ODP_TEST_INFO(time_test_monotony), - 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_constants), + ODP_TEST_INFO(time_test_local_res), + ODP_TEST_INFO(time_test_local_conversion), + ODP_TEST_INFO(time_test_local_monotony), + ODP_TEST_INFO(time_test_local_cmp), + ODP_TEST_INFO(time_test_local_diff), + ODP_TEST_INFO(time_test_local_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(time_test_local_to_u64), + ODP_TEST_INFO(time_test_global_res), + ODP_TEST_INFO(time_test_global_conversion), + ODP_TEST_INFO(time_test_global_monotony), + ODP_TEST_INFO(time_test_global_cmp), + ODP_TEST_INFO(time_test_global_diff), + ODP_TEST_INFO(time_test_global_sum), + ODP_TEST_INFO(time_test_global_to_u64), ODP_TEST_INFO_NULL }; diff --git a/test/validation/time/time.h b/test/validation/time/time.h index c2330f8..b734139 100644 --- a/test/validation/time/time.h +++ b/test/validation/time/time.h @@ -10,16 +10,23 @@ #include /* test functions: */ -void time_test_odp_constants(void); -void time_test_res(void); -void time_test_odp_conversion(void); -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_constants(void); +void time_test_local_res(void); +void time_test_global_res(void); +void time_test_local_conversion(void); +void time_test_global_conversion(void); +void time_test_local_monotony(void); +void time_test_global_monotony(void); +void time_test_local_cmp(void); +void time_test_global_cmp(void); +void time_test_local_diff(void); +void time_test_global_diff(void); +void time_test_local_sum(void); +void time_test_global_sum(void); void time_test_wait_until(void); void time_test_wait_ns(void); -void time_test_odp_to_u64(void); +void time_test_local_to_u64(void); +void time_test_global_to_u64(void); /* test arrays: */ extern odp_testinfo_t time_suite_time[];