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 647B2C433FE for ; Sun, 13 Nov 2022 20:46:01 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4B21D8516A; Sun, 13 Nov 2022 21:45:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1668372349; bh=As1SxOrhd6RIxOacIt6I2zLmJlHXRp3/pp2T5L3N/Yk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=jfz8WCwB3OvHCfDiPKNZPNFcSkp1E4Tte0vEvjHbSLORT/14FT00OWIV4ypGCObma xrevKpO8hC1wlEcBNP+zxAYz36WzYDSDH4kVS4pzCy1Aqh5tiz2IxZItDgiZAsMYTK 3xydwr8ddiG8MbpSMnbxPfttONPIw8YeOfpjvLFB1g+Y0zAxQb7uRDuEIb/W6QObHU dhi95kiXPTVtM6P/Wn9/BLQhEcnxr3UjQVj5W9i5B91PQ0a7FCKuaO/333AI0i5c0H 7021mNLs/h9EQzjUEOoCL3u3DGfvJfDfovyDvzEG4gIHGGYqLzH2JHB67vqTk4ctTD cbJNgEdzDUu+g== Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 88B7384E3C; Sun, 13 Nov 2022 21:45:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1668372346; bh=As1SxOrhd6RIxOacIt6I2zLmJlHXRp3/pp2T5L3N/Yk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f4FITMpwpxPtm3Iu1O2ye73gF57mDuxinwQHPg1iMxCM2q4BU0Spo5InfFHlrobeK 5Y+SxR6FlANL4Sp1E0D3U71Y2/taYs+tEQt1GmoLAh+kMiCr1JWoj0ccR9Cq44BZBf VxB/X7VG8rnRyx0tSggjpg7P034gZKqBmZMMqo7m2xk4IFx5Jpq6pM82I99d/+Mw6P mbvtSHv03xTZLUNI+wgMEEBZaTf4gIA+5If+ZYxJFqYj6za9UOO1hwj1IS16zAe8AL aYRggEO3XvREH5v8iMC9nzkKK0wXkeDHa8mjvdQOCy0y7hgZArjEm0+0LAyeJQWTnq fGG0+bjU/8+BQ== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 2/2] test: cmd: fdt: Add fdt get value test case Date: Sun, 13 Nov 2022 21:45:35 +0100 Message-Id: <20221113204535.104440-2-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221113204535.104440-1-marex@denx.de> References: <20221113204535.104440-1-marex@denx.de> 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 Add test case for 'fdt get value' sub command. The test case can be triggered using: " ./u-boot -d u-boot.dtb -c 'ut fdt' " Signed-off-by: Marek Vasut --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- test/cmd/fdt.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index ba9eaa42c14..7974c88c0d6 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -142,6 +142,59 @@ static int fdt_test_resize(struct unit_test_state *uts) } FDT_TEST(fdt_test_resize, UT_TESTF_CONSOLE_REC); +/* Test 'fdt get' reading an fdt */ +static int fdt_test_get(struct unit_test_state *uts) +{ + ulong addr; + + addr = map_to_sysmem(gd->fdt_blob); + set_working_fdt_addr(addr); + + /* Test getting default element of /clk-test node clock-names property */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_command("fdt get value fdflt /clk-test clock-names", 0)); + ut_asserteq_str("fixed", env_get("fdflt")); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting 0th element of /clk-test node clock-names property */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_command("fdt get value fzero /clk-test clock-names 0", 0)); + ut_asserteq_str("fixed", env_get("fzero")); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting 1st element of /clk-test node clock-names property */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_command("fdt get value fone /clk-test clock-names 1", 0)); + ut_asserteq_str("i2c", env_get("fone")); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting 2nd element of /clk-test node clock-names property */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_command("fdt get value ftwo /clk-test clock-names 2", 0)); + ut_asserteq_str("spi", env_get("ftwo")); + ut_assertok(ut_check_console_end(uts)); + + /* Test missing 10th element of /clk-test node clock-names property */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt get value ftwo /clk-test clock-names 10", 0)); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting default element of /clk-test node nonexistent property */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt get value fnone /clk-test nonexistent", 1)); + ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting default element of /nonexistent node */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt get value fnode /nonexistent nonexistent", 1)); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} +FDT_TEST(fdt_test_get, UT_TESTF_CONSOLE_REC); + int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct unit_test *tests = UNIT_TEST_SUITE_START(fdt_test); -- 2.35.1