From patchwork Fri Apr 28 12:09:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 98361 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp235120qgf; Fri, 28 Apr 2017 05:19:24 -0700 (PDT) X-Received: by 10.55.127.129 with SMTP id a123mr8957101qkd.127.1493381963968; Fri, 28 Apr 2017 05:19:23 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id g6si5796980qtd.160.2017.04.28.05.19.23; Fri, 28 Apr 2017 05:19:23 -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 7374A62BCA; Fri, 28 Apr 2017 12:19:23 +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 5A31862C3A; Fri, 28 Apr 2017 12:12:15 +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 1BC8862BCA; Fri, 28 Apr 2017 12:11:39 +0000 (UTC) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10092.outbound.protection.outlook.com [40.107.1.92]) by lists.linaro.org (Postfix) with ESMTPS id 3A7FD62BE0 for ; Fri, 28 Apr 2017 12:11:12 +0000 (UTC) Received: from HE1PR0701CA0078.eurprd07.prod.outlook.com (10.168.122.22) by HE1PR07MB0907.eurprd07.prod.outlook.com (10.162.26.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1075.1; Fri, 28 Apr 2017 12:11:10 +0000 Received: from AM5EUR03FT026.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::201) by HE1PR0701CA0078.outlook.office365.com (2603:10a6:3:64::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1075.1 via Frontend Transport; Fri, 28 Apr 2017 12:11:09 +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 AM5EUR03FT026.mail.protection.outlook.com (10.152.16.155) 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, 28 Apr 2017 12:11:09 +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 v3SC9wCT001673 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 28 Apr 2017 15:09:58 +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 v3SC9wn6001645 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Fri, 28 Apr 2017 15:09:58 +0300 X-HPESVCS-Source-Ip: 10.144.104.219 From: Petri Savolainen To: Date: Fri, 28 Apr 2017 15:09:55 +0300 Message-ID: <20170428120958.17526-9-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170428120958.17526-1-petri.savolainen@linaro.org> References: <20170428120958.17526-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)(39850400002)(39410400002)(39860400002)(39840400002)(39450400003)(39400400002)(2980300002)(199003)(189002)(9170700003)(86362001)(5003940100001)(2906002)(1076002)(50226002)(36756003)(22756006)(76176999)(47776003)(2950100002)(50986999)(6666003)(189998001)(6916009)(106466001)(8936002)(53936002)(5660300001)(77096006)(105596002)(81166006)(33646002)(8676002)(2351001)(50466002)(48376002)(110136004)(38730400002)(356003)(305945005)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR07MB0907; H:mailrelay.int.nokia.com; FPR:; SPF:SoftFail; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM5EUR03FT026; 1:yK7QSXfrVB+t5p7iGwOap8bGX8IGQHCS6yzerqtdpGB2oLJA2rzZNGmKWnnBsLN/DJpnzEzRI15NxkymLaYia7Ns8tiq/d/T6EaRUlAgaFapyBoiMte+FrlxIiULkenKjmdmFC83A60pk3Jmff+353efyCJpW/6yfmVgw/dkCbMQdNC/jdpWhf7JnI5xC0N70SY+Mz2awTTvIJKa4rtAVyfdz8DUiHYsASJp3IUkUl7teHEaWRhrs+1N20ig4SXvTtJHfK/QS24gqe4QnZg3WYe+Z2vF6JBejS9f8z0BxpV8PBUpMlozlQM+9M0QJP5m6fdxjzuWPzD2vex8OpQW514MgmApTR3GHDXl5AzNsT0eiHHpqsKvWGbnB6phbt479sgV4bOwuFaGx0C4hg2DFotKLe1n+qCdnhtQfPI1kph4MeEw/t9QB/wyOAf9DkbTWq2bRYY+VzJYJljORat526T3nD8Lcu5nyFN8FjhFVxrfdnZO85WPMI9qoeg4LcN2gpfHYOKPIr7Te49dPzaHmg== MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3fb38abc-4255-4998-32ba-08d48e2fa796 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(201703131423075)(201703031133081); SRVR:HE1PR07MB0907; X-Microsoft-Exchange-Diagnostics: 1; HE1PR07MB0907; 3:btIm+dnnqlfXIzxs9q0n3Zyp8yHv8TF9bQzX7YlWnkEpCxqdWdpel7lK9GITYMF8ErfHL7IaQVuV2PVuCtY/KQBhm7RX3fKDdH1x6ty9thTVCsOi8Mm3DjpVhkZ7xO0CzFe0O2LCNlAzVrR9c+m6HBxW8Vwtsn+qPdg4kUpq8TWVXWa5K189aZvb/GMVxOCVF86HCh8ge/AfrBMVmoQasbtfTn5hN9VSS8iovsyS3uTnpLFXCgLtjbpnlkQYFp+iZRMjfq5vmNJ1GV8QUU7HzDSgiPT/CAI9bcFMfa4RFEXqCYW31PtO6oBddznQiI9chCvrHI9eEL8eCPKfBor65QOB9C+q3Pgke0IsFzzThN9xx1g+RxnrBOY/4pe1U3IPQbdWbsyYYlAzQL/ydA1jQQEu8DiY0tRb/634ImUToyuwB0VoeK2nFF3OXpQig+SpT2xTBchdpoxEnK1MoYobVA== X-Microsoft-Exchange-Diagnostics: 1; HE1PR07MB0907; 25:9ylFQyYNcsmJpWSJH4CX4eISvyMNe/UB28hZAh4dF9nB3dSE9dGR0cvv793X1zAAlPYTT7YB+7mMVYZOurUo0TDvT6MNsltuWMrenn4PAx6il2XBdEzV/Ta07SGDkuAIdiL/00sweC+HaaS7Q8p4YsQoVmrIkr7vnNExr1uEuAsunw/UN4RaIe7twRowq+x/7Ra0A7dtmaKXWbtEPyGOSM+Kg2C0oKCWeyYzXA6BRn0EvWDLeXVb/2yKszQjXNVPAxwANlDOB+IsDGpwJi8iHtqIL1CFMKAdxi8AOLc+ic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POvFTRkb14nMGSH7DDul0tx+lOKut4= 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)(5005006)(8121501046)(13023025)(13021025)(93006095)(93003095)(3002001)(10201501046)(6055026)(6041248)(20161123558100)(20161123562025)(20161123560025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061750153)(20161123555025)(6072148); SRVR:HE1PR07MB0907; BCL:0; PCL:0; RULEID:; SRVR:HE1PR07MB0907; X-Microsoft-Exchange-Diagnostics: 1; HE1PR07MB0907; 4:qBlXEuxh7+evfB5AfTaJLE4syFErIa7UNaq2+Coe7psgo8ojijyGZNCIX514xTWOVMh4IYGIL8hnyOdU1Xw5uwjjTOXNWB/TYyuwJ/ykUt4knjmIwe2j/Kam+LQUL6gkvSFDTQJnrDzHq2F3b/FYxOf/MuAMky//1TlF8a89ClyvXFjUKUXCgt9BtPAfxup8zSnEL1i5YUShU5jpalW0uHe17I3CIn/du8rDpTnvPnOJliWxrz5kgoG5cu6pbhlZoyHFzC5F4s9S+uFlom/hketRX3ybe4wRDZOkgNRirBes8S1i9n2zaGZSNQgQJR9O4xcm/ZjbOE6EAD+uhlqvMbCZTyoEJbTkPSw2mUiZRgx48gOVBxQQe3ST2oCTmYpL78N+GZkCTIGOAdk5v971boG7cO4dE9D+I6sCcjrskeITvXJwWOslGO0ysLDz4ahz7DXQfFERC4EG1AVwsn4dLhP1PXI9lP5m/nP64JGix6aDtnx99znRORmCG2X0kZVyqgVEuoa21fR7XAz0EmCo7KACGXtbd/OheYs03Rqo5zT8DcCG4itu+iyfklPd8JGeUt6RLP5mzFHSKPjDHUqz48LV6VGLXcKIZi76ys/YxGVV0GV5q+w7IRja2yZHZFr2F6i/GOCK4/LPoIYUlCk/oHB8Cynt2HEuWxbGvJ3lOI3OSO2fXME91Rfgnxn23hxx+7RTLO1e2utla9/cziFRsrHB7IPNnZ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BOcRWX/7Cve6fQERkBD58SbgT9I4H+g= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR07MB0907; 7:TRLLZTQtGOipjxGF0CA6+7cOn65BTJIf0fD+s47dSgSBmBBtlYveUwS6OQJl/Z1A05ejuG8g/TKtrXUkhtAYaCiRmU01uW1F5x/c1d2LCBQR8/U1ekuoJagcLS5UNeMnZa/P4NBH/eI1fGzDb+EGC7LeQHHC49IRNRLBv7G617U5/2u0jCBxcFqukfohJCnjWUl7sE9somLM4OasIPDLLkOmSQol5MYj5CMmaVSIh7AmQumHQ7Lsu/MzB84MGbQo6icJSEwhJ8qC3njMBDXVomNlYDJr6EHr7l68XsIptOWlBIRONONGLrX8zmI7V/dygfQvLi+URnh66LuR1aVnDQ== X-OriginatorOrg: nokia.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2017 12:11:09.0765 (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: HE1PR07MB0907 Subject: [lng-odp] [API-NEXT PATCH v3 08/11] 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 | 66 +++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 12 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 36c419cb..e2ca2e17 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,6 +399,45 @@ void time_test_wait_ns(void) } } +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), @@ -408,12 +448,14 @@ 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_global_res), ODP_TEST_INFO(time_test_global_conversion), 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_wait_until), + ODP_TEST_INFO(time_test_global_accuracy), ODP_TEST_INFO_NULL };