From patchwork Mon Jan 5 18:45:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 42758 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6FDA025B5B for ; Mon, 5 Jan 2015 18:46:23 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf12405958lab.3 for ; Mon, 05 Jan 2015 10:46:22 -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=WCHkz9DPJ5ISsHfz+K37EEdzPXQDq/5l6QJJx1Xcu8E=; b=N8ZfIPm48J685Kdd6SwEOOCljLnHoL3FLdPc/UckLg9HEmPEdpdeKQGxJqZm0oUkzD IanaUZw2DWhYfAk2O7sFVdjqK1URux9fsYFpj3QtNamiLq3ELdbHOW09l5tDPt1fKyU3 dSznkw/cx9q5ne0ygKAC39ODlpbqItMRhtwAiNio7J1Ya5NguV50eLUouQkYGrdILLtM Dvw3xur6ZgaQ1MXMznVTFET3uC/PfF22rReQMgMpd13w+DhDim1pKdH1FftN+JtmGonE Out13bAWOPVlvLeAJFdCRiSNHhW/qo+BNLYCfJoVkwzWV46gb2A+s7dgA4wlOXhrYC6h 1Q1Q== X-Gm-Message-State: ALoCoQkazT7KGhPeT85GuqlWTnvLfsJy+LseUtixwp2MqMfqcPzIreQk5dbFtfmpmXg8U1FnD9wL X-Received: by 10.152.120.194 with SMTP id le2mr81249lab.8.1420483582116; Mon, 05 Jan 2015 10:46:22 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.1 with SMTP id p1ls242098lag.8.gmail; Mon, 05 Jan 2015 10:46:21 -0800 (PST) X-Received: by 10.152.30.6 with SMTP id o6mr95917784lah.64.1420483581898; Mon, 05 Jan 2015 10:46:21 -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 jq5si40511736lbc.39.2015.01.05.10.46.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 05 Jan 2015 10:46:21 -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 s18so18950137lam.16 for ; Mon, 05 Jan 2015 10:46:21 -0800 (PST) X-Received: by 10.152.87.100 with SMTP id w4mr95017528laz.71.1420483581741; Mon, 05 Jan 2015 10:46:21 -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.9.200 with SMTP id c8csp962465lbb; Mon, 5 Jan 2015 10:46:20 -0800 (PST) X-Received: by 10.140.108.9 with SMTP id i9mr56545962qgf.73.1420483580131; Mon, 05 Jan 2015 10:46:20 -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 s7si61387111qas.40.2015.01.05.10.46.18 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 05 Jan 2015 10:46:20 -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 1Y8CfP-0004tK-RD; Mon, 05 Jan 2015 18:46:15 +0000 Received: from mail-qc0-f177.google.com ([209.85.216.177]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y8CfK-0004s3-7c for lng-odp@lists.linaro.org; Mon, 05 Jan 2015 18:46:10 +0000 Received: by mail-qc0-f177.google.com with SMTP id x3so15455121qcv.8 for ; Mon, 05 Jan 2015 10:46:05 -0800 (PST) X-Received: by 10.224.54.2 with SMTP id o2mr146472411qag.63.1420483565001; Mon, 05 Jan 2015 10:46:05 -0800 (PST) Received: from localhost.localdomain ([98.221.136.245]) by mx.google.com with ESMTPSA id b13sm40525381qaw.31.2015.01.05.10.46.04 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Jan 2015 10:46:04 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Mon, 5 Jan 2015 13:45:58 -0500 Message-Id: <1420483558-22818-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 X-Topics: patch Subject: [lng-odp] [PATCH v3] validation: thread: add thread tests 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 tests for odp_thread_core and odp_thread_id Signed-off-by: Mike Holmes --- test/validation/.gitignore | 1 + test/validation/Makefile.am | 5 ++-- test/validation/odp_thread.c | 55 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 test/validation/odp_thread.c diff --git a/test/validation/.gitignore b/test/validation/.gitignore index d08db73..5b80834 100644 --- a/test/validation/.gitignore +++ b/test/validation/.gitignore @@ -8,3 +8,4 @@ odp_shm odp_system odp_pktio odp_buffer +odp_thread diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am index c0545b7..d52fbdb 100644 --- a/test/validation/Makefile.am +++ b/test/validation/Makefile.am @@ -6,9 +6,9 @@ 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_thread check_PROGRAMS = ${bin_PROGRAMS} -bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio odp_buffer odp_system +bin_PROGRAMS = odp_init odp_queue odp_crypto odp_shm odp_schedule odp_pktio odp_buffer odp_system odp_thread odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto odp_buffer_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/buffer endif @@ -27,3 +27,4 @@ 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_thread_SOURCES = odp_thread.c common/odp_cunit_common.c diff --git a/test/validation/odp_thread.c b/test/validation/odp_thread.c new file mode 100644 index 0000000..a183f25 --- /dev/null +++ b/test/validation/odp_thread.c @@ -0,0 +1,55 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include + +static void *run_thread_id_core(void *arg) +{ + int thr, core, core_count, num_workers; + odp_coremask_t mask; + + odp_coremask_zero(&mask); + + thr = odp_thread_id(); + core = odp_thread_core(); + core_count = odp_sys_core_count(); + + /* threads are limited */ + if (core_count > MAX_WORKERS) + num_workers = MAX_WORKERS; + else + num_workers = core_count; + + CU_ASSERT(core >= 0); + CU_ASSERT(thr >= 0); + CU_ASSERT(thr <= num_workers); + return arg; +} + +static void test_odp_thread_id_core(void) +{ + pthrd_arg thrdarg; + + thrdarg.numthrds = odp_sys_core_count(); + + if (thrdarg.numthrds > MAX_WORKERS) + thrdarg.numthrds = MAX_WORKERS; + + odp_cunit_thread_create(run_thread_id_core, &thrdarg); + odp_cunit_thread_exit(&thrdarg); +} + +CU_TestInfo test_odp_thread[] = { + {"id & core range", test_odp_thread_id_core}, + CU_TEST_INFO_NULL, +}; + +CU_SuiteInfo odp_testsuites[] = { + {"Thread", NULL, NULL, NULL, NULL, test_odp_thread}, + CU_SUITE_INFO_NULL, +}; +