From patchwork Mon Jan 19 01:56:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 43284 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AB3BC2034D for ; Mon, 19 Jan 2015 01:57:10 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id n3sf2281418wiv.0 for ; Sun, 18 Jan 2015 17:57:09 -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:in-reply-to :references: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=u84XI2lLrLMdJPinv4afS73+GGfmnMq1Rt3ecajY6ik=; b=G/YrE5I4wb6eJLaa/WA/MOEDKMSmRvZO6lTGinC8AZvEmztEEvqurjFsxklXPflxst KrZve0YSxDv3U5AqtBk5o8l6zFg9EeaOKpXdeFynQIBOb1N3tXdq9dOq9X7H8gXRmhK/ rHehRUiQdiUf/rUc90/H1OnRVmamQ9WN5nk2t1vuFTDfMaMNwzgdiekN6aoRRR8uWW6F ffPuWJ8EhXWpw3JFEwO0N9l5BfOII+Kd2jLVW1sQj8mTZxl2Jp/wUp+NmRZTZ1SBU8eO 5b8aBaOce8+Wh78ayJGF1pakg4/GCiOiZyKE7RW1u3DxB22v/HOVW0RCQjjaYiwSZQIJ KyNw== X-Gm-Message-State: ALoCoQnqfL36cZLCfrovw9fRaYhT/x8Wtk7Gu2DvMY/8y+TviCUtLeHGD6g4yrDIGaTb+ZFmRgOh X-Received: by 10.180.74.140 with SMTP id t12mr1692867wiv.2.1421632629918; Sun, 18 Jan 2015 17:57:09 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.229 with SMTP id e5ls411058laa.105.gmail; Sun, 18 Jan 2015 17:57:09 -0800 (PST) X-Received: by 10.152.164.167 with SMTP id yr7mr8060956lab.1.1421632629759; Sun, 18 Jan 2015 17:57:09 -0800 (PST) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id x12si9607700lbm.44.2015.01.18.17.57.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 18 Jan 2015 17:57:09 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by mail-la0-f42.google.com with SMTP id ms9so4012088lab.1 for ; Sun, 18 Jan 2015 17:57:09 -0800 (PST) X-Received: by 10.152.23.38 with SMTP id j6mr27352304laf.81.1421632629562; Sun, 18 Jan 2015 17:57:09 -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 c8csp945752lbb; Sun, 18 Jan 2015 17:57:08 -0800 (PST) X-Received: by 10.229.114.137 with SMTP id e9mr44100592qcq.0.1421632628313; Sun, 18 Jan 2015 17:57:08 -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 r6si15503527qac.28.2015.01.18.17.57.07 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 18 Jan 2015 17:57:08 -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 1YD1aT-0007Mm-IS; Mon, 19 Jan 2015 01:57:05 +0000 Received: from mail-qc0-f182.google.com ([209.85.216.182]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YD1aC-0007L6-6u for lng-odp@lists.linaro.org; Mon, 19 Jan 2015 01:56:48 +0000 Received: by mail-qc0-f182.google.com with SMTP id l6so20215530qcy.13 for ; Sun, 18 Jan 2015 17:56:43 -0800 (PST) X-Received: by 10.229.240.130 with SMTP id la2mr43979099qcb.9.1421632603067; Sun, 18 Jan 2015 17:56:43 -0800 (PST) Received: from mike-desktop.?.holmesfamily.ws ([98.221.136.245]) by mx.google.com with ESMTPSA id u15sm9532139qag.21.2015.01.18.17.56.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 18 Jan 2015 17:56:42 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Sun, 18 Jan 2015 20:56:23 -0500 Message-Id: <1421632584-26181-4-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1421632584-26181-1-git-send-email-mike.holmes@linaro.org> References: <1421632584-26181-1-git-send-email-mike.holmes@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 3/4] validation: odp_init: add replace log 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.42 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 a test for the ability to replace the logging function via init_global Signed-off-by: Mike Holmes --- test/validation/odp_init.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/test/validation/odp_init.c b/test/validation/odp_init.c index 5277d68..c8e5a11 100644 --- a/test/validation/odp_init.c +++ b/test/validation/odp_init.c @@ -4,12 +4,17 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include #include #include #define DEFAULT_MSG_POOL_SIZE (4*1024*1024) #define DEFAULT_MSG_SIZE (8) +int replacement_logging_used; + +static int odp_init_log(odp_log_level_e level , const char *fmt, ...); + static void test_odp_init_global(void) { int status; @@ -20,8 +25,27 @@ static void test_odp_init_global(void) CU_ASSERT(status == 0); } +static void test_odp_init_global_replace_log(void) +{ + int status; + struct odp_init_t init_data; + + init_data.log_fn = &odp_init_log; + + replacement_logging_used = 0; + + status = odp_init_global(&init_data, NULL); + CU_ASSERT_FATAL(status == 0); + + CU_ASSERT_TRUE(replacement_logging_used); + + status = odp_term_global(); + CU_ASSERT(status == 0); +} + CU_TestInfo test_odp_init[] = { {"test_odp_init_global", test_odp_init_global}, + {"replace log", test_odp_init_global_replace_log}, CU_TEST_INFO_NULL, }; @@ -50,3 +74,19 @@ int main(void) return ret; } + +int odp_init_log(odp_log_level_e level __attribute__((unused)), + const char *fmt, ...) +{ + va_list args; + int r; + + /* just set a flag to be sure the replacement fn was used */ + replacement_logging_used = 1; + + va_start(args, fmt); + r = vfprintf(stderr, fmt, args); + va_end(args); + + return r; +}