From patchwork Fri Apr 21 13:11:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 97902 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp321389qgf; Fri, 21 Apr 2017 06:16:45 -0700 (PDT) X-Received: by 10.237.36.105 with SMTP id s38mr14227395qtc.185.1492780605173; Fri, 21 Apr 2017 06:16:45 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id r29si9496078qtb.270.2017.04.21.06.16.44; Fri, 21 Apr 2017 06:16:45 -0700 (PDT) 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id BB72C62BE0; Fri, 21 Apr 2017 13:16:44 +0000 (UTC) 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=-4.7 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 12B7061BAC; Fri, 21 Apr 2017 13:12:42 +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 10D0462B60; Fri, 21 Apr 2017 13:12:36 +0000 (UTC) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40128.outbound.protection.outlook.com [40.107.4.128]) by lists.linaro.org (Postfix) with ESMTPS id BBD2762B5E for ; Fri, 21 Apr 2017 13:11:56 +0000 (UTC) Received: from DB6PR07CA0085.eurprd07.prod.outlook.com (2603:10a6:6:2b::23) by DB5PR07MB0901.eurprd07.prod.outlook.com (2a01:111:e400:5105::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1047.6; Fri, 21 Apr 2017 13:11:55 +0000 Received: from VE1EUR03FT060.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::208) by DB6PR07CA0085.outlook.office365.com (2603:10a6:6:2b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1061.6 via Frontend Transport; Fri, 21 Apr 2017 13:11:54 +0000 Received-SPF: SoftFail (protection.outlook.com: domain of transitioning linaro.org discourages use of 131.228.2.240 as permitted sender) Received: from mailrelay.int.nokia.com (131.228.2.240) by VE1EUR03FT060.mail.protection.outlook.com (10.152.19.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1047.9 via Frontend Transport; Fri, 21 Apr 2017 13:11:54 +0000 Received: from fihe3nok0734.emea.nsn-net.net (localhost [127.0.0.1]) by fihe3nok0734.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id v3LDBZVL025528 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 21 Apr 2017 16:11:35 +0300 Received: from 10.144.19.15 ([10.144.104.219]) by fihe3nok0734.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id v3LDBYOj025438 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Fri, 21 Apr 2017 16:11:35 +0300 X-HPESVCS-Source-Ip: 10.144.104.219 From: Petri Savolainen To: Date: Fri, 21 Apr 2017 16:11:33 +0300 Message-ID: <20170421131134.27992-8-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170421131134.27992-1-petri.savolainen@linaro.org> References: <20170421131134.27992-1-petri.savolainen@linaro.org> X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:131.228.2.240; IPV:CAL; CTRY:FI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(39400400002)(39850400002)(39860400002)(39840400002)(39450400003)(39410400002)(2980300002)(199003)(189002)(9170700003)(76176999)(356003)(36756003)(305945005)(1076002)(2906002)(47776003)(575784001)(86362001)(2950100002)(6916009)(33646002)(2351001)(50986999)(77096006)(189998001)(5003940100001)(8676002)(81166006)(106466001)(8936002)(105596002)(53936002)(50226002)(5660300001)(110136004)(48376002)(38730400002)(22756006)(50466002)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DB5PR07MB0901; H:mailrelay.int.nokia.com; FPR:; SPF:SoftFail; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; VE1EUR03FT060; 1:g0i+JJ007H4yzvMOmHvXgvd2RO+y8rJzVYBKorFTcn6BbNNqM4eN4WjTWmLf53ICE2MXtH+BL/ohmJv7wqgZfSEgbFnLA8CHDtui2GX2/ngGw/vaFDtTnqNoecKrvcfqUHoNCHan/t9GTwN22w0eemNBfusXwGEfpWB0ljyjaRIayYMwO1ti1SMBPfCbit1o2zopL2weJoogFnnBJsdIbQWCYovuHQNxKjLSHSN1oTGmUJNAN8Ylt9tDg8tZp5mpgKBtRgETeInRxHxYLI+RC+Vlbwi0vb4KhyHjsMIEs1/Wkl5q72lnbfr+/u1rdH7D+Sa5pAcn8KkwnIOCcuzbkjmbFTN93bNhHpRgOl6qGILastZrANooNnjJYE2pSB9+I0/LyZwgisvhhgbUfIuaWLg59FdP+MNdnZ5ZThpKBI9niD2L9p3gJeEUK/zr0Cp47jHhzEfmb3GD15wPCarU+0486fu098kLD3hzEEap7D6e4BwRM1l+nXuW0fiQZx8P44bV3gib+IAxgOHRFZ8fsQ== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: b6380bbf-4e89-4438-ceb8-08d488b7fb92 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(201703131423075)(201703031133081); SRVR:DB5PR07MB0901; X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB0901; 3:mdDontgt7qXq/lpAVG1bduyvWKzfpUXt0TCrVYbN+3fCudh1OIit2mqRHKf/73keE6hV+F4c3RWy4rCqsVg9CYhM+03lGT1jNRBdR/AXLYvKGvHmbVdzC/lgM2+oZpcSvVSRxi9PJyvC3v+Qtu/kynuhVK5V/tG1bibAZvBOCXFPWF5ZtetWOEX8OPc6DHCbyS2PTeU7/ynuxuZOEK6JNdQrF7l4CHpb9ZMgGTHKgz5SUKXx2UmFxR5ZdHOowhzF7Hvd30ZUFcJKBMMoOmfJ9BSv9ix/PHKX3xk7unutF5D7qbxosPODDjVjs/ekFKr8f5bZf1qrEnfz/32l76u2qHD+38VrnIXf1wnzP8gTdRLxuh3RzcGTWu/9tDxuUfUfCY6DotMxl0SlvxmiFSv4W/wML3vaZtUPAfcv7Hyaz437lVLg8sMvGPg4QNTAAhP8b3oR0gRKSIiuh4o1ZNV5hw== X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB0901; 25:qzDDkO8BN1xJW7uxsPcSFLeLXj3sTT9KLumvcL65bNiH1mz4dFaZZsq0vFvAJzPyQI3KmuCw6KHqR4HUcor2TsnOd2VUZpShiK5EqX9W09H+lFm0L0bwFJKRUB6L4T6sPMzFVz6m8JGRYdp+OGk1HVAHglYPC9IpoRUkx9pIel8oemnGyMX1vRfPeNrTS4FwFTEkLfUhZZdt8GapDY7BS8Mxi7r61HVhVyPfvDJiapCyfTYRQlTBjAc9Da3VXGOx+bjd4e1MGTIbuut1FeHKKWxMplSjL0EMq/6WsH7AF5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QuYo/u7t5vI631tvLCQ0KAB0roVqEtvH7f8+qqRUSBDw/Q6dLcnotcQFGE= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(13013025)(8121501046)(5005006)(13023025)(13021025)(93006095)(93003095)(10201501046)(3002001)(6055026)(6041248)(20161123560025)(20161123555025)(20161123564025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(6072148); SRVR:DB5PR07MB0901; BCL:0; PCL:0; RULEID:; SRVR:DB5PR07MB0901; X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB0901; 4:Y1SVHTVmMu+5wezylstt6L7aGzebG+8nwv0qAoygRM722bhzu1RI3TaY/1C3s897E3hoMZPSgwuWdp/peP/QLObIgji2Y9zgRpHO8M7KdCY5d4EVZwxDvqztWwssgce0ySIxvxtQcrv2qW4UmSb2WVwP7OX2pGAuoyrc2kLm3186ab7n1wQB3Mbu9vI/0hKKSc+Gz+nTZxUg3LbBWiag8Wd97HVgCwDGVscQ+vIeCSEnDTe2FivGzKhmIAfd7XMTdqHNBo7H4WaFq7YEKSjeYlLqJ6hZe2tB7nmzb48L/7bFV+G1R48+jVJHWjDSyn7VGAsjPgD1UBZUkFDcx8MnrcJEy1UiU/JspxaoYzrRdPYQnzMfN9XpZg7X3JIYH+CFiexOgfp97YaggXwS67Fqyd6XsSLHoj1YtvQBsr+EB97XK+TPknTBuy9wzkcTR7AolFyPrqf0RHIPWclRigF0YGf7HjuPQLshkE00u6Gpi514dg0vyh8KReTE3QK/WmREvRpYgjTwgMeA0k+JKXe1MNx1c8QfPSZ1wuG/fqRsG50+93F5kqDOozSJRsKkFLW4sAgvQOf76Ii/yz+pSW6K6jLnzErQGjJMo5k2NeKByXuLlgLFVaXQ9ZgMDkhd+zc+wb2MM9OM+Gi7gQQPDYlnM7bMy+8oAKqfyA2R0zqA7DGGkDURoKl4gxapXASG0kb2cdVv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: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB0901; 7:k9eF2KnhWD0c+5ydNAzCfRcGAlY7WY4b/ROL2rYFNI6SZ6jbEM8hukIUeLBWFyG6B7in5hzt0RWNr1/b03Lb+nzOSoLtxSMA29gf+IKXqBgbkqfiw6sgH45W2Zmdn2tLryRMGygqTrMmknI4YVP3wRdnhTKMo6fP7/DGtXJHTepdwzk8biSo8LUm0O56KtU5dcXWQNLT+B2jD1Bj+Wd7a0/GZuqpTtlYtKgdUPm63tqy7VQIKc/gHdLMNfrfG8OuyquQln88GspWDON/9ENamnpRXcsSn080mZeReHS6LfEohKv/qZXrz4akM6QetOY3CS/LJTd9GlV/amn7SjSJcg== X-OriginatorOrg: nokia.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2017 13:11:54.5146 (UTC) X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.2.240]; Helo=[mailrelay.int.nokia.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR07MB0901 Subject: [lng-odp] [API-NEXT PATCH 7/8] test: validation: add time accuracy test 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Test ODP time keeping accuracy against system time. Signed-off-by: Petri Savolainen --- test/common_plat/validation/api/time/time.c | 72 +++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 15 deletions(-) -- 2.11.0 diff --git a/test/common_plat/validation/api/time/time.c b/test/common_plat/validation/api/time/time.c index aee7ccef..90e0d301 100644 --- a/test/common_plat/validation/api/time/time.c +++ b/test/common_plat/validation/api/time/time.c @@ -7,6 +7,7 @@ #include #include "odp_cunit_common.h" #include "time_test.h" +#include #define BUSY_LOOP_CNT 30000000 /* used for t > min resolution */ #define BUSY_LOOP_CNT_LONG 6000000000 /* used for t > 4 sec */ @@ -140,25 +141,25 @@ void time_test_monotony(void) CU_ASSERT(ns3 > ns2); } -static void time_test_cmp(time_cb time, time_from_ns_cb time_from_ns) +static void time_test_cmp(time_cb time_cur, time_from_ns_cb time_from_ns) { /* volatile to stop optimization of busy loop */ volatile int count = 0; odp_time_t t1, t2, t3; - t1 = time(); + t1 = time_cur(); while (count < BUSY_LOOP_CNT) { count++; }; - t2 = time(); + t2 = time_cur(); while (count < BUSY_LOOP_CNT * 2) { count++; }; - t3 = time(); + t3 = time_cur(); CU_ASSERT(odp_time_cmp(t2, t1) > 0); CU_ASSERT(odp_time_cmp(t3, t2) > 0); @@ -191,7 +192,7 @@ void time_test_global_cmp(void) } /* check that a time difference gives a reasonable result */ -static void time_test_diff(time_cb time, +static void time_test_diff(time_cb time_cur, time_from_ns_cb time_from_ns, uint64_t res) { @@ -202,13 +203,13 @@ static void time_test_diff(time_cb time, uint64_t upper_limit, lower_limit; /* test timestamp diff */ - t1 = time(); + t1 = time_cur(); while (count < BUSY_LOOP_CNT) { count++; }; - t2 = time(); + t2 = time_cur(); CU_ASSERT(odp_time_cmp(t2, t1) > 0); diff = odp_time_diff(t2, t1); @@ -268,7 +269,7 @@ void time_test_global_diff(void) } /* check that a time sum gives a reasonable result */ -static void time_test_sum(time_cb time, +static void time_test_sum(time_cb time_cur, time_from_ns_cb time_from_ns, uint64_t res) { @@ -277,7 +278,7 @@ static void time_test_sum(time_cb time, uint64_t upper_limit, lower_limit; /* sum timestamp and interval */ - t1 = time(); + t1 = time_cur(); ns2 = 103; t2 = time_from_ns(ns2); ns1 = odp_time_to_ns(t1); @@ -319,20 +320,20 @@ void time_test_global_sum(void) time_test_sum(odp_time_global, odp_time_global_from_ns, global_res); } -static void time_test_wait_until(time_cb time, time_from_ns_cb time_from_ns) +static void time_test_wait_until(time_cb time_cur, time_from_ns_cb time_from_ns) { int i; odp_time_t lower_limit, upper_limit; odp_time_t start_time, end_time, wait; odp_time_t second = time_from_ns(ODP_TIME_SEC_IN_NS); - start_time = time(); + start_time = time_cur(); wait = start_time; for (i = 0; i < WAIT_SECONDS; i++) { wait = odp_time_sum(wait, second); odp_time_wait_until(wait); } - end_time = time(); + end_time = time_cur(); wait = odp_time_diff(end_time, start_time); lower_limit = time_from_ns(WAIT_SECONDS * ODP_TIME_SEC_IN_NS - @@ -398,13 +399,13 @@ void time_test_wait_ns(void) } } -static void time_test_to_u64(time_cb time) +static void time_test_to_u64(time_cb time_cur) { volatile int count = 0; uint64_t val1, val2; odp_time_t t1, t2; - t1 = time(); + t1 = time_cur(); val1 = odp_time_to_u64(t1); CU_ASSERT(val1 > 0); @@ -413,7 +414,7 @@ static void time_test_to_u64(time_cb time) count++; }; - t2 = time(); + t2 = time_cur(); val2 = odp_time_to_u64(t2); CU_ASSERT(val2 > 0); @@ -433,6 +434,45 @@ void time_test_global_to_u64(void) time_test_to_u64(odp_time_global); } +static void time_test_accuracy(time_cb time_cur, time_from_ns_cb time_from_ns) +{ + int i; + odp_time_t t1, t2, wait, diff; + clock_t c1, c2; + double sec_t, sec_c; + odp_time_t sec = time_from_ns(ODP_TIME_SEC_IN_NS); + + c1 = clock(); + t1 = time_cur(); + + wait = odp_time_sum(t1, sec); + for (i = 0; i < 5; i++) { + odp_time_wait_until(wait); + wait = odp_time_sum(wait, sec); + } + + t2 = time_cur(); + c2 = clock(); + + diff = odp_time_diff(t2, t1); + sec_t = ((double)odp_time_to_ns(diff)) / ODP_TIME_SEC_IN_NS; + sec_c = ((double)(c2 - c1)) / CLOCKS_PER_SEC; + + /* Check that ODP time is within +-5% of system time */ + CU_ASSERT(sec_t < sec_c * 1.05); + CU_ASSERT(sec_t > sec_c * 0.95); +} + +static void time_test_local_accuracy(void) +{ + time_test_accuracy(odp_time_local, odp_time_local_from_ns); +} + +static void time_test_global_accuracy(void) +{ + time_test_accuracy(odp_time_global, odp_time_global_from_ns); +} + odp_testinfo_t time_suite_time[] = { ODP_TEST_INFO(time_test_constants), ODP_TEST_INFO(time_test_local_res), @@ -443,6 +483,7 @@ odp_testinfo_t time_suite_time[] = { ODP_TEST_INFO(time_test_local_sum), ODP_TEST_INFO(time_test_local_wait_until), ODP_TEST_INFO(time_test_wait_ns), + ODP_TEST_INFO(time_test_local_accuracy), ODP_TEST_INFO(time_test_local_to_u64), ODP_TEST_INFO(time_test_global_res), ODP_TEST_INFO(time_test_global_conversion), @@ -450,6 +491,7 @@ odp_testinfo_t time_suite_time[] = { ODP_TEST_INFO(time_test_global_diff), ODP_TEST_INFO(time_test_global_sum), ODP_TEST_INFO(time_test_global_wait_until), + ODP_TEST_INFO(time_test_global_accuracy), ODP_TEST_INFO(time_test_global_to_u64), ODP_TEST_INFO_NULL };