From patchwork Thu Mar 2 03:08:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750329 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=kqmTKKDO; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=QWGXTwCl; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx0H3qhhz246G for ; Thu, 2 Mar 2023 14:09:19 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CB09285C2C; Thu, 2 Mar 2023 04:09:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="kqmTKKDO"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="QWGXTwCl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5924F85C28; Thu, 2 Mar 2023 04:09:14 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050:0:465::101]) (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 CD99285B7E for ; Thu, 2 Mar 2023 04:09:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4PRx05504bz9sQb; Thu, 2 Mar 2023 04:09:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726549; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dOdxuygSDSGd6X0UgxuIea3bmHrj8CONSsUXQz78//0=; b=kqmTKKDOje09xSj9+WZUIAR/v/3Lm8PxM+cKr1HJCUen+TJ7u+4naNUh8sGKjjLgOYGAt1 VU0JGXiSUnpJUcLQLf8C5/uu6qfsw4LgYhTXbkKsH4fnEPsnRq7xKH/cWvDm6x4fNzdqBA 0T3ZR4Vx/cqDmycwvXFxL3bvcM18kRITf5fa5dM1dvxv9rT04Tw7I88JkLFUREkjOnVSyf bBxHyMGbIJEpxL6mKOo63hQGnEepBRCajg7Ryhrpnw+aF/ne5PGOfm1nH/zGz8X3oFPgfO fnDH0rnTm6b1/fa+LZffUAxCImAISqcpJHmQ/QZluhRTKjkEwf4mXDgwvMOfDw== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726547; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dOdxuygSDSGd6X0UgxuIea3bmHrj8CONSsUXQz78//0=; b=QWGXTwClgQZEXTx8LULacyTomGFmMPyLp2YxpyaVRx2qqzCM6zyfkpksg3zvZywTScldsh 1jeI4EJPMfDGOPgyN8H815ph73EIKfKSKw9UWYQF29vvUvjl0PPh0L9CrcPuVfBxVkigcV KKPlagIvR+s7+x6THUlk8M6yjy8Znal3xULnBtrsfqFnrXVqvjBhijnqrprLhU2FZU72sF e09GGnRJ4dMvA12hxxcRT9QLvztuQDKOV9NnzBflUd11xMvP7jcKjAWF+eEISzkGGe+Gwg 5hmxgBgl/qwEEmzGzSI+HR5OPlI8TNnbk+RGyxx88X+e+KIbTvywRM7Dw1Xupg== To: u-boot@lists.denx.de Cc: Marek Vasut , Hai Pham , Nam Nguyen , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 01/32] cmd: fdt: Import is_printable_string() from DTC to fix u32 misprint Date: Thu, 2 Mar 2023 04:08:14 +0100 Message-Id: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: prehm8a4nq4us6nze18g9fzk4uxscsaf X-MBO-RS-ID: 35bc064b87731acf0dd X-Rspamd-Queue-Id: 4PRx05504bz9sQb 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 Import is_printable_string() implementation from DTC 1.7.0 as of DTC commit 039a994 ("Bump version to v1.7.0") . This fixes a print of u32 property which so far used to be printed as string by U-Boot fdt print command. We might see the case where the parsed property value, in this case it is a 32-bit integer, identified as a printable string or a null byte (concatenated strings) because of its last character happens to be: 0x00 (null character), 0xB (vertical tab character) or 0x10 (line feed character) In this situation, if the string is identified as printable string, it will be displayed as character instead of hex value When the isprint() condition is true, there are two possibilities: 1) The character is ASCII character (except the first 32) 2) The character is extended ASCII character For example, NG property in device tree: clock-frequency = <16640000>; by default, would be displayed as clock-frequency = "", "ýè"; and with this patch applied, would be displayed as clock-frequency = <0x00fde800>; Full investigation was done by Nam and Hai, patch reworked by Marek to use common code from DTC. Signed-off-by: Hai Pham Signed-off-by: Nam Nguyen Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Hai Pham Signed-off-by: Nam Nguyen Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- cmd/fdt.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/cmd/fdt.c b/cmd/fdt.c index 1972490bdc2..bf2415661e2 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -878,41 +878,33 @@ static int fdt_parse_prop(char * const *newval, int count, char *data, int *len) static int is_printable_string(const void *data, int len) { const char *s = data; + const char *ss, *se; /* zero length is not */ if (len == 0) return 0; - /* must terminate with zero or '\n' */ - if (s[len - 1] != '\0' && s[len - 1] != '\n') + /* must terminate with zero */ + if (s[len - 1] != '\0') return 0; - /* printable or a null byte (concatenated strings) */ - while (((*s == '\0') || isprint(*s) || isspace(*s)) && (len > 0)) { - /* - * If we see a null, there are three possibilities: - * 1) If len == 1, it is the end of the string, printable - * 2) Next character also a null, not printable. - * 3) Next character not a null, continue to check. - */ - if (s[0] == '\0') { - if (len == 1) - return 1; - if (s[1] == '\0') - return 0; - } + se = s + len; + + while (s < se) { + ss = s; + while (s < se && *s && isprint((unsigned char)*s)) + s++; + + /* not zero, or not done yet */ + if (*s != '\0' || s == ss) + return 0; + s++; - len--; } - /* Not the null termination, or not done yet: not printable */ - if (*s != '\0' || (len != 0)) - return 0; - return 1; } - /* * Print the property in the best format, a heuristic guess. Print as * a string, concatenated strings, a byte, word, double word, or (if all From patchwork Thu Mar 2 03:08:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750330 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=Xc4GvPJF; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=yS90SelM; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx0X4rMTz246G for ; Thu, 2 Mar 2023 14:09:32 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C0B7D85C2F; Thu, 2 Mar 2023 04:09:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="Xc4GvPJF"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="yS90SelM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1997A85C2F; Thu, 2 Mar 2023 04:09:15 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) (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 92BAC85B75 for ; Thu, 2 Mar 2023 04:09:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4PRx062KYhz9svP; Thu, 2 Mar 2023 04:09:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726550; 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=JZGFdAzoYCl5XPg/Ip0HsYEI1gyQXUR9Wv8x8LeR4CA=; b=Xc4GvPJFQAZaZeL+45TVvsK2kYLJ6zTOnRsVGQfM+6C4oR5aAzQ6mT+kJSSWm1pogYc1IH dL2HNhHSsp5A8kLR+og3/XlSGZriYBhue5tc67KehtjxcmMfKvZF4kBZY5OjmZrxrSJzdh Gf9S7KdeoLMRbsWoNfwHdJlyavdDMityEeKBLPuQex8WtKqaQ4QzWhY4RSAv/9QMqQGqAw sl3jU3rq8H5GEDeJr1MZx2uW65lzwo5mLCzMh3VSaHbxPDQFg21XLpP4JH+YazXpp1kSqX zidL2nqu2SatlX13/wf5aq/AsrLbWzdtcOwi7Jrcwy85pVJzGvNa1uBOAZKbeg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726548; 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=JZGFdAzoYCl5XPg/Ip0HsYEI1gyQXUR9Wv8x8LeR4CA=; b=yS90SelMqkAX1TkdE1clPDPpZ+KNHzeCj0OdjT/zHOf7xQSt2/GUfjR+yVUVTqmhab/v41 KOKKfqrvFh9PZJE4SNpyY2MjtBbh1VHmI7tguz/T911NZToLHzCvs1MrsoumEYYmnPOoMP rLbE8HhhI55QBkFkFZJs3pQRSEErNxPyDZQ6HTGycYXkrdcRPKTfJ6NqMweEREw1VqTZlD 9vTSvOqGZGeK6EEVDcZev+w7ETncwxDe89aZQmGVPqibpiEOqH9G0ShE4DVd99Ftmy6L+D MutDudr/kL/iV7jh+16pQzF2SG3MzqKmSfD2iinR7zdrQDklBv+GHpaJk0K0+w== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 02/32] cmd: fdt: Fix handling of empty properties for fdt get addr and fdt get size Date: Thu, 2 Mar 2023 04:08:15 +0100 Message-Id: <20230302030845.322552-2-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: ppbaist8gwgjxbpf8m76eg3zs75m3f17 X-MBO-RS-ID: 6366b409f8908758e10 X-Rspamd-Queue-Id: 4PRx062KYhz9svP 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 It is perfectly valid to request an address or size of FDT property without value, the only special case if requesting of the value of FDT property without value. Invert the test such, that properties without value still set the variable from 'fdt get addr/size' to address of the property or size of the property, where the later is 0. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- cmd/fdt.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/fdt.c b/cmd/fdt.c index bf2415661e2..56b3585c3ac 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -446,15 +446,17 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) } else { nodep = fdt_getprop( working_fdt, nodeoffset, prop, &len); - if (len == 0) { - /* no property value */ - env_set(var, ""); - return 0; - } else if (nodep && len > 0) { + if (nodep && len >= 0) { if (subcmd[0] == 'v') { int index = 0; int ret; + if (len == 0) { + /* no property value */ + env_set(var, ""); + return 0; + } + if (argc == 7) index = simple_strtoul(argv[6], NULL, 10); From patchwork Thu Mar 2 03:08:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750331 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=Wv6fCAEw; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=DlJgzniT; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx0s1ZL5z246G for ; Thu, 2 Mar 2023 14:09:49 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 40E8585C0D; Thu, 2 Mar 2023 04:09:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="Wv6fCAEw"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="DlJgzniT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 85ADD85C2F; Thu, 2 Mar 2023 04:09:17 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) (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 3E8CA85C0D for ; Thu, 2 Mar 2023 04:09:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4PRx0674Fmz9sjD; Thu, 2 Mar 2023 04:09:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726551; 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=9ZlPfZEqYYCL5fUnX+HqCnOLK9tbtMuShEPZTSb0qBs=; b=Wv6fCAEwO8Okq5dlATlXNvUd6OSSPJ+/K9qstbixoUC+6YOJdUsna9+EsFdcPcQNkMhm6V UW9rtcGCXDvF5W+sfnWg3qQPfyn9pOjYpeBnXlWHfbTMYjFn6U52WoYN02zv1YKaVCjo6Z gYpPjB5/DKv6H5shrJVw6tzCBruyHNIkppRmyN+Rk2V/0f8sGoAqPJ97vAleLPyShXixHT wo9f/zuFn8uw0WrmdYXJXY0Ary3KZETjVTQmdpIGyU/MSfc8ZX5iN7wFgFsGwbkKe6l+sV 5dtoQvZ7Y32V9ORTkcFzUYddpv77sDijux+f7BctHN+ZSjgu5juhzJq/Jn2unQ== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726548; 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=9ZlPfZEqYYCL5fUnX+HqCnOLK9tbtMuShEPZTSb0qBs=; b=DlJgzniT02YATPkAiY6TJbyqoGuY2GtjwaU4C6rn48KL0aUXFuoRKVk4/1Hwets5cRhoGo cGI4qNNq4s/0KdrML3YF9djv2KJXaaBsZGwn6XPvdFODdemOiQRtv7pPTVXOzC4isiTIEZ bwpvTBsUyx2tGcqy8WlzeF6Z16R92UpghzYvzSQFyeUdPzBCJBH1Toac8XiJeIYaNUXcw0 bu662k3YELEH6xL6IYdsSVXwzdurTMwoxLzm+OY5PHfMM/2SPb+FTWuOW1o0JPsA8p98PF csSt8skStH8BcMrcGiCR2ciLgH5wTr+27znUChM0GkBUGL8/4H/l2nEn8yUYnw== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 03/32] cmd: fdt: Fix fdt rm behavior on non-existent property and error message space Date: Thu, 2 Mar 2023 04:08:16 +0100 Message-Id: <20230302030845.322552-3-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: fxu1rnjfre1ijh8sk1xjmtnthzu81sij X-MBO-RS-ID: db041569e2b90b8e4f6 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 In case an FDT contains a node '/test-node@1234' , with no property called 'noprop' in that node, the following command triggers a print of help message for 'fdt' command instead of erroring out: => fdt rm /test-node@1234 noprop This is because the subcommand errornously returns 'err' instead of CMD_RET_FAILURE, fix it. Furthermore, align the number of spaces past fdt_delprop() in error message with the rest of the code. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- cmd/fdt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/fdt.c b/cmd/fdt.c index 56b3585c3ac..644b58ac4d7 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -547,16 +547,16 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if (argc > 3) { err = fdt_delprop(working_fdt, nodeoffset, argv[3]); if (err < 0) { - printf("libfdt fdt_delprop(): %s\n", + printf("libfdt fdt_delprop(): %s\n", fdt_strerror(err)); - return err; + return CMD_RET_FAILURE; } } else { err = fdt_del_node(working_fdt, nodeoffset); if (err < 0) { - printf("libfdt fdt_del_node(): %s\n", + printf("libfdt fdt_del_node(): %s\n", fdt_strerror(err)); - return err; + return CMD_RET_FAILURE; } } From patchwork Thu Mar 2 03:08:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750332 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=Q1/c8K6c; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=bfDUhpxi; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx185FVwz246G for ; Thu, 2 Mar 2023 14:10:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DEF6985C54; Thu, 2 Mar 2023 04:09:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="Q1/c8K6c"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="bfDUhpxi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DC22F85C45; Thu, 2 Mar 2023 04:09:17 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [IPv6:2001:67c:2050:0:465::103]) (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 DF3F285C13 for ; Thu, 2 Mar 2023 04:09:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4PRx075d5sz9sky; Thu, 2 Mar 2023 04:09:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726551; 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=TyXHn9toLnCvgk7sWZ7S1TXELF6hwlg9OlAYRIJqNk0=; b=Q1/c8K6cIUx8nHFRIkE5U8ayFudPvdi2gZwg0jmOI9vu64KioAUod+5buZ/CbRxCZVTNoF sAVEoVyzgsWKiWHHd/E2ZasNp6LXArlb4MMKVoAnLoBy7Q+y5G6MAJz7yjijGj65jfKsIR J4NWe1Tblsi3phOQYIfzOY6bx2ueKSsM0S/wr8issW0ae1/j6iLkf8Cu7fTYOfzz+kHA49 FZuLPG2gXBSXUY/SpB5rIJ2IxAxTuJLEYhU7ADJW1UPYSXNIH37wLYa6/tnCHFwFcXxLqc JVT0zrqvxXLFSRUUbUI+CWGiAFLiyPMujCO1r4Ra5VpTUmUSFIgIa3ZxCUKlnA== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726549; 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=TyXHn9toLnCvgk7sWZ7S1TXELF6hwlg9OlAYRIJqNk0=; b=bfDUhpxifQHkgEQMcoKVj7i4JYgT/bppIZdTxSOLGCiGbSxU8wFg93gMSy06iOp+s/hFUv MaDFlFBx/GhhdeOQ/xQvQB9F779Pnk3ZqVJ+VJRxy+MfKqBAhlwmfczNXkH6pxdTFPfmJH OguixxafN9g/iMz4pYvG6qTX7tZ0kwM90LwtbnBKF1PI7nkfZFOMKrV7g51jtmq6SpxjNN zNJYsaXEX1DwPoFaIS9uAR0Iy12oB0e2BLtGvV6dpnDUsUiVMy+/1Yt7by5ZcS2lCbCcTW hxxgZVywKX55ZMZ46bVqQlKkNw7/UGdV6YioUhCBzthNOD0Hpz6c22EMemRDJQ== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 04/32] cmd: fdt: Fix fdt rsvmem behavior on non-existent index and error message space Date: Thu, 2 Mar 2023 04:08:17 +0100 Message-Id: <20230302030845.322552-4-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: 51qbgo6w5ofcmqt7r8psf5zxh5hz6m5w X-MBO-RS-ID: d20da238a4e1db1ff51 X-Rspamd-Queue-Id: 4PRx075d5sz9sky 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 In case 'fdt rsvmem delete index' is passed a non-existent index, one which does not exist in 'fdt rsvmem print', then the following command triggers a print of help message for 'fdt' command instead of erroring out: => fdt rsvmem delete 1234 This is because the subcommand errornously returns 'err' instead of CMD_RET_FAILURE, fix it. Furthermore, align the number of spaces past fdt_del_mem_rsv() and fdt_add_mem_rsv() in error message with the rest of the code. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- cmd/fdt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/fdt.c b/cmd/fdt.c index 644b58ac4d7..29d748891d0 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -644,18 +644,18 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) err = fdt_add_mem_rsv(working_fdt, addr, size); if (err < 0) { - printf("libfdt fdt_add_mem_rsv(): %s\n", + printf("libfdt fdt_add_mem_rsv(): %s\n", fdt_strerror(err)); - return err; + return CMD_RET_FAILURE; } } else if (argv[2][0] == 'd') { unsigned long idx = hextoul(argv[3], NULL); int err = fdt_del_mem_rsv(working_fdt, idx); if (err < 0) { - printf("libfdt fdt_del_mem_rsv(): %s\n", + printf("libfdt fdt_del_mem_rsv(): %s\n", fdt_strerror(err)); - return err; + return CMD_RET_FAILURE; } } else { /* Unrecognized command */ From patchwork Thu Mar 2 03:08:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750333 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=E6XS1NzB; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=hrRhLZuI; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx1S2WCtz1yXC for ; Thu, 2 Mar 2023 14:10:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 83C4285C63; Thu, 2 Mar 2023 04:09:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="E6XS1NzB"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="hrRhLZuI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 15E4185C0D; Thu, 2 Mar 2023 04:09:18 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) (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 708BB85B58 for ; Thu, 2 Mar 2023 04:09:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4PRx081bgPz9sWt; Thu, 2 Mar 2023 04:09:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726552; 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=SZtXB8MwZhwzWLwZQyfSp7twUgn2x6xU8hUI2PjGibY=; b=E6XS1NzBtAp49Uxxxm1Vj+ZkpYoAP231zjwMCTQsy1vCF3Ut9mf8fGChltdfFevE59QjxQ +sq35kA5JZYvQESLyqZIvRnxSL/bzYgmQUUl7fHWOI2F+6Gh4ByrkfpfoHfhRD4cskxuzU jSVnWEpvY7hL98v/eGRtWYQvI1K3O8r+tktULUPKD9HOFGF3IlYlo53ZkGh/luRnKVMTsD 57J+tuG7boj6a0RD8QPq+ctqqPh2OkRCN8Gr/Cat/fQmIXVk1txIn9jKqrgEmThJmgqXLX WRKWFssfOwS/cpqzmLeQ7Krx6cbsdv5vw3VIzvxHST9lrhLI2tk2kfw4d05DlQ== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726550; 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=SZtXB8MwZhwzWLwZQyfSp7twUgn2x6xU8hUI2PjGibY=; b=hrRhLZuIA4YfZCy2eWlVX/3WqISwx6TyoRhBIiabkNGFVQKx9Ssn3OGRya3WC2E0RzrCdp LmtEbNrtS+zDy4rMbzEqPDPUuZbHWTctEfr32cVym1lYJ/zM+B+vW5ETVi/xDthaGjxINU fPQmpL1eu6nbwHXx3SDQYiMCUmRFKkHiRx5S0wUfKZXVxGm5voGAIbP7QLuRbafb9tTqqX 1oetJjVZXkqBxEilXrlX5IGnFzA7Q9nAfXfr7MxgNJGLRlOVIM7qISSZzD5NNya8DG1P3v 0NTtPcQWIcsQ/VR4/349tKL7lIuOcWWEDpEQpsmTzKcHDxIM70l3DfYq6b+sow== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 05/32] cmd: fdt: Check argc before accessing argv in fdt bootcpu Date: Thu, 2 Mar 2023 04:08:18 +0100 Message-Id: <20230302030845.322552-5-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-ID: 120daf470e190c8351a X-MBO-RS-META: 89arjsciemaztxjckrdxqwjscxjwhg9m X-Rspamd-Queue-Id: 4PRx081bgPz9sWt 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 On case 'fdt bootcpu' is invoked without parameters, argv[2] is not valid and this command would SEGFAULT in sandbox environment. Add missing argc test to avoid the crash and rather print usage help message. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- cmd/fdt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/fdt.c b/cmd/fdt.c index 29d748891d0..734c9b36a07 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -597,7 +597,12 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) * Set boot cpu id */ } else if (strncmp(argv[1], "boo", 3) == 0) { - unsigned long tmp = hextoul(argv[2], NULL); + unsigned long tmp; + + if (argc != 3) + return CMD_RET_USAGE; + + tmp = hextoul(argv[2], NULL); fdt_set_boot_cpuid_phys(working_fdt, tmp); /* From patchwork Thu Mar 2 03:08:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750334 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=G/xcZo2S; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=ZSnRl/En; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx1k2fHMz1yXC for ; Thu, 2 Mar 2023 14:10:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A81C985C77; Thu, 2 Mar 2023 04:09:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="G/xcZo2S"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="ZSnRl/En"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2A74A85C26; Thu, 2 Mar 2023 04:09:19 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050:0:465::101]) (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 0E43585C28 for ; Thu, 2 Mar 2023 04:09:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4PRx086Ms3z9sgK; Thu, 2 Mar 2023 04:09:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726552; 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=0g1+kC0mmYeN/0DGEK+eYzmRdgDhvWvLD79xiVdBTLo=; b=G/xcZo2SiwmOZv+pu7xRvOw+M8KciyP8/BZ6bNboY/bIrEFSRYfNfoq9swmIh9mdAaPYky o2AZOxOXTS7l4lG8cSqJg8z88b4pZh+Mv/PsAwzYAXsLBnbMOYEjoHEar32hjpZsg55IE2 RPRHFzuuAdU1FFASfwybanvy6CEIACnUJg17dDAnD2+9O1k2HVRL88c43prKKzKkNuUrdx sviWAFNfhnRzw0OqDu0LJYr6kZivO7Axbi6Q4+JEUOPeNXNXvldEsk3sb16qTOgc+sMxgo lco+8LYfvDTcvt6yIfj6o8oAuXUkbexSXfvf8ANJCsbJGqWEmKJiN2ZM3Vyqog== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726550; 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=0g1+kC0mmYeN/0DGEK+eYzmRdgDhvWvLD79xiVdBTLo=; b=ZSnRl/EnIPByw34sA0WRjoTS8QeHXfM/hAjYLX6XimMnjTRCy84IYg99V2uIxfIo4WnB4S /rVxdO+Gq52Fmyb6cURO4ulzz8PMNWEzB3pfC03+OkwjcM9C4kuwhRG+ngHtHo+ie/rNnA qiMFfPKlkhaH2FHTSCPuN5Dn5v+Fg2C3oyZ/EeY2GHKiGTuLt1oAl7ZN4DEysUFsKYxHAZ qzquIddP7lgTp83cFNnK6WOEsabW06CgqszbaAldeyan3QjiJV+ufnv54JEhbIXFcm1AmQ +8ZYiFZS7F9DFzjZYq2rgCk9Seqy/PykVTtFowj1wnyG9lWDg+3F31S11B7faA== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 06/32] cmd: fdt: Check argc before accessing argv in fdt memory Date: Thu, 2 Mar 2023 04:08:19 +0100 Message-Id: <20230302030845.322552-6-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-ID: 87b0374ea1056d698bc X-MBO-RS-META: i6f91toih37gs3byn9mdgijx7tmjpzpp X-Rspamd-Queue-Id: 4PRx086Ms3z9sgK 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 On case 'fdt memory' is invoked without parameters, argv[2]/argv[3] is not valid and this command would SEGFAULT in sandbox environment. Add missing argc test to avoid the crash and rather print usage help message. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- cmd/fdt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/fdt.c b/cmd/fdt.c index 734c9b36a07..f257bee8643 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -611,6 +611,10 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) } else if (strncmp(argv[1], "me", 2) == 0) { uint64_t addr, size; int err; + + if (argc != 4) + return CMD_RET_USAGE; + addr = simple_strtoull(argv[2], NULL, 16); size = simple_strtoull(argv[3], NULL, 16); err = fdt_fixup_memory(working_fdt, addr, size); From patchwork Thu Mar 2 03:08:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750335 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=Qwdw1hcL; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=Ury99xPN; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx2003Ffz1yXC for ; Thu, 2 Mar 2023 14:10:48 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 185BA85C7A; Thu, 2 Mar 2023 04:09:32 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="Qwdw1hcL"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="Ury99xPN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 47B8C85B7D; Thu, 2 Mar 2023 04:09:19 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [IPv6:2001:67c:2050:0:465::201]) (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 AF80185B75 for ; Thu, 2 Mar 2023 04:09:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4PRx0948GGz9sh9; Thu, 2 Mar 2023 04:09:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726553; 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=T3N830rZrFqfm8G4jLiDa7mX/oKILNZTm6Grt999164=; b=Qwdw1hcLpp9qM9OHwPStYaxQHejUIwEEz1R0TE10Aed2aITtlFEP6Q9rl2oWpNNbBsIg1w H+1V1sQDpSPhgJa4Qp2X/qsWpKZFIbm+21MHDEqfWj2sQUZlokNUguCN6gTPja9eBqvhGf phQyiO8qqvlz6msk69uX91iezQ57gqMp70M12W4V3oVjze6WliQlvtdiFybVyDR3iz2oHV Xyk//FoE9TkWIFi/9OIXfDKztO+hAZ5y1AN6THKmClB+lQ/9RyFCj9V35MOptcqYS3TB0Q vpzHDA4UI5CbwqJPclZRNe0j0LgH/3biIfypym3sFqzAzIedBYJtg4+alqtC4A== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726551; 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=T3N830rZrFqfm8G4jLiDa7mX/oKILNZTm6Grt999164=; b=Ury99xPNaIJcO45E0Yt7izmPnHMVJOeOgrUMwuGaLAEkNULfuOBDX07INtZwblJcVo1CF1 Vy/Ju3GbcSTleK0myWoLyZIlrL/agJvgoMd68CZX7pBTBG1a0jpS+PoUilNxE8QPtwAMTP PcfJ0YnpdTyRUl9TwJDZvs/ujj8tGsUPNWC7MXEhnCY28J/x9icTRkA6Tj7/0Q90CwDT55 E/MobKgn6SuQOB1U9cENGK4LORkA9Xy6RJHDhwRYDliIBchonRAyUJtTQFgKmH1E1K02hY iujffhJXEA68Ij5vpx0qH15Xdqr1husZASgzTzjylTz5ACd3nSMdcPxMRGnKcA== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 07/32] cmd: fdt: Align checksign parameter names in help text Date: Thu, 2 Mar 2023 04:08:20 +0100 Message-Id: <20230302030845.322552-7-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: sfg1w7quw6owiyba7p7jzb8cgpqyecya X-MBO-RS-ID: ea4ad682ffe247e970f X-Rspamd-Queue-Id: 4PRx0948GGz9sh9 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 The help text references 'addr' as an optional key start address, but the explanation references the same as 'start', make sure they both read as 'addr'. Also update the abbreviated 'addr' in the explanation to 'address'. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- cmd/fdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/fdt.c b/cmd/fdt.c index f257bee8643..279dad9fe11 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -1138,8 +1138,8 @@ static char fdt_help_text[] = " / - initrd start addr/size\n" #if defined(CONFIG_FIT_SIGNATURE) "fdt checksign [] - check FIT signature\n" - " - addr of key blob\n" - " default gd->fdt_blob\n" + " - address of key blob\n" + " default gd->fdt_blob\n" #endif "NOTE: Dereference aliases by omitting the leading '/', " "e.g. fdt print ethernet0."; From patchwork Thu Mar 2 03:08:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750336 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=vdW+mlOi; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=KdJvraS5; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx2G4sxzz1yXC for ; Thu, 2 Mar 2023 14:11:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8E84385C5D; Thu, 2 Mar 2023 04:09:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="vdW+mlOi"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="KdJvraS5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 926D585C3E; Thu, 2 Mar 2023 04:09:20 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [IPv6:2001:67c:2050:0:465::103]) (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 6C09685C2A for ; Thu, 2 Mar 2023 04:09:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4PRx0B2CLZz9slj; Thu, 2 Mar 2023 04:09:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726554; 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=u/BFOX05knsYvhW/dwQpXTSQ0aJW5ktYNhmTaBGOKRQ=; b=vdW+mlOi+0d+AdqflQCyJBaQP6ltk3X2pGV+3QeowLtiJ0Sm850JnHsOsclUi27MMU1EML xN7nGiBKc1zO7gzXoib9P+Z28dxtJl5999EcwUsMOBCZEb+lwON1ussN6+0W8hZkEe+HMh kcukgu39EIC1jp/Cf6yOf6iFVfh4DJ7naxfkOXB4XHtmPAuLdJLL+kHPlQnmbyJak8+kjm 6FA5fYPjO2Cx+V9mCFx9FvXtgmrcWVCsGPrPPWnM7OdqMUsDzGLYyfZHOpA25CaJfyqFIi 70JN6YOg4C6d35By/6N9mBYhZfwxAPYNcuxjEGmp8omWTSbu/ddhrHcEJHq8hg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726552; 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=u/BFOX05knsYvhW/dwQpXTSQ0aJW5ktYNhmTaBGOKRQ=; b=KdJvraS5pis+vilsCXnQs9lvACs56O8LVhxz3YRYOPF9TpdcrWI7yVn1t7O837pGqxBeXm bKTWWIl+7VAFODDV11gg7aqRcO0kJ5MksnPB4ovcjNvXhKD1P6U90uixRLteK8yjMkzw79 AekN+GbFKgCSVdLJxfSaE2bgxcZyI6kbr6uV+vocWdBDY77MzaTyA3pzAGyvs8tgEQSTwE thZcy9wIlWQQc1rCFX20IpbVC1q3uFDK0gY61+H8tiNc3/+Da+KGBms+YoJwbcb9HyQHjl J1baKjnqw1TALvi1e5UY0BEXARnaChWnTeXY1gZuKRWbWswtq8T2YVV2i3A4xA== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 08/32] cmd: fdt: Handle 64bit pointers in fdt get addr Date: Thu, 2 Mar 2023 04:08:21 +0100 Message-Id: <20230302030845.322552-8-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: 7zfrsgespgzkf9kcfkno9gjwusinty7w X-MBO-RS-ID: 98d8d88dd729e00d2f1 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 The command assumed 32bit pointers so far, with 64bit pointer the command would overwrite a piece of stack. Fix it by extending the array size to cater for 64bit pointer, and use snprintf() to avoid writing past the end of the array ever again. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- cmd/fdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/fdt.c b/cmd/fdt.c index 279dad9fe11..bc19303159d 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -466,9 +466,9 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return ret; } else if (subcmd[0] == 'a') { /* Get address */ - char buf[11]; + char buf[19]; - sprintf(buf, "0x%p", nodep); + snprintf(buf, sizeof(buf), "0x%p", nodep); env_set(var, buf); } else if (subcmd[0] == 's') { /* Get size */ From patchwork Thu Mar 2 03:08:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750337 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=ehRM94Kz; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=uDuGZwXT; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx2Y1Vq6z1yXC for ; Thu, 2 Mar 2023 14:11:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 15E1585C8E; Thu, 2 Mar 2023 04:09:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="ehRM94Kz"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="uDuGZwXT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6978785B7D; Thu, 2 Mar 2023 04:09:20 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [IPv6:2001:67c:2050:0:465::201]) (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 1CF3885C31 for ; Thu, 2 Mar 2023 04:09:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4PRx0C03vLz9sjD; Thu, 2 Mar 2023 04:09:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726555; 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=FUWA0vNTbOhMp3gQfs6tHdRI7Z0tFK47lxc+3diSKpA=; b=ehRM94KzGsZoBUlXDFh6cSQ4OZSVFeaBdrnVpemLRefiryd/RFE07Bix2i8Mc5wIacQ5Yd aVgjdp7lheWLkIPcgH46Q4knIUs6nVy5uwXcDHPx2oeXe6k6HBf23gB4C8qBuD4PuVZH1r m2HPYMHnd+3gAn6PurWJIuOzvTSmMrcO3ck6GEdPcBTYzVUQ/89KhximQnZUYgBxJMWmK+ 2uCDRDoq0m1rxKV6NbPV2vThtDkySv6ho1Dy0aVGDsB2zMM1EhjLuen677x4QvOTrxQgag rpS6MmhPmauO4xLykYGdpkjOGtvpRYaHOQ0Mr168enz1tKIrAdJTMNsCVenUNg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726552; 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=FUWA0vNTbOhMp3gQfs6tHdRI7Z0tFK47lxc+3diSKpA=; b=uDuGZwXT8UggIBdIrtdAr862E/PDfFIQTdrU9ufXb/vxe/+p3CK9d0E+kcWHpXm0aOkA0O MEhKq237xGS/hdfGxRWIJMbSeVsqATrFe3W6KDCUtBw/bb558UYx5GlfBTtqST//CsNNqn 8+nj+BusVO4MSUsH4MCsJLZPggpPHe/9gdcY41rpzHxjZ60R/FT56ofKXM3uqQSZ+eDCR7 PXn5+iITr+z4zi9Do/6is5179q3hiGxzSgOlKXevTeUJstF2HBHBVpCPi0WwZfs3kdC/Om bZm2FzvBkyxsUTxjPvqYc+u1vVSpiyW+VNaJASa2cfXc5fkfhkJHzu38WcIeTw== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 09/32] cmd: fdt: Map address returned from fdt get addr to sysmem Date: Thu, 2 Mar 2023 04:08:22 +0100 Message-Id: <20230302030845.322552-9-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: emzukxmuhijqzqyto3hpfdpu398am75o X-MBO-RS-ID: cfaaff68a2be6e2102f X-Rspamd-Queue-Id: 4PRx0C03vLz9sjD 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 The address returned from 'fdt get addr' command must be mapped into sysmem, as this is a working FDT. Access to this address without mapping it would lead to crash e.g. in sandbox. The following command triggers the crash: " ./u-boot -Dc 'fdt addr $fdtcontroladdr ; fdt get addr var / compatible ; md $var' " Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- cmd/fdt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/fdt.c b/cmd/fdt.c index bc19303159d..f2576ab4b38 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -468,7 +468,8 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) /* Get address */ char buf[19]; - snprintf(buf, sizeof(buf), "0x%p", nodep); + snprintf(buf, sizeof(buf), "0x%lx", + (ulong)map_to_sysmem(nodep)); env_set(var, buf); } else if (subcmd[0] == 's') { /* Get size */ From patchwork Thu Mar 2 03:08:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750338 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=sxJj0NaA; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=LTz7nNdZ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx2s1r2Gz1yXC for ; Thu, 2 Mar 2023 14:11:33 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D46DF85C51; Thu, 2 Mar 2023 04:09:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="sxJj0NaA"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="LTz7nNdZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D449C85C2A; Thu, 2 Mar 2023 04:09:20 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) (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 D0B2385C39 for ; Thu, 2 Mar 2023 04:09:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4PRx0C4GMXz9sky; Thu, 2 Mar 2023 04:09:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726555; 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=0FqWkOkRHF2UmFEDNpUnsJoxigWpFpiVgLDA3+EdTTQ=; b=sxJj0NaANxSfCVFPq2Rydh4bKzXKXxVMATD/VmV8dnR/a8jwMHeQm0/PWiGCtOEfpC83wt mlLGqZGmGOBkJDbrmLzjfLEwyH8oNIixirg2DeGYIRLxsHCIjATJOJonv+cF23IHiTOvc3 GbwLr2VK/0xiRnqd3BQLw6HnSnqZtWK3pyr+JACCypBQKwRyDUxpidXdCjVlrspl0VatjW viCKfyx0/KeR6OCPJrjaSf3lL7hbUOHxyvxYTa/8wf8TBFKV8Zat5fMQvdWY3UQ70Jl5CF VkWOtdbg6lMhlvJVTG2JCaWExqdz82/4DiYYk7bz9xCoqWiAfrbwCj6l1lJJaw== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726553; 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=0FqWkOkRHF2UmFEDNpUnsJoxigWpFpiVgLDA3+EdTTQ=; b=LTz7nNdZnwN8jkNQiju1Kbvkut4BQXJfrXNfwowMhW6l3JLHTrICQ/dEPjUxmtP2rFDbxM 5qDm847zRV4GjWvzUAChKUzGZb4wCp7zjSOLqhOiLnux3w3hyZd+3p515AHxawAcpkNuTF cZRmUSgt3x7Nmr2FxNf5pfhfG3+RcvJeU1+Il6Jjez59s8aK5CLlbd4/Xq1fpwWuCrPi4D JoBqBvSfFEW38KSm2+gOBNoyiXHy31GDBeu9UTBIQVEc5KZBBquFEvKFFNmURg5Jc+c5SS Ugn5WhiF37SAek/rapw5JO8UzqHVERrLt/QlCTmMSXRL1RGTQbfcBchi3jSJ9g== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 10/32] cmd: fdt: Add support for integer arrays in fdt get value with index Date: Thu, 2 Mar 2023 04:08:23 +0100 Message-Id: <20230302030845.322552-10-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: zjtmkmymq8j8du86y1ump6hzhza5d94r X-MBO-RS-ID: ebbd4b6271cecb017ab 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 Currently any integer array value is set as long up-to-40 character hexadecimal string into environment variable when extracted from an FDT using 'fdt get value path prop index', because the support for handling integer arrays is not implemented, and fdt_value_env_set() code falls back into the hash handling behavior instead. Implement this support simply by checking whether user supplied any index. If index is set and the property length is multiple of four, then this is an integer array, and the code would extract value at specified index. There is a subtle change where default index is set to -1 instead of 0. This is OK, since the only place which checks for index to be less or equal zero is the string array handling code in fdt_value_env_set() and that code would work perfectly well with index -1 too. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- cmd/fdt.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/fdt.c b/cmd/fdt.c index f2576ab4b38..f38fe909c3e 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -77,7 +77,17 @@ static int fdt_value_env_set(const void *nodep, int len, sprintf(buf, "0x%08X", fdt32_to_cpu(*(fdt32_t *)nodep)); env_set(var, buf); - } else if (len%4 == 0 && len <= 20) { + } else if (len % 4 == 0 && index >= 0) { + /* Needed to print integer arrays. */ + const unsigned int *nodec = (const unsigned int *)nodep; + char buf[11]; + + if (index * 4 >= len) + return 1; + + sprintf(buf, "0x%08X", fdt32_to_cpu(*(nodec + index))); + env_set(var, buf); + } else if (len % 4 == 0 && len <= 20) { /* Needed to print things like sha1 hashes. */ char buf[41]; int i; @@ -448,7 +458,7 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) working_fdt, nodeoffset, prop, &len); if (nodep && len >= 0) { if (subcmd[0] == 'v') { - int index = 0; + int index = -1; int ret; if (len == 0) { From patchwork Thu Mar 2 03:08:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750339 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=B7VKnZ6b; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=N6D/fSJe; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx3761b8z1yXC for ; Thu, 2 Mar 2023 14:11:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6E0EE85C68; Thu, 2 Mar 2023 04:09:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="B7VKnZ6b"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="N6D/fSJe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A99DA85C2E; Thu, 2 Mar 2023 04:09:21 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050:0:465::101]) (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 4FB9985B7E for ; Thu, 2 Mar 2023 04:09:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4PRx0D1MfPz9sQb; Thu, 2 Mar 2023 04:09:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726556; 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=7DJH1ji/tm2hOH827piOXqvtaRyHIzAImi88rYtSAVs=; b=B7VKnZ6bhEkwcSyt1dgvpC1wp9IorSfr5flU69+vSG5KS6WzNkiztsreA9rpwjj7XI5yg+ pdlDFbbW6jUAHclmAZSqvPKED+h+REFtKOzE1l4AtFg3WD1/mo42VdfTI4g6QJu+iR9n1m Y9hpH26p13lsBZ29FJHdn0Cdqj1yX+0j84t0ISxnGWPfoWda6cTUODfDFhBW9CTY42VdqL ckHAV9XWmpfdrLe8enaf1s58OcGkOFibPQO5ZWGk0zQ72tBSjfYw2ih4oTk6g6wgYcnitt 6r3OHX1kLlqaClaT5AeyN2dV8VvTCViCPRmmJMP69Je6UtnAI9zLzCWH2JWkLg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726554; 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=7DJH1ji/tm2hOH827piOXqvtaRyHIzAImi88rYtSAVs=; b=N6D/fSJeqj8XYBT8vBzO578/x/ST00Agz6P7lyfOrQjp9CdAr3vNr9d7FqXks3LE9wVk9w /HSS+hhO2vMd3PmgghHCFVEkHTXntFRwZ42Iyl/RmGkrewhsOUTcEaN3kSxUHpaHO6kt8H ebMipvQY8BUdBu3YplYyB1vRFytxBBvjTOFP9sQv/SuU+4tqAKKN+LV2oM+0iBKuHj/CX0 cm2rysclrCo+9ogwF0rJvxqLrUfVj0zQJ6vvT0HwofqmMfohU9nQR9207NHCpMs2vuSMPM QgSA4pfig2cVuJh1o/fRRPjaQ64V+ii93RQCOJ5d0V84YVjrDynChj3Pquj3ng== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 11/32] test: Add ut_assert_nextline_empty() empty line helper Date: Thu, 2 Mar 2023 04:08:24 +0100 Message-Id: <20230302030845.322552-11-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: b4kgmcyw4smz8kj5kj66rdhpewkwym7y X-MBO-RS-ID: bf90bcb3302e71b9f30 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 helper macro to test for empty lines, which is an inobvious wrapper around ut_assert_nextline("%s", "") . Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- include/test/ut.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/test/ut.h b/include/test/ut.h index 4d00b4eeca1..2b0dab32f68 100644 --- a/include/test/ut.h +++ b/include/test/ut.h @@ -334,6 +334,10 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes); return CMD_RET_FAILURE; \ } \ +/* Assert that the next console output line is empty */ +#define ut_assert_nextline_empty() \ + ut_assert_nextline("%s", "") + /** * ut_check_free() - Return the number of bytes free in the malloc() pool * From patchwork Thu Mar 2 03:08:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750340 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=H+IURXG7; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=JbZno65O; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx3Q3PCnz1yXC for ; Thu, 2 Mar 2023 14:12:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8201785C28; Thu, 2 Mar 2023 04:09:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="H+IURXG7"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="JbZno65O"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C98D285C13; Thu, 2 Mar 2023 04:09:21 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050:0:465::101]) (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 EF4BC85C0D for ; Thu, 2 Mar 2023 04:09:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4PRx0D6WkKz9sWt; Thu, 2 Mar 2023 04:09:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726556; 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=k9F8gVuKVmj9pqV3zYA3nH2DeoqWt2bkisc2wdjI8ZQ=; b=H+IURXG7MeWl4TQbF6mGxSGotvUdnYkOqHcsWtTSbQrzuBTbMQr/of1dS/lDhsfv0QKHzI 6qXtG6JiiUZPzVztL3pmHUC4tB0hcQk11mNuNwuwNXdgJcCF3LZr/AQ5Or5bQDPw8+Ir9B NzmBM0ClBpZ2ckvb768NNF27EA5y0hJ3X8wupueFWzLM0rDUDmYAt0yMzBxRs6E6DrketE u9QVmKSTcZo+54XCD5JsnqNzV4yU5TLs59QnQT5vwtIiab15PoMblvcLDtNK1x6ikfBWih r683QHDVv6pxgTuwKMpjg8JcB6LIM7hOeSpntRpH7rEVuMbp7soaP30sGB3x6A== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726554; 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=k9F8gVuKVmj9pqV3zYA3nH2DeoqWt2bkisc2wdjI8ZQ=; b=JbZno65OrMl1BgiV646JzF1rvGaW6DKsa/5OPSOy7LUfITRZMIyPpgrUhfhtAmuAC7b3II tTit7mNS6ziggmlx/qMpEH37CBHizwx8KKQXtlQFgCLm3GQcSZIjP9MNbvbyA96GjmxwK4 s8OwmQx8fw5rfdb09XqT4ev4NhzcNmQdqFjWi4Yd5bT1StqPJAyVmppM2rgEwpvxARwdXv qOJT9vjwiluOhdZfpDM6d0r9LdK0Qlix51zJ/twsfQxNw90bYnzT4g7g+/bOvotCPQJujL mPvdoePjDztkNbdjk8NuEC3JcZcLbZE7MykSPwUUhDYB9h8HX1z0z04Uv/bE+A== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 12/32] test: cmd: fdt: Rename fdt_test_resize() to fdt_test_addr_resize() Date: Thu, 2 Mar 2023 04:08:25 +0100 Message-Id: <20230302030845.322552-12-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: aq57hazn5r5uxqj8u3wjcpkmpgprgw93 X-MBO-RS-ID: 47de6e33802c015c9e4 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 The 'fdt' command has a 'resize' subcommand, rename the fdt_test_resize() to fdt_test_addr_resize() to avoid confusion about what it is testing. There is currently no resize test. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 7974c88c0d6..a50285eafab 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -108,7 +108,7 @@ static int fdt_test_addr(struct unit_test_state *uts) FDT_TEST(fdt_test_addr, UT_TESTF_CONSOLE_REC); /* Test 'fdt addr' resizing an fdt */ -static int fdt_test_resize(struct unit_test_state *uts) +static int fdt_test_addr_resize(struct unit_test_state *uts) { char fdt[256]; const int newsize = sizeof(fdt) / 2; @@ -140,7 +140,7 @@ static int fdt_test_resize(struct unit_test_state *uts) return 0; } -FDT_TEST(fdt_test_resize, UT_TESTF_CONSOLE_REC); +FDT_TEST(fdt_test_addr_resize, UT_TESTF_CONSOLE_REC); /* Test 'fdt get' reading an fdt */ static int fdt_test_get(struct unit_test_state *uts) From patchwork Thu Mar 2 03:08:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750341 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=HyEufHeK; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=gvHwvwn5; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx3k6zZyz1yXC for ; Thu, 2 Mar 2023 14:12:18 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 72D0285C56; Thu, 2 Mar 2023 04:09:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="HyEufHeK"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="gvHwvwn5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7CFD585C4F; Thu, 2 Mar 2023 04:09:24 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [IPv6:2001:67c:2050:0:465::102]) (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 A53CE85B75 for ; Thu, 2 Mar 2023 04:09:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4PRx0F3xD3z9svP; Thu, 2 Mar 2023 04:09:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726557; 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=/y+U1TnX5ulyVnSQnk7d8RhyLZmcAYs6u1pq7Qindfs=; b=HyEufHeK3wcJfKLBJrNiYli1Ps1wyAywHHhTCDZfW82rB+wrqPXpp9GlP9YLsJfm4T34vj jfgV8dr6MocZpdzZkMAJmmxtdyP7mj1f3hCOKRM5xafYd+3MkBFmpEY5K8vDe79yl60a5p k2Q436C5t6zRpqUWJsZgDP97Tiebz+DYj583doK8/Sgl2E64/+PdBlOOI6zn7jOLMl7KJk lZhat2n7dxZMnaqxrtEIhpyK+P5iRYwC1F3ATkgFHIlYaJbIJTbX+0lRTdpZ6M5ZwC4Nev dq4K6z/rsZ8ofZO6WIsgo8e+nZHe2+IyLsULesHuiZOoP2Im+0G3tVZHrQL2GA== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726555; 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=/y+U1TnX5ulyVnSQnk7d8RhyLZmcAYs6u1pq7Qindfs=; b=gvHwvwn5UpzTZt9QF+sqSQ8galWwazcyZTeUttMOR3UHpiyuvzTvqlAqri2ORdNxiBUPGM Gc7w1jp1lpAPMwms1tBcs/lohiRdpdXw/OICfakM5F9i+/Hkgk7g6pqBED0Uyi4dkPG67/ umPlWmYP8X4MhkdLYLBm5FeN9VHcGBqJTr2lrJgaWrpa8kSFxD5eY1Wn++GE63u36Squ+H 5tLfzrMtcmdazA4jciG2eU2Eezr/FV0amE1ybgpsAJpCKy0IJFppX6h1mXGuWee365xjdM rrr6ruQ9yopSIFFRgVfDIj18qG2Vpgz4l4TertzxdV0Pi/H41fjOIVQhUnOUpg== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 13/32] test: cmd: fdt: Rename fdt_test_get() to fdt_test_get_value() Date: Thu, 2 Mar 2023 04:08:26 +0100 Message-Id: <20230302030845.322552-13-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: whcfyfd6pcbduuogo167pc9k5j1dk881 X-MBO-RS-ID: f1a516408f6b29d902a 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 The 'fdt get' command has a 'get value' subcommand, rename the fdt_test_get() to fdt_test_get_value() to avoid confusion about what it is testing. There is currently no get 'get name', 'get addr', 'get size' subcommand test. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index a50285eafab..03a29c6b9c0 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -142,8 +142,8 @@ static int fdt_test_addr_resize(struct unit_test_state *uts) } FDT_TEST(fdt_test_addr_resize, UT_TESTF_CONSOLE_REC); -/* Test 'fdt get' reading an fdt */ -static int fdt_test_get(struct unit_test_state *uts) +/* Test 'fdt get value' reading an fdt */ +static int fdt_test_get_value(struct unit_test_state *uts) { ulong addr; @@ -193,7 +193,7 @@ static int fdt_test_get(struct unit_test_state *uts) return 0; } -FDT_TEST(fdt_test_get, UT_TESTF_CONSOLE_REC); +FDT_TEST(fdt_test_get_value, UT_TESTF_CONSOLE_REC); int do_ut_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { From patchwork Thu Mar 2 03:08:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750342 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=AHUD7D5x; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=QzBkp/v4; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx421W9Wz1yXC for ; Thu, 2 Mar 2023 14:12:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 46F5685C79; Thu, 2 Mar 2023 04:09:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="AHUD7D5x"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="QzBkp/v4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BB7FA85B75; Thu, 2 Mar 2023 04:09:24 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) (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 7656085C31 for ; Thu, 2 Mar 2023 04:09:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4PRx0G1hjtz9sb2; Thu, 2 Mar 2023 04:09:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726558; 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=vN334T82TT0ddMAPZ76RNWYLWmEKLCHjUx1NfRfU2Z8=; b=AHUD7D5xwjOy/oFb1oYox4wLoeRFeN912QG4uDQswTR9qKw9C0eLKd+86VD2mITJalfjUh 6550d7/+p/1pz4em6Rrq7w3o99ZX44QFdeqpNtoNRIzkmEuYC8SK+Wc++K81uquf2lST6h YgIv5UXKA9g/GGItUNwOZtOUX0QPADHuCs+Pd18rsIdH3WJ0818RJvDH/knUBONol3g+iO X8iZLqf/Ia9HJop/Ex/Q+HbVlIw2Iooh6e1kCHMRTB82xIXjS/TJNqoUxcwlmfAJJcplZG dgjz/AC7Mj6E6L65UsHz6rGAClAhdbG02ZPFw9yUeKYQaJZM6JAYrCc0jD4L4w== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726556; 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=vN334T82TT0ddMAPZ76RNWYLWmEKLCHjUx1NfRfU2Z8=; b=QzBkp/v4jd4U3MoMzj+HXbcZhoXYfVub+wLiwy1+lFV2aW30sMy+xwuhoA+yDoX2eSJlXT 33qfNqb4LHlalGWPazAFZNa0OsT7zdQ49ZcJpO+Hyv6zHzNe11Mm3w6rMfiJ+zPw7kaG3h Bg0ZRmDGNn/IQPZrJ72uwBXauPB4g3gXNJT71OrCS8bkeUCzW5nkBIsQVZ0REOIqSTONYs OnVa2Qy/YovNEQZhOgjbo3espVrmi0FvHYk+2UHvaDRSph5Tm9EYrRXnNl3BAQ6TWlfh+b d+EJ+0WcpRvVeEXsl8TbQKhDSsrnakQeM+CgnwPZwzoxGlcNZAsOcX3I9qlNFA== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 14/32] test: cmd: fdt: Generate fuller DT internally and switch fdt get value to it Date: Thu, 2 Mar 2023 04:08:27 +0100 Message-Id: <20230302030845.322552-14-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: dwbmjo3ktews7fu4iide1cqzordsh57k X-MBO-RS-ID: 2b6890124b7779ef65c 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 Implement function to generate internal test DT fragment and switch the 'fdt get value' test to this instead of depending on the sandbox DT. Rename clk-test node to test-node node. This FDT fragment will be reused by other tests. No functional change. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 124 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 111 insertions(+), 13 deletions(-) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 03a29c6b9c0..21553a2f3dc 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -39,6 +39,102 @@ static int make_test_fdt(struct unit_test_state *uts, void *fdt, int size) return 0; } +/** + * make_fuller_fdt() - Create an FDT with root node and properties + * + * The size is set to the minimum needed + * + * @uts: Test state + * @fdt: Place to write FDT + * @size: Maximum size of space for fdt + */ +static int make_fuller_fdt(struct unit_test_state *uts, void *fdt, int size) +{ + fdt32_t regs[2] = { cpu_to_fdt32(0x1234), cpu_to_fdt32(0x1000) }; + + /* + * Assemble the following DT for test purposes: + * + * / { + * #address-cells = <0x00000001>; + * #size-cells = <0x00000001>; + * compatible = "u-boot,fdt-test"; + * model = "U-Boot FDT test"; + * + * aliases { + * badalias = "/bad/alias"; + * subnodealias = "/test-node@1234/subnode"; + * testnodealias = "/test-node@1234"; + * }; + * + * test-node@1234 { + * #address-cells = <0x00000000>; + * #size-cells = <0x00000000>; + * compatible = "u-boot,fdt-test-device1"; + * clock-names = "fixed", "i2c", "spi", "uart2", "uart1"; + * u-boot,empty-property; + * clock-frequency = <0x00fde800>; + * regs = <0x00001234 0x00001000>; + * + * subnode { + * #address-cells = <0x00000000>; + * #size-cells = <0x00000000>; + * compatible = "u-boot,fdt-subnode-test-device"; + * }; + * }; + * }; + */ + + ut_assertok(fdt_create(fdt, size)); + ut_assertok(fdt_finish_reservemap(fdt)); + ut_assert(fdt_begin_node(fdt, "") >= 0); + + ut_assertok(fdt_property_u32(fdt, "#address-cells", 1)); + ut_assertok(fdt_property_u32(fdt, "#size-cells", 1)); + /* */ + ut_assertok(fdt_property_string(fdt, "compatible", "u-boot,fdt-test")); + /* */ + ut_assertok(fdt_property_string(fdt, "model", "U-Boot FDT test")); + + ut_assert(fdt_begin_node(fdt, "aliases") >= 0); + /* */ + ut_assertok(fdt_property_string(fdt, "badalias", "/bad/alias")); + /* */ + ut_assertok(fdt_property_string(fdt, "subnodealias", "/test-node@1234/subnode")); + /* */ + ut_assertok(fdt_property_string(fdt, "testnodealias", "/test-node@1234")); + ut_assertok(fdt_end_node(fdt)); + + ut_assert(fdt_begin_node(fdt, "test-node@1234") >= 0); + ut_assertok(fdt_property_cell(fdt, "#address-cells", 0)); + ut_assertok(fdt_property_cell(fdt, "#size-cells", 0)); + /* */ + ut_assertok(fdt_property_string(fdt, "compatible", "u-boot,fdt-test-device1")); + /* */ + ut_assertok(fdt_property(fdt, "clock-names", "fixed\0i2c\0spi\0uart2\0uart1\0", 26)); + /* */ + ut_assertok(fdt_property(fdt, "u-boot,empty-property", NULL, 0)); + /* + * + * This value is deliberate as it used to break cmd/fdt.c + * is_printable_string() implementation. + */ + ut_assertok(fdt_property_u32(fdt, "clock-frequency", 16640000)); + /* */ + ut_assertok(fdt_property(fdt, "regs", ®s, sizeof(regs))); + ut_assert(fdt_begin_node(fdt, "subnode") >= 0); + ut_assertok(fdt_property_cell(fdt, "#address-cells", 0)); + ut_assertok(fdt_property_cell(fdt, "#size-cells", 0)); + ut_assertok(fdt_property_string(fdt, "compatible", "u-boot,fdt-subnode-test-device")); + ut_assertok(fdt_end_node(fdt)); + ut_assertok(fdt_end_node(fdt)); + + ut_assertok(fdt_end_node(fdt)); + ut_assertok(fdt_finish(fdt)); + + return 0; +} + /* Test 'fdt addr' getting/setting address */ static int fdt_test_addr(struct unit_test_state *uts) { @@ -145,43 +241,45 @@ FDT_TEST(fdt_test_addr_resize, UT_TESTF_CONSOLE_REC); /* Test 'fdt get value' reading an fdt */ static int fdt_test_get_value(struct unit_test_state *uts) { + char fdt[4096]; ulong addr; - addr = map_to_sysmem(gd->fdt_blob); + ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt))); + addr = map_to_sysmem(fdt); set_working_fdt_addr(addr); - /* Test getting default element of /clk-test node clock-names property */ + /* Test getting default element of /test-node@1234 node clock-names property */ ut_assertok(console_record_reset_enable()); - ut_assertok(run_command("fdt get value fdflt /clk-test clock-names", 0)); + ut_assertok(run_command("fdt get value fdflt /test-node@1234 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 */ + /* Test getting 0th element of /test-node@1234 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_assertok(run_command("fdt get value fzero /test-node@1234 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 */ + /* Test getting 1st element of /test-node@1234 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_assertok(run_command("fdt get value fone /test-node@1234 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 */ + /* Test getting 2nd element of /test-node@1234 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_assertok(run_command("fdt get value ftwo /test-node@1234 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 */ + /* Test missing 10th element of /test-node@1234 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_asserteq(1, run_command("fdt get value ften /test-node@1234 clock-names 10", 0)); ut_assertok(ut_check_console_end(uts)); - /* Test getting default element of /clk-test node nonexistent property */ + /* Test getting default element of /test-node@1234 node nonexistent property */ ut_assertok(console_record_reset_enable()); - ut_asserteq(1, run_command("fdt get value fnone /clk-test nonexistent", 1)); + ut_asserteq(1, run_command("fdt get value fnone /test-node@1234 nonexistent", 1)); ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND"); ut_assertok(ut_check_console_end(uts)); From patchwork Thu Mar 2 03:08:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750344 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=dbk712Mg; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=ZIWiLDoD; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx4Z3HK1z1yXC for ; Thu, 2 Mar 2023 14:13:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6228085C92; Thu, 2 Mar 2023 04:09:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="dbk712Mg"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="ZIWiLDoD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7298985C28; Thu, 2 Mar 2023 04:09:25 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [IPv6:2001:67c:2050:0:465::201]) (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 023ED85B58 for ; Thu, 2 Mar 2023 04:09:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4PRx0G6Bybz9sQX; Thu, 2 Mar 2023 04:09:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726558; 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=VosYbnHltUeIoUdq6w1Ta77h8oxX+WGeI2e9AGEVOso=; b=dbk712MgrZgKzBtSufMQmIZK+MfKuA6XJWL/AN1yYrgGk+dLlLx9AhQYZaM3Sovrm8DR8s qbjgPAJEexXtdD8Yh+Q7qfTJY2ac8PO5Aqr7U+GgVjo92Uvzk6wQUEXhIWqmKrn2F56jhq 8Z2EF5nk5wPdaHfEM1hacSGbvFDPkWl50vcXVEB65xI+w/e+YEYLUvusDjockGQOeBSZiN ONPEBxuzbUrpG+22NSVp4b2DLK1HPRtO205aXpfa2GISJyDlrykJHuBF+VPn44H0cJZx6Z hBQ9c1NjD9oRcbSWDNtI5BpibeigeE0QGVr7gkxQ/O8+wsw4jBBmdVdzQToakQ== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726556; 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=VosYbnHltUeIoUdq6w1Ta77h8oxX+WGeI2e9AGEVOso=; b=ZIWiLDoD16jDoKije/ptmVZz6ntZWIrDnSc3bm0UtAVS3kDhcKMRqTOV8lTu7FafMRIZUr HgezJkuDdwjkqjoX0+f5W2PfJYU5wyADbFrucUgVUu3iD/z+zV3Qwk0MPsb/8oc6MftVQQ anvgvb+sw8gGf2SoRaBSxtogpURYj8quXUSWhjZSM7K+HYcb59albQ0qOqBVEOo5ItuOmA 0couAiQOaz20y8EOvvxEa/8rM5FS61U23OICRIhS6rf3F05Xc6KKfFQdQBWlUfo9/OBiVp fCba1FrnigeOKJrPvwY9J43dGdV7Cswtr2faLAxmw0FY+KEvl89ygQAjY42Rqg== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 15/32] test: cmd: fdt: Test alias resolution in 'fdt get value' Date: Thu, 2 Mar 2023 04:08:28 +0100 Message-Id: <20230302030845.322552-15-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: 3foc9bym7k1sxuh5u63m34kjjhgp6t6x X-MBO-RS-ID: 887d3aa1661f89690c9 X-Rspamd-Queue-Id: 4PRx0G6Bybz9sQX 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 The 'fdt' command help contains the following note: " Dereference aliases by omitting the leading '/', e.g. fdt print ethernet0. " Add test for it. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 65 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 21553a2f3dc..e04ba37f19f 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -239,56 +239,81 @@ static int fdt_test_addr_resize(struct unit_test_state *uts) FDT_TEST(fdt_test_addr_resize, UT_TESTF_CONSOLE_REC); /* Test 'fdt get value' reading an fdt */ -static int fdt_test_get_value(struct unit_test_state *uts) +static int fdt_test_get_value_common(struct unit_test_state *uts, + const char *node) { - char fdt[4096]; - ulong addr; - - ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt))); - addr = map_to_sysmem(fdt); - set_working_fdt_addr(addr); - - /* Test getting default element of /test-node@1234 node clock-names property */ + /* Test getting default element of $node node clock-names property */ ut_assertok(console_record_reset_enable()); - ut_assertok(run_command("fdt get value fdflt /test-node@1234 clock-names", 0)); + ut_assertok(run_commandf("fdt get value fdflt %s clock-names", node)); ut_asserteq_str("fixed", env_get("fdflt")); ut_assertok(ut_check_console_end(uts)); - /* Test getting 0th element of /test-node@1234 node clock-names property */ + /* Test getting 0th element of $node node clock-names property */ ut_assertok(console_record_reset_enable()); - ut_assertok(run_command("fdt get value fzero /test-node@1234 clock-names 0", 0)); + ut_assertok(run_commandf("fdt get value fzero %s clock-names 0", node)); ut_asserteq_str("fixed", env_get("fzero")); ut_assertok(ut_check_console_end(uts)); - /* Test getting 1st element of /test-node@1234 node clock-names property */ + /* Test getting 1st element of $node node clock-names property */ ut_assertok(console_record_reset_enable()); - ut_assertok(run_command("fdt get value fone /test-node@1234 clock-names 1", 0)); + ut_assertok(run_commandf("fdt get value fone %s clock-names 1", node)); ut_asserteq_str("i2c", env_get("fone")); ut_assertok(ut_check_console_end(uts)); - /* Test getting 2nd element of /test-node@1234 node clock-names property */ + /* Test getting 2nd element of $node node clock-names property */ ut_assertok(console_record_reset_enable()); - ut_assertok(run_command("fdt get value ftwo /test-node@1234 clock-names 2", 0)); + ut_assertok(run_commandf("fdt get value ftwo %s clock-names 2", node)); ut_asserteq_str("spi", env_get("ftwo")); ut_assertok(ut_check_console_end(uts)); - /* Test missing 10th element of /test-node@1234 node clock-names property */ + /* Test missing 10th element of $node node clock-names property */ ut_assertok(console_record_reset_enable()); - ut_asserteq(1, run_command("fdt get value ften /test-node@1234 clock-names 10", 0)); + ut_asserteq(1, run_commandf("fdt get value ften %s clock-names 10", node)); ut_assertok(ut_check_console_end(uts)); - /* Test getting default element of /test-node@1234 node nonexistent property */ + /* Test getting default element of $node node nonexistent property */ ut_assertok(console_record_reset_enable()); - ut_asserteq(1, run_command("fdt get value fnone /test-node@1234 nonexistent", 1)); + ut_asserteq(1, run_commandf("fdt get value fnone %s nonexistent", node)); ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND"); ut_assertok(ut_check_console_end(uts)); + return 0; +} + +static int fdt_test_get_value(struct unit_test_state *uts) +{ + char fdt[4096]; + ulong addr; + int ret; + + ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt))); + addr = map_to_sysmem(fdt); + set_working_fdt_addr(addr); + + ret = fdt_test_get_value_common(uts, "/test-node@1234"); + if (!ret) + ret = fdt_test_get_value_common(uts, "testnodealias"); + if (ret) + return ret; + /* 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)); + /* Test getting default element of bad alias */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt get value vbadalias badalias nonexistent", 1)); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting default element of nonexistent alias */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt get value vnoalias noalias nonexistent", 1)); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_BADPATH"); + ut_assertok(ut_check_console_end(uts)); + return 0; } FDT_TEST(fdt_test_get_value, UT_TESTF_CONSOLE_REC); From patchwork Thu Mar 2 03:08:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750343 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=u0/r/0tD; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=dMki0wF1; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx4K1zC3z1yXC for ; Thu, 2 Mar 2023 14:12:49 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BE95285C4F; Thu, 2 Mar 2023 04:09:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="u0/r/0tD"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="dMki0wF1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4FEEC85C31; Thu, 2 Mar 2023 04:09:25 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) (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 D370385B7D for ; Thu, 2 Mar 2023 04:09:21 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4PRx0H4L1jz9sky; Thu, 2 Mar 2023 04:09:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726559; 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=Ev0Gb9ShEmOivKG4QJ+sGjWxFJWibIqck8T90duKdSw=; b=u0/r/0tDnJMNGM5yJHdev5njv+nhjbtqRVquoe5JkAoEn4huOV4Czlsj/O5YW3TjlhjTym epvx4w909wDOEp49qE2eKtR0Io6+uEbRxpKkuUiFCnNmIouICXv4gWQSCuS9Gxde6qj56c 8l9HlXPH3n52+H87uyPg92naZe+AlJDzmcAYa9mptGcDUPDqY+3pSXNms+txZZ4Ey3bf7q 0lmP1yuIOq1mUHR2PzLWwyn5NTZsGVr9JiStvaZOD+ORM+B2EXS3CbloUwQbmLStFirBjb 8muMyg+V02K/tFXRuffTkrTicOy/F8rJ44xKovBSESfqSMNiApIIH/IinCQvrQ== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726557; 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=Ev0Gb9ShEmOivKG4QJ+sGjWxFJWibIqck8T90duKdSw=; b=dMki0wF1ODgztNNgb8vMWPzlToqMEC/j3nGZRIz7bulveGt1FIbFHT54SznLGHErMzbwJQ 733Bq9W5CiaRmf6RKAFYGGOyvd7Ea4YDUwXkEkWaXbOgkGFp5ke6BTzWgsf37SKrd4E/Bx OCMAX84y6DEptdDJufSj+WaMa+wre5iKHZJULezV2GchElWoL80TF3xtIkkj15Xazqp72F n7Tt8eKpa2eoTs1oBVoRehF/aNTH72TE+yV4ssfaN4WAZiOetcaNF2OWwvzPdsWRBqFqbc +YB3WyXDM7Eoa1UptFT312C9A+YeiZjIviJmLehJgcorTGyp9npcpxDsqwZ1Mw== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 16/32] test: cmd: fdt: Test both string and integer arrays in 'fdt get value' Date: Thu, 2 Mar 2023 04:08:29 +0100 Message-Id: <20230302030845.322552-16-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: r77cdmpiyfzy9ap7usqaqxeadcs1w87r X-MBO-RS-ID: 7b8da3e3f4f9a64e6b3 X-Rspamd-Queue-Id: 4PRx0H4L1jz9sky 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 The 'fdt get value' subcommand now supports extraction of integer value from integer arrays, add test for it, including a test for special case unindexed integer array read, which is handled as hash and treated as a long string instead of integer. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 58 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index e04ba37f19f..69a69c5c75c 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -239,38 +239,64 @@ static int fdt_test_addr_resize(struct unit_test_state *uts) FDT_TEST(fdt_test_addr_resize, UT_TESTF_CONSOLE_REC); /* Test 'fdt get value' reading an fdt */ +static int fdt_test_get_value_string(struct unit_test_state *uts, + const char *node, const char *prop, + const char *idx, const char *strres, + const int intres) +{ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt get value var %s %s %s", + node, prop, idx ? : "")); + if (strres) { + ut_asserteq_str(strres, env_get("var")); + } else { + ut_asserteq(intres, env_get_hex("var", 0x1234)); + } + ut_assertok(ut_check_console_end(uts)); + + return 0; +} + static int fdt_test_get_value_common(struct unit_test_state *uts, const char *node) { /* Test getting default element of $node node clock-names property */ - ut_assertok(console_record_reset_enable()); - ut_assertok(run_commandf("fdt get value fdflt %s clock-names", node)); - ut_asserteq_str("fixed", env_get("fdflt")); - ut_assertok(ut_check_console_end(uts)); + fdt_test_get_value_string(uts, node, "clock-names", NULL, "fixed", 0); /* Test getting 0th element of $node node clock-names property */ - ut_assertok(console_record_reset_enable()); - ut_assertok(run_commandf("fdt get value fzero %s clock-names 0", node)); - ut_asserteq_str("fixed", env_get("fzero")); - ut_assertok(ut_check_console_end(uts)); + fdt_test_get_value_string(uts, node, "clock-names", "0", "fixed", 0); /* Test getting 1st element of $node node clock-names property */ - ut_assertok(console_record_reset_enable()); - ut_assertok(run_commandf("fdt get value fone %s clock-names 1", node)); - ut_asserteq_str("i2c", env_get("fone")); - ut_assertok(ut_check_console_end(uts)); + fdt_test_get_value_string(uts, node, "clock-names", "1", "i2c", 0); /* Test getting 2nd element of $node node clock-names property */ - ut_assertok(console_record_reset_enable()); - ut_assertok(run_commandf("fdt get value ftwo %s clock-names 2", node)); - ut_asserteq_str("spi", env_get("ftwo")); - ut_assertok(ut_check_console_end(uts)); + fdt_test_get_value_string(uts, node, "clock-names", "2", "spi", 0); + + /* + * Test getting default element of $node node regs property. + * The result here is highly unusual, the non-index value read from + * integer array is a string of concatenated values from the array, + * but only if the array is shorter than 40 characters. Anything + * longer is an error. This is a special case for handling hashes. + */ + fdt_test_get_value_string(uts, node, "regs", NULL, "3412000000100000", 0); + + /* Test getting 0th element of $node node regs property */ + fdt_test_get_value_string(uts, node, "regs", "0", NULL, 0x1234); + + /* Test getting 1st element of $node node regs property */ + fdt_test_get_value_string(uts, node, "regs", "1", NULL, 0x1000); /* Test missing 10th element of $node node clock-names property */ ut_assertok(console_record_reset_enable()); ut_asserteq(1, run_commandf("fdt get value ften %s clock-names 10", node)); ut_assertok(ut_check_console_end(uts)); + /* Test missing 10th element of $node node regs property */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_commandf("fdt get value ften %s regs 10", node)); + ut_assertok(ut_check_console_end(uts)); + /* Test getting default element of $node node nonexistent property */ ut_assertok(console_record_reset_enable()); ut_asserteq(1, run_commandf("fdt get value fnone %s nonexistent", node)); From patchwork Thu Mar 2 03:08:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750345 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=pDTusoc0; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=xkdBPEUJ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx4r4YZgz1yXC for ; Thu, 2 Mar 2023 14:13:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DEC2285C99; Thu, 2 Mar 2023 04:09:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="pDTusoc0"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="xkdBPEUJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3605A85B7D; Thu, 2 Mar 2023 04:09:26 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [IPv6:2001:67c:2050:0:465::102]) (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 6AA0785C2A for ; Thu, 2 Mar 2023 04:09:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4PRx0J1NpDz9sxM; Thu, 2 Mar 2023 04:09:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726560; 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=Rd1m1Bnn4tnCya25MsyfC0JsSyJbQNbW0rcIYiYD/xY=; b=pDTusoc0dzFQoCl2Et6qo2HqJFXjwm0RkaWlrX8t5eiGOBqq+KGTY9Pg7v7QJVlwdWifEU bAyuWi2emXfLyfDYETcKOCu7+eVIayA2Z7J72slYTi96YIDYxDQQwug5jkKZpwTmAFpGiE huj9WgRDSlD+XZYT5Jg2d/UruL0evadESqQlhNx+DJoy6i1bTOwfLc1oCYq8Vpy5fEoH10 M5hEejB+3YDdGoX6F+K5dNWKJLq0p+FkNZrbdEjS3KqiwfYGRvB7K/TaKGL7vQBtI9jugG rz8gRTXiLjDkyrJi+MqArwIB3MgRrj2dKNwion4tyOMbR9l9/NsbzjkAmjwzEA== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726558; 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=Rd1m1Bnn4tnCya25MsyfC0JsSyJbQNbW0rcIYiYD/xY=; b=xkdBPEUJIN8YdE91KukELH5VyecxfU5+n41hVp9kVtYEUj9mF2w6lM5VA3ywd7HldXzCrl 7kHMYXY3iwX5aLDC3G34IysL2BjScfIoOPIQO0/xpMZsuT9JHyIqXsOCbE2Y2uZf9m34Bf wXA1xYqaY03GWHn82aF0KB/VCHA/OGVG6xiuOmKil1Pf7M0RJ3+ahVXSpkGUUs0SqkibVy 3zWxMIf9erRiisehdXn2K1ADfXyO5Ektx3zvnSjSc9DO7r0r6D6uMw17OGDNEqYJvWuhek 2KU3FdEBgqh0txnLA2SaqFK4xFuJIYCLBGlJ8TxJbO+KNPY03+9VWI89+dP55g== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 17/32] test: cmd: fdt: Test fdt move Date: Thu, 2 Mar 2023 04:08:30 +0100 Message-Id: <20230302030845.322552-17-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-ID: bd41765cc563a0d3e0f X-MBO-RS-META: 71oiqdy99y94oxbye81xxsi6oikxwdf1 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 'fdt move' test which works as follows: - Create simple FDT, map it to sysmem - 'move' the FDT into new zeroed out sysmem location - Verify newly active FDT is in the new location - Compare both locations The test case can be triggered using: " ./u-boot -Dc 'ut fdt' " To dump the full output from commands used during test, add '-v' flag. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 69a69c5c75c..023b83eb019 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -238,6 +238,40 @@ static int fdt_test_addr_resize(struct unit_test_state *uts) } FDT_TEST(fdt_test_addr_resize, UT_TESTF_CONSOLE_REC); +static int fdt_test_move(struct unit_test_state *uts) +{ + char fdt[256]; + ulong addr, newaddr = 0x10000; + const int size = sizeof(fdt); + uint32_t ts; + void *buf; + + /* Original source DT */ + ut_assertok(make_test_fdt(uts, fdt, size)); + ts = fdt_totalsize(fdt); + addr = map_to_sysmem(fdt); + set_working_fdt_addr(addr); + + /* Moved target DT location */ + buf = map_sysmem(newaddr, size); + memset(buf, 0, size); + + /* Test moving the working FDT to a new location */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt move %08x %08x %x", addr, newaddr, ts)); + ut_assert_nextline("Working FDT set to %lx", newaddr); + ut_assertok(ut_check_console_end(uts)); + + /* Compare the source and destination DTs */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("cmp.b %08x %08x %x", addr, newaddr, ts)); + ut_assert_nextline("Total of %d byte(s) were the same", ts); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} +FDT_TEST(fdt_test_move, UT_TESTF_CONSOLE_REC); + /* Test 'fdt get value' reading an fdt */ static int fdt_test_get_value_string(struct unit_test_state *uts, const char *node, const char *prop, From patchwork Thu Mar 2 03:08:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750346 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=bfYCxm0q; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=M1oiwCes; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx570cjmz1yXC for ; Thu, 2 Mar 2023 14:13:31 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 37C6385CA2; Thu, 2 Mar 2023 04:09:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="bfYCxm0q"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="M1oiwCes"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8949585C5E; Thu, 2 Mar 2023 04:09:27 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) (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 22FFF85C4C for ; Thu, 2 Mar 2023 04:09:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4PRx0J5wrDz9sZh; Thu, 2 Mar 2023 04:09:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726560; 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=gjqtYCms6VzxifYXZy5EypeDTW+0et35g85GJpC1GdQ=; b=bfYCxm0qwON41GEn6GPy5It/ePi3qS3NvGViDieY/SfZGwr5yvtU8VrPDYrWPozod6s5JM 7oubhiJwAbfD6j9fnKyBEEofOY4flBoyY1kS6kbzMevDsVRVM8dd9UultFbs/2027ISlMd OQsveIfCvv/NaU4vxA7Hk2bLJ+CJmN6wcOAuJVMJyPlgOpIxhrvgfClXwJuXiGM6xXW+9C mYYEhsNAB0TPD79OOprVfdwbY//B/Nhct2xFnD2y4kpzlHuk9V4xLC3mGMkffqIcjaw7G5 tRz9e97/T04Fwr9/RuM07ggIjeNNLeQO90WfjK85+n4eSA+r/Rm+3gXQ/CkncQ== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726558; 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=gjqtYCms6VzxifYXZy5EypeDTW+0et35g85GJpC1GdQ=; b=M1oiwCesRqz8B+/rP31W1Nn9zNLMv026kFAY8f7LjCgAbbR5GQi/Fk1+H8d8ol5ug1qPb0 ahMCj0g3X1529n/LvKtyoi42K89F0RN7Wcx0vbG+dl9bPkdw5DnF2wAOcaf1SiFbOMxoyV DZzA/0oVrLxCUUzxKbCwNT4NKHD9C4j1rdgSRbYSW04J6wkR9MRt1xzft28K+EuSZ7shnl Np6M0DfwzL/HKd4gqhctKjWsY5tXkxab64NMZcwfUTjQz/enAqRi1ZvxdvQQvU7bAmi870 d5w83+hLwt3vhI/xvgT78yckRFmGBYqigmFQdYo1joVYbA6XohsbdPhbQZCc9g== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 18/32] test: cmd: fdt: Test fdt resize Date: Thu, 2 Mar 2023 04:08:31 +0100 Message-Id: <20230302030845.322552-18-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: 7bthdjab61ee1wuri37x1ouohnder1kw X-MBO-RS-ID: 48c6a6d32568e70c222 X-Rspamd-Queue-Id: 4PRx0J5wrDz9sZh 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 'fdt resize' test which works as follows: - Create simple FDT with extra size 0, map it to sysmem - 'resize' the FDT by 0x2000 bytes - Verify the new space has been added to the FDT The test case can be triggered using: " ./u-boot -Dc 'ut fdt' " To dump the full output from commands used during test, add '-v' flag. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 023b83eb019..266fb6e3ed0 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -272,6 +272,30 @@ static int fdt_test_move(struct unit_test_state *uts) } FDT_TEST(fdt_test_move, UT_TESTF_CONSOLE_REC); +static int fdt_test_resize(struct unit_test_state *uts) +{ + char fdt[256]; + const unsigned int newsize = 0x2000; + uint32_t ts; + ulong addr; + + /* Original source DT */ + ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt))); + fdt_shrink_to_minimum(fdt, 0); /* Resize with 0 extra bytes */ + ts = fdt_totalsize(fdt); + addr = map_to_sysmem(fdt); + set_working_fdt_addr(addr); + + /* Test resizing the working FDT and verify the new space was added */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt resize %x", newsize)); + ut_asserteq(ts + newsize, fdt_totalsize(fdt)); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} +FDT_TEST(fdt_test_resize, UT_TESTF_CONSOLE_REC); + /* Test 'fdt get value' reading an fdt */ static int fdt_test_get_value_string(struct unit_test_state *uts, const char *node, const char *prop, From patchwork Thu Mar 2 03:08:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750347 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=PjK+V6jg; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=GujD4oSi; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx5P3Nvlz1yXC for ; Thu, 2 Mar 2023 14:13:45 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0B89F85CAC; Thu, 2 Mar 2023 04:09:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="PjK+V6jg"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="GujD4oSi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 53A7185C65; Thu, 2 Mar 2023 04:09:28 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050:0:465::101]) (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 B15D685C3A for ; Thu, 2 Mar 2023 04:09:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4PRx0K41Npz9sQb; Thu, 2 Mar 2023 04:09:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726561; 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=b6L55VmRMhEpHtKCBzKJb0e28rHuS6u4Oy35zR5tILA=; b=PjK+V6jgVBj4aFX4iZggHETpY01JmZUBXHwELc/pdZFdf2gwXMDm/hObR4ir51UCM/gmQ7 pCZxRcagtGLOAgpKoxisP8Qyrjm47ILB+AXME09dOfjwfBV9uGK0dTWm1paBjxrGS8I/oi ZDzegG6GgG94Yyoe3nSPmfXvIdT4m5ZLZabiLZ2NHKWfVhJMQbtlktlE+tPmiIpDOoKdjZ QRqMuA8H2Uw0gpuFudmhWyZVhTDR2FOHbYYIq6CntLqnP4Hf/usd2zCuIt0SXcrS1ai5Or pxa5YyMIwHpBH9+LFSVzbYskD1l/mWxVZtso41R/G2LkKsd0whDvUY1dNmS7zQ== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726559; 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=b6L55VmRMhEpHtKCBzKJb0e28rHuS6u4Oy35zR5tILA=; b=GujD4oSiLcVY5COwTz9FtK2pXaSdNwa1WITN40YSyWrGqckiUJ+Syan6or7guEos1LFfv7 WuzDOyzytuImNn1SXDCWWnwppdYZB42QP2tPxksd/s46/Bq0DajkZsqEk/X5mVlhW1qcJA WPX+/u1zRNwNGCAtpE5hW+X9Vthlst7O48Rzp+lyekauBGWvrxvBbaK8k+/oy+SqKE41co ciS9H7SWa+M810jgBzvcqfYh+sCE6g1MUPyanGA8OyETUWccN5XaTorm4sd5G8V973iAeI uy9wqv8H9U83SwU1EMRQ07JwnebjVwo/g3/0wztEhe+gxAuPsHX53jt4Zz33fQ== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 19/32] test: cmd: fdt: Test fdt print and list Date: Thu, 2 Mar 2023 04:08:32 +0100 Message-Id: <20230302030845.322552-19-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-ID: 6818b64b4d36e0d4f96 X-MBO-RS-META: 3tscf36niq47x7g1zik47hirkika9dqn X-Rspamd-Queue-Id: 4PRx0K41Npz9sQb 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 'fdt print' and 'fdt list' test which works as follows: - Create fuller FDT, map it to sysmem - Print the entire FDT, parts of the FDT and select properties - Compare output from the print or list The test case can be triggered using: " ./u-boot -Dc 'ut fdt' " To dump the full output from commands used during test, add '-v' flag. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 266fb6e3ed0..793525c02c5 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -296,6 +296,149 @@ static int fdt_test_resize(struct unit_test_state *uts) } FDT_TEST(fdt_test_resize, UT_TESTF_CONSOLE_REC); +static int fdt_test_print_list_common(struct unit_test_state *uts, + const char *opc, const char *node) +{ + /* + * Test printing/listing the working FDT + * subnode $node/subnode + */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt %s %s/subnode", opc, node)); + ut_assert_nextline("subnode {"); + ut_assert_nextline("\t#address-cells = <0x00000000>;"); + ut_assert_nextline("\t#size-cells = <0x00000000>;"); + ut_assert_nextline("\tcompatible = \"u-boot,fdt-subnode-test-device\";"); + ut_assert_nextline("};"); + ut_assertok(ut_check_console_end(uts)); + + /* + * Test printing/listing the working FDT + * path / string property model + */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt %s / model", opc)); + ut_assert_nextline("model = \"U-Boot FDT test\""); + ut_assertok(ut_check_console_end(uts)); + + /* + * Test printing/listing the working FDT + * path $node string property compatible + */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt %s %s compatible", opc, node)); + ut_assert_nextline("compatible = \"u-boot,fdt-test-device1\""); + ut_assertok(ut_check_console_end(uts)); + + /* + * Test printing/listing the working FDT + * path $node stringlist property clock-names + */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt %s %s clock-names", opc, node)); + ut_assert_nextline("clock-names = \"fixed\", \"i2c\", \"spi\", \"uart2\", \"uart1\""); + ut_assertok(ut_check_console_end(uts)); + + /* + * Test printing/listing the working FDT + * path $node u32 property clock-frequency + */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt %s %s clock-frequency", opc, node)); + ut_assert_nextline("clock-frequency = <0x00fde800>"); + ut_assertok(ut_check_console_end(uts)); + + /* + * Test printing/listing the working FDT + * path $node empty property u-boot,empty-property + */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt %s %s u-boot,empty-property", opc, node)); + /* + * This is the only 'fdt print' / 'fdt list' incantation which + * prefixes the property with node path. This has been in U-Boot + * since the beginning of the command 'fdt', keep it. + */ + ut_assert_nextline("%s u-boot,empty-property", node); + ut_assertok(ut_check_console_end(uts)); + + /* + * Test printing/listing the working FDT + * path $node prop-encoded array property regs + */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt %s %s regs", opc, node)); + ut_assert_nextline("regs = <0x00001234 0x00001000>"); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} + +static int fdt_test_print_list(struct unit_test_state *uts, bool print) +{ + const char *opc = print ? "print" : "list"; + char fdt[4096]; + ulong addr; + int ret; + + /* Original source DT */ + ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt))); + addr = map_to_sysmem(fdt); + set_working_fdt_addr(addr); + + /* Test printing/listing the working FDT -- node / */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt %s", opc)); + ut_assert_nextline("/ {"); + ut_assert_nextline("\t#address-cells = <0x00000001>;"); + ut_assert_nextline("\t#size-cells = <0x00000001>;"); + ut_assert_nextline("\tcompatible = \"u-boot,fdt-test\";"); + ut_assert_nextline("\tmodel = \"U-Boot FDT test\";"); + ut_assert_nextline("\taliases {"); + if (print) { + ut_assert_nextline("\t\tbadalias = \"/bad/alias\";"); + ut_assert_nextline("\t\tsubnodealias = \"/test-node@1234/subnode\";"); + ut_assert_nextline("\t\ttestnodealias = \"/test-node@1234\";"); + } + ut_assert_nextline("\t};"); + ut_assert_nextline("\ttest-node@1234 {"); + if (print) { + ut_assert_nextline("\t\t#address-cells = <0x00000000>;"); + ut_assert_nextline("\t\t#size-cells = <0x00000000>;"); + ut_assert_nextline("\t\tcompatible = \"u-boot,fdt-test-device1\";"); + ut_assert_nextline("\t\tclock-names = \"fixed\", \"i2c\", \"spi\", \"uart2\", \"uart1\";"); + ut_assert_nextline("\t\tu-boot,empty-property;"); + ut_assert_nextline("\t\tclock-frequency = <0x00fde800>;"); + ut_assert_nextline("\t\tregs = <0x00001234 0x00001000>;"); + ut_assert_nextline("\t\tsubnode {"); + ut_assert_nextline("\t\t\t#address-cells = <0x00000000>;"); + ut_assert_nextline("\t\t\t#size-cells = <0x00000000>;"); + ut_assert_nextline("\t\t\tcompatible = \"u-boot,fdt-subnode-test-device\";"); + ut_assert_nextline("\t\t};"); + } + ut_assert_nextline("\t};"); + ut_assert_nextline("};"); + ut_assertok(ut_check_console_end(uts)); + + ret = fdt_test_print_list_common(uts, opc, "/test-node@1234"); + if (!ret) + ret = fdt_test_print_list_common(uts, opc, "testnodealias"); + + return 0; +} + +static int fdt_test_print(struct unit_test_state *uts) +{ + return fdt_test_print_list(uts, true); +} +FDT_TEST(fdt_test_print, UT_TESTF_CONSOLE_REC); + +static int fdt_test_list(struct unit_test_state *uts) +{ + return fdt_test_print_list(uts, false); +} +FDT_TEST(fdt_test_list, UT_TESTF_CONSOLE_REC); + /* Test 'fdt get value' reading an fdt */ static int fdt_test_get_value_string(struct unit_test_state *uts, const char *node, const char *prop, From patchwork Thu Mar 2 03:08:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750348 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=O9De6Zfc; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=jmSZFqS5; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx5j1bk1z1yXC for ; Thu, 2 Mar 2023 14:14:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C97C985CC3; Thu, 2 Mar 2023 04:09:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="O9De6Zfc"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="jmSZFqS5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 83FEE85C3A; Thu, 2 Mar 2023 04:09:28 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) (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 6CB3D85C4E for ; Thu, 2 Mar 2023 04:09:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4PRx0L1Sxdz9sWt; Thu, 2 Mar 2023 04:09:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726562; 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=eQ6N9GX1M64/FmxgURYlGBXiMwSXn2VwmSnjLwObYDs=; b=O9De6Zfc79tvA/vX4nPPO1K5Rbb7jZJ+jhyszpT7PHmoWPKtQAff9KcZVoPldLcAbjsY/q BMY0GGTrQcKNBhDOPvShDj80B0Me+jARBqXsuRm9VcLng0j+TUO8S27zdQCMnwAXCCD8CA e1pbTaoV6okMZ+hzyn9eRRGmeCuIyogUCERTjUF1kL4INaObtRuXed+S/JOHZKcK2wqSYQ JCTHQuyMdZwsuS5uP8NXToDzYRPpAGr4kR3IOt0HnanU8gAjoYStvS+4a4iFZhl/lIecLn oMOqzgCMQcKQr+xBTwzBUCwGlKoJ1GiNH862OhCMwF9DoeAV/IBBG+JnEk2blQ== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726560; 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=eQ6N9GX1M64/FmxgURYlGBXiMwSXn2VwmSnjLwObYDs=; b=jmSZFqS5ouN3qN7mFIvvIRBwxqdiLDAuqD65yhaVCA+iThzyWT7gztDHbHszhvPBlA/lbe otHbIGGEmxBAE5yRFXn/1AO0aYiW4B/7VUl/6PM0i7KgQLID5uFj2twNBQK5dKK8AivFel c65tFol57OxJWJO2DpBdfxSM601dOJaJBWFPufD8yve8eVycL1ehgfgqW/AhRxInba0/pc 3EiEPyrFBEaCk8AcCSusk163D/83c23jqaxi725oKo28yhrvPuzGdbcXqOSEcQznST/cGb S4mrohRjVIbHED/TB8zoMmwjwu/XCbtqHuBe8/Yy4HKStw6ZpfTtEO9c5v1i5w== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 20/32] test: cmd: fdt: Test fdt get name Date: Thu, 2 Mar 2023 04:08:33 +0100 Message-Id: <20230302030845.322552-20-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: wijk6exmqpni5fz4n4rpeo9n46mhe6ad X-MBO-RS-ID: 5a1621db05f6845d0b9 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 'fdt get name' test which works as follows: - Create fuller FDT, map it to sysmem - Get name of / node 0, 1 and /clk-test node 0 - Compare output and validate the node name - Get name of / node 2 and /clk-test node 1 - Compare output and validate the node is not present - Get name of / node -1 and /clk-test node -1 - Compare output and validate the node name equals node 0 name - Check nonexistent node, verify the command errors out The test case can be triggered using: " ./u-boot -Dc 'ut fdt' " To dump the full output from commands used during test, add '-v' flag. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 793525c02c5..fa95241c8f2 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -545,6 +545,85 @@ static int fdt_test_get_value(struct unit_test_state *uts) } FDT_TEST(fdt_test_get_value, UT_TESTF_CONSOLE_REC); +static int fdt_test_get_name(struct unit_test_state *uts) +{ + char fdt[4096]; + ulong addr; + + ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt))); + addr = map_to_sysmem(fdt); + set_working_fdt_addr(addr); + + /* Test getting name of node 0 in /, which is /aliases node */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_command("fdt get name nzero / 0", 0)); + ut_asserteq_str("aliases", env_get("nzero")); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting name of node 1 in /, which is /test-node@1234 node */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_command("fdt get name none / 1", 0)); + ut_asserteq_str("test-node@1234", env_get("none")); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting name of node -1 in /, which is /aliases node, same as 0 */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_command("fdt get name nmone / -1", 0)); + ut_asserteq_str("aliases", env_get("nmone")); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting name of node 2 in /, which does not exist */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt get name ntwo / 2", 1)); + ut_assert_nextline("libfdt node not found"); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting name of node 0 in /test-node@1234, which is /subnode node */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_command("fdt get name snzero /test-node@1234 0", 0)); + ut_asserteq_str("subnode", env_get("snzero")); + ut_assertok(run_command("fdt get name asnzero testnodealias 0", 0)); + ut_asserteq_str("subnode", env_get("asnzero")); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting name of node 1 in /test-node@1234, which does not exist */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt get name snone /test-node@1234 1", 1)); + ut_assert_nextline("libfdt node not found"); + ut_asserteq(1, run_command("fdt get name asnone testnodealias 1", 1)); + ut_assert_nextline("libfdt node not found"); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting name of node -1 in /test-node@1234, which is /subnode node, same as 0 */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_command("fdt get name snmone /test-node@1234 -1", 0)); + ut_asserteq_str("subnode", env_get("snmone")); + ut_assertok(run_command("fdt get name asnmone testnodealias -1", 0)); + ut_asserteq_str("subnode", env_get("asnmone")); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting name of nonexistent node */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt get name nonode /nonexistent 0", 1)); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting name of bad alias */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt get name vbadalias badalias 0", 1)); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting name of nonexistent alias */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt get name vnoalias noalias 0", 1)); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_BADPATH"); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} +FDT_TEST(fdt_test_get_name, 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); From patchwork Thu Mar 2 03:08:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750349 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=rYPbiVms; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=xNz0VjrJ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx632pQwz1yXC for ; Thu, 2 Mar 2023 14:14:19 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8755085CBD; Thu, 2 Mar 2023 04:09:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="rYPbiVms"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="xNz0VjrJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 977B185C6D; Thu, 2 Mar 2023 04:09:29 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) (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 17BF785C4F for ; Thu, 2 Mar 2023 04:09:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4PRx0L61nMz9sgK; Thu, 2 Mar 2023 04:09:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726562; 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=s1AnBsSVwePGRYfM0ZRHTIS/wqmFWLCEEARrL/nPbWg=; b=rYPbiVmsTUrzm7+vuicNl3VM+qkLx/AzxXRf7nVL2xz3QHOCoDgpV5QRgoTGPOajWX+1aj S+WOopjO4j4Ck+Bpo1eStpiMJ94TGlpu5FqzvA3TupahRZS1wPWUlfGkHHshAyrirA+ADN jQd0Zbgr+KdfqDpz/RmXPHMLdJ/NqhV7fCRoUIaRiQXEeEOeUmGFGcpR8Ay/tpQyo4/46e ydxuVm5x3gXXtHgqPD+llv2sLtPdWaWCSHNG0qedG1AYzc8UzZCaRaGa5YeyfwDvXCpgWT w/poHP52Hazz2COmoBXPVE3TWMLAmPbg1aQtr+zr2Y1iKNKpmfsOonQR+o8rdg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726560; 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=s1AnBsSVwePGRYfM0ZRHTIS/wqmFWLCEEARrL/nPbWg=; b=xNz0VjrJ2upi74TVyw0oMGgv0s+EinOSBq6m1HcZxNyvVfMD4N2KPkv6Q46HfNoI3K9oXd DO/mByl4syrcWwCxyLE5hzPsKXuUc8qEXFPt1t/1KzUkFnMSY9SlbEjk8vnD9YB6CrLYo8 6WZpS7aBqpxS9yIcIPkgXBpf6H/eIighqSePGTVFXNVxA3yazfgADM4GQiZ3xc8vCMPoar 1C7XQvWbDzAU3FfV2xoU90pr1Tw4aPe7lwO2//yCIe5foLNVjkdx0Fs3VCfIpm+s2Jiw9Q 3lNpga2blCrpDItRe/08m1Z5px0sBvq5JfVPH8oUYvYUCwYz31Z6vZVsU2vbYQ== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 21/32] test: cmd: fdt: Test fdt get addr Date: Thu, 2 Mar 2023 04:08:34 +0100 Message-Id: <20230302030845.322552-21-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-ID: 5895d105686e235de7f X-MBO-RS-META: ps6gm33m6gk8ccn1hpk6r4hoijrq3mqt X-Rspamd-Queue-Id: 4PRx0L61nMz9sgK 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 'fdt get addr' test which works as follows: - Create fuller FDT, map it to sysmem - Get address of various properties - Compare addresses calculated by UT and fdt command This test is special in that it has to go through gruesome remapping scheme where the test calculates: - pointer offsets of the generated FDT root and the property being tested - map_sysmem() result of environment variable "fdtaddr" and the one set by the test matching address of property being tested - difference between the later and the former, to obtain offset of the DT property from start of DT The offsets must match in both the UT and the tested U-Boot, if they do not, the test fails. The test case can be triggered using: " ./u-boot -Dc 'ut fdt' " To dump the full output from commands used during test, add '-v' flag. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Do assignment first, assert second Add RB from Simon --- test/cmd/fdt.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index fa95241c8f2..27c23926ce0 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -624,6 +624,73 @@ static int fdt_test_get_name(struct unit_test_state *uts) } FDT_TEST(fdt_test_get_name, UT_TESTF_CONSOLE_REC); +static int fdt_test_get_addr_common(struct unit_test_state *uts, char *fdt, + const char *path, const char *prop) +{ + unsigned int offset; + int path_offset; + void *prop_ptr; + int len = 0; + + path_offset = fdt_path_offset(fdt, path); + ut_assert(path_offset >= 0); + prop_ptr = (void *)fdt_getprop(fdt, path_offset, prop, &len); + ut_assertnonnull(prop_ptr); + offset = (char *)prop_ptr - fdt; + + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt get addr pstr %s %s", path, prop)); + ut_asserteq((ulong)map_sysmem(env_get_hex("fdtaddr", 0x1234), 0), + (ulong)(map_sysmem(env_get_hex("pstr", 0x1234), 0) - offset)); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} + +static int fdt_test_get_addr(struct unit_test_state *uts) +{ + char fdt[4096]; + ulong addr; + + ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt))); + addr = map_to_sysmem(fdt); + set_working_fdt_addr(addr); + + /* Test getting address of root node / string property "compatible" */ + fdt_test_get_addr_common(uts, fdt, "/", "compatible"); + + /* Test getting address of node /test-node@1234 stringlist property "clock-names" */ + fdt_test_get_addr_common(uts, fdt, "/test-node@1234", "clock-names"); + fdt_test_get_addr_common(uts, fdt, "testnodealias", "clock-names"); + + /* Test getting address of node /test-node@1234 u32 property "clock-frequency" */ + fdt_test_get_addr_common(uts, fdt, "/test-node@1234", "clock-frequency"); + fdt_test_get_addr_common(uts, fdt, "testnodealias", "clock-frequency"); + + /* Test getting address of node /test-node@1234 empty property "u-boot,empty-property" */ + fdt_test_get_addr_common(uts, fdt, "/test-node@1234", "u-boot,empty-property"); + fdt_test_get_addr_common(uts, fdt, "testnodealias", "u-boot,empty-property"); + + /* Test getting address of node /test-node@1234 array property "regs" */ + fdt_test_get_addr_common(uts, fdt, "/test-node@1234", "regs"); + fdt_test_get_addr_common(uts, fdt, "testnodealias", "regs"); + + /* Test getting address of node /test-node@1234/subnode non-existent property "noprop" */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt get addr pnoprop /test-node@1234/subnode noprop", 1)); + ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting address of non-existent node /test-node@1234/nonode@1 property "noprop" */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt get addr pnonode /test-node@1234/nonode@1 noprop", 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_addr, 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); From patchwork Thu Mar 2 03:08:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750350 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=BIxCTPCN; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=DKVUJkIR; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx6M4tQNz1yXC for ; Thu, 2 Mar 2023 14:14:35 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 280B685CCA; Thu, 2 Mar 2023 04:10:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="BIxCTPCN"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="DKVUJkIR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5C4A785C73; Thu, 2 Mar 2023 04:09:31 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) (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 EA51C85C58 for ; Thu, 2 Mar 2023 04:09:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4PRx0M4Vqwz9sxV; Thu, 2 Mar 2023 04:09:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726563; 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=ZdlXpxK8OSfbL4VbA9zvR7LYLGJkANCOSSCxxFpDM3I=; b=BIxCTPCNhah80DYpYWWRarWT4MemRTeTmJsz5O3zh+VvMkvi56ltV6RvYB4PzWRkqXcBnM LKCFwK9R36i7gbhfOx5lVNtWKwliojFGxs7WinLUfJONFPQL14KYGEgJEukZyUFdY4SRBq /6uTH1CK6DqXtyjKRH59qPX4o4QkEgBJxOFqABqVLtjCNDTjykXUQssZ6OsowB6nFkajas M4Yhzpx3e8gFSmPpONMzpG/PaNjVFwDykYJDaZUdce8HR/DhOt2eTe8msB0sJY6WLqNa1L qfJ5D0bJ0goymT+uiNqckeGWdNb59shnV8mi6YVhC1JGTfmfzAhPJDgxFh3tcg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726561; 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=ZdlXpxK8OSfbL4VbA9zvR7LYLGJkANCOSSCxxFpDM3I=; b=DKVUJkIR23yLJ+6GutzNQ+ueCj2p3/IrEgenNt5sEVVK4dLsvL+RWsxuk8QIgEIaAD7CT0 cCN0Dpw6MjoV+diuqhxhVk9w/AAaa27ggNLcFFmb2Yi8Q6ZOlmq5SbmBse1bHckxvqryop A8VP5ssHMjiWFtghj9jIc5c3iGUCI8hwju+JAhb2rgflqYjVZRw+qnozebM4OeltyqFZe1 l5Q7jK1O98WkvvStC3+2nhmPDNmt606hBC+KQ1LCuHbYN8FcdTCXwEhpK2qJi+EBA2XtGC pPZgiYhkat/leoxNtqc4/HfV57fnv8xBUXKFlhfwfe2VVvkn7xCGvcaLjMm65Q== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 22/32] test: cmd: fdt: Test fdt get size Date: Thu, 2 Mar 2023 04:08:35 +0100 Message-Id: <20230302030845.322552-22-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: hw8psnsf7jze6re9p4cmny3guawhjd8g X-MBO-RS-ID: 7890607b80458920fa9 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 'fdt get size' test which works as follows: - Create fuller FDT, map it to sysmem - Get size of various properties - Get node count of available nodes - Test non-existent nodes and properties The test case can be triggered using: " ./u-boot -Dc 'ut fdt' " To dump the full output from commands used during test, add '-v' flag. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 27c23926ce0..9adcbc7bb19 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -691,6 +691,93 @@ static int fdt_test_get_addr(struct unit_test_state *uts) } FDT_TEST(fdt_test_get_addr, UT_TESTF_CONSOLE_REC); +static int fdt_test_get_size_common(struct unit_test_state *uts, + const char *path, const char *prop, + const unsigned int val) +{ + ut_assertok(console_record_reset_enable()); + if (prop) { + ut_assertok(run_commandf("fdt get size sstr %s %s", path, prop)); + } else { + ut_assertok(run_commandf("fdt get size sstr %s", path)); + } + ut_asserteq(val, env_get_hex("sstr", 0x1234)); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} + +static int fdt_test_get_size(struct unit_test_state *uts) +{ + char fdt[4096]; + ulong addr; + + ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt))); + addr = map_to_sysmem(fdt); + set_working_fdt_addr(addr); + + /* Test getting size of root node / string property "compatible" */ + fdt_test_get_size_common(uts, "/", "compatible", 16); + + /* Test getting size of node /test-node@1234 stringlist property "clock-names" */ + fdt_test_get_size_common(uts, "/test-node@1234", "clock-names", 26); + fdt_test_get_size_common(uts, "testnodealias", "clock-names", 26); + + /* Test getting size of node /test-node@1234 u32 property "clock-frequency" */ + fdt_test_get_size_common(uts, "/test-node@1234", "clock-frequency", 4); + fdt_test_get_size_common(uts, "testnodealias", "clock-frequency", 4); + + /* Test getting size of node /test-node@1234 empty property "u-boot,empty-property" */ + fdt_test_get_size_common(uts, "/test-node@1234", "u-boot,empty-property", 0); + fdt_test_get_size_common(uts, "testnodealias", "u-boot,empty-property", 0); + + /* Test getting size of node /test-node@1234 array property "regs" */ + fdt_test_get_size_common(uts, "/test-node@1234", "regs", 8); + fdt_test_get_size_common(uts, "testnodealias", "regs", 8); + + /* Test getting node count of node / */ + fdt_test_get_size_common(uts, "/", NULL, 2); + + /* Test getting node count of node /test-node@1234/subnode */ + fdt_test_get_size_common(uts, "/test-node@1234/subnode", NULL, 0); + fdt_test_get_size_common(uts, "subnodealias", NULL, 0); + + /* Test getting size of node /test-node@1234/subnode non-existent property "noprop" */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt get size pnoprop /test-node@1234/subnode noprop", 1)); + ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND"); + ut_asserteq(1, run_command("fdt get size pnoprop subnodealias noprop", 1)); + ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting size of non-existent node /test-node@1234/nonode@1 property "noprop" */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt get size pnonode /test-node@1234/nonode@1 noprop", 1)); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting node count of non-existent node /test-node@1234/nonode@1 */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt get size pnonode /test-node@1234/nonode@1", 1)); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting node count of bad alias badalias */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt get size pnonode badalias noprop", 1)); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting node count of non-existent alias noalias */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt get size pnonode noalias", 1)); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_BADPATH"); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} +FDT_TEST(fdt_test_get_size, 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); From patchwork Thu Mar 2 03:08:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750352 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=XKSoqmmc; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=f62W6BV1; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx6x63ZZz246G for ; Thu, 2 Mar 2023 14:15:05 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 55DC785CB2; Thu, 2 Mar 2023 04:10:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="XKSoqmmc"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="f62W6BV1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7EBCC85B75; Thu, 2 Mar 2023 04:09:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [IPv6:2001:67c:2050:0:465::102]) (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 5C4C585C2A for ; Thu, 2 Mar 2023 04:09:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4PRx0N1pCmz9sQl; Thu, 2 Mar 2023 04:09:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726564; 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=oO69ZYDpu1FDlTf2v53ftfcLKcVPIO/bN8oi454UcQM=; b=XKSoqmmcUSVfW+bnDPEaRLh/extDcU7efEevelK2i7ATdcE2gK+ESPTowQE/kcqJEFg564 yHOLWGlUPF2tGv/WupMPQLoG6V6kdmYGzy9LR2nRV7wmCSvGaaQtZ/t4QfhPjZOobcjjdf dEbpYsfD87ekJEGwPebQUaV0IBKN2UYAJgQ6j+dR2wm2RT6Ti+zMOn+De452Zt7np9w2ea yn2TeOcKcaOA3MuJOgZQUX49JCg+Pz+wzgErGbVwcxNWxjkX4LEwIUocf2dZxGqoyC49SZ dRnfZPwzhWMJPW2LnVAm5EiQMsewq4Xv1fzSIs8U5hg4m3GOsGrEuXmP8UkVeg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726562; 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=oO69ZYDpu1FDlTf2v53ftfcLKcVPIO/bN8oi454UcQM=; b=f62W6BV1ZQyTQPmGW3Rz0DTSOjvihfFSB0CT22GU9SffMTFSqwM+GrI6BfMe1TeVJeDbTx bwdriwmN2nUUyLpWE1KGG+49ACQ5uVjZfRO9uA2lPJs2uHJxOUe5m2pKWNLi1WNQYrNJE7 6s4UXDevqgDb+/onJpG3+DWC6nZj23QG+G2ELnQ+zQ0797lv/5/m63B0fXvVWVkmJzreq2 gMD8N4BZmoneI7DHFdG8ntdiAzOhIbOPhdTS5FsPAnpIv+9PYq3YuMbvS3vcE1Lpty0k1B qmZTFqG1o90NTFNBSfNQKWoTWgsySNGxkg7HJlkO5qZJjRdMgSzUaHbdyA/JCw== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 23/32] test: cmd: fdt: Test fdt set Date: Thu, 2 Mar 2023 04:08:36 +0100 Message-Id: <20230302030845.322552-23-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: wdzf1yyzkgprwc3uu5uj9f3dno1cd3cm X-MBO-RS-ID: 7ff52728be3e14cbe02 X-Rspamd-Queue-Id: 4PRx0N1pCmz9sQl 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 'fdt set' test which works as follows: - Create fuller FDT, map it to sysmem - Set either existing property to overwrite it, or new property - Test setting both single properties as well as string and integer arrays - Test setting to non-existent nodes and aliases - Verify set values using 'fdt get value' The test case can be triggered using: " ./u-boot -Dc 'ut fdt' " To dump the full output from commands used during test, add '-v' flag. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add comments --- test/cmd/fdt.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 9adcbc7bb19..64d04f2f2ed 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -778,6 +778,150 @@ static int fdt_test_get_size(struct unit_test_state *uts) } FDT_TEST(fdt_test_get_size, UT_TESTF_CONSOLE_REC); +static int fdt_test_set_single(struct unit_test_state *uts, + const char *path, const char *prop, + const char *sval, int ival, bool integer) +{ + /* + * Set single element string/integer/ property into DT, that is: + * => fdt set /path property string + * => fdt set /path property integer + * => fdt set /path property + */ + ut_assertok(console_record_reset_enable()); + if (sval) { + ut_assertok(run_commandf("fdt set %s %s %s", path, prop, sval)); + } else if (integer) { + ut_assertok(run_commandf("fdt set %s %s <%d>", path, prop, ival)); + } else { + ut_assertok(run_commandf("fdt set %s %s", path, prop)); + } + + /* Validate the property is present and has correct value. */ + ut_assertok(run_commandf("fdt get value svar %s %s", path, prop)); + if (sval) { + ut_asserteq_str(sval, env_get("svar")); + } else if (integer) { + ut_asserteq(ival, env_get_hex("svar", 0x1234)); + } else { + ut_assertnull(env_get("svar")); + } + ut_assertok(ut_check_console_end(uts)); + + return 0; +} + +static int fdt_test_set_multi(struct unit_test_state *uts, + const char *path, const char *prop, + const char *sval1, const char *sval2, + int ival1, int ival2) +{ + /* + * Set multi element string/integer array property in DT, that is: + * => fdt set /path property + * => fdt set /path property + * + * The set is done twice in here deliberately, The first set adds + * the property with an extra trailing element in its array to make + * the array longer, the second set is the expected final content of + * the array property. The longer array is used to verify that the + * new array is correctly sized and read past the new array length + * triggers failure. + */ + ut_assertok(console_record_reset_enable()); + if (sval1 && sval2) { + ut_assertok(run_commandf("fdt set %s %s %s %s end", path, prop, sval1, sval2)); + ut_assertok(run_commandf("fdt set %s %s %s %s", path, prop, sval1, sval2)); + } else { + ut_assertok(run_commandf("fdt set %s %s <%d %d 10>", path, prop, ival1, ival2)); + ut_assertok(run_commandf("fdt set %s %s <%d %d>", path, prop, ival1, ival2)); + } + + /* + * Validate the property is present and has correct value. + * + * The "end/10" above and "svarn" below is used to validate that + * previous 'fdt set' to longer array does not polute newly set + * shorter array. + */ + ut_assertok(run_commandf("fdt get value svar1 %s %s 0", path, prop)); + ut_assertok(run_commandf("fdt get value svar2 %s %s 1", path, prop)); + ut_asserteq(1, run_commandf("fdt get value svarn %s %s 2", path, prop)); + if (sval1 && sval2) { + ut_asserteq_str(sval1, env_get("svar1")); + ut_asserteq_str(sval2, env_get("svar2")); + ut_assertnull(env_get("svarn")); + } else { + ut_asserteq(ival1, env_get_hex("svar1", 0x1234)); + ut_asserteq(ival2, env_get_hex("svar2", 0x1234)); + ut_assertnull(env_get("svarn")); + } + ut_assertok(ut_check_console_end(uts)); + + return 0; +} + +static int fdt_test_set_node(struct unit_test_state *uts, + const char *path, const char *prop) +{ + fdt_test_set_single(uts, path, prop, "new", 0, false); + fdt_test_set_single(uts, path, prop, "rewrite", 0, false); + fdt_test_set_single(uts, path, prop, NULL, 42, true); + fdt_test_set_single(uts, path, prop, NULL, 0, false); + fdt_test_set_multi(uts, path, prop, NULL, NULL, 42, 1701); + fdt_test_set_multi(uts, path, prop, NULL, NULL, 74656, 9); + fdt_test_set_multi(uts, path, prop, "42", "1701", 0, 0); + fdt_test_set_multi(uts, path, prop, "74656", "9", 0, 0); + + return 0; +} + +static int fdt_test_set(struct unit_test_state *uts) +{ + char fdt[8192]; + ulong addr; + + ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt))); + fdt_shrink_to_minimum(fdt, 4096); /* Resize with 4096 extra bytes */ + addr = map_to_sysmem(fdt); + set_working_fdt_addr(addr); + + /* Test setting of root node / existing property "compatible" */ + fdt_test_set_node(uts, "/", "compatible"); + + /* Test setting of root node / new property "newproperty" */ + fdt_test_set_node(uts, "/", "newproperty"); + + /* Test setting of subnode existing property "compatible" */ + fdt_test_set_node(uts, "/test-node@1234/subnode", "compatible"); + fdt_test_set_node(uts, "subnodealias", "compatible"); + + /* Test setting of subnode new property "newproperty" */ + fdt_test_set_node(uts, "/test-node@1234/subnode", "newproperty"); + fdt_test_set_node(uts, "subnodealias", "newproperty"); + + /* Test setting property of non-existent node */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt set /no-node noprop", 1)); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test setting property of non-existent alias */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt set noalias noprop", 1)); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_BADPATH"); + ut_assertok(ut_check_console_end(uts)); + + /* Test setting property of bad alias */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_command("fdt set badalias noprop", 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_set, 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); From patchwork Thu Mar 2 03:08:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750351 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=iqCShU1L; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=J0XezewB; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx6d6dWyz1yXC for ; Thu, 2 Mar 2023 14:14:49 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 382E885CBF; Thu, 2 Mar 2023 04:10:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="iqCShU1L"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="J0XezewB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2C06785C86; Thu, 2 Mar 2023 04:09:34 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [IPv6:2001:67c:2050:0:465::102]) (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 1389E85B7D for ; Thu, 2 Mar 2023 04:09:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4PRx0N6jfXz9sRv; Thu, 2 Mar 2023 04:09:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726564; 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=114FPK9NjdJfwyZIOH4c7B47HxbJbIro7R6XVUsUJRA=; b=iqCShU1LezdJT2kCmHJpM6JE3xpQg19Lzs5GXRpo2MMMpU3CG4ojRzJQklBVW9oYnAoIO3 S6/6mPBAUHSgkHrC970Mahm/5y+6Zy1TSs4C2ymcVRoAABbeON63KhhfvphivAyT45Yot3 0VE1oQnfF6wJCygI5XwlsnKUmUk2KFnIgBCzl8qmgf6ZeQdRnxtZNsNtNspn8TztMYdaN7 +LAUvothCKX6i5tg8+8uynA84TtOPI/I62Gjbr2yhGISqeVYDCGguTX4qrWzHMHV8k0S6F UoTNcs2mU9X1+Aizvh+5ePL1O7HW4vWY5ZhDPLj3GD/5ujcC9X0P7qEr2lMa+Q== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726562; 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=114FPK9NjdJfwyZIOH4c7B47HxbJbIro7R6XVUsUJRA=; b=J0XezewB3qu/4W9cTFeFTb8e0ivhZdYOOVu0MBRVecTVSHWoUUYGhCkXwP4sfziFfZbZxT mteZCqHF00CGtqi4Utjg7RJlC0tDQXq//t9AY5IgouToGVcM0YBn0IiTzaljsWxulLKGv3 faVlPdVIYsLowdXVAd0pycL+eNYDme8AJcSAb1MWx1YVldSc0jw9W0fM1Elr0JcbZWF8B/ i6jLfHqZW5enhlLFPYOySH82u0Pu4xrELUwd9WlD0P/QzE6MN8fcaYGk78+j6CHTP/TrMd JT87ztqABAVEAwM4vNJ1hJd8NKgDuAShJMqMvC0fW3f1PuC+NxUxSmsBcf2XEg== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 24/32] test: cmd: fdt: Test fdt mknode Date: Thu, 2 Mar 2023 04:08:37 +0100 Message-Id: <20230302030845.322552-24-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: 7fumyksn1hie5s7nhpno9hj81yun7ffd X-MBO-RS-ID: c6284861c224dbe271a X-Rspamd-Queue-Id: 4PRx0N6jfXz9sRv 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 'fdt mknode' test which works as follows: - Create fuller FDT, map it to sysmem - Create node either in / or subnode - Attempt to create node over existing node, which fails - Attempt to create subnodes in non-existing nodes or aliases - Verify created nodes using fdt list command The test case can be triggered using: " ./u-boot -Dc 'ut fdt' " To dump the full output from commands used during test, add '-v' flag. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 64d04f2f2ed..5e395e23fed 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -922,6 +922,74 @@ static int fdt_test_set(struct unit_test_state *uts) } FDT_TEST(fdt_test_set, UT_TESTF_CONSOLE_REC); +static int fdt_test_mknode(struct unit_test_state *uts) +{ + char fdt[8192]; + ulong addr; + + ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt))); + fdt_shrink_to_minimum(fdt, 4096); /* Resize with 4096 extra bytes */ + addr = map_to_sysmem(fdt); + set_working_fdt_addr(addr); + + /* Test creation of new node in / */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt mknode / newnode")); + ut_assertok(run_commandf("fdt list /newnode")); + ut_assert_nextline("newnode {"); + ut_assert_nextline("};"); + ut_assertok(ut_check_console_end(uts)); + + /* Test creation of new node in /test-node@1234 */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt mknode /test-node@1234 newsubnode")); + ut_assertok(run_commandf("fdt list /test-node@1234/newsubnode")); + ut_assert_nextline("newsubnode {"); + ut_assert_nextline("};"); + ut_assertok(ut_check_console_end(uts)); + + /* Test creation of new node in /test-node@1234 by alias */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt mknode testnodealias newersubnode")); + ut_assertok(run_commandf("fdt list testnodealias/newersubnode")); + ut_assert_nextline("newersubnode {"); + ut_assert_nextline("};"); + ut_assertok(ut_check_console_end(uts)); + + /* Test creation of new node in /test-node@1234 over existing node */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_commandf("fdt mknode testnodealias newsubnode")); + ut_assert_nextline("libfdt fdt_add_subnode(): FDT_ERR_EXISTS"); + ut_assertok(ut_check_console_end(uts)); + + /* Test creation of new node in /test-node@1234 by alias over existing node */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_commandf("fdt mknode testnodealias newersubnode")); + ut_assert_nextline("libfdt fdt_add_subnode(): FDT_ERR_EXISTS"); + ut_assertok(ut_check_console_end(uts)); + + /* Test creation of new node in non-existent node */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_commandf("fdt mknode /no-node newnosubnode")); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test creation of new node in non-existent alias */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_commandf("fdt mknode noalias newfailsubnode")); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_BADPATH"); + ut_assertok(ut_check_console_end(uts)); + + /* Test creation of new node in bad alias */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_commandf("fdt mknode badalias newbadsubnode")); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} +FDT_TEST(fdt_test_mknode, 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); From patchwork Thu Mar 2 03:08:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750353 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=QWWBiq0s; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=Lcpk7adB; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx7F1DNsz1yWw for ; Thu, 2 Mar 2023 14:15:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8424185CD7; Thu, 2 Mar 2023 04:10:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="QWWBiq0s"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="Lcpk7adB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 813B585C26; Thu, 2 Mar 2023 04:09:37 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050:0:465::101]) (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 A94DA85C4C for ; Thu, 2 Mar 2023 04:09:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4PRx0P40VHz9sQb; Thu, 2 Mar 2023 04:09:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726565; 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=LHjn3dJxaxYtojz4iSiAXCTlQAEFlGY1mZXjK63W0Gg=; b=QWWBiq0sZhPm1aYx52DpjSM1uNsrCeMBitXbUyLmWffT+6BnmxwjcPvXMAnxpZVPUIaTbL uL4KiIFxojSZMnQbOOh1EZX//zxZpuf3T0i28mJiNMo+K/CsbR2fq6RS5R+OreEToIkMyo MU+loqN66uqF9t95zPj8Rm+/WM9JZW0C18CfaxSYY6asZ1FmxkOhRQ4etd7dI3VCTD8L3k DKuz5TyuTY0QDvY23rqerwxd0/BE0hp9rWHzxAXVZSku8DDMSbAAlRm2baEf0iivBkScrK TcHAjpFBmO2wNLr98aYGHgngsvOol5LOXINA+ljwzRXcVcrkqb2FvB6dXKExUQ== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726563; 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=LHjn3dJxaxYtojz4iSiAXCTlQAEFlGY1mZXjK63W0Gg=; b=Lcpk7adBEvYtDxSahzldejgQzokPxigjpveA/jZ39YAgUfPVjGPKKz5z1jJvOabbPgxxvB WVFnf6YhXy3AVLUV/Y8w6I9flAR4Th3/uc48KZNZTAxXGbexQNTmcYc/ixfm9Pq4yGU5WD WSoZyReJYbYxn+NF03eJcRJ+3tQq3NrEvVpmBQWfDPV5f8zJLr88IUrKC4f76sM56c85aS 9NAnNYetqStwBlazBRIaMsST3sRi0oN0htoARmRT0Y1RQrQReyQsOBtkdbMtZ51aRH3JvP YkIX+2Qnm2CnWnJEupNCm4K1WyzZwMYu0k414W4YsggxW1qETH7VFKq8AnW4Lw== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 25/32] test: cmd: fdt: Test fdt rm Date: Thu, 2 Mar 2023 04:08:38 +0100 Message-Id: <20230302030845.322552-25-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: b4wu8f4fr456oa1zbs8dutucsocooatx X-MBO-RS-ID: acb208075dfece4fe62 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 'fdt rm' test which works as follows: - Create fuller FDT, map it to sysmem - Selectively delete nodes or properties by both path and aliases - Verify created nodes or properties using fdt print command The test case can be triggered using: " ./u-boot -Dc 'ut fdt' " To dump the full output from commands used during test, add '-v' flag. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 5e395e23fed..509e9e8369b 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -990,6 +990,90 @@ static int fdt_test_mknode(struct unit_test_state *uts) } FDT_TEST(fdt_test_mknode, UT_TESTF_CONSOLE_REC); +static int fdt_test_rm(struct unit_test_state *uts) +{ + char fdt[4096]; + ulong addr; + + ut_assertok(make_fuller_fdt(uts, fdt, sizeof(fdt))); + addr = map_to_sysmem(fdt); + set_working_fdt_addr(addr); + + /* Test removal of property in root node / */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt print / compatible")); + ut_assert_nextline("compatible = \"u-boot,fdt-test\""); + ut_assertok(run_commandf("fdt rm / compatible")); + ut_asserteq(1, run_commandf("fdt print / compatible")); + ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test removal of property clock-names in subnode /test-node@1234 */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt print /test-node@1234 clock-names")); + ut_assert_nextline("clock-names = \"fixed\", \"i2c\", \"spi\", \"uart2\", \"uart1\""); + ut_assertok(run_commandf("fdt rm /test-node@1234 clock-names")); + ut_asserteq(1, run_commandf("fdt print /test-node@1234 clock-names")); + ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test removal of property u-boot,empty-property in subnode /test-node@1234 by alias */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt print testnodealias u-boot,empty-property")); + ut_assert_nextline("testnodealias u-boot,empty-property"); + ut_assertok(run_commandf("fdt rm testnodealias u-boot,empty-property")); + ut_asserteq(1, run_commandf("fdt print testnodealias u-boot,empty-property")); + ut_assert_nextline("libfdt fdt_getprop(): FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test removal of non-existent property noprop in subnode /test-node@1234 */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_commandf("fdt rm /test-node@1234 noprop")); + ut_assert_nextline("libfdt fdt_delprop(): FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test removal of non-existent node /no-node@5678 */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_commandf("fdt rm /no-node@5678")); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test removal of subnode /test-node@1234/subnode by alias */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt rm subnodealias")); + ut_asserteq(1, run_commandf("fdt print /test-node@1234/subnode")); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test removal of node by non-existent alias */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_commandf("fdt rm noalias")); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_BADPATH"); + ut_assertok(ut_check_console_end(uts)); + + /* Test removal of node by bad alias */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_commandf("fdt rm noalias")); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_BADPATH"); + ut_assertok(ut_check_console_end(uts)); + + /* Test removal of node /test-node@1234 */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt rm /test-node@1234")); + ut_asserteq(1, run_commandf("fdt print /test-node@1234")); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test removal of node / */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt rm /")); + ut_asserteq(1, run_commandf("fdt print /")); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} +FDT_TEST(fdt_test_rm, 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); From patchwork Thu Mar 2 03:08:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750355 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=d61SyjVC; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=R/0L6uS1; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx7q5p7Zz1yWw for ; Thu, 2 Mar 2023 14:15:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C071485CF0; Thu, 2 Mar 2023 04:10:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="d61SyjVC"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="R/0L6uS1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2B32885C4D; Thu, 2 Mar 2023 04:09:39 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050:0:465::101]) (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 4DBC185C66 for ; Thu, 2 Mar 2023 04:09:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4PRx0Q1SzXz9sWt; Thu, 2 Mar 2023 04:09:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726566; 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=qr74tiosrM2kimIlnI0BPbudDP5tHLgTqhvEnaNA1hc=; b=d61SyjVCheB0MevHVughcdf1nfs8VfkC/hu27i63SN4GxCQDDWgW7/jHcO/X317GIRO9Eg lGRCyRmzFrQTDxSIzdk4eoW2zxyCcBHQ+nR41c9i6X7yUDyrCooWRtua9jczKZoJUBjIOQ GfF+2QX3l1XzatoxvETiT+gqgQ7ctJuDQsuQKlf+GHy4Lb0zWBVqfm0+8S/958wnbIhZjq ma1GQyuAS8um3gyNLf29+Z0Z0A0jP3eOVdvlGlb5qmTRlRZRvqn4S6NgXel7X1QWHqkoER mjrxgmnommdT6hL0d7CFNOzFhr70YFgBasIHErIzlEeSA73TzXavy9f6ZoidBg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726564; 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=qr74tiosrM2kimIlnI0BPbudDP5tHLgTqhvEnaNA1hc=; b=R/0L6uS13ImbQjj0fDefghUNDzcKpgPuSK1qYn05xBP4UzN0HHrwtGPPLlb9GN8Y7hfbCI M6yf8K8ePqxxnSXXvPlhefExa8eHW9DVYx9XYaC8L3QETZDBCJQP6coILYk+x1XKBr3Im1 2OliNBwt9r/jIngwXFbJGN4ZZ/jQ/N310E8WWmoyK3z2M07LeQSItKKcK5swTth1n8zuqP 4fAFCgE8LteJwmictFyEFsiiuXO1B3yzxxnflWyYGzOcNUHyb4AHL9xbLiXs+d27Gg7o93 nWJmmDj34aFdG9h7v0DzoCp6HPMFmp5R8ZMFf8q3XhnKg7ZKqTUr4h18Oqvsug== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 26/32] test: cmd: fdt: Test fdt header Date: Thu, 2 Mar 2023 04:08:39 +0100 Message-Id: <20230302030845.322552-26-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-ID: 685546112ea355a35f6 X-MBO-RS-META: oh47yhib5xo74qjr7u8m5injfddqswda X-Rspamd-Queue-Id: 4PRx0Q1SzXz9sWt 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 'fdt header' test which works as follows: - Create basic FDT, map it to sysmem - Print the FDT header - Get all members of the FDT header into variable and verify the variables contain correct data The test case can be triggered using: " ./u-boot -Dc 'ut fdt' " To dump the full output from commands used during test, add '-v' flag. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 509e9e8369b..7dc9e800d38 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -1074,6 +1074,65 @@ static int fdt_test_rm(struct unit_test_state *uts) } FDT_TEST(fdt_test_rm, UT_TESTF_CONSOLE_REC); +static int fdt_test_header_get(struct unit_test_state *uts, char fdt[4096], + const char *field, const unsigned long val) +{ + /* Test getting valid header entry */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt header get fvar %s", field)); + ut_asserteq(val, env_get_hex("fvar", 0x1234)); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting malformed header entry */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_commandf("fdt header get fvar typo%stypo", field)); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} + +static int fdt_test_header(struct unit_test_state *uts) +{ + char fdt[256]; + ulong addr; + + ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt))); + addr = map_to_sysmem(fdt); + set_working_fdt_addr(addr); + + /* Test header print */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt header")); + ut_assert_nextline("magic:\t\t\t0x%x", fdt_magic(fdt)); + ut_assert_nextline("totalsize:\t\t0x%x (%d)", fdt_totalsize(fdt), fdt_totalsize(fdt)); + ut_assert_nextline("off_dt_struct:\t\t0x%x", fdt_off_dt_struct(fdt)); + ut_assert_nextline("off_dt_strings:\t\t0x%x", fdt_off_dt_strings(fdt)); + ut_assert_nextline("off_mem_rsvmap:\t\t0x%x", fdt_off_mem_rsvmap(fdt)); + ut_assert_nextline("version:\t\t%d", fdt_version(fdt)); + ut_assert_nextline("last_comp_version:\t%d", fdt_last_comp_version(fdt)); + ut_assert_nextline("boot_cpuid_phys:\t0x%x", fdt_boot_cpuid_phys(fdt)); + ut_assert_nextline("size_dt_strings:\t0x%x", fdt_size_dt_strings(fdt)); + ut_assert_nextline("size_dt_struct:\t\t0x%x", fdt_size_dt_struct(fdt)); + ut_assert_nextline("number mem_rsv:\t\t0x%x", fdt_num_mem_rsv(fdt)); + ut_assert_nextline_empty(); + ut_assertok(ut_check_console_end(uts)); + + /* Test header get */ + fdt_test_header_get(uts, fdt, "magic", fdt_magic(fdt)); + fdt_test_header_get(uts, fdt, "totalsize", fdt_totalsize(fdt)); + fdt_test_header_get(uts, fdt, "off_dt_struct", fdt_off_dt_struct(fdt)); + fdt_test_header_get(uts, fdt, "off_dt_strings", fdt_off_dt_strings(fdt)); + fdt_test_header_get(uts, fdt, "off_mem_rsvmap", fdt_off_mem_rsvmap(fdt)); + fdt_test_header_get(uts, fdt, "version", fdt_version(fdt)); + fdt_test_header_get(uts, fdt, "last_comp_version", fdt_last_comp_version(fdt)); + fdt_test_header_get(uts, fdt, "boot_cpuid_phys", fdt_boot_cpuid_phys(fdt)); + fdt_test_header_get(uts, fdt, "size_dt_strings", fdt_size_dt_strings(fdt)); + fdt_test_header_get(uts, fdt, "size_dt_struct", fdt_size_dt_struct(fdt)); + + return 0; +} +FDT_TEST(fdt_test_header, 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); From patchwork Thu Mar 2 03:08:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750354 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=Zp4Nuyhn; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=MbjBgzl9; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx7Y2pgHz1yWw for ; Thu, 2 Mar 2023 14:15:37 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 68D3D85CE5; Thu, 2 Mar 2023 04:10:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="Zp4Nuyhn"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="MbjBgzl9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4216785C56; Thu, 2 Mar 2023 04:09:39 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) (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 2CEA185C3A for ; Thu, 2 Mar 2023 04:09:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4PRx0Q6Qqlz9sQX; Thu, 2 Mar 2023 04:09:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726566; 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=5upXMD/Z3UuW/2Vx5lsbPkLN2ubqeQcmiq4kd1/JgGs=; b=Zp4NuyhniqJYRQX5KOT3RyEIWaJcgZkoxVaP4ZjeodVVUh+C5iDwr+YQe0h2eYRmbNUljs 71+8MblrW31trWfJXKlICGmoS4CDtxQ1EdVQpZx5UAWPMyni9GPC2c/ggLMW9CC4nCmVxx XAbM8AyKjr8jZ+AHgp4uM9S5VbMmEcXJIRDH8leFA6OzYGm6dIlWrzdeAgn3C+X0eMdDoY MSY2n9amkLHpD9fsOZfjE5bhbXbumkP474C4o3xfdoGbPaURlKJOAtBF6SvhFdOCWzrQHD 7u73P3UEStXmrY8Dom/0VLuIkZxFG8WYpQiwIOr3at9eaQm9EZ826LecHzBitg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726564; 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=5upXMD/Z3UuW/2Vx5lsbPkLN2ubqeQcmiq4kd1/JgGs=; b=MbjBgzl9jWiDEsmadVOKag+g5o5x2l7ANMqNCViu1FMA8U7iTjDpVBRNLeTUl3I7tL9UFQ aM1U5lxaYP3N+BgDWl4Vq/ZPO2gbc7ASzN4zAucC8R0oehTlzBeSi4QK70LVlJTx8Jz+Pk YEiupZr6GuBIi+RUZ0AydmExaJDAaKT2f3Riq/dINXcf2iWR22V2/uVRTJ9tCnFn4tCuyJ 9wZSvpyNXLsxcbDQpv8Zne0QovpLBGW4zY5E79Uv2BYEIAMkplsEzXO+NqatiBP/VDZYlp C9zKvP/n/8d+J7oBrj4rdhlewrson/Uo4qHSSRSu3Drv0LH2rqzx1VHJdzJOCw== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 27/32] test: cmd: fdt: Test fdt bootcpu Date: Thu, 2 Mar 2023 04:08:40 +0100 Message-Id: <20230302030845.322552-27-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: ixdiweq86ghyrmj1qtd5r5sghi9bk96c X-MBO-RS-ID: a3f2bd37f963363a81e 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 'fdt bootcpu' test which works as follows: - Create basic FDT, map it to sysmem - Print the FDT bootcpu - Set the FDT bootcpu and read the value back using 'fdt header get' - Perform the previous step twice to validate bootcpu overwrite The test case can be triggered using: " ./u-boot -Dc 'ut fdt' " To dump the full output from commands used during test, add '-v' flag. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 7dc9e800d38..03ec080716c 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -1133,6 +1133,39 @@ static int fdt_test_header(struct unit_test_state *uts) } FDT_TEST(fdt_test_header, UT_TESTF_CONSOLE_REC); +static int fdt_test_bootcpu(struct unit_test_state *uts) +{ + char fdt[256]; + ulong addr; + int i; + + ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt))); + addr = map_to_sysmem(fdt); + set_working_fdt_addr(addr); + + /* Test getting default bootcpu entry */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt header get bootcpu boot_cpuid_phys")); + ut_asserteq(0, env_get_ulong("bootcpu", 10, 0x1234)); + ut_assertok(ut_check_console_end(uts)); + + /* Test setting and getting new bootcpu entry, twice, to test overwrite */ + for (i = 42; i <= 43; i++) { + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt bootcpu %d", i)); + ut_assertok(ut_check_console_end(uts)); + + /* Test getting new bootcpu entry */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt header get bootcpu boot_cpuid_phys")); + ut_asserteq(i, env_get_ulong("bootcpu", 10, 0x1234)); + ut_assertok(ut_check_console_end(uts)); + } + + return 0; +} +FDT_TEST(fdt_test_bootcpu, 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); From patchwork Thu Mar 2 03:08:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750357 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=nPsQYPeC; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=pfXMOnWH; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx8N4Cgjz1yWw for ; Thu, 2 Mar 2023 14:16:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BA49585CDC; Thu, 2 Mar 2023 04:10:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="nPsQYPeC"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="pfXMOnWH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7DAD885C3A; Thu, 2 Mar 2023 04:09:39 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [IPv6:2001:67c:2050:0:465::201]) (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 997E685B58 for ; Thu, 2 Mar 2023 04:09:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4PRx0R3cCfz9sh9; Thu, 2 Mar 2023 04:09:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726567; 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=2uTkH6yqrM4noX88jV9SyJDVI81Otou53Sv8l8Qi8PA=; b=nPsQYPeC0OCarmULTjbNQXxE9WpceU+HM9pTp0w2xRalTyCxCIyxZpQAjHXFsTB0dG0YEI JzoAVbhMzg5yFPxkLyiWpEiT+KVsFIfr7ZQmF5c/AWRD62jt80XDzVaLLM9YCkizdeDCiW PLiWfryudwquimVaeTWMozxAtnx/56bY5zYmBFvW0XCc7qo81ApTnwCeK280cK84+7Reda 7UFs8kIhssAIT2kQ/bkN4mFAQtuWiG6RSk9nPnVcMGSAfivfGHdPlgGZm07Uzn8ChZus2O beLsqLPRwVIzs6r260lNkjI7158XcZFlI5Dm0owP2AqVz0Q3IjJet1TIgKcm0A== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726565; 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=2uTkH6yqrM4noX88jV9SyJDVI81Otou53Sv8l8Qi8PA=; b=pfXMOnWHeAx9dA+rh0tzHVxxIPpWKYb5YypEYuZd/8VvZuQBl+DhK5RERmn9GArM0kZoK4 qb8rdneE4OxK5Dz9qq49smPKsGPlNPInS9YzgndHijmal3EXSDtfbver+EbEHq4z25j6jT fPUgXC3x/jC546uSpgUzsepOWltpM0Ui6E7ZdK15ST91M40InKtJ2JO5LJS0njqnHWRDd8 VX7fv+RYasy7/A1pfw0sPyptiSkuVANO/u1HKla1hOEyHnRCKYbyvf9wSJ0fZhK0tXmd12 eDzwhB6NiuFKOFzOs48ZKiO1NvLBbG/5/DOKxk2lR/pAyngQ1o8wyPRViz8hOA== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 28/32] test: cmd: fdt: Test fdt memory Date: Thu, 2 Mar 2023 04:08:41 +0100 Message-Id: <20230302030845.322552-28-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: nn35yowxce344omhtbgrg7d8pjuxzgna X-MBO-RS-ID: a226f75801df25ec153 X-Rspamd-Queue-Id: 4PRx0R3cCfz9sh9 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 'fdt memory' test which works as follows: - Create custom FDT with /memory node, with select #*cells, map it to sysmem - Perform memory fixup - Read back the /memory node and validate its content The test case can be triggered using: " ./u-boot -Dc 'ut fdt' " To dump the full output from commands used during test, add '-v' flag. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 03ec080716c..27eb1349a2b 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -1166,6 +1166,89 @@ static int fdt_test_bootcpu(struct unit_test_state *uts) } FDT_TEST(fdt_test_bootcpu, UT_TESTF_CONSOLE_REC); +static int fdt_test_memory_cells(struct unit_test_state *uts, + const unsigned int cells) +{ + unsigned char *pada, *pads; + unsigned char *seta, *sets; + char fdt[8192]; + const int size = sizeof(fdt); + fdt32_t *regs; + ulong addr; + char *spc; + int i; + + /* Create DT with node /memory { regs = <0x100 0x200>; } and #*cells */ + ut_assertnonnull(regs = calloc(2 * cells, sizeof(*regs))); + ut_assertnonnull(pada = calloc(12, cells)); + ut_assertnonnull(pads = calloc(12, cells)); + ut_assertnonnull(seta = calloc(12, cells)); + ut_assertnonnull(sets = calloc(12, cells)); + for (i = cells; i >= 1; i--) { + regs[cells - 1] = cpu_to_fdt32(i * 0x10000); + regs[(cells * 2) - 1] = cpu_to_fdt32(~i); + snprintf(seta + (8 * (cells - i)), 9, "%08x", i * 0x10000); + snprintf(sets + (8 * (cells - i)), 9, "%08x", ~i); + spc = (i != 1) ? " " : ""; + snprintf(pada + (11 * (cells - i)), 12, "0x%08x%s", i * 0x10000, spc); + snprintf(pads + (11 * (cells - i)), 12, "0x%08x%s", ~i, spc); + } + + ut_assertok(fdt_create(fdt, size)); + ut_assertok(fdt_finish_reservemap(fdt)); + ut_assert(fdt_begin_node(fdt, "") >= 0); + ut_assertok(fdt_property_u32(fdt, "#address-cells", cells)); + ut_assertok(fdt_property_u32(fdt, "#size-cells", cells)); + ut_assert(fdt_begin_node(fdt, "memory") >= 0); + ut_assertok(fdt_property_string(fdt, "device_type", "memory")); + ut_assertok(fdt_property(fdt, "reg", ®s, cells * 2)); + ut_assertok(fdt_end_node(fdt)); + ut_assertok(fdt_end_node(fdt)); + ut_assertok(fdt_finish(fdt)); + fdt_shrink_to_minimum(fdt, 4096); /* Resize with 4096 extra bytes */ + addr = map_to_sysmem(fdt); + set_working_fdt_addr(addr); + + /* Test updating the memory node */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt memory 0x%s 0x%s", seta, sets)); + ut_assertok(run_commandf("fdt print /memory")); + ut_assert_nextline("memory {"); + ut_assert_nextline("\tdevice_type = \"memory\";"); + ut_assert_nextline("\treg = <%s %s>;", pada, pads); + ut_assert_nextline("};"); + ut_assertok(ut_check_console_end(uts)); + + free(sets); + free(seta); + free(pads); + free(pada); + free(regs); + + return 0; +} + +static int fdt_test_memory(struct unit_test_state *uts) +{ + /* + * Test memory fixup for 32 and 64 bit systems, anything bigger is + * so far unsupported and fails because of simple_stroull() being + * 64bit tops in the 'fdt memory' command implementation. + */ + fdt_test_memory_cells(uts, 1); + fdt_test_memory_cells(uts, 2); + + /* + * The 'fdt memory' command is limited to /memory node, it does + * not support any other valid DT memory node format, which is + * either one or multiple /memory@adresss nodes. Therefore, this + * DT variant is not tested here. + */ + + return 0; +} +FDT_TEST(fdt_test_memory, 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); From patchwork Thu Mar 2 03:08:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750356 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=YCVw9K33; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=Bg8WHFtZ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx861cVPz1yWw for ; Thu, 2 Mar 2023 14:16:06 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CFF9B85CD4; Thu, 2 Mar 2023 04:10:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="YCVw9K33"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="Bg8WHFtZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B4AD985C56; Thu, 2 Mar 2023 04:09:39 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) (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 686E885C13 for ; Thu, 2 Mar 2023 04:09:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4PRx0S1FyVz9sgK; Thu, 2 Mar 2023 04:09:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726568; 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=v9TPKcxX8+2KRmprI8p1ViErvK6ZBBAan3+I6xZY+V0=; b=YCVw9K33tqc3a7cFqkQ7M7YUJm5VjEEK/9Tld/1X7hBk4SUst/GgxSDeC5DFf19J9ZIxCc 46LM4aoKHMpdUyAEOHJXTxXKj+WHREmmRHzzThBMcHXEcOmdTuqGxFqL9WMOctZekmjPJ4 YDdxPbWDTC+CWTXLX8U9g9FRAGRwa4nFjKW+G4kMltnWyqQsZPtRku1AIpbsiw7EYa4xvI +b2NnhKOhLgYPxn6uh0rlQfvHcpJAqhBrqHtVoCBe15cJo+N0PY8lBP/GUCZ8JCA/yuNtK ZqLGaxLZ/7a5UxSDhnsQKS8MpSEyv4dz6lMHOAgHdca7YNGx8S3GKrHlN5bGqg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726566; 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=v9TPKcxX8+2KRmprI8p1ViErvK6ZBBAan3+I6xZY+V0=; b=Bg8WHFtZzB4RwuR0YAGAn1oojiTKj8UznYG/YjzIuEKNo7+Tq08d7byLq1jn0klhUM7YSF SsfgDZ4/T27SvD8pYqTqTEReWnbWqm7+NfM2XjNPrCuL7z1ZT5ceAeWqu9x7R1/Rb9s5xt W3TDzOIyDoJb+lOX48tsy8MiWV3BLXprDPLi5TuK9rte2VFUmIA4G1NMoSd55JUGzUX+Jv K01cOdPatpoE4U7xwr7Npilt05O0E56+bXTiosw//2zzbegXU+0lIccgiw/ODzXpSIRusp ChiNJ/OnWYKNyuPY0gbek+p63O3Neh28I5c/Up/ul9Mlpb6jqmy1BVpvZpM2xw== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 29/32] test: cmd: fdt: Test fdt rsvmem Date: Thu, 2 Mar 2023 04:08:42 +0100 Message-Id: <20230302030845.322552-29-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: m6qw4uh1yafzseoka1nru7aeix8m355p X-MBO-RS-ID: 0076460558b52d1bf39 X-Rspamd-Queue-Id: 4PRx0S1FyVz9sgK 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 'fdt rsvmem' test which works as follows: - Create custom FDT with single reserved memory (rsvmem) entry, map it to sysmem - Add new rsvmem entry - Delete existing older rsvmem entry - Add new rsvmem entry again - Always print the rsvmem list and validate it The test case can be triggered using: " ./u-boot -Dc 'ut fdt' " To dump the full output from commands used during test, add '-v' flag. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 27eb1349a2b..fc552d11a0f 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -1249,6 +1249,69 @@ static int fdt_test_memory(struct unit_test_state *uts) } FDT_TEST(fdt_test_memory, UT_TESTF_CONSOLE_REC); +static int fdt_test_rsvmem(struct unit_test_state *uts) +{ + char fdt[8192]; + ulong addr; + + ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt))); + fdt_shrink_to_minimum(fdt, 4096); /* Resize with 4096 extra bytes */ + fdt_add_mem_rsv(fdt, 0x42, 0x1701); + fdt_add_mem_rsv(fdt, 0x74656, 0x9); + addr = map_to_sysmem(fdt); + set_working_fdt_addr(addr); + + /* Test default reserved memory node presence */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt rsvmem print")); + ut_assert_nextline("index\t\t start\t\t size"); + ut_assert_nextline("------------------------------------------------"); + ut_assert_nextline(" %x\t%016x\t%016x", 0, 0x42, 0x1701); + ut_assert_nextline(" %x\t%016x\t%016x", 1, 0x74656, 0x9); + ut_assertok(ut_check_console_end(uts)); + + /* Test add new reserved memory node */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt rsvmem add 0x1234 0x5678")); + ut_assertok(run_commandf("fdt rsvmem print")); + ut_assert_nextline("index\t\t start\t\t size"); + ut_assert_nextline("------------------------------------------------"); + ut_assert_nextline(" %x\t%016x\t%016x", 0, 0x42, 0x1701); + ut_assert_nextline(" %x\t%016x\t%016x", 1, 0x74656, 0x9); + ut_assert_nextline(" %x\t%016x\t%016x", 2, 0x1234, 0x5678); + ut_assertok(ut_check_console_end(uts)); + + /* Test delete reserved memory node */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt rsvmem delete 0")); + ut_assertok(run_commandf("fdt rsvmem print")); + ut_assert_nextline("index\t\t start\t\t size"); + ut_assert_nextline("------------------------------------------------"); + ut_assert_nextline(" %x\t%016x\t%016x", 0, 0x74656, 0x9); + ut_assert_nextline(" %x\t%016x\t%016x", 1, 0x1234, 0x5678); + ut_assertok(ut_check_console_end(uts)); + + /* Test re-add new reserved memory node */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt rsvmem add 0x42 0x1701")); + ut_assertok(run_commandf("fdt rsvmem print")); + ut_assert_nextline("index\t\t start\t\t size"); + ut_assert_nextline("------------------------------------------------"); + ut_assert_nextline(" %x\t%016x\t%016x", 0, 0x74656, 0x9); + ut_assert_nextline(" %x\t%016x\t%016x", 1, 0x1234, 0x5678); + ut_assert_nextline(" %x\t%016x\t%016x", 2, 0x42, 0x1701); + ut_assertok(ut_check_console_end(uts)); + + /* Test delete nonexistent reserved memory node */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_commandf("fdt rsvmem delete 10")); + ut_assert_nextline("libfdt fdt_del_mem_rsv(): FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} +FDT_TEST(fdt_test_rsvmem, 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); From patchwork Thu Mar 2 03:08:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750358 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=j0hUGgyr; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=GMJlcHb8; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx8f2Rmgz1yWw for ; Thu, 2 Mar 2023 14:16:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A64C185CF6; Thu, 2 Mar 2023 04:10:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="j0hUGgyr"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="GMJlcHb8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3736985C52; Thu, 2 Mar 2023 04:09:40 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [IPv6:2001:67c:2050:0:465::201]) (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 121C085C79 for ; Thu, 2 Mar 2023 04:09:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4PRx0S6dcQz9sjD; Thu, 2 Mar 2023 04:09:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726568; 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=QwZzezkCQhGF1oDiynHyqzp8dzySDZq7QMnv6owJFGw=; b=j0hUGgyryBgjKJrzPO0NCAE4ghAdTmTmf/xFPz1tAngo3vakrM3s4V2af55SzKYA+N14KP ay4g7FsQXlR8UEnmMFYv4ZqzTQ5J16NZS4/F1xGR33R8I8JQpM47uGbb7TFUBUmgkZ7jYx N4NfxTUMQwBx4W/tg6cIkkphAD2F3n5x0dowWtJNzj4fGfeQp2zqy7uD+JXYu5msOkkXii xNMTep6wiLIyMNlHn62PGIH2tS1IZnE1DfFIe74tQhtW3pGO8/96kDAMhxW9sbjr8JlEqI FrdfJYvkIiqt+KhUV1fJzwiTlGvbLKllQuiGRJJfV4wmiA7cpS+8uBi5OzTcQA== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726566; 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=QwZzezkCQhGF1oDiynHyqzp8dzySDZq7QMnv6owJFGw=; b=GMJlcHb8FSkPsbkz8Lft9EOOh6XCucbbDDdCmt0Wxk3jCj66dMYDwJVXBso+f18IJNPF5t Lvs6n0NX7vGXTOJQCsv+G7vXU9RD0aOi0p+StbY1ueABOnjn79ADVN4kI7AZVNZjvEEsFK g9IblP7oN6ulR8CkcKHGJ0qvQLZQDqCXvFEzUcrIJRQaNlKkDA10bLT2QrhmIc2M0nma/A fCFDrT4H+ML2YtY81JV/9620dTM1SxsuYKXoNH21nm+fYSPxHvcqlv+IFMA8dtrA5bmaAh QjVKXt4+6OsrssdCR8Qy4AEEFu+QatoLr6odWpcfE0qPStgn5/91x/rVjlCqCg== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 30/32] test: cmd: fdt: Test fdt chosen Date: Thu, 2 Mar 2023 04:08:43 +0100 Message-Id: <20230302030845.322552-30-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: gkw966sjbt6w31iodewbt1dy3uhfp8df X-MBO-RS-ID: d0ada72b417a5e2ff81 X-Rspamd-Queue-Id: 4PRx0S6dcQz9sjD 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 'fdt chosen' test which works as follows: - Create basic DT, map it to sysmem - Print /chosen node, verify it is nonexistent - Create chosen node - Print /chosen node, verify it contains only version - Create /chosen node with initrd entries - Print /chosen node, verify it contains version and initrd entries The test case can be triggered using: " ./u-boot -Dc 'ut fdt' " To dump the full output from commands used during test, add '-v' flag. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index fc552d11a0f..d320f1f7b79 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -1312,6 +1312,54 @@ static int fdt_test_rsvmem(struct unit_test_state *uts) } FDT_TEST(fdt_test_rsvmem, UT_TESTF_CONSOLE_REC); +static int fdt_test_chosen(struct unit_test_state *uts) +{ + const char *env_bootargs = env_get("bootargs"); + char fdt[8192]; + ulong addr; + + ut_assertok(make_test_fdt(uts, fdt, sizeof(fdt))); + fdt_shrink_to_minimum(fdt, 4096); /* Resize with 4096 extra bytes */ + addr = map_to_sysmem(fdt); + set_working_fdt_addr(addr); + + /* Test default chosen node presence, fail as there is no /chosen node */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_commandf("fdt print /chosen")); + ut_assert_nextline("libfdt fdt_path_offset() returned FDT_ERR_NOTFOUND"); + ut_assertok(ut_check_console_end(uts)); + + /* Test add new chosen node without initrd */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt chosen")); + ut_assertok(run_commandf("fdt print /chosen")); + ut_assert_nextline("chosen {"); + ut_assert_nextlinen("\tu-boot,version = "); /* Ignore the version string */ + if (env_bootargs) + ut_assert_nextline("\tbootargs = \"%s\";", env_bootargs); + ut_assert_nextline("};"); + ut_assertok(ut_check_console_end(uts)); + + /* Test add new chosen node with initrd */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt chosen 0x1234 0x5678")); + ut_assertok(run_commandf("fdt print /chosen")); + ut_assert_nextline("chosen {"); + ut_assert_nextline("\tlinux,initrd-end = <0x%08x 0x%08x>;", + upper_32_bits(0x1234 + 0x5678 - 1), + lower_32_bits(0x1234 + 0x5678 - 1)); + ut_assert_nextline("\tlinux,initrd-start = <0x%08x 0x%08x>;", + upper_32_bits(0x1234), lower_32_bits(0x1234)); + ut_assert_nextlinen("\tu-boot,version = "); /* Ignore the version string */ + if (env_bootargs) + ut_assert_nextline("\tbootargs = \"%s\";", env_bootargs); + ut_assert_nextline("};"); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} +FDT_TEST(fdt_test_chosen, 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); From patchwork Thu Mar 2 03:08:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750360 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=OSqUGsZT; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=aPEBd9fA; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx985Dtbz1yWw for ; Thu, 2 Mar 2023 14:17:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DA11985D03; Thu, 2 Mar 2023 04:10:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="OSqUGsZT"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="aPEBd9fA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 304C085C72; Thu, 2 Mar 2023 04:09:42 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) (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 CD7E985C58 for ; Thu, 2 Mar 2023 04:09:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4PRx0T41lTz9sSr; Thu, 2 Mar 2023 04:09:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726569; 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=JNJHn3xBLlksjZtqyJKme9JgBA81PM6aYywF8SDs9Pc=; b=OSqUGsZT8PLTQ68YxmKfewBXQYNKl7iSd+0bycd6JUZ3UJSjMZBZJ8wkH/pg4gn2Z08PDf Bz2G+EzOA74mKtG/+LQXfy0UfizOgeSQZKCPcflOg2pQlJhvLWtvYDNdhAEbgJMZkWHdQP I6dqoLCxRMLMrgsCpcKmkn2BkFwLCdV/jLYVEWzjHtJ60QW+XdMXqUA/okO4Z2s0kjLiQM ULw8KO9QjQ21LVL+Cm0e3EfhB9hk7FLYxg/8ix5G1/uCAfkVF55z3iwLmcnvP2rmhWGxLo myQ0WcigSmUotzSGWzDXxLOXWQguMsV92x35axcN6caMMe8zr/e4I2s+x8Wxew== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726567; 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=JNJHn3xBLlksjZtqyJKme9JgBA81PM6aYywF8SDs9Pc=; b=aPEBd9fAwgR6AC1cq8129XJas4SgUQTyZlasmzFPLA2Rh2ve4UA6eZKaRZ/pM/t/IcSvkS 0gWzqrwUksWXEq90yVcLDLDOg0QMMK6QahDXmqj8lCnZBpzA01doH50Vlq28FfkHnTF9XI Wf7RhfJLVlo0uudivGZtaUaihguyCqZdLAE+fGtSAYwtp/GbWeCM8fe4rWpi1m5/pK8R7X KXJ/hxZlP+EoGLaeUrNsC0jNvWhqxwIjD7ujAtTPZWhYqkIuRwH/uV4qvT7yEOowkWeBPL M8Z8Yn6fUPEuJttqK3XfolOwVcwX6y7jAAEwgmk1r+ewLje6PYIx0qKcybuuyw== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 31/32] test: cmd: fdt: Test fdt apply Date: Thu, 2 Mar 2023 04:08:44 +0100 Message-Id: <20230302030845.322552-31-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: 8eg6wk1bbjg5uendnymu7qs3wb616466 X-MBO-RS-ID: cada0d376e9124b4176 X-Rspamd-Queue-Id: 4PRx0T41lTz9sSr 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 'fdt chosen' test which works as follows: - Create basic DT, map it to sysmem - Apply DTO which adds single property via fragment (without address spec) - Apply DTO which adds more properties (string, u32, empty) and a subnode, with phandle via frament@0 and thus tests /__symbols__ node - Apply DTO which modifies property of the previous DTO via phandle and thus tests the /__fixups__ node - Print modified DT, verify it contains updates from DTOs The test case can be triggered using: " ./u-boot -Dc 'ut fdt' " To dump the full output from commands used during test, add '-v' flag. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index d320f1f7b79..99e6450bb10 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -1360,6 +1360,158 @@ static int fdt_test_chosen(struct unit_test_state *uts) } FDT_TEST(fdt_test_chosen, UT_TESTF_CONSOLE_REC); +static int fdt_test_apply(struct unit_test_state *uts) +{ + char fdt[8192], fdto[8192]; + ulong addr, addro; + + /* Create base DT with __symbols__ node */ + ut_assertok(fdt_create(fdt, sizeof(fdt))); + ut_assertok(fdt_finish_reservemap(fdt)); + ut_assert(fdt_begin_node(fdt, "") >= 0); + ut_assert(fdt_begin_node(fdt, "__symbols__") >= 0); + ut_assertok(fdt_end_node(fdt)); + ut_assertok(fdt_end_node(fdt)); + ut_assertok(fdt_finish(fdt)); + fdt_shrink_to_minimum(fdt, 4096); /* Resize with 4096 extra bytes */ + addr = map_to_sysmem(fdt); + set_working_fdt_addr(addr); + + /* Create DTO which adds single property to root node / */ + ut_assertok(fdt_create(fdto, sizeof(fdto))); + ut_assertok(fdt_finish_reservemap(fdto)); + ut_assert(fdt_begin_node(fdto, "") >= 0); + ut_assert(fdt_begin_node(fdto, "fragment") >= 0); + ut_assertok(fdt_property_string(fdto, "target-path", "/")); + ut_assert(fdt_begin_node(fdto, "__overlay__") >= 0); + ut_assertok(fdt_property_string(fdto, "newstring", "newvalue")); + ut_assertok(fdt_end_node(fdto)); + ut_assertok(fdt_end_node(fdto)); + ut_assertok(fdt_finish(fdto)); + addro = map_to_sysmem(fdto); + + /* Test default DT print */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt print /")); + ut_assert_nextline("/ {"); + ut_assert_nextline("\t__symbols__ {"); + ut_assert_nextline("\t};"); + ut_assert_nextline("};"); + ut_assertok(ut_check_console_end(uts)); + + /* Test simple DTO application */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt apply 0x%08x", addro)); + ut_assertok(run_commandf("fdt print /")); + ut_assert_nextline("/ {"); + ut_assert_nextline("\tnewstring = \"newvalue\";"); + ut_assert_nextline("\t__symbols__ {"); + ut_assert_nextline("\t};"); + ut_assert_nextline("};"); + ut_assertok(ut_check_console_end(uts)); + + /* + * Create complex DTO which: + * - modifies newstring property in root node / + * - adds new properties to root node / + * - adds new subnode with properties to root node / + * - adds phandle to the subnode and therefore __symbols__ node + */ + ut_assertok(fdt_create(fdto, sizeof(fdto))); + ut_assertok(fdt_finish_reservemap(fdto)); + ut_assert(fdt_begin_node(fdto, "") >= 0); + ut_assertok(fdt_property_cell(fdto, "#address-cells", 1)); + ut_assertok(fdt_property_cell(fdto, "#size-cells", 0)); + + ut_assert(fdt_begin_node(fdto, "fragment@0") >= 0); + ut_assertok(fdt_property_string(fdto, "target-path", "/")); + ut_assert(fdt_begin_node(fdto, "__overlay__") >= 0); + ut_assertok(fdt_property_string(fdto, "newstring", "newervalue")); + ut_assertok(fdt_property_u32(fdto, "newu32", 0x12345678)); + ut_assertok(fdt_property(fdto, "empty-property", NULL, 0)); + ut_assert(fdt_begin_node(fdto, "subnode") >= 0); + ut_assertok(fdt_property_string(fdto, "subnewstring", "newervalue")); + ut_assertok(fdt_property_u32(fdto, "subnewu32", 0x12345678)); + ut_assertok(fdt_property(fdto, "subempty-property", NULL, 0)); + ut_assertok(fdt_property_u32(fdto, "phandle", 0x01)); + ut_assertok(fdt_end_node(fdto)); + ut_assertok(fdt_end_node(fdto)); + ut_assertok(fdt_end_node(fdto)); + + ut_assert(fdt_begin_node(fdto, "__symbols__") >= 0); + ut_assertok(fdt_property_string(fdto, "subnodephandle", "/fragment@0/__overlay__/subnode")); + ut_assertok(fdt_end_node(fdto)); + ut_assertok(fdt_finish(fdto)); + addro = map_to_sysmem(fdto); + + /* Test complex DTO application */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt apply 0x%08x", addro)); + ut_assertok(run_commandf("fdt print /")); + ut_assert_nextline("/ {"); + ut_assert_nextline("\tempty-property;"); + ut_assert_nextline("\tnewu32 = <0x12345678>;"); + ut_assert_nextline("\tnewstring = \"newervalue\";"); + ut_assert_nextline("\tsubnode {"); + ut_assert_nextline("\t\tphandle = <0x00000001>;"); + ut_assert_nextline("\t\tsubempty-property;"); + ut_assert_nextline("\t\tsubnewu32 = <0x12345678>;"); + ut_assert_nextline("\t\tsubnewstring = \"newervalue\";"); + ut_assert_nextline("\t};"); + ut_assert_nextline("\t__symbols__ {"); + ut_assert_nextline("\t\tsubnodephandle = \"/subnode\";"); + ut_assert_nextline("\t};"); + ut_assert_nextline("};"); + ut_assertok(ut_check_console_end(uts)); + + /* + * Create complex DTO which: + * - modifies subnewu32 property in subnode via phandle and uses __fixups__ node + */ + ut_assertok(fdt_create(fdto, sizeof(fdto))); + ut_assertok(fdt_finish_reservemap(fdto)); + ut_assert(fdt_begin_node(fdto, "") >= 0); + ut_assertok(fdt_property_cell(fdto, "#address-cells", 1)); + ut_assertok(fdt_property_cell(fdto, "#size-cells", 0)); + + ut_assert(fdt_begin_node(fdto, "fragment@0") >= 0); + ut_assertok(fdt_property_u32(fdto, "target", 0xffffffff)); + ut_assert(fdt_begin_node(fdto, "__overlay__") >= 0); + ut_assertok(fdt_property_u32(fdto, "subnewu32", 0xabcdef01)); + ut_assertok(fdt_end_node(fdto)); + ut_assertok(fdt_end_node(fdto)); + + ut_assert(fdt_begin_node(fdto, "__fixups__") >= 0); + ut_assertok(fdt_property_string(fdto, "subnodephandle", "/fragment@0:target:0")); + ut_assertok(fdt_end_node(fdto)); + ut_assertok(fdt_end_node(fdto)); + ut_assertok(fdt_finish(fdto)); + addro = map_to_sysmem(fdto); + + /* Test complex DTO application */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("fdt apply 0x%08x", addro)); + ut_assertok(run_commandf("fdt print /")); + ut_assert_nextline("/ {"); + ut_assert_nextline("\tempty-property;"); + ut_assert_nextline("\tnewu32 = <0x12345678>;"); + ut_assert_nextline("\tnewstring = \"newervalue\";"); + ut_assert_nextline("\tsubnode {"); + ut_assert_nextline("\t\tphandle = <0x00000001>;"); + ut_assert_nextline("\t\tsubempty-property;"); + ut_assert_nextline("\t\tsubnewu32 = <0xabcdef01>;"); + ut_assert_nextline("\t\tsubnewstring = \"newervalue\";"); + ut_assert_nextline("\t};"); + ut_assert_nextline("\t__symbols__ {"); + ut_assert_nextline("\t\tsubnodephandle = \"/subnode\";"); + ut_assert_nextline("\t};"); + ut_assert_nextline("};"); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} +FDT_TEST(fdt_test_apply, 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); From patchwork Thu Mar 2 03:08:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1750359 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=k7q4m7ff; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=Fw38gjZE; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PRx8v4j8Gz1yWw for ; Thu, 2 Mar 2023 14:16:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3C35085CFF; Thu, 2 Mar 2023 04:10:21 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="k7q4m7ff"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="Fw38gjZE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AE6B985C72; Thu, 2 Mar 2023 04:09:41 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [IPv6:2001:67c:2050:0:465::202]) (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 5668385C73 for ; Thu, 2 Mar 2023 04:09:32 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4PRx0V1dZDz9sZh; Thu, 2 Mar 2023 04:09:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726570; 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=cXsXW2dtQmcwdrBfvoYgrF5PSkm10c8wVTl387Jcjco=; b=k7q4m7ffB61BHmLAgclyfLJnCRDcz0Pt+W39mYuQ3G5qRFv9Go5n0icU+NQRDzmlNm0nI0 nZXc2DHOaG53PfX19gEfTdDOnFq231bFnruNHmQG3CM+i2fHeHiKzgtEtgZEYY1ZZKhhXe ikY0AZs3WvuvsPRGeHQASiiGXy/+M0z+6Mwp4rY6Bui4h1y1XGTCgrXP59WHswbAv07FhV 8sTr7HXOGq+HVrsFrST0UlhdPgDAswuVg2RNS44mGpH3tL9Gf8Qj6jSTwKyNam3sDPrL7E QA6vq80t4DjXH1n6+P42UrafatWsqfNfMpinosuCS9OwqQkJig34xrC4B0+Krg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677726568; 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=cXsXW2dtQmcwdrBfvoYgrF5PSkm10c8wVTl387Jcjco=; b=Fw38gjZEBRzZAXluxA2BdYnhrnIKKwJBe2uq+3TWUEhNGw3NWh+TtgNmg6zNwIqQxSWS/Y kmBGpU9xIMn/FEEsvCQaGlzjlgOzd+3QjK7QcgsX2U2Ti4F1dxnXNYQWFsiNattrqKvolg o0n0NqBXlY4zzlHHcOAcS2twDBnmfHDCuC/XzRgYXMlOVVvQsUL+cf+4ne3dOgfMwBZgs/ jVm/rX6ctyIcdMJo2iHEFfPs3wmXql8/U3Y5vC0W5/p9kmKeMp3XVCjM+9qvIMloV3vAUf f+uJfwBIAMalpbGjiJ7czpWldllYAaD7zEXkSEeK3X6sHE8H0fu1Be/trw9KIA== To: u-boot@lists.denx.de Cc: Marek Vasut , Simon Glass , Heinrich Schuchardt , Tom Rini Subject: [PATCH v2 32/32] test: cmd: fdt: Add list of remaining missing tests Date: Thu, 2 Mar 2023 04:08:45 +0100 Message-Id: <20230302030845.322552-32-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> References: <20230302030845.322552-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: 7z17uf8jgwyc18nf3tuctq3x6fa816fp X-MBO-RS-ID: 565c8ea5287e4108c08 X-Rspamd-Queue-Id: 4PRx0V1dZDz9sZh 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 list of missing tests for the 'fdt' command, currently the missing sandbox tests are only 'fdt boardsetup' and 'fdt checksign' . Signed-off-by: Marek Vasut Reviewed-by: Simon Glass Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- V2: Add RB from Simon --- test/cmd/fdt.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 99e6450bb10..79ec45bbc2a 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -15,6 +15,13 @@ #include DECLARE_GLOBAL_DATA_PTR; +/* + * Missing tests: + * fdt boardsetup - Do board-specific set up + * fdt checksign [] - check FIT signature + * - address of key blob + * default gd->fdt_blob + */ /* Declare a new fdt test */ #define FDT_TEST(_name, _flags) UNIT_TEST(_name, _flags, fdt_test)