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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 3FE30C19F2A for ; Sat, 30 Jul 2022 21:54:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DE58384218; Sat, 30 Jul 2022 23:53:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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; unprotected) header.d=chromium.org header.i=@chromium.org header.b="mWbHRUVl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A64A7841B1; Sat, 30 Jul 2022 23:53:18 +0200 (CEST) Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B0A9284205 for ; Sat, 30 Jul 2022 23:53:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-10ea30a098bso4716475fac.8 for ; Sat, 30 Jul 2022 14:53:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=qiqC2KjRwe7qGWEtLhXoCp2FfgUVQtzv0ZFk37u3TDI=; b=mWbHRUVlI/GWMUYn1rgAOdBfAXFnQoi9oSoawA5Py/pzgHpAqen9cd1TRKTqVyiQQ4 tUHGxIfGuFyEJi5Q4gErt3q2ISplTcSNfdevRi65F0YoE08uYgvtwlo9zhSKH4zB2tUV PbopYUjQav4QbEXwm50UpC6W6TRWn0MDEktAI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=qiqC2KjRwe7qGWEtLhXoCp2FfgUVQtzv0ZFk37u3TDI=; b=AJDgehY88N+pn5A7Sos4rejeE40JzkDKQYuezj+a//ewRCVailBCy9dnmUe8b9O6gq QLGEZhv9JhRauB1dwAFg3/ih8S/bu6F+7XcYRWyMpWmvdxzPf3tFFvE5Cj7CILpJQb5V TX8dbxoahUdzGKAZYCfU6ll+Wf45tWZ6AZ8+QKbmvdbFM0SnCJA8cNw10Txqza2KtPBi +8ynLQHEmhEPtWentfwl/Luqb0ExIVMiuWT/fUOMX02KlUZqYCC7cjUh3ExbMFxH6QsS wAjZoIGdg8pIY7WODy2rg4dR1zjTFHnINrgUOvpVzArfTtbVk88kiA8z09KVQXf8Ia0Q L+vw== X-Gm-Message-State: AJIora/ffkEWqdofkBj2VhnF7Jw1+DpuJlqf4r3EBiJ1OCLyVDOVcqUU RITN1jr/fqEtzID7zMYnXqLvJ3ssnkguIJVM X-Google-Smtp-Source: AGRyM1v1Nb4A9UDbT+AYCta+FMQF3PfJnBcXFVYvETV80rVCICaMW6k9LBaR55Urchj0OGGBtoPsaQ== X-Received: by 2002:a05:6870:15c5:b0:10e:6cb2:fec2 with SMTP id k5-20020a05687015c500b0010e6cb2fec2mr4934021oad.124.1659217990175; Sat, 30 Jul 2022 14:53:10 -0700 (PDT) Received: from sjg1.lan (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id 19-20020a544193000000b0032f75714af1sm1699656oiy.18.2022.07.30.14.53.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Jul 2022 14:53:09 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Bin Meng , Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH v2 07/35] dm: core: Move ofnode-writing test to ofnode Date: Sat, 30 Jul 2022 15:52:09 -0600 Message-Id: <20220730215237.818368-6-sjg@chromium.org> X-Mailer: git-send-email 2.37.1.455.g008518b4e5-goog In-Reply-To: <20220730215237.818368-1-sjg@chromium.org> References: <20220730215237.818368-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean This fits better in the ofnode tests, so move it. Signed-off-by: Simon Glass --- (no changes since v1) test/dm/ofnode.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ test/dm/test-fdt.c | 53 ------------------------------------------- 2 files changed, 56 insertions(+), 53 deletions(-) diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 6a252f3f504..b8d8e440dbc 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -4,8 +4,12 @@ #include #include #include +#include +#include #include +#include #include +#include #include #include @@ -536,3 +540,55 @@ static int dm_test_ofnode_root(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_ofnode_root, UT_TESTF_SCAN_FDT); + +static int dm_test_ofnode_livetree_writing(struct unit_test_state *uts) +{ + struct udevice *dev; + ofnode node; + + if (!of_live_active()) { + printf("Live tree not active; ignore test\n"); + return 0; + } + + /* Test enabling devices */ + + node = ofnode_path("/usb@2"); + + ut_assert(!of_device_is_available(ofnode_to_np(node))); + ofnode_set_enabled(node, true); + ut_assert(of_device_is_available(ofnode_to_np(node))); + + device_bind_driver_to_node(dm_root(), "usb_sandbox", "usb@2", node, + &dev); + ut_assertok(uclass_find_device_by_seq(UCLASS_USB, 2, &dev)); + + /* Test string property setting */ + + ut_assert(device_is_compatible(dev, "sandbox,usb")); + ofnode_write_string(node, "compatible", "gdsys,super-usb"); + ut_assert(device_is_compatible(dev, "gdsys,super-usb")); + ofnode_write_string(node, "compatible", "sandbox,usb"); + ut_assert(device_is_compatible(dev, "sandbox,usb")); + + /* Test setting generic properties */ + + /* Non-existent in DTB */ + ut_asserteq_64(FDT_ADDR_T_NONE, dev_read_addr(dev)); + /* reg = 0x42, size = 0x100 */ + ut_assertok(ofnode_write_prop(node, "reg", 8, + "\x00\x00\x00\x42\x00\x00\x01\x00")); + ut_asserteq(0x42, dev_read_addr(dev)); + + /* Test disabling devices */ + + device_remove(dev, DM_REMOVE_NORMAL); + device_unbind(dev); + + ut_assert(of_device_is_available(ofnode_to_np(node))); + ofnode_set_enabled(node, false); + ut_assert(!of_device_is_available(ofnode_to_np(node))); + + return 0; +} +DM_TEST(dm_test_ofnode_livetree_writing, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c index f9e81747595..6118ad42ca8 100644 --- a/test/dm/test-fdt.c +++ b/test/dm/test-fdt.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -735,58 +734,6 @@ static int dm_test_fdt_remap_addr_name_live(struct unit_test_state *uts) DM_TEST(dm_test_fdt_remap_addr_name_live, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); -static int dm_test_fdt_livetree_writing(struct unit_test_state *uts) -{ - struct udevice *dev; - ofnode node; - - if (!of_live_active()) { - printf("Live tree not active; ignore test\n"); - return 0; - } - - /* Test enabling devices */ - - node = ofnode_path("/usb@2"); - - ut_assert(!of_device_is_available(ofnode_to_np(node))); - ofnode_set_enabled(node, true); - ut_assert(of_device_is_available(ofnode_to_np(node))); - - device_bind_driver_to_node(dm_root(), "usb_sandbox", "usb@2", node, - &dev); - ut_assertok(uclass_find_device_by_seq(UCLASS_USB, 2, &dev)); - - /* Test string property setting */ - - ut_assert(device_is_compatible(dev, "sandbox,usb")); - ofnode_write_string(node, "compatible", "gdsys,super-usb"); - ut_assert(device_is_compatible(dev, "gdsys,super-usb")); - ofnode_write_string(node, "compatible", "sandbox,usb"); - ut_assert(device_is_compatible(dev, "sandbox,usb")); - - /* Test setting generic properties */ - - /* Non-existent in DTB */ - ut_asserteq_64(FDT_ADDR_T_NONE, dev_read_addr(dev)); - /* reg = 0x42, size = 0x100 */ - ut_assertok(ofnode_write_prop(node, "reg", 8, - "\x00\x00\x00\x42\x00\x00\x01\x00")); - ut_asserteq(0x42, dev_read_addr(dev)); - - /* Test disabling devices */ - - device_remove(dev, DM_REMOVE_NORMAL); - device_unbind(dev); - - ut_assert(of_device_is_available(ofnode_to_np(node))); - ofnode_set_enabled(node, false); - ut_assert(!of_device_is_available(ofnode_to_np(node))); - - return 0; -} -DM_TEST(dm_test_fdt_livetree_writing, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); - static int dm_test_fdt_disable_enable_by_path(struct unit_test_state *uts) { ofnode node; -- 2.37.1.455.g008518b4e5-goog