From patchwork Tue May 13 14:58:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 30060 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1C95220369 for ; Tue, 13 May 2014 15:07:22 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id rl12sf2176783iec.6 for ; Tue, 13 May 2014 08:07:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=1x9qq1bIRsCZjCdS5Uabqv9jmNL3zi10lip+EWwKszc=; b=aXBddP/HvwtgWkodTaov5YDC4HfIjQcOx8QHxsjwlDag2ui+vMpst+FCIkaRmALvpb We0M+/mUyeLFY+MOKfCRyJNRn70lmMV26C+53jKXg+70KhLDGY8dnQaf7YoO6xjeay64 02qebu6mieni1CwmkjeaN84nllUQ2atQehntByHsoIylb/m5MCNP9tgrwmD/rOcFlLEW l+rOS68jm0RIe1a4ryJPzPI+IM2QP6fAhZCEP35ZAlEKLE5v+Sp9qBt3tmgvbuM5b/kU 9XFTMnK5IK8v7vmKRCe+gsxyFG3EfJrBlMrsudBU9cZFsYnTiceBg/dQLWH7ozfLAM4K MJow== X-Gm-Message-State: ALoCoQk2UeRiZSyutO70U/XFy//Wk/LJOI9q8TZ/bqLQtz1f8/1FksgGSA4cxaabsv2SkFAUBOvf X-Received: by 10.43.79.196 with SMTP id zr4mr15970118icb.3.1399993641350; Tue, 13 May 2014 08:07:21 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.107.97 with SMTP id g88ls1838711qgf.40.gmail; Tue, 13 May 2014 08:07:21 -0700 (PDT) X-Received: by 10.220.139.198 with SMTP id f6mr738778vcu.47.1399993641216; Tue, 13 May 2014 08:07:21 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id dr8si2703626vcb.13.2014.05.13.08.07.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 May 2014 08:07:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.179 as permitted sender) client-ip=209.85.128.179; Received: by mail-ve0-f179.google.com with SMTP id oy12so613471veb.10 for ; Tue, 13 May 2014 08:07:21 -0700 (PDT) X-Received: by 10.52.130.225 with SMTP id oh1mr24613080vdb.8.1399993641117; Tue, 13 May 2014 08:07:21 -0700 (PDT) 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.220.221.72 with SMTP id ib8csp158436vcb; Tue, 13 May 2014 08:07:20 -0700 (PDT) X-Received: by 10.68.226.197 with SMTP id ru5mr5941048pbc.77.1399993640298; Tue, 13 May 2014 08:07:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sg3si13588052pac.93.2014.05.13.08.07.19; Tue, 13 May 2014 08:07:19 -0700 (PDT) Received-SPF: none (google.com: devicetree-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934110AbaEMPAR (ORCPT + 8 others); Tue, 13 May 2014 11:00:17 -0400 Received: from mail-ee0-f50.google.com ([74.125.83.50]:59874 "EHLO mail-ee0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964983AbaEMO6u (ORCPT ); Tue, 13 May 2014 10:58:50 -0400 Received: by mail-ee0-f50.google.com with SMTP id e51so512539eek.23 for ; Tue, 13 May 2014 07:58:48 -0700 (PDT) X-Received: by 10.15.83.68 with SMTP id b44mr41957562eez.11.1399993128779; Tue, 13 May 2014 07:58:48 -0700 (PDT) Received: from trevor.secretlab.ca (host109-150-134-147.range109-150.btcentralplus.com. [109.150.134.147]) by mx.google.com with ESMTPSA id t4sm40747126eeb.29.2014.05.13.07.58.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 May 2014 07:58:46 -0700 (PDT) Received: by trevor.secretlab.ca (Postfix, from userid 1000) id 72592C4095B; Tue, 13 May 2014 15:58:42 +0100 (BST) From: Grant Likely To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Grant Likely Subject: [PATCH 3/3] of: Add a testcase for of_find_node_by_path() Date: Tue, 13 May 2014 15:58:35 +0100 Message-Id: <1399993115-21552-4-git-send-email-grant.likely@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1399993115-21552-1-git-send-email-grant.likely@linaro.org> References: <1399993115-21552-1-git-send-email-grant.likely@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: grant.likely@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.128.179 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add a testcase for the find_node_by_path() function to make sure it handles all the valid scenarios. Signed-off-by: Grant Likely --- drivers/of/selftest.c | 39 +++++++++++++++++++++++++++++ drivers/of/testcase-data/tests-phandle.dtsi | 6 ++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c index ae4450070503..f5b4dcffbe32 100644 --- a/drivers/of/selftest.c +++ b/drivers/of/selftest.c @@ -30,6 +30,43 @@ static struct selftest_results { } \ } +static void __init of_selftest_find_node_by_name(void) +{ + struct device_node *np; + + np = of_find_node_by_path("/testcase-data"); + selftest(np && !strcmp("/testcase-data", np->full_name), + "find /testcase-data failed\n"); + of_node_put(np); + + np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a"); + selftest(np && !strcmp("/testcase-data/phandle-tests/consumer-a", np->full_name), + "find /testcase-data/phandle-tests/consumer-a failed\n"); + of_node_put(np); + + np = of_find_node_by_path("testcase-alias"); + selftest(np && !strcmp("/testcase-data", np->full_name), + "find testcase-alias failed\n"); + of_node_put(np); + + np = of_find_node_by_path("testcase-alias/phandle-tests/consumer-a"); + selftest(np && !strcmp("/testcase-data/phandle-tests/consumer-a", np->full_name), + "find testcase-alias/phandle-tests/consumer-a failed\n"); + of_node_put(np); + + np = of_find_node_by_path("/testcase-data/missing-path"); + selftest(!np, "non-existent path returned node %s\n", np->full_name); + of_node_put(np); + + np = of_find_node_by_path("missing-alias"); + selftest(!np, "non-existent alias returned node %s\n", np->full_name); + of_node_put(np); + + np = of_find_node_by_path("testcase-alias/missing-path"); + selftest(!np, "non-existent alias with relative path returned node %s\n", np->full_name); + of_node_put(np); +} + static void __init of_selftest_dynamic(void) { struct device_node *np; @@ -89,6 +126,7 @@ static void __init of_selftest_dynamic(void) if (prop->value) selftest(of_add_property(np, prop) == 0, "Adding a large property should have passed\n"); + } static void __init of_selftest_parse_phandle_with_args(void) @@ -439,6 +477,7 @@ static int __init of_selftest(void) of_node_put(np); pr_info("start of selftest - you will see error messages\n"); + of_selftest_find_node_by_name(); of_selftest_dynamic(); of_selftest_parse_phandle_with_args(); of_selftest_property_match_string(); diff --git a/drivers/of/testcase-data/tests-phandle.dtsi b/drivers/of/testcase-data/tests-phandle.dtsi index 788a4c24b8f5..ce0fe083d406 100644 --- a/drivers/of/testcase-data/tests-phandle.dtsi +++ b/drivers/of/testcase-data/tests-phandle.dtsi @@ -1,6 +1,10 @@ / { - testcase-data { + aliases { + testcase-alias = &testcase; + }; + + testcase: testcase-data { security-password = "password"; duplicate-name = "duplicate"; duplicate-name { };