From patchwork Mon Dec 15 17:39:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 42271 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 207712456A for ; Mon, 15 Dec 2014 17:39:47 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id gd6sf7631156lab.4 for ; Mon, 15 Dec 2014 09:39:46 -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=71IGH+EhhPgB174+z0ILm2hFM2e/NetCEqBgq9X3U30=; b=WL+Oq5l+ZkdnV1QqIxudLYaGXAOei4IA5CdtgNlRyYOE3lo17aGIMPw4spycMiwDql ZU0Ju85X6GEJWNdPUIjG4QXsRA92ozWvxfk9vuABRZAyMlKvBa8AbAWf95eE1JdkB8g0 YuCSixYj1UqL9f9qDOeLJ2jrLvILR/eg+d99xSslNretcH7MYaZxihkRQTLjBbrZnx7c Mk0a+aScPI4KzC6sMGvcZm3xXkwYq6rMWeI44xWbD1KvQnHD/9w6kJzKH5N5mN1rEwHd gaEQuVf+bXTXTCyRkYMN7APUxNqj7Cow8Fblal7St+c64C8LjihtuDP1ptepfDNDsI3w NMww== X-Gm-Message-State: ALoCoQlYPU7dCuB2WtmYCRkwL7VkoS+CVTCda7XmebPwBEhs+ej4j80ykQsS/VN5nDu1BvlFfpNf X-Received: by 10.180.19.42 with SMTP id b10mr3722675wie.0.1418665186103; Mon, 15 Dec 2014 09:39:46 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.42 with SMTP id g10ls699279laa.56.gmail; Mon, 15 Dec 2014 09:39:45 -0800 (PST) X-Received: by 10.152.43.103 with SMTP id v7mr31600256lal.29.1418665185939; Mon, 15 Dec 2014 09:39:45 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id r3si1252501lbo.9.2014.12.15.09.39.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Dec 2014 09:39:45 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id gd6so9977798lab.3 for ; Mon, 15 Dec 2014 09:39:45 -0800 (PST) X-Received: by 10.152.26.201 with SMTP id n9mr25023001lag.50.1418665185835; Mon, 15 Dec 2014 09:39:45 -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 ru5csp789843lbb; Mon, 15 Dec 2014 09:39:44 -0800 (PST) X-Received: by 10.140.18.103 with SMTP id 94mr18036375qge.44.1418665184025; Mon, 15 Dec 2014 09:39:44 -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 p94si11417476qga.7.2014.12.15.09.39.43 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 15 Dec 2014 09:39:44 -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 1Y0ZcT-000429-4s; Mon, 15 Dec 2014 17:39:41 +0000 Received: from mail-qc0-f169.google.com ([209.85.216.169]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y0ZcM-000400-9A for lng-odp@lists.linaro.org; Mon, 15 Dec 2014 17:39:34 +0000 Received: by mail-qc0-f169.google.com with SMTP id w7so8939517qcr.0 for ; Mon, 15 Dec 2014 09:39:29 -0800 (PST) X-Received: by 10.140.41.169 with SMTP id z38mr18683311qgz.56.1418665168985; Mon, 15 Dec 2014 09:39:28 -0800 (PST) Received: from fedora1.holmesfamily.ws ([98.221.136.245]) by mx.google.com with ESMTPSA id i32sm11117711qgf.12.2014.12.15.09.39.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Dec 2014 09:39:28 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Mon, 15 Dec 2014 12:39:19 -0500 Message-Id: <1418665159-37208-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 X-Topics: patch Subject: [lng-odp] [PATCH] 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.44 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 | 4 +++- test/validation/odp_time.c | 50 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 test/validation/odp_time.c diff --git a/test/validation/.gitignore b/test/validation/.gitignore index 32834ae..3c81566 100644 --- a/test/validation/.gitignore +++ b/test/validation/.gitignore @@ -5,3 +5,4 @@ odp_queue odp_crypto odp_schedule odp_shm +odp_time diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am index d0b5426..8e78865 100644 --- a/test/validation/Makefile.am +++ b/test/validation/Makefile.am @@ -6,7 +6,7 @@ AM_LDFLAGS += -static if ODP_CUNIT_ENABLED TESTS = ${bin_PROGRAMS} check_PROGRAMS = ${bin_PROGRAMS} -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_time odp_init_LDFLAGS = $(AM_LDFLAGS) odp_queue_LDFLAGS = $(AM_LDFLAGS) odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto @@ -15,6 +15,7 @@ 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 @@ -25,6 +26,7 @@ dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \ odp_crypto.c common/odp_cunit_common.c dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c dist_odp_schedule_SOURCES = odp_schedule.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 diff --git a/test/validation/odp_time.c b/test/validation/odp_time.c new file mode 100644 index 0000000..dfb304f --- /dev/null +++ b/test/validation/odp_time.c @@ -0,0 +1,50 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include "odp_cunit_common.h" + +#define TOLLERANCE 1 + +static void test_odp_time_basic(void) +{ + uint64_t t1, t2, diff, cycles; + uint64_t upper_limit, lower_limit; + + t1 = odp_time_cycles(); + CU_ASSERT(t1 > 0); + + t2 = odp_time_cycles(); + CU_ASSERT(t2 > 0); + + diff = odp_time_diff_cycles(t1, t2); + CU_ASSERT(diff > 0); + + t1 = 100; + cycles = odp_time_ns_to_cycles(t1); + CU_ASSERT(cycles > 0); + + t2 = odp_time_cycles_to_ns(cycles); + + /* need to check within arithmetic tolerance */ + upper_limit = t1 + TOLLERANCE; + lower_limit = t1 - TOLLERANCE; + printf("\nTolerance %" PRId64 " upper %" PRId64 " lower\n", + upper_limit, lower_limit); + printf("%" PRId64 " ns -> %" PRId64 " cycles -> %" PRId64 " ns\n", + t1, cycles, t2); + CU_ASSERT((t2 <= upper_limit) && (t2 >= lower_limit)); +} + +CU_TestInfo test_odp_time[] = { + {"odp_time", test_odp_time_basic}, + CU_TEST_INFO_NULL +}; + +CU_SuiteInfo odp_testsuites[] = { + {"Time", NULL, NULL, NULL, NULL, test_odp_time}, + CU_SUITE_INFO_NULL +};