From patchwork Tue Dec 30 02:24:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 42653 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1FE2C25B8B for ; Tue, 30 Dec 2014 02:24:28 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id q1sf8526999lam.6 for ; Mon, 29 Dec 2014 18:24:26 -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=SlitZeV/nB2Q7MQqNstnWQRn7VEPWKusdYEDKOrJYOM=; b=D3fxjDWr9nbdYVrAUvoR1xD2L1ZKkxpgtIFjCe2yevqsAnUcOv79ln5wsxau3YfIiX Hn1/jHh4o+jXJGZW5JiiJL68PhP10MSS+ROc7UFIgoXARpvu4bAZa/HiBr9A3oxPzsvO KnQCZW+UWyUyyBmbM4QVbHhZFLwvrgDkfJQWQcIrFN6bW+uMgMFumEBcPNQ6VRTg/HAr jP+skxAjfu1XH5TrBqNqkDTPmwnLYECqiWCfBmZUEX3mc/gmj7sBRkuWEbXTnYU2hJ2k Y/WtKYy/CUzp1Cj3VtMEPBJreK9F3a1tGGm3y2HLJLvRFVB7TBr8pOSOd8z/ddwxiwhS O1cA== X-Gm-Message-State: ALoCoQmmUXjURC3Ba57Yw2TpTl4+iVQU6rbon16gqm6IZzP2KPuHBml880IMO6muACu6hqaduBxi X-Received: by 10.152.10.233 with SMTP id l9mr6904822lab.0.1419906266617; Mon, 29 Dec 2014 18:24:26 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.100 with SMTP id m4ls1821773lae.49.gmail; Mon, 29 Dec 2014 18:24:26 -0800 (PST) X-Received: by 10.112.136.69 with SMTP id py5mr58321749lbb.56.1419906266406; Mon, 29 Dec 2014 18:24:26 -0800 (PST) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id y8si5489246lbw.107.2014.12.29.18.24.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 29 Dec 2014 18:24:26 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id hz20so11710645lab.20 for ; Mon, 29 Dec 2014 18:24:26 -0800 (PST) X-Received: by 10.152.43.103 with SMTP id v7mr60021027lal.29.1419906266164; Mon, 29 Dec 2014 18:24:26 -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 ru5csp2937910lbb; Mon, 29 Dec 2014 18:24:24 -0800 (PST) X-Received: by 10.224.137.65 with SMTP id v1mr87539847qat.95.1419906264182; Mon, 29 Dec 2014 18:24:24 -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 i9si42311037qaz.51.2014.12.29.18.24.22 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 29 Dec 2014 18:24:24 -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 1Y5mTq-0002KM-SD; Tue, 30 Dec 2014 02:24:18 +0000 Received: from mail-qc0-f174.google.com ([209.85.216.174]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y5mTl-0002KD-0d for lng-odp@lists.linaro.org; Tue, 30 Dec 2014 02:24:13 +0000 Received: by mail-qc0-f174.google.com with SMTP id c9so10016707qcz.19 for ; Mon, 29 Dec 2014 18:24:07 -0800 (PST) X-Received: by 10.224.26.132 with SMTP id e4mr47005901qac.7.1419906247808; Mon, 29 Dec 2014 18:24:07 -0800 (PST) Received: from localhost.localdomain ([98.221.136.245]) by mx.google.com with ESMTPSA id j6sm22460456qga.9.2014.12.29.18.24.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Dec 2014 18:24:07 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Mon, 29 Dec 2014 21:24:01 -0500 Message-Id: <1419906241-25267-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 X-Topics: patch Subject: [lng-odp] [PATCH] 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.47 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 | 47 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 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..1c03b16 --- /dev/null +++ b/test/validation/odp_thread.c @@ -0,0 +1,47 @@ +/* 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; + pthrd_arg *thrdarg = arg; + + thr = odp_thread_id(); + core = odp_thread_core(); + + /* cores start from 0 */ + CU_ASSERT((core >= 0) && (core <= thrdarg->numthrds-1)); + /* threads start from 1 */ + CU_ASSERT((thr >= 1) && (core <= thrdarg->numthrds)); + 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, +}; +