From patchwork Fri Mar 14 17:11:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 26272 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8851820143 for ; Fri, 14 Mar 2014 17:12:11 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id to1sf9592281ieb.1 for ; Fri, 14 Mar 2014 10:12:10 -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=PcgVyir6mceSnIRaQpBBREz9n9fRK/lWKrE3ftSve0Q=; b=Y0yStCWFflkn2g0kG48bCQBlXfwP9ZnU2zdH4N6Hr98I2Iof1xmrXT6QWtB6FKqJDX 6hHOtKQIBFWi+CvVRYQYTJRvs1ufi3wtvDtdBPf/l6GIxmmdEK494jjvAmjLaF479OM+ LMjb1NXAStN3fokWfeRHHEY2jr0s09cQBZxKk5kZjvispESmjyWcIIy9BD3BNCJ5Vs0d 5Y5s4US3P5qp6poZ7wo8llzgOKkTuUXtmrJ0sMrggnOQmZEYqOSWdCCbKh/iHaHQnMs7 zHfWPaZIVzmOu/uZ79x7e0wgXUBg7to5pUWbGSzO0hX15PKuPji3axtfKxctXBOd+HR/ iZbg== X-Gm-Message-State: ALoCoQkYLMIMmj44FuicLrgqwyt5cA1y29LAc87s1JHHRHtDoLXSgDW/BDkuGP3fQ3zlg6xvpNRO X-Received: by 10.183.3.36 with SMTP id bt4mr3640024obd.29.1394817130784; Fri, 14 Mar 2014 10:12:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.85.35 with SMTP id m32ls747753qgd.81.gmail; Fri, 14 Mar 2014 10:12:10 -0700 (PDT) X-Received: by 10.58.34.101 with SMTP id y5mr7298762vei.8.1394817130630; Fri, 14 Mar 2014 10:12:10 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id qi7si731711veb.88.2014.03.14.10.12.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Mar 2014 10:12:10 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id oz11so2994070veb.20 for ; Fri, 14 Mar 2014 10:12:10 -0700 (PDT) X-Received: by 10.58.165.68 with SMTP id yw4mr7399910veb.17.1394817130538; Fri, 14 Mar 2014 10:12:10 -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.78.9 with SMTP id i9csp35738vck; Fri, 14 Mar 2014 10:12:10 -0700 (PDT) X-Received: by 10.68.4.232 with SMTP id n8mr10252139pbn.114.1394817129513; Fri, 14 Mar 2014 10:12:09 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w5si1115189pan.394.2014.03.14.10.12.08; Fri, 14 Mar 2014 10:12:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756205AbaCNRMD (ORCPT + 26 others); Fri, 14 Mar 2014 13:12:03 -0400 Received: from mail-ee0-f52.google.com ([74.125.83.52]:62804 "EHLO mail-ee0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755432AbaCNRL7 (ORCPT ); Fri, 14 Mar 2014 13:11:59 -0400 Received: by mail-ee0-f52.google.com with SMTP id e49so1592446eek.25 for ; Fri, 14 Mar 2014 10:11:58 -0700 (PDT) X-Received: by 10.15.63.73 with SMTP id l49mr9336036eex.27.1394817118667; Fri, 14 Mar 2014 10:11:58 -0700 (PDT) Received: from trevor.secretlab.ca (host109-153-30-112.range109-153.btcentralplus.com. [109.153.30.112]) by mx.google.com with ESMTPSA id 4sm6074343eeq.33.2014.03.14.10.11.56 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Mar 2014 10:11:57 -0700 (PDT) Received: by trevor.secretlab.ca (Postfix, from userid 1000) id CFD4BC40B4B; Fri, 14 Mar 2014 17:11:52 +0000 (GMT) From: Grant Likely To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Pantelis Antoniou , Grant Likely Subject: [RFC v3 1/3] of: Add a testcase for of_find_node_by_path() Date: Fri, 14 Mar 2014 17:11:47 +0000 Message-Id: <1394817109-26199-2-git-send-email-grant.likely@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1394817109-26199-1-git-send-email-grant.likely@linaro.org> References: <1394817109-26199-1-git-send-email-grant.likely@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@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=neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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 { };