Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAE0BC433FE for ; Fri, 15 Oct 2021 13:16:16 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 629C061151 for ; Fri, 15 Oct 2021 13:16:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 629C061151 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=walle.cc Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A093083877; Fri, 15 Oct 2021 15:16:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=walle.cc Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=walle.cc header.i=@walle.cc header.b="DzCEBVaj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CC1CC83851; Fri, 15 Oct 2021 15:15:44 +0200 (CEST) Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BDB918386B for ; Fri, 15 Oct 2021 15:15:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=walle.cc Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=michael@walle.cc Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 243E722249; Fri, 15 Oct 2021 15:15:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1634303732; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=itVgeEHlav5AHTvsld71br8kQWDvENJUboiA+V7kFZk=; b=DzCEBVajTmuEOT4v/tB2mpaG6OrhlSTt0yjPC5mGeI7T5eCmwliDN+OlhlHFF6aC+OZ9/H uoQQP/gGVsBVTjH41ki5kk+oorfZtuwr9yoOCsoeBDhnlLQBr3O2OTsfYAdza5jlRvjKrC H6ALBXd71a5sHp+tmAmVsXLq0CSWbbg= From: Michael Walle To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Ran Wang , Michael Walle Subject: [PATCH v2 2/9] test: dm: add test for ofnode_for_each_compatible_node() Date: Fri, 15 Oct 2021 15:15:18 +0200 Message-Id: <20211015131525.721323-3-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211015131525.721323-1-michael@walle.cc> References: <20211015131525.721323-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Check that all matching nodes have the correct compatible and that there is at least one match. Signed-off-by: Michael Walle --- test/dm/ofnode.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 49efabe871..cea0746bb3 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -333,3 +333,21 @@ static int dm_test_ofnode_conf(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_ofnode_conf, 0); + +static int dm_test_ofnode_for_each_compatible_node(struct unit_test_state *uts) +{ + const char compatible[] = "denx,u-boot-fdt-test"; + bool found = false; + ofnode node; + + ofnode_for_each_compatible_node(node, compatible) { + ut_assert(ofnode_device_is_compatible(node, compatible)); + found = true; + } + + /* There should be at least one matching node */ + ut_assert(found); + + return 0; +} +DM_TEST(dm_test_ofnode_for_each_compatible_node, UT_TESTF_SCAN_FDT); -- 2.30.2