From patchwork Mon Apr 24 10:49:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 98035 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp1421980qgf; Mon, 24 Apr 2017 03:53:49 -0700 (PDT) X-Received: by 10.36.54.129 with SMTP id l123mr13029620itl.50.1493031229599; Mon, 24 Apr 2017 03:53:49 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id l186si10971912ite.74.2017.04.24.03.53.49; Mon, 24 Apr 2017 03:53:49 -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 331B060962; Mon, 24 Apr 2017 10:53:49 +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=-1.9 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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 C80DC608DF; Mon, 24 Apr 2017 10:51:13 +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 454A16069C; Mon, 24 Apr 2017 10:50:47 +0000 (UTC) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10105.outbound.protection.outlook.com [40.107.1.105]) by lists.linaro.org (Postfix) with ESMTPS id F004560C0D for ; Mon, 24 Apr 2017 10:50:07 +0000 (UTC) Received: from DB6PR07CA0069.eurprd07.prod.outlook.com (10.175.237.159) by HE1PR0701MB2121.eurprd07.prod.outlook.com (10.168.36.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1061.6; Mon, 24 Apr 2017 10:50:05 +0000 Received: from AM5EUR03FT060.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::207) by DB6PR07CA0069.outlook.office365.com (2603:10a6:6:2a::31) 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; Mon, 24 Apr 2017 10:50:05 +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 AM5EUR03FT060.mail.protection.outlook.com (10.152.16.160) 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; Mon, 24 Apr 2017 10:50:05 +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 v3OAnHvq005824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 24 Apr 2017 13:49:17 +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 v3OAnHYV005796 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Mon, 24 Apr 2017 13:49:17 +0300 X-HPESVCS-Source-Ip: 10.144.104.219 From: Petri Savolainen To: Date: Mon, 24 Apr 2017 13:49:16 +0300 Message-ID: <20170424104917.24102-8-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170424104917.24102-1-petri.savolainen@linaro.org> References: <20170424104917.24102-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)(39450400003)(39850400002)(39840400002)(39860400002)(39400400002)(39410400002)(2980300002)(199003)(189002)(9170700003)(356003)(189998001)(110136004)(38730400002)(8676002)(81166006)(8936002)(50226002)(50986999)(76176999)(305945005)(2906002)(22756006)(48376002)(5660300001)(2351001)(1076002)(33646002)(50466002)(105596002)(106466001)(5003940100001)(6916009)(2950100002)(77096006)(53936002)(575784001)(86362001)(47776003)(36756003)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0701MB2121; H:mailrelay.int.nokia.com; FPR:; SPF:SoftFail; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM5EUR03FT060; 1:1SlT8jKiUyrD0DZiGGpjxl1NM27keT7+R9FwWupWQjszEtPnRkq5BLsh017Fpr8rEBV6X0ecEjvFoLdrjsdE5jOBoOgEeh+P/jA4lZ9Sc0VA/zemN+ijeAjXvuCNIitdjKeXuEasOQ0O018rDRiTDihox8frVwUaAhbVCMwQWrXso7Pt06ExmD2Ltgpsr6qzhnFnhJvkPsS9vyugmwWsEJRV/whG0oiHuJT/g5ZQHwvnTja9qkIkCyJVZCPSsvQI3MlU7I8adSyT2af1/QM8gyZj8bHJdWkNoK1o+UIiKHoeCaCLmfgwNXRbkeHdUlwu+83ws9xVMuTb+AFNO0paK1PKI025vlBhurozbn6yUKksbRQVdDoRE9OYoXLagf65x5qGp/88klqWRLo3UisSYPCKqyZcskm+pTZZ0F1qLbcaWKPSA8unxJQ2TiSRLDyfsioxj4+x4t/xGWw3bM5WT7PdfLRr0DAeiZY0kfeabIg9lkbL6GQM7r/t2clFBWGXMYludXjU3a4rBMptXHVC+g== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 107f0544-ae54-432e-d1c2-08d48affaaf3 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(201703131423075)(201703031133081); SRVR:HE1PR0701MB2121; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB2121; 3:RnZmpI0pWvQmEjtAgmnycOw4wDX3mGCXo08U/6SG01EOKqkleg8xMrCgxaK3QIRdzuFhjZXV7+5I/Xt7PX0b/2VZWB9vjbxTGqt8iejkE4y02D4ptJPdE/iYg39LWyWV8DIghkwAP/64ZiCN8Yxphv2NJe+w/8sZBBzqQ57AMk7TUnUqZ/6DquDxrde0CFuNV+xTcQvNC+u1p+e7s+JRgGxA7DTCgqyJ0xpolZCSR+lQm0S8FYPdh8nQEd/EBhq94+BcgUK2IISBz9y1J4N1XSRe4xxrD4gamEjqwQg9eQcK2kmX813ZABVxEbc2w/gjQhJC7qSuAQgYezB2Kx9cY1hk+k7IioG30QGeAFB+rrAiPcoOxPTrD6M8+gxd4fLq1ujK6awaCMcfUXxo/3M4MA8WLhrrKptTcS0inoAeUgDouRQz0CxW/2m4rD8u+OI3STyuOsZ9KkoHPndtzO0JVw== X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB2121; 25:aou0iegUK6KN2UMZ34w1E1mAapPYPRh3in/ngmaAlwGlcWjN5AvtDnq8rC7QfPldkLalx2PTHKhUcYWcr+MuVwUOM9JiQCmNVFljrwMLlKVUcE9Y0UG6dzBZB14iHZNUEY5yydMMgf4z52R74MAgo84yDgkFXk/sNeNPJXhhKdnycCt2j7OHkaEXfpljj+3Z71Gyq94DNlH9Rvu8z4RDMuuasx1FAYUNAJdTRIKGnAyKXWVpAZi1JzHTybqWca6kVC50jaUVzxkB7oJEefJ1YXpvGpgcT9ccCPoP/z/xY2OeB8KK5HUb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XUC5AqKfZQdNIgC4IRvyoMbI3PDssI/Jj4hntR0= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(13021025)(13013025)(5005006)(13023025)(3002001)(93006095)(93003095)(10201501046)(6055026)(6041248)(20161123564025)(20161123560025)(20161123555025)(20161123558099)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061750152)(6072148); SRVR:HE1PR0701MB2121; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0701MB2121; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB2121; 4:kNX4T6FmRJafISeLp0ryPJ7J+OqsVgOcKR74N9h6EeGGHygEcdNWiIqlLMEKbcr5s2Cs2PDLYyOmyHnCYJpC8a2uu/cGD9ra/G7HQd11QKDR3X1mKvtOyPhou3f+EJiw0LbpCdRq6xDLVdU2ch1k8ImKcV55ylP4Jue1kTVB1J8kRRXyMj95Oopo17dVu/jbmf3Gy590hs7j4MBC+Ou7nyT2Vf+3j/ggx6PTTf1An9P9uWEGF//dwBO7vQRpFc0xzA3Z6rZbbrd6QMJpJcP7+jf32Eywc2oLvceF3kHTtJI45Cg4oL/ILNQR2LlsmqhtDNhmMK86eUmD4Am7XExdmWnlY0/uvBf5sl0gFvyoc58dZt20VhFD0d+QokH37tMuOa8OUvtcgKECHVICJ0ZMijTPIFnC7ltN3fhqL3uWbYe7WkgIht0nSJcdcHaIXcxBGEvyJahAatZu6GLtzVMDRUvzLy3NJlC/F7q9STs9uXRO1oCjaWrKD7e4gwdXlqc4wc/3RcK/nmnal/sq6FamZc1devetDpkZNklvNaM6304ku1tfLsmzZZAfkiv/crLVjm6LETffbLmw7vnFUowUjoyOqVQ6iot0lDoaS4s2PfXdxmKfrFFV7C5KCtl0bmIvcYpVax8q4eglj1chVXK7p9FK0DV6+aBNoMnnwI307DfeVJcenLyduc/of7oPndEZOiDmjp7km2JxT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NXt5Zuqet4tKHXd79ns54ngeruEfvlxltjmrNwgNinkCAUG1B4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB2121; 7:VMHDUMAFPwaQGqFHt/d7y8wFOLaihfh1cjC2kETljHgjQrO/tofCREmSkuXM6ILa7XxyrHXUjdmOzAz6Aej3fU5h8d0tB2ionQv5uWgX21HNy2lTY4P6s6YZV56opgM2pKJznoTTNlARZSDVZQCOfu5oQ1KWSDU583/JtRJwfnEhvIqDhvNigWMQL6KFOLL3rZePoz+GdwRKDfL+nvDxtjCjZZ+41waifxZ1pu4U3mdWr85x3Sbx3AvD5lU7Kvm2aklu6OAiX8LhMExeHqSuDPqa2L3J7/3715E1whODLXRV9yr+uI4o5+l2nXaAJ5w5r7enB8XCVwXWUFw3htyNng== X-OriginatorOrg: nokia.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2017 10:50:05.3762 (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: HE1PR0701MB2121 Subject: [lng-odp] [API-NEXT PATCH v2 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 };