From patchwork Mon Dec 29 03:29:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 42635 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1440B25B8B for ; Mon, 29 Dec 2014 03:29:50 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id x12sf7601390wgg.8 for ; Sun, 28 Dec 2014 19:29:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=IXLc+WiyhyPsdloC/Kp/VCi6uGVWGctI4qKjCCIF/Tk=; b=Dk090yVl2DXHGTmNQIH646wipBpONfbEei8EjFuz2FjL34ppzZYc17iOczQkMHuHoB id7apxWI06dv3ApJIrbr7drdGUd6g7Pc5P7GEWqkn3+OOSvAvM+ruaxqz9lw0WX3dYCD tg99q5UVRyzJpSLcogy/m8oXbNK3q/0Y0DIGYLOE0Ef2xLR0ZsHZuWoeGdMh64sh9Fi2 3eLAnXgbi7DQAPRlfDqPiTtqAO5YI4I1jVfyln8E7F+n3KoVkMGCv8tNRpEtHYo9wI8X 2O/DvYSD93cgqrVAAKxOvoV9Ne3MRFMude+Fj/NLURr4zvcXxRSLAqRLeMFhXuCcNq7a TqeA== X-Gm-Message-State: ALoCoQmMSR9fszGBBhzK8ipKLkE3BNq1zV9vom8y8XFaC8UMQ/Fo+Za3AEZmztXPyFbmeJsCfKi1 X-Received: by 10.180.19.42 with SMTP id b10mr5620927wie.0.1419823789205; Sun, 28 Dec 2014 19:29:49 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.200 with SMTP id d8ls1489968lah.18.gmail; Sun, 28 Dec 2014 19:29:49 -0800 (PST) X-Received: by 10.152.37.7 with SMTP id u7mr54699246laj.74.1419823789040; Sun, 28 Dec 2014 19:29:49 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id e1si28118940laa.119.2014.12.28.19.29.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 28 Dec 2014 19:29:48 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id s18so10605436lam.2 for ; Sun, 28 Dec 2014 19:29:48 -0800 (PST) X-Received: by 10.152.37.7 with SMTP id u7mr54699237laj.74.1419823788799; Sun, 28 Dec 2014 19:29:48 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp2665568lbb; Sun, 28 Dec 2014 19:29:48 -0800 (PST) X-Received: by 10.140.29.138 with SMTP id b10mr50278348qgb.34.1419823787178; Sun, 28 Dec 2014 19:29:47 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id n5si15558139qac.34.2014.12.28.19.29.45 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 28 Dec 2014 19:29:47 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y5R1a-0004HD-9D; Mon, 29 Dec 2014 03:29:42 +0000 Received: from mail-qg0-f43.google.com ([209.85.192.43]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y5R1Q-0004H2-HV for lng-odp@lists.linaro.org; Mon, 29 Dec 2014 03:29:32 +0000 Received: by mail-qg0-f43.google.com with SMTP id z107so8863566qgd.2 for ; Sun, 28 Dec 2014 19:29:27 -0800 (PST) X-Received: by 10.140.101.163 with SMTP id u32mr55877200qge.71.1419823767307; Sun, 28 Dec 2014 19:29:27 -0800 (PST) Received: from localhost.localdomain ([98.221.136.245]) by mx.google.com with ESMTPSA id b109sm32599326qgf.40.2014.12.28.19.29.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 28 Dec 2014 19:29:26 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Sun, 28 Dec 2014 22:29:17 -0500 Message-Id: <1419823757-5792-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 X-Topics: patch Subject: [lng-odp] [PATCH v2] validation: add odp_time test X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: 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-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mike.holmes@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Add odp_time_x API tests Signed-off-by: Mike Holmes --- test/validation/.gitignore | 1 + test/validation/Makefile.am | 19 ++++++++++-- test/validation/odp_time.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 test/validation/odp_time.c diff --git a/test/validation/.gitignore b/test/validation/.gitignore index d08db73..40ea12d 100644 --- a/test/validation/.gitignore +++ b/test/validation/.gitignore @@ -8,3 +8,4 @@ odp_shm odp_system odp_pktio odp_buffer +odp_time diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am index c0545b7..3de5bdb 100644 --- a/test/validation/Makefile.am +++ b/test/validation/Makefile.am @@ -6,11 +6,19 @@ AM_LDFLAGS += -static TESTS_ENVIRONMENT = ODP_PLATFORM=${with_platform} if ODP_CUNIT_ENABLED -TESTS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio_run odp_buffer odp_system +TESTS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio_run odp_buffer odp_system odp_time check_PROGRAMS = ${bin_PROGRAMS} -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio odp_buffer odp_system -odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio odp_buffer odp_system odp_time odp_buffer_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/buffer +odp_init_LDFLAGS = $(AM_LDFLAGS) +odp_queue_LDFLAGS = $(AM_LDFLAGS) +odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto +odp_crypto_LDFLAGS = $(AM_LDFLAGS) +odp_shm_CFLAGS = $(AM_CFLAGS) +odp_shm_LDFLAGS = $(AM_LDFLAGS) +odp_schedule_CFLAGS = $(AM_CFLAGS) +odp_schedule_LDFLAGS = $(AM_LDFLAGS) +odp_time_LDFLAGS = $(AM_LDFLAGS) endif dist_odp_init_SOURCES = odp_init.c @@ -27,3 +35,8 @@ dist_odp_buffer_SOURCES = buffer/odp_buffer_pool_test.c \ buffer/odp_packet_test.c \ odp_buffer.c common/odp_cunit_common.c dist_odp_system_SOURCES = odp_system.c common/odp_cunit_common.c +dist_odp_time_SOURCES = odp_time.c common/odp_cunit_common.c + +#For Linux generic the unimplemented crypto API functions break the +#regression TODO: https://bugs.linaro.org/show_bug.cgi?id=975 +XFAIL_TESTS=odp_crypto diff --git a/test/validation/odp_time.c b/test/validation/odp_time.c new file mode 100644 index 0000000..1198bea --- /dev/null +++ b/test/validation/odp_time.c @@ -0,0 +1,70 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include "odp_cunit_common.h" + +#define TOLERANCE 1 +#define BUSY_LOOP_CNT 100 + +/* check that a cycles difference gives a reasonable result */ +static void test_odp_time_diff(void) +{ + /* volatile to stop optimization of busy loop */ + volatile int count; + uint64_t diff, cycles1, cycles2; + + cycles1 = odp_time_cycles(); + + while (count < BUSY_LOOP_CNT) { + count++; + }; + + cycles2 = odp_time_cycles(); + CU_ASSERT(cycles2 > cycles1); + + diff = odp_time_diff_cycles(cycles1, cycles2); + CU_ASSERT(diff > 0); +} + +/* check that a negative cycles difference gives a reasonable result */ +static void test_odp_time_negative_diff(void) +{ + uint64_t diff, cycles1, cycles2; + cycles1 = 10; + cycles2 = 5; + diff = odp_time_diff_cycles(cycles1, cycles2); + CU_ASSERT(diff > 0); +} +/* check that related conversions come back to the same value */ +static void test_odp_time_conversion(void) +{ + uint64_t ns1, ns2, cycles1; + uint64_t upper_limit, lower_limit; + ns1 = 100; + cycles1 = odp_time_ns_to_cycles(ns1); + CU_ASSERT(cycles1 > 0); + + ns2 = odp_time_cycles_to_ns(cycles1); + + /* need to check within arithmetic tolerance that the same + * value in ns is returned after conversions */ + upper_limit = ns1 + TOLERANCE; + lower_limit = ns1 - TOLERANCE; + CU_ASSERT((ns2 <= upper_limit) && (ns2 >= lower_limit)); +} + +CU_TestInfo test_odp_time[] = { + {"diff", test_odp_time_diff}, + {"negative diff", test_odp_time_negative_diff}, + {"conversion", test_odp_time_conversion}, + CU_TEST_INFO_NULL +}; + +CU_SuiteInfo odp_testsuites[] = { + {"Time", NULL, NULL, NULL, NULL, test_odp_time}, + CU_SUITE_INFO_NULL +};