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 76B0AC433EF for ; Wed, 20 Jul 2022 17:01:44 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A6917840FB; Wed, 20 Jul 2022 19:00:43 +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="SvJlft9p"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 09446840CB; Wed, 20 Jul 2022 19:00:28 +0200 (CEST) Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (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 93DD0811CA for ; Wed, 20 Jul 2022 19:00:18 +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-wm1-x32d.google.com with SMTP id n185so11248703wmn.4 for ; Wed, 20 Jul 2022 10:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/1bO33n/wizy5AD4ADwoaoBIaQAsoJo1tWDLH3U0Wsc=; b=SvJlft9pKsdvUndlrj6jboUnmq27QdkYJrrPlzRiWPR7Z5vjU1Xe+IsfaXJAx055/O pl/WSDtPmVjr2zbYye5Du3gJ/0O2fanVnFHp3uStUzMX4M8/GGVqFgHO8QD36/cTf0yv 6c74w0NteRd93ndd/6wcOoCc97aV+114rVE0Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/1bO33n/wizy5AD4ADwoaoBIaQAsoJo1tWDLH3U0Wsc=; b=X6aoDa7PEGvz0U6up+ldlCXlDbHT9aTHGeylQMgLVJDQ725BXDlgr22d2Hy8IxeBRL oZf6uNc00Vx+ACjep7x6PCl2lhchyiY0qDhSkdSPPKVjK2pDjjbPTTnHU4azzo6rdeDw 5JVUTYqLS/le9Ah+ICB7Fi53vWvmYDexDAlnDDS47sfH7Ml7jEgNBbx0Pe5yOzxwvu8m gTfw5fJKaGa+ZLQpRLRbuq0ozET7DUq3BSsNIy0mf79tu5TWykj2WAG5QRFmnyCQ+pN0 m27ZN+VGoZhri6y+Av0lBhU2r92WRLK5Z4JMWXDGpBcW2fnuns3RGEvjzOau7ZvHReRW wGUA== X-Gm-Message-State: AJIora/niBCsObLPhzhNCdSVQpNBm4SbZPv9mb9az92T3zAX75RDqHLD SqMnnv6zUWdox9OTN4sOyFkXzbWWnyP0qmMH X-Google-Smtp-Source: AGRyM1sq9i7MRl0twwfRdX2qt56AB4VZY4CToiw9ibY7/w6gVBWl8Af6FNnFGHFcwepFhYULSBsZdA== X-Received: by 2002:a05:600c:591:b0:3a3:205f:e2ca with SMTP id o17-20020a05600c059100b003a3205fe2camr4653660wmd.147.1658336417646; Wed, 20 Jul 2022 10:00:17 -0700 (PDT) Received: from sjg1.roam.corp.google.com ([62.48.169.138]) by smtp.gmail.com with ESMTPSA id u16-20020a05600c00d000b003a31c4f6f74sm3690906wmm.32.2022.07.20.10.00.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 10:00:16 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH 06/19] dm: core: Move ofnode-writing test to ofnode Date: Wed, 20 Jul 2022 10:59:34 -0600 Message-Id: <20220720165947.12728-7-sjg@chromium.org> X-Mailer: git-send-email 2.37.0.170.g444d1eabd0-goog In-Reply-To: <20220720165947.12728-1-sjg@chromium.org> References: <20220720165947.12728-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 --- 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.0.170.g444d1eabd0-goog