From patchwork Mon Jan 1 22:00:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 123088 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8281560qgn; Mon, 1 Jan 2018 14:10:14 -0800 (PST) X-Google-Smtp-Source: ACJfBosMKm24qq31u8Wde1qHgVtgxNk12CWk0bHTnSAB+2yxsnM1GwHnnX5QRicY8CLxS55qEVBw X-Received: by 10.200.23.18 with SMTP id w18mr54666611qtj.47.1514844614790; Mon, 01 Jan 2018 14:10:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514844614; cv=none; d=google.com; s=arc-20160816; b=h0yOfHQw6mxtC/K/xnYTPOcGqpHhxf2HjDSb1oGoLawVyDPk0+hrWVUJGESd3S4jQd jtkuOfSNfKxY3OBGfKE1X4XM3kktFbJ6ipBQ72rwjw5thHohmbQfnEBqmu0CIwTdbkuS 7E5EqtL8ISA0c1dC3luEIDRf5YDhU4HAbsszBApLhKXMXk28jNEgGnmjPP6DVk3t1Muo /acVlCPFvwdWa0r6rMFi/iesWNgAeOHfopEFoDfgtjYMK9O4HGkTBswXoUkZ89tnXKLN PKnwj2kkjB8crBU8CNIpOTquBQ27ftleffKFMwBHrmrrsIdwItDKsi03UGTx0KxB2N08 K19A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=c5zTm97iOPvjMlNPilpBVw6ZCjMO9xKKRn+rDyNBk+Y=; b=b8fO3sCQyXFY5GxPhyA5rgZTdb15rKLaUU96Nzl0lYxQX1xh2m3xhE4gigC3PypaLc V9CsAPaWEPPPcdz8WhnlP/x0i3cy+fAAPnFh+A3swc2ppFZ6+/cPIBOOP1NaNOEjLT+5 lC3iDNKR4DXKa5k63KAJeMXeNFVKDMyt4nxNGaC2ljIy3Cf+2GitHNmWlnMPLQt1IO0d COtyCChRjnOqLMVWwLzBeNCMdrH5pDJckUmQDk2Cxvb9pUeU/tKl6kUzZlXzYaYKu6lm dnIPsWugCMoyQA+QbTCBFTpi84B1d9DOCLhA3HXRTjQ3YgBz+HW0F5SsoMreUeDgjg0n 5wtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id l5si959984qti.111.2018.01.01.14.10.14; Mon, 01 Jan 2018 14:10:14 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 698E4616B9; Mon, 1 Jan 2018 22:10:14 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 59376616E2; Mon, 1 Jan 2018 22:01:31 +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 BED14616E2; Mon, 1 Jan 2018 22:01:25 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id 3C03C60865 for ; Mon, 1 Jan 2018 22:00:22 +0000 (UTC) Received: from mxback12g.mail.yandex.net (mxback12g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:91]) by forward103j.mail.yandex.net (Yandex) with ESMTP id A362134C26E6 for ; Tue, 2 Jan 2018 01:00:20 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback12g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id ShnlHBgaG2-0EXaVQ9w; Tue, 02 Jan 2018 01:00:14 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id X57ZRXUA30-0EPaHKbI; Tue, 02 Jan 2018 01:00:14 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 2 Jan 2018 01:00:07 +0300 Message-Id: <1514844007-22122-12-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514844007-22122-1-git-send-email-odpbot@yandex.ru> References: <1514844007-22122-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 377 Subject: [lng-odp] [PATCH v5 11/11] validation: time: use time() instead of clock() 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" From: Dmitry Eremin-Solenikov ODP test for time API uses clock() to compare time against. However clock() returns processor time used by program, which can differ between runs. Use time() as a time source to compare against. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 377 (lumag:misc-fixes) ** https://github.com/Linaro/odp/pull/377 ** Patch: https://github.com/Linaro/odp/pull/377.patch ** Base sha: 49ebafae0edebbc750742d8874ad0a7588286dea ** Merge commit sha: 3b7e2ac62accecc65b9f91635a4b6ef04ca77988 **/ test/validation/api/time/time.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/validation/api/time/time.c b/test/validation/api/time/time.c index c8f90dbac..95422b683 100644 --- a/test/validation/api/time/time.c +++ b/test/validation/api/time/time.c @@ -423,11 +423,11 @@ 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; + time_t c1, c2; double sec_t, sec_c; odp_time_t sec = time_from_ns(ODP_TIME_SEC_IN_NS); - c1 = clock(); + c1 = time(NULL); t1 = time_cur(); wait = odp_time_sum(t1, sec); @@ -436,12 +436,12 @@ static void time_test_accuracy(time_cb time_cur, time_from_ns_cb time_from_ns) wait = odp_time_sum(wait, sec); } + c2 = time(NULL); 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; + sec_c = ((double)(c2 - c1)); /* Check that ODP time is within +-5% of system time */ CU_ASSERT(sec_t < sec_c * 1.05);