From patchwork Tue Jan 20 23:37:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 43427 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8113A218DB for ; Tue, 20 Jan 2015 23:38:44 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id u10sf3739387lbd.3 for ; Tue, 20 Jan 2015 15:38:43 -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=mZ5DCvpBqaEeHgj44M5QyjID8ziDPtqxmUF7+Fa8us/fji5LejTSCXnGxOrVf4uUfB sjfzf+sug4m7gE2ijYuGHBD2fTh9l4+Yu6llXjRfb+kFFKH7bBNB3F0nji90St9SxfNN TK1aCj4kt/AyxKoQVbQxj87zU2mmnexCIGs/bW5yydRQ/Gi88Aldtx6g1FLpfOMbiQe5 y5LJmI9bPK4OH2XSegDm9W5mv1hRTghZcLFhXkjJIDQ6nJOvo0BGg0EHYgzjUTRUut4r UvI0b9qpGA35gPdchbG7um8LsxNfI7JruWtCBz/gMJSiCXF3GCqjC6FjXA2h/RQe8C18 9pCQ== X-Gm-Message-State: ALoCoQlfrzSUMRyhMaha8Y72fKT2JkxiKXml+awt834+Vhpxz7n6k1ujcTzqlnIIzA4afG92SW1G X-Received: by 10.152.115.241 with SMTP id jr17mr1835706lab.0.1421797123055; Tue, 20 Jan 2015 15:38:43 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.1.101 with SMTP id 5ls776895lal.72.gmail; Tue, 20 Jan 2015 15:38:42 -0800 (PST) X-Received: by 10.153.5.35 with SMTP id cj3mr27997435lad.49.1421797122912; Tue, 20 Jan 2015 15:38:42 -0800 (PST) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id s8si929249laj.69.2015.01.20.15.38.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Jan 2015 15:38:42 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by mail-lb0-f173.google.com with SMTP id p9so13177360lbv.4 for ; Tue, 20 Jan 2015 15:38:42 -0800 (PST) X-Received: by 10.152.197.5 with SMTP id iq5mr41134572lac.6.1421797122811; Tue, 20 Jan 2015 15:38:42 -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 c8csp1587245lbb; Tue, 20 Jan 2015 15:38:42 -0800 (PST) X-Received: by 10.140.91.201 with SMTP id z67mr50930280qgd.27.1421797121564; Tue, 20 Jan 2015 15:38:41 -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 c6si2254380qan.115.2015.01.20.15.38.40 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 20 Jan 2015 15:38:41 -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 1YDiNa-0003xC-B8; Tue, 20 Jan 2015 23:38:38 +0000 Received: from mail-qc0-f181.google.com ([209.85.216.181]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YDiNO-0003wM-6h for lng-odp@lists.linaro.org; Tue, 20 Jan 2015 23:38:26 +0000 Received: by mail-qc0-f181.google.com with SMTP id l6so24952247qcy.12 for ; Tue, 20 Jan 2015 15:38:21 -0800 (PST) X-Received: by 10.229.48.132 with SMTP id r4mr62824690qcf.5.1421797101037; Tue, 20 Jan 2015 15:38:21 -0800 (PST) Received: from mike-desktop.?.holmesfamily.ws ([98.221.136.245]) by mx.google.com with ESMTPSA id 66sm8323596qgl.42.2015.01.20.15.38.20 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jan 2015 15:38:20 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Tue, 20 Jan 2015 18:37:57 -0500 Message-Id: <1421797078-14262-3-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1421797078-14262-1-git-send-email-mike.holmes@linaro.org> References: <1421797078-14262-1-git-send-email-mike.holmes@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v2 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.217.173 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; +}