From patchwork Mon Feb 27 19:53:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1749097 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=DGumR2fJ; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=WaLuYIBe; 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) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PQWSV2W1yz1yWy for ; Tue, 28 Feb 2023 06:55:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 944C185A6E; Mon, 27 Feb 2023 20:55:09 +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="DGumR2fJ"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="WaLuYIBe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BFAEE85A35; Mon, 27 Feb 2023 20:55:07 +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 EF1858339E for ; Mon, 27 Feb 2023 20:55:04 +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 smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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 4PQWS650Ckz9scb; Mon, 27 Feb 2023 20:55:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527702; 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=jswLA+BbAl65+9BlRXSJ69t02Ipwm4ZjdjpNbPywKD8=; b=DGumR2fJWWuYpZt0iESed/hiU4tOuHCwJC1kBsqqyS7qoZwmldIzjIr9nnRkcbD1dmRY9h QkYg1ub8AWwAMbWtO3AtqJvOE/2dJ8qlYKTRP6wcGL78cob+uMB+zVQsVEg7Vv67WzzglB +vQqHdrnO0pDUOgNRd05fjmY5BTrDwY3BCrZSQkml3eOoZqsx0llaGdYKbzasr/GGr4jQJ S8qlX8TlrevGjVdBgXCv6Yob/o41kyGN1IxD7+HaeppdBNRRTQeXq/fexf9I3SWVXuLwYD yi4RLkJgAWPAEVah30nM0EYs1lXZZoZkyaCa0+lkNaD3PPdkyHS8PpErQUVTbw== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527700; 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=jswLA+BbAl65+9BlRXSJ69t02Ipwm4ZjdjpNbPywKD8=; b=WaLuYIBed2eqJWib6sR+jc+vy0ltfARlkuUTMpmxRGXcsoNR6snL58e+blGNABEgVIx5MD YZy07imiqTVPs+g+heg/eXmPPu7yg+0pKCrArWav0Ftom+AjVEYvxuWxfkNhCh0YWMQkQk NuL0jUiF63H6nbzE+eRXRkx+h1+VEXqkq29nVQDLVDbXCA7UdzJJXLXJDgsqsrtC4JodWs IUo2d6jKH7D/12Estxoxe6Ra6h3Ju2Csr5sP0ixULwApBRTzKX9PkTX6005Z7bTsF1d3C/ HqHUoQ8eSmchPZ1X7YiOaq624+e0/2+D5LPI65R6bEvqpWBx+V1czpWnlfoDnQ== To: u-boot@lists.denx.de Cc: Marek Vasut , Hai Pham , Nam Nguyen , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 01/32] cmd: fdt: Import is_printable_string() from DTC to fix u32 misprint Date: Mon, 27 Feb 2023 20:53:26 +0100 Message-Id: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: p7py78w734dh1nka48zusdt8tmzkfuhw X-MBO-RS-ID: 6587c5e3962245cadcf 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53: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: 1749098 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=XnwhXdjJ; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=htf7FU87; 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) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PQWSj0tzdz1yWy for ; Tue, 28 Feb 2023 06:55:33 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B339785AA2; Mon, 27 Feb 2023 20:55: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="XnwhXdjJ"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="htf7FU87"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0B1708339E; Mon, 27 Feb 2023 20:55:08 +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 9C5D18567B for ; Mon, 27 Feb 2023 20:55:05 +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 smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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 4PQWS73Kvhz9swT; Mon, 27 Feb 2023 20:55:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527703; 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=xkpoduNIpkGUAiqHXsJ1MjelLM3oXUxoR3JEABzR5z4=; b=XnwhXdjJrHJo0fw/0U+wfjV/afUJDMAVD5ikPXcfi90tLDkS5OHPQ9Ata9d4tnofs8yigE QirZtH9JEuKZLX6lS1LTCZVZbazQmvR8prxwEtnHa4awOdTBorkaIYPHbfSLIixJ6spMqa lYPDIkExIWIyOhqFce/bCYjRslGeidmS7KjXQPXVwNMURAao+GVTy3S3RTRUElXjncXzc0 vbORNP6DxwmGRumoZLtpjb9Bd8ax9H66OvckibvSY54pHr0vs4mUbcqUz8CowBv2YM4eAp QI/YyYkd5B+7hpfVb9OulTiP/9wHuX9sLxRWq5RhoverPixek787BOKfyWu8Hg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527701; 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=xkpoduNIpkGUAiqHXsJ1MjelLM3oXUxoR3JEABzR5z4=; b=htf7FU87rVMxF9iW41CK5tJLOn+lt8kULLKRDzbBACEG0Qx59LkTUNMuqUZwud+ZJxMK6q LnxOeA9c80oB+NkprzpW/qW8bCNZtAn+gbwOXSjzcvutM4kPgmH5eVVhg6P9SDtbQgLnBt C/NY8u7Gg4kTADjYNw9nxQkakZ4yN73bx+sgjWpZjflyWwE51z/v2/AupwMk3g8EzkrrF0 bAdVLJVmcTjTBSAWTaqsj1rUVgIyWBEHenuNnxhoewcXVMEwLtxOX7EJ70YybheoItL+w9 njrYgCcXrIgJOgC+TbU634Y4M79x3QTqMQI2PkH357uQzsaVnbzbRNHdXK/JIg== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 02/32] cmd: fdt: Fix handling of empty properties for fdt get addr and fdt get size Date: Mon, 27 Feb 2023 20:53:27 +0100 Message-Id: <20230227195357.98723-2-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: roudpq8usjwtpang5hycmhttiubdwsqn X-MBO-RS-ID: 6378a5afd6100f28834 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 --- 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 Mon Feb 27 19:53: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: 1749100 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=ODu/rGzV; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=cWV4vaiM; 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) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PQWTV5JbZz1yWy for ; Tue, 28 Feb 2023 06:56:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 58AAF85AA0; Mon, 27 Feb 2023 20:55: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="ODu/rGzV"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="cWV4vaiM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6D33685AA5; Mon, 27 Feb 2023 20:55:10 +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 A723385942 for ; Mon, 27 Feb 2023 20:55: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=marek.vasut+renesas@mailbox.org Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 4PQWS83DmZz9sS1; Mon, 27 Feb 2023 20:55:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527704; 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=pZ2rZd7cz5AIMMUnKnkWIBHE6hwkPDbQyU87O8Flljo=; b=ODu/rGzVZ7rKfLUf0g+0xiEXfKUCTds5RGSPM0tPzN/Ogk8B1ajbJvYY6HiJLNSQxYRRlv 0RZcIxADDETtwKIiboxrYatMPgLG+2jSRjMtuJER4PRCgz8wkABliEMucJTG3m4nex/yJl iG7MA/sNTPVSbe6Cd/nzdvmYc7pvWX66C3YbfA4tUuM1QWowLD8b2nSBhPem6VtVliCFNf enCEd+qhz1qCgtIIERNVklXQupQMN4ejr4kWPNYHx8hc+nIT9793XCaqnxTaPMyxvmNvSt /PV+2DCt+SN7d9InXESad5PoKPAC05pzLOFUQ4XSDEPphtTPCieHmZcnYLxXqQ== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527702; 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=pZ2rZd7cz5AIMMUnKnkWIBHE6hwkPDbQyU87O8Flljo=; b=cWV4vaiMic769rnaNptcUCzwweZHjcXJdu5x5UvBJn9ybEuWjRJhATG5TZX53ZG4j+oKky b6/eoM1hjwa6aZps9Jsyue8NJvw3egfjs6mDORmoTwOPm5rAL8gzM+l7EvuWAfJ/QSYly3 6foOfk/C2I+ya7zFsu+sIVeKRDVQzGSNj5YqD2P3w6lgS1ra7iFiv7+uOiNHkYfjd6nbyK FOftp/TrjhNABepjy+bab8+hPkARkZ7hgNaH/7QURLltJSZVllFTv2EvPhzkaZIpom62N0 VX68ht64/Y9arc1G+qtLAEW4iJL6o5nqey5GD16qU1sJdA3qaafvN5dgypQ8yw== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 03/32] cmd: fdt: Fix fdt rm behavior on non-existent property and error message space Date: Mon, 27 Feb 2023 20:53:28 +0100 Message-Id: <20230227195357.98723-3-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: yu8ergxhotzp1gmh1hnjs7zzair6wxcg X-MBO-RS-ID: 2f473e8441456d4125d X-Rspamd-Queue-Id: 4PQWS83DmZz9sS1 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53: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: 1749101 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=PLiEt7DD; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=a8NV64g5; 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 4PQWTj0h6Pz1yWy for ; Tue, 28 Feb 2023 06:56:25 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DB40F85AB0; Mon, 27 Feb 2023 20:55: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="PLiEt7DD"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="a8NV64g5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EF98E85953; Mon, 27 Feb 2023 20:55:12 +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 577C785958 for ; Mon, 27 Feb 2023 20:55:07 +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 smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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 4PQWS91hwKz9sh9; Mon, 27 Feb 2023 20:55:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527705; 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=QfQVs/G2SS/Yi/CtjY4I2BX6uL4hDC09GtFl+yGh2Wo=; b=PLiEt7DDzZpkZenbmLgMqkRHT/Z6uNoXk1l3nAClffZXM8OeGU7KL6u71yDMDc1jkBA4lC +WqRXbkMOnMxJzGrwVqWlzhCn6RxhtIPmUVhwakvbAu4N3IXXxg0BMoTtAgDEUkz475eFO s3rDkkrAFAjD+Vy2cWMC0ICWzq4bORikduUdzZiAVErvvHMGkmJKuAjL1jyNQGgek+xFtR Cdhtez9XszwLlt7/ENYEsY0rcr0UOAa5JajBdxKYVbFJvAabG2Wre5HJM7uN0YIAwB07X3 fvgieBGeDjbk5WUmZQAkjrH/HlWqlS8nzrh2ju0i3+Ve4r0ju62fUxxQ6TAslQ== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527703; 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=QfQVs/G2SS/Yi/CtjY4I2BX6uL4hDC09GtFl+yGh2Wo=; b=a8NV64g5Lfy4LIFaqKi4DybY0s+1o4rlT1h8UcM3LWo/horP8dAd5DbVdhhL5dDgMDLilD TBQd7IzWPOU/91V0SSirJSjZ8ao1CeT8HQMyZ5gMvUQsEQrR7Us32qq/63llJeHURUpHII am1wL9IQ/9XRvxUIaaxQ7BdW955d+Dwvop/lHIED02gPQUgnRfIaqIsJaGa4pzCAGFdFeF HZvkogLhkpdBb0WEF6tkBKfuY7Dr0FksrFvl8BMVMyKIKyPbvWKsVeNzzXWOhEg1rT1ys7 zzqeu9cJUDCXxyPVT5FfyQaAULEkYH/XYgMOdVqSlMtqq90b0000AL8ncQkf4g== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 04/32] cmd: fdt: Fix fdt rsvmem behavior on non-existent index and error message space Date: Mon, 27 Feb 2023 20:53:29 +0100 Message-Id: <20230227195357.98723-4-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: x1n7x36bfkhs8x4tpnqhq9s9o7fo4ozc X-MBO-RS-ID: 362d08ff6829ad01120 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53: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: 1749099 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=uE+hAYg1; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=cJbUaBE3; 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 4PQWSy60D7z1yWy for ; Tue, 28 Feb 2023 06:55:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A64F68567B; Mon, 27 Feb 2023 20:55: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=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="uE+hAYg1"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="cJbUaBE3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ACFC485942; Mon, 27 Feb 2023 20:55:10 +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 2A857855BA for ; Mon, 27 Feb 2023 20:55: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=marek.vasut+renesas@mailbox.org Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 4PQWS96bQ3z9sdv; Mon, 27 Feb 2023 20:55:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527705; 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=25/IZeBB2nR7X1SkrkNxULo8jtyLfhoOTEYJTNDlImQ=; b=uE+hAYg1LgcnC+vFBXGFT8yJtQXCZm2vvNdibQ3kGEvIDVi4U1Srr44XUiwPtuL7mfyL4w VLN+mnfk2PgvkVoBsDrcvfIWRrL6Kga8RWKoRfe3R9TmsSYhZdJgJDuUv67mLL2G9384hu QiCd/sWn03OxAXNf/qOcCKNdUigGqoNNp0BotcHGnLQmUHVjefzNiVpLmYj0q1CtcS0pOG J/Q0iUln7KPWgD1n6dk+qm9a8kh8H31vv6VrWnMtfSxQnAOFPkTXV5MeL/2qL4iAoiueDS Awh0ZN63FpWdiQfqlqMhoggNBmq+aECv97oYuNXNYRLy330sbA4VV8RePB2Qcw== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527703; 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=25/IZeBB2nR7X1SkrkNxULo8jtyLfhoOTEYJTNDlImQ=; b=cJbUaBE32PGi/Txiqa3/dmMFHRNeoCu3ezJrVaoqZZhvC963xT754YJHuXnJ+mdBLR0euH ay1PD1srJE2LK56pf0/J1OZbZ3htSddu6fDWuhoi+b+KDWW2VWOVN5lxbH1V9JtMMi9HT2 Yjj3+4ECUYAPCpNlJlXXZcwALa1WEuicg1WkQ8dd7cLSZvwbSnJRdKxyvTj7I3lx8UjVim V47e2yh3llBqVqVX7NkMZA7suL/x6jke9ViSxP5CKq/b//MaqcuoADXhg/8lcXH8czIIA9 1zJYr0ooaR44QV4+jhmvviTTlnUUOSVcQqWDYcHCjLRs1IPhfCFiq3k3GoSy4w== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 05/32] cmd: fdt: Check argc before accessing argv in fdt bootcpu Date: Mon, 27 Feb 2023 20:53:30 +0100 Message-Id: <20230227195357.98723-5-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: qbijup66nbwg6oc4spfkrfnwg5qgxex5 X-MBO-RS-ID: 563ed98035773be161f X-Rspamd-Queue-Id: 4PQWS96bQ3z9sdv 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53: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: 1749102 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=tO7QPoCv; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=LjumqULI; 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 4PQWTz0Qb2z1yWy for ; Tue, 28 Feb 2023 06:56:39 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DABBE85AAA; Mon, 27 Feb 2023 20:55:35 +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="tO7QPoCv"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="LjumqULI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ED7FC85AA0; Mon, 27 Feb 2023 20:55:11 +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 CDE208339E for ; Mon, 27 Feb 2023 20:55: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=marek.vasut+renesas@mailbox.org Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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 4PQWSB4xtkz9sjf; Mon, 27 Feb 2023 20:55:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527706; 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=weNcylS/jnS1qpyV4WZs1rcmfhKWiaFioXKsbSF/MhE=; b=tO7QPoCvMcBhEZPoxzLhvF8myEFNq8i2mrLvZXdANzdhtBwcspsvwFRRAp8fvi4ZGDP/3d cYdu5sYUsMhIMrilF6OQXRUUbPd+8kreoHkKcfUG4eQ8okBdOihf0JApWU/qvhH9OQIvdE /K62hkjAlNpIrwdQjUyVrF92RdKRJ0HbRxZAjpd0DuDPxv05RC5A9WN5h8z9705d2iOFj9 ZFEVJMoAqfjGdhAlNQi5C81Seb7oP7dkdmwu2y57c4pMKpzMV1Go+sNo4XNINtCUCWv8OK TVWftFTe/l0/bAxLhIkqxP4o6ME3+2DgrJ5XMGghf7jBd8ceZtP372dRgRultg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527704; 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=weNcylS/jnS1qpyV4WZs1rcmfhKWiaFioXKsbSF/MhE=; b=LjumqULIVZEHwIOohB5UW5mEpDRjb9IbIwvMjU7OrH7OxjwnHyrkaTEZ3hcJLaVs5y+qjC 7xU2MNXWPtR3S8ADhCXqQWLYKUekMLxf9UAFXm4QYDzR2zhyfmHXExURTy2Uh5C7nMVwMz 9zLozAsnY4+9kY87vJWkzPfb8Xdh0OK1U5rRySB5TifWpR1p2dQfqj69/OiiX/OTlsY+VJ +6FXhjFuZ9w5dq6MtM0KPg5M0/KsXEanWT1anuD7w1gAqBtkjX4exnVIJhO0Kjy6D/AGhV N4ZbKuB3WNB6eKFb+oKyAIDIYntMukluoVd/4hUIcF5ij1NBDGwwhGGbsfiFmQ== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 06/32] cmd: fdt: Check argc before accessing argv in fdt memory Date: Mon, 27 Feb 2023 20:53:31 +0100 Message-Id: <20230227195357.98723-6-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: zznkgbidy1jsnktackijbfanfccfcjmo X-MBO-RS-ID: 6505b7ba36fcab462b4 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53: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: 1749103 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=EVOekiw6; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=X1XgUBUl; 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 4PQWVF2HSMz1yWy for ; Tue, 28 Feb 2023 06:56:53 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 158E085AB3; Mon, 27 Feb 2023 20:55: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="EVOekiw6"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="X1XgUBUl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ABE2885AB1; Mon, 27 Feb 2023 20:55:13 +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 B864885A71 for ; Mon, 27 Feb 2023 20:55:09 +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 smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 4PQWSC3dWjz9sw0; Mon, 27 Feb 2023 20:55:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527707; 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=KL0dQ46K7IAyCX4ruRbxRLWdI01d21ZOPpWmHlUk0qU=; b=EVOekiw6J7vrzCnfuf5ir/Dq2sogZSqKz0nOicUEd3JKDrY6xzo+2jtwAvHjUa4fp2WXB9 bkHWEO2xNzOtBbOxidaeNt/WSIrnfbUpy+WZ5EdzuO4j1kEkaNIn875QaEGTCWFgeB6nGr ytI9YZhcmXG1+BxbGjfRAUeHi8KGo37VXSUOn0WRHRY+nOYIWcBc+noscg6MLYUwW9YPF1 EKOOmGpHnfU28UlBu8OBqUu5YVrDjBm5KamvR0jdAsCYcN7q8dLUBK7f9QftY0aaUizGUF Dt+bFFac4NNzuyb6uk8RE6oIieMEXy1bJsXAydWhMuCcezIr6l5Uw6ho4ycROQ== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527705; 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=KL0dQ46K7IAyCX4ruRbxRLWdI01d21ZOPpWmHlUk0qU=; b=X1XgUBUljbDeKs/hLkHddteGj0a+Qw7IP/gGcbf4poJF7VseIzNVKnjb5U8UsyDmvJlaKN qLxGAa8/SC2u7jR+ANS63a2NIoqa2aU85AbU024r9R/TQEZujQgM8H2ng6a434uZBr4a0G OhCS4/hircKO2DnorjPa2Sn2AGuwaRt0M3dWkLdP6KG45j8XkxdLBH0EP2wiCffARIbsFU gzD+QKPPHOUKAQjK3Ck9JBLwbEjgeaYRG1clDM6acwlFNhYW50EVSAgTgeU+uMGorDKR+M 5LJ71yLlGjIG9mm5tia04BV/o8B3Yyn82KhnUImWSJAfI+kKr/Yu9PXvV7n8Og== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 07/32] cmd: fdt: Align checksign parameter names in help text Date: Mon, 27 Feb 2023 20:53:32 +0100 Message-Id: <20230227195357.98723-7-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: gnjposmhh7wwhriiuc69t63jyofbmiks X-MBO-RS-ID: 5a7e792c5f7ec64a395 X-Rspamd-Queue-Id: 4PQWSC3dWjz9sw0 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53: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: 1749108 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=slUY0AyW; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=h4zxb1Pw; 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 4PQWWd03Rlz1yWy for ; Tue, 28 Feb 2023 06:58:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6A78E85B6C; Mon, 27 Feb 2023 20:56: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=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="slUY0AyW"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="h4zxb1Pw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 49A8C85953; Mon, 27 Feb 2023 20:55: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-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 6038485A9B for ; Mon, 27 Feb 2023 20:55: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=marek.vasut+renesas@mailbox.org Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 4PQWSD1lhbz9sby; Mon, 27 Feb 2023 20:55:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527708; 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=nwbjFmMi7vjgBOn8TTQpQfWrfGItqszT9QSq11ZWd4Y=; b=slUY0AyWx00j0Z0zqgDrb16Wx/X8vEWHrhQgDUwoykVcxCQ8+mgnqTI3WO0u12yh1ckmp1 UE6w+UGJ2LqtAbfkHn6C8Om+RruXbICA36jrhRKA3EIa6gqglvUcfgNjcT1GyoATrPdIGq /P0cSEdI6FpKLTRB5QTjsKzegbMwbZIBkE94QbbxkzjaBtEWrYyJkWsbUTD8sRpXSKX+wa 3zMKCJbK3+x2JPpZJ8jT0Y9T/L7oOy+p2lHhFkxxgZMrnp8qUN7UOnOcFEUx21IeGBBGpD XsRKstlDwaHdY84SOyGMkswDcat+XCxti/QJL0LErSY2oxFs5oZUzuXf607Cdg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527706; 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=nwbjFmMi7vjgBOn8TTQpQfWrfGItqszT9QSq11ZWd4Y=; b=h4zxb1PwWaJCVfFRPv3fROlTClXj0dOErQdmUKw4+ph4LMKMlvUha5WtrfMwNgXRpU/Sh6 7dARFwSbhJVWUEnKyRg/7K48kj1T2OCsm0Sm+OLEJ92rVEimcuUi6WKK9hxiyiM+JBTYLL vJtisd+Ou2lkGLUn+cNI72f9wLLps8f/vJZOW1YnM8k4VD9NaSLLTKQlIbx7s8g8hN+Sya MtZiSIEJqKuIbIHNlWMnNNMJ+Q0s6ghaOllMJTGsX89PGOUVmWOUv+IK41POfER6lkRB4y n3Pa0j0xDnmlzFuVeIuEn8jNByf+bRJMt5OAwtrlpkN+ptEWf1mD7wnPjJQYUw== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 08/32] cmd: fdt: Handle 64bit pointers in fdt get addr Date: Mon, 27 Feb 2023 20:53:33 +0100 Message-Id: <20230227195357.98723-8-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: gzmc3bouhmqy13wqrhm1mw7y3w6r3wbw X-MBO-RS-ID: 52d905cc72523fbb87d X-Rspamd-Queue-Id: 4PQWSD1lhbz9sby 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53: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: 1749107 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=ZMIsY1GC; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=nEfI7zg4; 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 4PQWWM3tSmz1yWy for ; Tue, 28 Feb 2023 06:57:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C31C985ACB; Mon, 27 Feb 2023 20:56: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="ZMIsY1GC"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="nEfI7zg4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1988985A7B; Mon, 27 Feb 2023 20:55: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-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 29F858567B for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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 4PQWSD6khZz9sdv; Mon, 27 Feb 2023 20:55:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527708; 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=dUzRCODO9Jtc48f1ij61j2ZgvKsmdaDuzccqG/i/FEQ=; b=ZMIsY1GCCyqZx5oAC+H5e5ZPRWwUZNc5kpxjSFRR3uvBhkzLwBx6YqHfoFm3TN0ooQqtoq PV9qiS9MqIeZ099wmf8Xjnq63Qzz03P24OV6Cva8+9TGA3nGzdVgNbbylMJRQKPZAbOtUy XGwaTKethot4wYmuRO2ALOLamNyrciC3sBtnjjLlDl6ZL4rG9msmZG6s6rR7AwigVbuf+C Y4xxWwMV/o+H9m5SfeFR6LxnMcTVk9aTlg1EkMBC4BGHfOLdzc1D3W+pJouhFkeRPUzgWC iziw0kZO0SqWTv92spNytkaCMxN9DlFzB+Sb30B9r9nbQpq1gEL4lgZN2LO1DQ== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527706; 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=dUzRCODO9Jtc48f1ij61j2ZgvKsmdaDuzccqG/i/FEQ=; b=nEfI7zg4WtUMgnQ6hko0UPEos2oI1TZr8QU4IUHY8Fc1eomzq2EMdQKLebx/b2Ce/XMCNV GIUa9sZK7Umv2dhKh6rDSRbbg683lZoV/vPAzN3PnyE4fR2zmS8lEJFEZUUSTW3w0EKqMv S9XDRsyDjIYyDVG7RiVYhjOkmAcbHTUVj2vJZU5zWCyKDq5EgFOXTgSBTSaVJEAEj36QCS DP7y/Zm/JsrsvEJjlINgD5ETQH2B6nYel6AUNzp54Q8ocDkQwgOu59RJXBSphy0tQkzaFk jntQw3m/dfnuiLouKLRUezjDyLW/mXBT1haXmADWb4TueSKJTmRLFPbQ9+xA4g== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 09/32] cmd: fdt: Map address returned from fdt get addr to sysmem Date: Mon, 27 Feb 2023 20:53:34 +0100 Message-Id: <20230227195357.98723-9-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: tjxsey8hcey91b5z6hqwysu17b4bp49y X-MBO-RS-ID: 7e99042b4f1efce8eed 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53: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: 1749109 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=e3Mgm5i8; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=BiRjNe3N; 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 4PQWWs6ZgHz1yWy for ; Tue, 28 Feb 2023 06:58:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C8DFB85BA8; Mon, 27 Feb 2023 20:56:33 +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="e3Mgm5i8"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="BiRjNe3N"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E729285953; Mon, 27 Feb 2023 20:55:16 +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 0EE3D85757 for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 4PQWSF5dhbz9sh9; Mon, 27 Feb 2023 20:55:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527709; 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=Lh4fJz3v7L5iJYBhuMtKjdD4P5Vd2HR+3psXwqnLwF0=; b=e3Mgm5i8oGoJq+yMf/leGW+qrQNAiAH6WX7f4cNglDf2etKgxaftXtWXeML/L56hYiQsy3 2G5oXsoxroEqCZ/wlizc1Wvp8xIF60vZgo6xN44oQy7DtyHIsI1f5If/fi1pz33XrWBHKu FzlZAIr5vsRFJoyZ7IZCHNYm6i7PcgUaQeRcEdGcTvIpIRpllXNBasDnkCHy2pWR3wuECE wDpTMd/1BXyA4FJAhCe9Ql8FYRbcP1xavIN/XUAtHXWZeFNFHAjTWHuARapl81faKpoh8A f4KhxfAW6tyN1pEGowYNiWkrcx7CnsgzfwjeyaUpJUOQCAENfnWiOJGvzcNcZg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527707; 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=Lh4fJz3v7L5iJYBhuMtKjdD4P5Vd2HR+3psXwqnLwF0=; b=BiRjNe3Nr0K3oRH2+XblCRRrC2t58NlQ4umdovHJ3INfq4TAI1pPBV77X5/x8MsYTeHrsm t9+ELuTkJt3fsKgmMlXzox9GDkc52EML/Q66+OcdR1OIhJIoyjxMDoL7/YabSTkeHFHrqJ acrKmGbW0iydqE3mBczRBY6tRAnIqMA4DsDb7CsdLE0lpgnX1iDJLcc5n76I1pyDzT9Y8m SY2lulqg0mkfX9RbN9jHnqk9RMCYkf9Z0JFU75b1mDeui71Lnu1/i3MTAubsVaRhFREDXd d5Q/IpRL07TkDqS8pAGGCQjd+fMkGmteO7uqveO/34PdoIKLEQ+JJ1xrelbMkA== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 10/32] cmd: fdt: Add support for integer arrays in fdt get value with index Date: Mon, 27 Feb 2023 20:53:35 +0100 Message-Id: <20230227195357.98723-10-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: woci39i3g1e7ftjzyx3gapuzohzdggpy X-MBO-RS-ID: d831f04c62ddeeefc22 X-Rspamd-Queue-Id: 4PQWSF5dhbz9sh9 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53: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: 1749105 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=SJbqSkU0; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=OKdqfWFW; 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 4PQWVr28Gjz1yWy for ; Tue, 28 Feb 2023 06:57:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2048285AC5; Mon, 27 Feb 2023 20:56: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="SJbqSkU0"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="OKdqfWFW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A456785AAB; Mon, 27 Feb 2023 20:55:16 +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 E104885AAA for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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 4PQWSG4ZL8z9sxZ; Mon, 27 Feb 2023 20:55:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527710; 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=E/Cj1Ju01UVT/JEqtSYq+UfnUJylyzjJ/RNg12yqO4k=; b=SJbqSkU0pmJi6JEBU31/1kUaiq1McLLo+IKMgwacvA61lwmsuIJAPJZnTJhW/ipUqWp2l1 N+bBMaSqR7PGyTjBxo+px7qaECoy6hWm14GM1Moidy3Z7Inlc9igwcOGeC4dDCuuIfdAns 62orvO8AJcUlAmEbqcbHqWV0eCpW28BKZ6MLKmynIuWyAZncP12Lyv1E1yKvz8Ov4CQoOU 1Q86XvrDRG22v2D7KPhyFQPDc1i9rJSW1ibjc02slaSIJ8zzN1V51soirtz8n2RR0PeCpA lNkjXsI7ecV4lGyDnzl+ApUjhBtVEq887+DbpBGTqpEBPJEwh0KHZaIHJaaZbA== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527708; 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=E/Cj1Ju01UVT/JEqtSYq+UfnUJylyzjJ/RNg12yqO4k=; b=OKdqfWFWESoAsO1aiCzxzhK+zEIHVlR08CGN4FM2a1sZnnmHD8r05KEeoyGSUL1SEMSSq/ oXG+9evuhiofC37MX1GkNNGqxJZv6+11S0D28zqTSawQR6/xZiQpY/FkzVvprLpD/5cPR7 Z6+tnNtoCyRqHoghAUmZU1sBLwWVbU0lRVygq2+UxSOm4akgAW9VCyjK5U4L8g72XiISxj Gf0hXISikbpJUF3pJaDRMGGwkbtXcpCcqLOILFpZHqvk52rcDzCRCf8WkM3m+FllOLb5Dj L67clIZRNyqQ7CmV71I8KD/ytWQfPGzhIZTbUc1nvheKAjbouDz5vzTShGLYXA== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 11/32] test: Add ut_assert_nextline_empty() empty line helper Date: Mon, 27 Feb 2023 20:53:36 +0100 Message-Id: <20230227195357.98723-11-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: pukdrx5hihjcprz8umurorbfnex11x8j X-MBO-RS-ID: eb79be5011d8495abd3 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53: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: 1749104 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=Zgw6E9Od; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=vv+UaQ/9; 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 4PQWVY6NMPz1yWy for ; Tue, 28 Feb 2023 06:57:09 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3815D85B68; Mon, 27 Feb 2023 20:56: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="Zgw6E9Od"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="vv+UaQ/9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3BDD485953; Mon, 27 Feb 2023 20:55:16 +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 8868085AAB for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 4PQWSH2th1z9sS9; Mon, 27 Feb 2023 20:55:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527711; 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=WYLCTWh1lPPYcOHzn8Rl/9jcQ4QTyYo6Ia6Dpkm74zs=; b=Zgw6E9OdN+zbP3o2IdydfZ3/4SnU50Frun89p60suESi7X3h/rQBdde5cjB4xYxlvYNb0u 72MHBsgzA0tR16ljY7Mvko9erCvqPket7BOMcCR3hnUisFmQp3plCVcpyGvtvxkaD7F2SB Zwy3cLa0u+vqGmS93sTObajR25kF9nEC5x0TX0zgO5SN0YAmCwF6cXec5ClIeRBRr5CJy0 +EkT/AyM4kUGi0yFpnjmte5NLQ2hqMo/C4QCKu5FF4yjr7UV3PnNrdfifXwh0gVEFwlMBX uOwDVn/zYnKyooJGpjvwXZfNFbcm1OR5C1X8a1i870hJ6A7E44m7J/f/+HmE/Q== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527709; 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=WYLCTWh1lPPYcOHzn8Rl/9jcQ4QTyYo6Ia6Dpkm74zs=; b=vv+UaQ/9KURfrwbF5BZQuP6oZIzeawMqNLIfF6UF4oIPqPCkwohzigXZCfHW39czjh1rku y22r9Sg61pHm9YJBQEMMIdFI2sR+33/gWgjwF3xm7Q6gK4aGD/Ork8F+pH6iJQFKUD7TqR vvohX5jUFFWc/b6KY5LZ5/Smj93yBrizoGjVKSjZisz+8B9HxJCEkDH0qUnR5AGoZHXDCv hR+XUmOwdNZWcCiRCVvRztf4DKpFWaM1JnISxzTTcpsKZtmLOf/+eNIjsJsb1Iv/4o2Pr6 lw2EW+CDjcraPP32P0SFS7dQqPkyTcrPuyr4N7FueZ59fHCFeqYkhYP7vnRnaQ== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 12/32] test: cmd: fdt: Rename fdt_test_resize() to fdt_test_addr_resize() Date: Mon, 27 Feb 2023 20:53:37 +0100 Message-Id: <20230227195357.98723-12-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: 15qqi7mnmp1ewncwj4jnq8f9ahgpjtzb X-MBO-RS-ID: 8df39cfd6f8715a044c X-Rspamd-Queue-Id: 4PQWSH2th1z9sS9 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53: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: 1749110 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=C9vP/Byf; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=wa8SGRx1; 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 4PQWX71x1Hz1yWy for ; Tue, 28 Feb 2023 06:58:31 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8071F85B91; Mon, 27 Feb 2023 20:56:35 +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="C9vP/Byf"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="wa8SGRx1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0E7A285942; Mon, 27 Feb 2023 20:55: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 7DB2E855BA for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 4PQWSJ1VVfz9sw0; Mon, 27 Feb 2023 20:55:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527712; 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=AVaXt3v9EMtD7b876feRj8jYpq5MJVAkiIzqmtRQaxo=; b=C9vP/ByfpGRQ7JveKdFEHF9NE19/b1DIBAWDt9+5fUSx+0HWgRGfhlvEsicwzUmEP5yaz/ Sy9AURS0gHaUtqa5CCNsK/zW1mAMMhT0J+iwKNEb9AwyVyhOumWuqeUJZ5CaCgzOgwOJqn 6mvnuBAXIxfj418ThIc5LLqYBn2mEdJID+gxRe7iICtU0UAWCUpCwq9iTnCU88gAUmlBF8 JTxqFyx+SAufAZI3pyg4naJ5bJjCsPoMM2haqPsv5dZ7GxlgXkSBXv+njCNcAFdTsj31az gV+Y3Uv8HHdxhyV/qDV8tnlCn+MljvfA06mhD6GSmCkWUbBsZpcPoACbFkNB1w== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527710; 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=AVaXt3v9EMtD7b876feRj8jYpq5MJVAkiIzqmtRQaxo=; b=wa8SGRx1fvOWTm7w4uvc02bZTgsDC0GhHbwOkcTqxWBy9ew6pKau9oayY3ZGhT41o8ODRu Z+/iHzk3P21vToBs7Rao0gw9CWYc3nO1pHDB1/18hzWl0QFZsOIfwXiwf1P6g4F+UWF66O AJjIrNecAMgU0PV7ngF9L/Y7IIPpR4sNFxdv/QoLbt6ElpsOPN67zIkkVeu2unK9Hoch+2 KSvb6Hd+1bv6xZJuxvjNnF/wFl+U5a15th3xyDSGbE8sOW8Gk5T5ppHcW4fGCWY25P9GaQ T9b+EH+2xrQq1ztdzwfnt7ehCgE1oCB4sAuml9CUo/mpJalEWUGwT/25RhRJ2w== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 13/32] test: cmd: fdt: Rename fdt_test_get() to fdt_test_get_value() Date: Mon, 27 Feb 2023 20:53:38 +0100 Message-Id: <20230227195357.98723-13-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: z7c1qm5t7b71n1s45jb8ym3qeu7j5n5w X-MBO-RS-ID: 821fed5b2e43bd0cc28 X-Rspamd-Queue-Id: 4PQWSJ1VVfz9sw0 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53: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: 1749111 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=djgt58lJ; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=Y2dckAEH; 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 4PQWXP0f1sz1yWy for ; Tue, 28 Feb 2023 06:58:45 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2FED085B9A; Mon, 27 Feb 2023 20:56: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="djgt58lJ"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="Y2dckAEH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7EB1785A71; Mon, 27 Feb 2023 20:55: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-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 3687E8567B for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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 4PQWSK0Stbz9scb; Mon, 27 Feb 2023 20:55:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527713; 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=84hLZ3fFosBhwOIN44eTlxqUAriohyvdE2U1Q0igyFk=; b=djgt58lJhH8azoVS2RfFP6f6K/aPTtBPhY6aUw4v8UAlHKZd+uRpkRi5HhUfA9Na2ulr5F F0+csmVre+G8hfxzTjFaY9zS7kR2HsfjDQTaqKooYV7u1IKIoJiRYpE8mLNO8KA+8yu9ac aM7ZRDhX5YvpG4n0DGyHQbgnCsO8uX0vr2EbB2NFVYKY3al5+C7ufYN5VuyF8Gzn4SDc1c /exJlTP5ZJ1mwlQG0yuYJ2MBAQaMJf5ZY5Gm3VDKgUBPc90AdDnaitzlN6jd5dKAeJ6veJ PV+5S8Mfb6Pw0uOB7EXTjXsRbG5mdcClrRtVW8fa5Mzj6cJYL/4Veh2d/jxK6w== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527710; 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=84hLZ3fFosBhwOIN44eTlxqUAriohyvdE2U1Q0igyFk=; b=Y2dckAEHnKO9tGBexAVCThxgJ8UcdeRKiSvrOuZnBEwvdA2BxKTzsvFfXUkcRLiXhZcktc J1mh+vrLNRxwGEx5Fq3p61NvonNypn52nOJU8uAmTMhokyCefsjQVDhmQDr9Fzc2PTYoNA 8MwO8LVTimMXDVw+1gMPZ39tBl1KElLDQYJDyki2ZxMeiaW810o8CaGEYW+XxrBcDkHM2g NW86ry19MRbRtVAauyxkCbu69LHm7zmNPp6PULt8yjBQo6L9ajg++P/MFPjg73id2NT0St NKXqWdvM18gvrk4qUOf6IdjQoDhPh05oKOVEibNMtiDOrILMLczM+QQFldcswg== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 14/32] test: cmd: fdt: Generate fuller DT internally and switch fdt get value to it Date: Mon, 27 Feb 2023 20:53:39 +0100 Message-Id: <20230227195357.98723-14-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: 7k697zsh7tgxc1uubys1a7mddpumwiah X-MBO-RS-ID: da1e0540accc689f08b 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53: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: 1749106 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=x0/1Chyx; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=kWQypTQS; 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 4PQWW62hDsz1yWy for ; Tue, 28 Feb 2023 06:57:38 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 305EA85A71; Mon, 27 Feb 2023 20:56: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=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="x0/1Chyx"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="kWQypTQS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9CB3185A35; Mon, 27 Feb 2023 20:55: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-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 E9E6185AB0 for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 4PQWSK5kSpz9sS1; Mon, 27 Feb 2023 20:55:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527713; 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=TobjvJplNXxj9OUnT9ACxlFvgW3T/I6IDZ6jPM/QzNg=; b=x0/1ChyxTuJ2woC0gak7jF/83+U0C547FGMJHQrDh2hSKw5tot1eXjukvjQ3FAYCHRdjTH UCH8Wte4nux9FBDAPWo/bsXNg4G1KgNeBICOtdiygW4OC8/YFJbKIMHGxDGTYvBy3O5GaE SjUG3dPqPZ2VKqwsU5LMPcyDA9kdjXtmzEAAlxCUXkVbPo61PVXj+IzRJ5fAdCwb+8rL8z w0YwGPHyMU3Gh0Y3zwYWAN8QXzzKhIa4OCg+ofYPiRuduxiQhPM96xzxdOL/vpX206OtT2 HHI+c+4yS5nNrToiuVpYh/HNgA+W+gCdiwIyzeUCUYc25OxpnGDDZb0dxTbnkQ== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527711; 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=TobjvJplNXxj9OUnT9ACxlFvgW3T/I6IDZ6jPM/QzNg=; b=kWQypTQS9Ju5IweMUl+6uNEtH+YMNKqkGs7nJe/jMUOuzELEJPpTqjeAikKNJHTPkS2LA/ aHx8ek0k40iIbyGeAPNHUOcKCme8zmw1K5tWPVgZ9xnrCLqLVJnAGp0ncnR1HtW8i7IPCl HQwRMR8C/Te1Fvgk7PML2u2Fwwted6PDZSfSFhKFbBlY/HDm9mBgfXv5ikcfbajoNkesk3 +jqxqYc3M1IkNrsmjyhcCN3/tlWAQH1i3nKML3j4/Vj2RRRH0BSg5DOAhS/2GbVWbQIM20 PHTQI9M3QvrfO6STMRE+mKtJ8Aq2fCDHrSOINphCfo89yEk4XJoUd4I/i5bA+g== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 15/32] test: cmd: fdt: Test alias resolution in 'fdt get value' Date: Mon, 27 Feb 2023 20:53:40 +0100 Message-Id: <20230227195357.98723-15-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: 95jsuxi3pb1j5i63kedxdxatqm88e5ue X-MBO-RS-ID: 583c256e77fa694646d X-Rspamd-Queue-Id: 4PQWSK5kSpz9sS1 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53: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: 1749112 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=yiocHDOx; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=rBrRis7P; 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 4PQWXg686qz1yWy for ; Tue, 28 Feb 2023 06:58:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 74B9C85BA6; Mon, 27 Feb 2023 20:56:39 +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="yiocHDOx"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="rBrRis7P"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1892F85A9B; Mon, 27 Feb 2023 20:55: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-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 2CAA78339E for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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 4PQWSL3mccz9sS9; Mon, 27 Feb 2023 20:55:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527714; 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=i4eP+QzgQFfbw6bRsxTB3k5fvbhVwo/WooEIyWtsp2U=; b=yiocHDOxcfe2GXmQBa1InTRkeLV6cK10VR7SaN3L/rrOzUDQArcoddXV0riN8CS0UsMYtN 8nk9fmJ9QgeRUPTEg/YQ8GmuWULqTj22teo+TACx5pxhO6UShtzon2H/SetkeqAN2g2ift KIef1jgjiJZ3rxQ73NfoKhwQj+9hEIxZtpOvIIkENJDMQt2Ppqr2eW0DjbGIaybx37KlCk qKWGHyubJBQltEh7NnAl8ys9XLWY49B/NK4NiNBKCeuKjEz+b8OoYKu/Ptx+p0F1K4rwNS uPfzlJZiX7TmMIauEkzky3BBweeTl2VRrwyPSdS/G1Lqg9fZNlu+yjccEE8VTg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527712; 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=i4eP+QzgQFfbw6bRsxTB3k5fvbhVwo/WooEIyWtsp2U=; b=rBrRis7Pr8bDA4Che6wZ5vlKt5qIP4e9tsejb+eMqeCSNo7n2Rbu8wJ2gTrMwh2t9dBlpG tAVt83GPp79XfN4ANXvT6sP4+jodXSE/kc3lKVGsQC261yoQjMxOFXEkvnM9wJ4+1xkcvg 7IsQZeTzGRZ5TncNgnj+KAfeWGRo0+Aly5KuqC6GyQv/ByN5QFZkfREp9ye35yqhOLtPlo nuvgSchbMC3Uy4x0h/wIXB2mp2tBSqPwQxCTYh0oN8xDyRInVEA/4ftpRiQzcB+GAWvrkM JzG4L5QKVQgSPx5jsUNj1C6DzjcCksaJOohv4pleHe+Nvv2Ow8S6Y1kx9u/grg== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 16/32] test: cmd: fdt: Test both string and integer arrays in 'fdt get value' Date: Mon, 27 Feb 2023 20:53:41 +0100 Message-Id: <20230227195357.98723-16-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: k79fcme4uizgjau1yzsmaut7g85dxpwo X-MBO-RS-ID: 3606145c4dbdd2199b5 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53: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: 1749113 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=hqdiHN5h; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=xjjEiRXb; 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 4PQWXx5dVNz1yWy for ; Tue, 28 Feb 2023 06:59:13 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D9F3E85BBB; Mon, 27 Feb 2023 20:56: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="hqdiHN5h"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="xjjEiRXb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AE0AA85A35; Mon, 27 Feb 2023 20:55: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 7FCB3859B4 for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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 4PQWSM2JDlz9sZF; Mon, 27 Feb 2023 20:55:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527715; 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=cxd3PmCsLQKuvY607VwbL02RuZdrhtCHTl93HP53fz8=; b=hqdiHN5hEUV34O4okvdyEfpPNJKRuJLPuImRW6Fzs56MqRsJW9Zq6uA+ldwWeawW8jCmnC 2893F2UcoixgiubeyAU889vGQRzPobS/d9ldmKjRjdR7QPOdOpxwkajzdP82LABUAVWktp u+UwXm/C3+HKz6qQzZtUax4xNcMDomoRBb7g2zqkTUtju4jmV52y1w4eQj7+Tecm47+A+6 UFOnAqsLY+L0IpHLAdldsaVGBmH1yQCn/LiwnEHFCKL37bTD9YBN7Zrli93GqXAhhiNihg kHE9q6s5aWjjwiJieLLRWxH7wegH022s8rGlru/h/pcJ6EnIZlibQP9Pr7iGcw== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527713; 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=cxd3PmCsLQKuvY607VwbL02RuZdrhtCHTl93HP53fz8=; b=xjjEiRXbR8dDoPh1pIqzdyA2ZizBUSNCY9tsY3/EjwPQq8MZYEtpd5apfgXxQvdC8cIwga QLJMerwdspyNt9GUW778K3ZcamyOgamUD9FCQ4CUdEu7JkvpxpqyB7ZWQQuMOT9VuyQ2aE WsjIirTLyWuMZUd27RV4uCVh130h48UypkfhhrF1ZAzmX6IOi2EcyPPSyLnFkZjcf+KEz7 hA7mPXlgD1L0aeH+Yz02PxoPAHZP2rBVwyW3F+t+DxMwbQMucYtPwHEjuDcg//zHzWtETi NMtxYEXXzJf9k2hwVRLPG0QKN0vu90CTbkUVMiwO0UKUGXg8lde/vPwe8W665A== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 17/32] test: cmd: fdt: Test fdt move Date: Mon, 27 Feb 2023 20:53:42 +0100 Message-Id: <20230227195357.98723-17-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: qa5h7ora4hzk9pqzwu6ej1utzw51uitg X-MBO-RS-ID: cdcc5830ee4dfca5d3e 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53: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: 1749114 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=LNYkL8De; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=qupBvmqf; 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 4PQWYD3wS6z1yWy for ; Tue, 28 Feb 2023 06:59:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6EFC185BC0; Mon, 27 Feb 2023 20:56:44 +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="LNYkL8De"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="qupBvmqf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5839585A35; Mon, 27 Feb 2023 20:55: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-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 49B76855BA for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 4PQWSN0Gp4z9scb; Mon, 27 Feb 2023 20:55:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527716; 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=kYGr1wOXcD3FzBG8IQ3KicLmP5Lx1JwjtlqIYlFYnec=; b=LNYkL8Dech3c4OvNEarQpJVmUOlUZKzM1aVP429UtxZG88nWLq1LkCFFwlRoIIDrFkJYqt mGwIlN3Y4d9LofNI7UntxDuu76E1EXGLk2w2f9/UTXd6CFtTfD8pUMALIqTZ3goZAeQ3U+ MVCEpezXCWopkpwN/OUjCUbnFbx++qu00auQWdeGK3LjqD4Wdmaw4KTQeEPLOGBXPuDdqA uw04xVlOp2Kfug5aph6aRkCD4uWrlw8jr3TDPUU5B6e9opm8Y9RfIua7Rf8GhiG95KZrvu 81qSgRSX5qbdL+J+myFnqjCBy3dt9DiEbRoap6f23yKiVeQScHdwYNYSOBEzqg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527713; 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=kYGr1wOXcD3FzBG8IQ3KicLmP5Lx1JwjtlqIYlFYnec=; b=qupBvmqfsMwpFN/cjFUVEZHVWm4L3Um5igpKloQ/ScWNFSH8DTXddjsMxdBfpl7WCFe3df TKeeXZGOM6c+A0Bx4+liBEqhSIUgy2gu7++DVd4stkVSftDO8hBp5pEs598xD27eqE08wp FyxWzaERl+eKB2slQSuRBbbkPxMqPJG3UfOApj8IkiDltSA0a8IJks8w6oinCBRhAr5OxX AXulxmsHmu2u3QRHYzFFIbttm2Hi/uaU1fIqQxhcGwyWYZEtKZPqFWmMf7gJFprfAOMYbw YK1adKKqvkBOuknlIeaHfvCrZ5hGi0nKG0xyZEIXYIWJNVr3/DN+Mgu/Zmwffw== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 18/32] test: cmd: fdt: Test fdt resize Date: Mon, 27 Feb 2023 20:53:43 +0100 Message-Id: <20230227195357.98723-18-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: t3ia7tiouktztw7qcxcxuew55163a6j9 X-MBO-RS-ID: baf131ff0eb94467ad8 X-Rspamd-Queue-Id: 4PQWSN0Gp4z9scb 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53: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: 1749115 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=F3U9U1al; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=PVJzev6e; 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 4PQWYV6XwMz1yWy for ; Tue, 28 Feb 2023 06:59:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8EC4285BD0; Mon, 27 Feb 2023 20:56:46 +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="F3U9U1al"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="PVJzev6e"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A34E485A35; Mon, 27 Feb 2023 20:55:22 +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 617FF85942 for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 4PQWSP0ymMz9sh9; Mon, 27 Feb 2023 20:55:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527717; 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=vVWXaYD/Sg3YoTyjnMNJeBLPCCokC7uSsV5akf7frHg=; b=F3U9U1al2jNZWjgRdthwNDsXYg5tR5329AtE/EHaymw8dSIpcqtJT6jIbgfnyV5aVcKKAI bR6sg7+72wPZ0xkIwfpBlCh9Vr29qTnl8zlSw/PIMfYDHZfhjSa0ygRoBmlinc8fkcnaTr K4u9lP7aYvx3ozTKUNSKFe1o6gPV+1NlyJVzE5CMYJvCjc7KnpldieN1o9iwqg2424UzLZ Az7bcHC0voVjLEMZl/gtLz8sXM4G0QEczeXhMyIUwdI5IzWAiMpAdn5jVRyhxsjDlTqLEA ynGChrycMLfNwF2pMx/sjrcZrXIadIO2SqsyPhAmahM0ggfAUKmR0X4LRKf4Vw== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527715; 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=vVWXaYD/Sg3YoTyjnMNJeBLPCCokC7uSsV5akf7frHg=; b=PVJzev6eVxLMJM1J3BmVXJHXxaH2AoZqUtu55Mv7N7pXSB7D1AxQhrP0jomVpINGDcGz1e G3Ir7TgqeXp8sHwJ2GLPlnXyKX/MVdUigw8U59RuOYH5USPUirPJFpSAsp4ERcAXKsPG/C znSniWo2J75uybKlOmNBr0Jojp9wQL7qfx1Fv8zE5Hd5B4ZE/SSG6ffO98OBmIaKtVDg55 OWWziG6vi4/sZhKNmB/faMJKVeweoCkK4yEtNax7q0j3a0DnhmHx4QPTuOOJuzoK6huMuq 96L4MBXqdtRMMWvdt5iv9olwm9y8Js0yRR0zgMlcSfT9YtrZ7AIGLF1qlz90qQ== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 19/32] test: cmd: fdt: Test fdt print and list Date: Mon, 27 Feb 2023 20:53:44 +0100 Message-Id: <20230227195357.98723-19-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: 366xjr4e4k98osq8sznkm64aacodw358 X-MBO-RS-ID: 03ebbfdb3a94c7f05b2 X-Rspamd-Queue-Id: 4PQWSP0ymMz9sh9 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53: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: 1749116 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=KlMvko9X; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=GeaR6Nx1; 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 4PQWYn64dtz1yWy for ; Tue, 28 Feb 2023 06:59:57 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7264985BC9; Mon, 27 Feb 2023 20:56: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="KlMvko9X"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="GeaR6Nx1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F1DA685942; Mon, 27 Feb 2023 20:55:22 +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 E091C85A7B for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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 4PQWSP5ywMz9sby; Mon, 27 Feb 2023 20:55:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527717; 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=ksH1QiU18/2eDR5X9N2WkJABaCZMUVcy6NH1vwc0bC8=; b=KlMvko9XfQ9oHsdascZ1+Vu10IdanMfqTn15qPJltm98Y/VJPTWuDfufTI/0x90T+/t4yy 9fxNvWuvJ2Tr+7REoDdKKFBHL/6QmGQA62r2r438D3YbSBo8qa63FqK/r26AxCtZFnus3F N+B5InafXFoJMudQT0LwRWf9noAgW9qd2of9GvSd2CA40EKCeavRN12/QsKNtcSVTtwp3C KHuVAMCSAkTNB6f7gCBSyrS3BkbrWW32GoYWX1XS8lHQB7v799ImWSKWBB4K9IchAzS/Lh kQH2c802m6QOHOPBnePt295eNvfn5H+vHGgeJ6bNCqrPRkeVogTVO5v49XkJBw== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527715; 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=ksH1QiU18/2eDR5X9N2WkJABaCZMUVcy6NH1vwc0bC8=; b=GeaR6Nx16eiXnffy8jWrHsmNkIWMaNfTB8oG/79w458Bo0+JjaBvzWxhTKK4F+Eu9LNGz/ Fd8730lvsaiRsSdKtz3zduQsvbMAOQwUuJYEwyNzzlHfjwnbyR5kaQSjchS3r/A/tTNKdJ M+OjWngSwnLt6yTpOT4OzO2jeug3xRKK4EqQnGG6LwM85LelR1ETUjgHroDE63RaEuD54z 0LkRLHd+zryBXA0ioBhYjUf3CNUZibEPcZqsrEychAdfA9DXnlIp5kaJv6h8f50orVxTUN Hks97/FDQFEx7HGfhoUKfl+KXYQURQoZ7I6MROT/ZDyzYOyWWhMlFp1vc8Ukpg== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 20/32] test: cmd: fdt: Test fdt get name Date: Mon, 27 Feb 2023 20:53:45 +0100 Message-Id: <20230227195357.98723-20-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: idw3tuyu7smf6u43o7btmzqr36s1kdqf X-MBO-RS-ID: eabfd612898308f7a33 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- 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 Mon Feb 27 19:53:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1749117 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=aktUOYtN; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=d0fDM6eZ; 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 4PQWZL4fHpz1yWw for ; Tue, 28 Feb 2023 07:00:26 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7C0E685BBE; Mon, 27 Feb 2023 20:56: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="aktUOYtN"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="d0fDM6eZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 729BE85942; Mon, 27 Feb 2023 20:55:23 +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 A852A8339E for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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 4PQWSQ47HNz9swT; Mon, 27 Feb 2023 20:55:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527718; 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=d9lgvPVte9opbKQlx/pUDnjBVEGSevfLKZkZfzkudRs=; b=aktUOYtNbravWoKhpqW+9A+H7bTveyAFR/bat3Gsyk9M+e3tr812HhqVfD7AmvD/UJKBDZ Wk62zr1rM35OzgcLIAGgfzCEZGvwsDq/OSjEDLgLSQqtJrlT8hOO8lIUZRQIyDIfCAus3o Rnp1yG98o8yd3oJsNpiIcHCT7RUn6cwenpRF9DcSX2bx5Rf6+jfzJDTarl56ezq7lZDADD K+lKTtrkduMJLwOx3KPU0yinDtEg4MkSKHo8WlMe+jb4FoiolBihPh5Ua8uBcE1TPkSqQi nBqtOi7UUdZ81MEXO9IFV/9vxVE3dceumcYmKDLn9D5o4+Ha2///ZjgABBWPQQ== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527716; 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=d9lgvPVte9opbKQlx/pUDnjBVEGSevfLKZkZfzkudRs=; b=d0fDM6eZtE8yKrIQqVbLrgZDZ4B9r+IejsY/09DtKT5fYhbZ9WRdk333CdavrYl01aLegn fMhzH0ZMRB5G4yBYzd3jf+77XS+vc3G0fWvoORh+OwgLDT818e7mThrCxLsJqPbS2cUsW8 vLf4h/D5s+7Htp02nDUeGzzhRUNLTmTQ4ft+HJma9+Ptkbt3I1xyFxalGHcuaWc5wS4Pjg QFv/mwGTKkIHfHh4Y2lQ3LoaXiQuiXWYb3Q1U47Xee6YEKerrY9LeHc4E+nYThU07emFXz uI2+HZB51LTk4rC27jP3QuSF+ShlWBvgv1wCEncLKOLGiK8tsrED1I6Xs2lC3g== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 21/32] test: cmd: fdt: Test fdt get addr Date: Mon, 27 Feb 2023 20:53:46 +0100 Message-Id: <20230227195357.98723-21-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: ap6w9wh8px5tz8dfdmd7erctgm35eoyn X-MBO-RS-ID: da2a260215ec280ce64 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- test/cmd/fdt.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index fa95241c8f2..e829052bfd9 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -624,6 +624,72 @@ 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; + + ut_assert((path_offset = fdt_path_offset(fdt, path)) >= 0); + ut_assertnonnull(prop_ptr = (void *)fdt_getprop(fdt, path_offset, + prop, &len)); + 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 Mon Feb 27 19:53:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1749118 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=h5TRcfOg; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=g+w7V55t; 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 4PQWZc4ZThz1yWw for ; Tue, 28 Feb 2023 07:00:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C5E5485BC6; Mon, 27 Feb 2023 20:56: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="h5TRcfOg"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="g+w7V55t"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 29EBD8339E; Mon, 27 Feb 2023 20:55: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-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 9A0BC855BA for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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 4PQWSR3J7Cz9sxb; Mon, 27 Feb 2023 20:55:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527719; 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=6HZWxYrAOp687AmxFi2rKQ+9Mu/SHK/EsPr5aGV5NjA=; b=h5TRcfOgFGA7JOWFC+TwV6XcqVFCrI0ukQe1bHrfewK9J5P6BtAPDOfXWItOJWyfGSVxwe Yza0M/gSCvvl4572mIahWR5et1cBOSWtJl527UMYmMqFHIfONO9Lb+XL9DptlLCDEwrCyD uIXz+3jK7tN+HpyO6arXx+m9+TH8+XS1b9NXGSI5RDgCYJ7t9ioxXA0+qiaurhGZntGiAl DHLbVLWsxpWvZ3SvSNKd/KlRJecGtK/7l2zk3xFslHjeotWHCnqbQnPpRyzj+fydDK7gRY 8D2WXPUN1jrIFj9PdVgqRnR6MfAVQEXlOhpAqI/pN/SiQIihp9BiLOk0276b7Q== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527717; 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=6HZWxYrAOp687AmxFi2rKQ+9Mu/SHK/EsPr5aGV5NjA=; b=g+w7V55tJPnKl59jL3NkdD2T1Dg+NOzNwnsEX1bjMe6GRj9J2S7UBmEH9QMmyP803iFxXc Thd2ets+gAx2QAbR3+vdofuJKJae22SKaMqc2Ase7hC/yqUgQbVItt5Dz8jLaykSED3hwO Zn0rxMWwFFZe0ouEq5MsIttpfxomXssvAfqxKAV0zqKGROKu+5c4ufDVmDOwRmjDoBbnSP xcCWfUu9YvsSt1yanFSZOOpzHaHvOgDr1UXTVdc/yHjHEeQmH6yiTj404pQmPk9DMFhYvO GUKtLVSb4LMoLtf0yjlXNU06gjYr4SkAIc7qM+usDAkSTRFN67i5ZsRLiXu3FA== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 22/32] test: cmd: fdt: Test fdt get size Date: Mon, 27 Feb 2023 20:53:47 +0100 Message-Id: <20230227195357.98723-22-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: gbzzhmh64fa88nkdja4nrqg4qgcr3d1e X-MBO-RS-ID: fe1a0d6c54cbc1bc42e 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- test/cmd/fdt.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index e829052bfd9..ae67b468b71 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -690,6 +690,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 Mon Feb 27 19:53:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1749119 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=Idze3ao9; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=E5ijKfr4; 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 4PQWZt2BqPz1yWw for ; Tue, 28 Feb 2023 07:00:54 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C2BD485BEA; Mon, 27 Feb 2023 20:56: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="Idze3ao9"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="E5ijKfr4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 85C4885AB6; Mon, 27 Feb 2023 20:55: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-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 8CA4485A71 for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 4PQWSS2KXPz9sxj; Mon, 27 Feb 2023 20:55:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527720; 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=pXbB8F2pgpTBvWOZMvWQ9ZAx2w3OGmWn2NWOA4f6CpY=; b=Idze3ao9K3teEncYg3SY/ylp9aW1/doCcjJ9lDKtrqlaDhoPbZ5zgap6XluVIIpkiS8fzq CguUvuo32dXj1D16J+WzUf9zd/r3+XONN9EHwZaLjZ0rga8yO4P6yR/EvAtd3AgAdrJ9e9 ucLbaPFZ9OH13NFEzihWUkZ8Tn8Cp7Yrtp2LIKU4CCcuFw2OlRycztdpr0ubqx5W4hgV60 vyqpDnmpk5Sc2nJxqwDhFWEgK3WR2Y/EQBm2X3QfSLpa1OPx11ijXITFvYgRaktWJtIAmK /lXEN0x7aiRVxiXXV8nQmGdS0zI7WL0mNbBcwxWGBSibv+DA8Vz+lPqQZDjBPA== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527718; 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=pXbB8F2pgpTBvWOZMvWQ9ZAx2w3OGmWn2NWOA4f6CpY=; b=E5ijKfr4kQ9qsBue11or3wMEpe4+AI9Ao4Y8xEtK+5CsDxiLFsONCFKqHMpdCdhyDubN9G rgL9/PspbPi7oPzTIMwP3N9kzeqya4rO989RPiRkF7hEM0CmxntecGTuFr6FjtpSTI/gNq hl+DMUN53StOtdUCn3MP4ndS8swSirTjl1NCe0xGn2tcTziNrziBYgwM770oeP9j33skIC DBlmRSYJcmlzCF8dw+ReCnw6f68hDzx73P9sWO0ZFZdZv2gJvLccnwhhbHE/k/YV6TP8KH 47YC4wbDAFUBAJk64KhXX2KJ6aCkoRzt/YCGPYBM3GeWnSG219L2R0ULOANtPw== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 23/32] test: cmd: fdt: Test fdt set Date: Mon, 27 Feb 2023 20:53:48 +0100 Message-Id: <20230227195357.98723-23-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: ju9borfwhdqx4onifef3b9uzzxhe8jem X-MBO-RS-ID: 595660169b39430f633 X-Rspamd-Queue-Id: 4PQWSS2KXPz9sxj 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- test/cmd/fdt.c | 123 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index ae67b468b71..42d067090aa 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -777,6 +777,129 @@ 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) +{ + 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)); + } + + 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) +{ + 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)); + } + + /* + * 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 Mon Feb 27 19:53:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1749120 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=ON/a6mpd; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=cn//i96w; 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 4PQWb74Dvyz1yWw for ; Tue, 28 Feb 2023 07:01:07 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8FF6F85BE9; Mon, 27 Feb 2023 20:57:00 +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="ON/a6mpd"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="cn//i96w"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2E34485757; Mon, 27 Feb 2023 20:55: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-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 2AA2985757 for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 4PQWST0NRrz9shY; Mon, 27 Feb 2023 20:55:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527721; 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=zrYEVAHcREAHndxTg8SwZnfZrQhXHIzu5pJ5Qt7ZnI0=; b=ON/a6mpdYTUgmpUSkiLSjUurUhboCoLKfa1UAZMZLibCqg+/EIvl+V3RqYMI2qiuGHA5U0 fjHEFm2EtaMGgHeZMVOo9575Bi4o/AZqv0jhe1BTUAvj+XFQuDZBLmrWreGoW67nLvRjbh hbdtLOa5pYy7jHEeHipipGtuQQYwEvAbYfJCbUAiN+OUIsW0l6pJfR7cxZd/mrTpBPPGCO pDuwxSPo7EEr95s+GedoA6Pw424OpE/FaDbx8/aXBK52iCXuOBXgrjVVgftfkyFsyhmzR7 TkfFLSoJzXN+VQUhnXTfAr+1APaEt6CjqKVTf/kk8weaObInBO7Dn8Gj1uWryA== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527718; 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=zrYEVAHcREAHndxTg8SwZnfZrQhXHIzu5pJ5Qt7ZnI0=; b=cn//i96w+XnICN9I1KOE+1JWM4xXYCs+Eb076b0fm+fOsKMmKHv+xSegr91rC/00f4z3xM 3mEOQTe1cYA7vZtr76ftCOCRmMwn88Ql5e+z/7e/NEHemRzPeinaF0dGLmE6q9Z6LhN3Yg gfOo3zAdQM+Zhe9tI85L4Wek/7Elj/+HqKSHBrxdyEOdPlzZJufD8fZwZlB1I5dN3mvmri OTJUw+qk4h78kfWmCz4UvWA467v+4PDfDLtxn0uVjPjiNFPBJvNuJyrbst9AfwN8Vs0oL6 qBI8vPmzU4kqGpB9mYIyy7lDwutfunEDorRCzUPplG72aZ2hMCN5dmeQy+ERtw== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 24/32] test: cmd: fdt: Test fdt mknode Date: Mon, 27 Feb 2023 20:53:49 +0100 Message-Id: <20230227195357.98723-24-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: b6nuxs8uszf187ow37r41roat83ar13o X-MBO-RS-ID: 5669ed1d7ca89cf30d6 X-Rspamd-Queue-Id: 4PQWST0NRrz9shY 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- test/cmd/fdt.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 42d067090aa..dec783f6e26 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -900,6 +900,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 Mon Feb 27 19:53:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1749121 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=Gm36nLbF; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=Lp2/oLsH; 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 4PQWbP08WWz1yWw for ; Tue, 28 Feb 2023 07:01:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D95D985BFE; Mon, 27 Feb 2023 20:57:05 +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="Gm36nLbF"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="Lp2/oLsH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 007F885AC1; Mon, 27 Feb 2023 20:55: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-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 20BDF85942 for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 4PQWST6NB0z9sby; Mon, 27 Feb 2023 20:55:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527721; 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=ERxdrHxXJeaipwgCy1ry0pyRihQBdVYRBE8pmPIpuK0=; b=Gm36nLbFsUTGKq6tG5vAG+6jSbfXwXRe4q3l3RepgZHc2YixZVoVpE2EI8/FoTWnog/Zu4 PoTEQyodWqm2LMUnf7ehukdSW4YX9LET2ofXvRz+ZoUSqn9IwQC/Vqj2Y4YZY+wE259JQQ j/bbvJMNaDYZbFMW4Lima2cgoMblDVJjGUbrYJ1OsomWL4XZrknAnqCfJci67j2COvdp24 ZBmcqbuptPuDwuQD0LFF4gXnO4mLDHmCIPMUmHusJ8bqHk7b1bEixorAaeAbgmxsxl659q Tr3D+2ef8PYXKT588nK4AXZ34Gx7bBuKQKlHYH7UQnwfnfh0UlD5dLBzbRE9mg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527719; 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=ERxdrHxXJeaipwgCy1ry0pyRihQBdVYRBE8pmPIpuK0=; b=Lp2/oLsHWq4BaFq9v/NY01kmUu4B9cIm+Q0XJED0Vdy+tcpsl6z7gC/SilvTtRo6Yo3LVU tXUeiLci+Ro03ojytGA7r6iVLzRp1Fbak8BPtSp3G5/IHUSNmBzWKMST5F/va/dgQotxuB 8H8lS1Gm9/bT8Aw06cgUU9pq2JjX9DiE+c5xNQY5bM05Jrqq2CJYxpm9RBE6p7tqTJBXuj iXqDDRCcJrTt18Ge8752YZAUPHYG0dK9u4Bfkvk5rPPXlAyBCgkGFtetVpCM7805jdzTfu S3R0iRVV6mssFvBRPnpLzN3FQX4a4/1F8vOPsjTINxP5JA5jADJqGN4CcXAKCg== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 25/32] test: cmd: fdt: Test fdt rm Date: Mon, 27 Feb 2023 20:53:50 +0100 Message-Id: <20230227195357.98723-25-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: eztw53c1u9wxnicw3gghrxr5b6ukiymh X-MBO-RS-ID: 8ec87e3cb74d805514f X-Rspamd-Queue-Id: 4PQWST6NB0z9sby 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- test/cmd/fdt.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index dec783f6e26..39a20337c95 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -968,6 +968,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 Mon Feb 27 19:53:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1749122 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=hO6TdiAO; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=B6HBMplZ; 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 4PQWbf4xhjz1yWw for ; Tue, 28 Feb 2023 07:01:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D35ED85BD5; Mon, 27 Feb 2023 20:57: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="hO6TdiAO"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="B6HBMplZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7756A85AC1; Mon, 27 Feb 2023 20:55: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-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 0DE8285A9F for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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 4PQWSV5d4Sz9scb; Mon, 27 Feb 2023 20:55:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527722; 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=yuZO2EXwLCRDhiBoBcY6fqmq4m0vb9/+66btoVTXCEM=; b=hO6TdiAOaO9cwUQRz1gNjQEYARV7iK70NA56UGfwZTZIaCV8/7m05vvTMlWMTm9TuXNAH+ xy2LRdjdUbavvE97zn4Q70jMjnq4QJ7K/qqPQAaH4/n6GKoqkcJxfmeC7kl9AcGg/r/TJa dAAp4XN0SHou0tSg+8LqmY9DzmRH8V22isIv8C5ARj8Rd6udj7fbLMPPpxvVa6TJYf+cmi SnPmFDn6BAAWOvgTPyin/Iui7SRX2Q44ArwdkvtYDhZvn0VppApgfLCMbHgS1yGX8Ez8ee murq0ZoihbqfKAH4wh3mQJVxenB7XMwsCDYZudY+pzrmmKou5S27IF2xmDN9Vg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527720; 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=yuZO2EXwLCRDhiBoBcY6fqmq4m0vb9/+66btoVTXCEM=; b=B6HBMplZMOsZoxtwMqfXJoorXVYSLuaDzkS/nfJjiDKpL3WruGy70dKalStawnFVhhhiFM 3rR3+suIo6kydKCOo7gu4aZ0CMVID0rGDFI3n/CJpTflaKzx3w4e+TS5rJLSXF4gAOlvKB P3XKsamiQPsK/y+/q1HHHdJSWSIrRsPfFQpunA7mZWpFfCLRmnwrKvgu0u2YH73KoAa1ND +T4LPUdVCUL9wvojYWbOGk6O/k37UmHXsZWwwNZCGK8nrfBYZaSH0HBz24P+kzp+Rp5LzY 681dGx/ELUFpn2bjXHQP4uRoIYEc32BRCJJYSSPsd4IhFRSCw2quTIeByk3JEA== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 26/32] test: cmd: fdt: Test fdt header Date: Mon, 27 Feb 2023 20:53:51 +0100 Message-Id: <20230227195357.98723-26-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: ykdj5wnmybro8duhtrbg6z9me3x3s4hm X-MBO-RS-ID: 31bc2fe3698b3b7bb19 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- test/cmd/fdt.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 39a20337c95..b0c7ff52ca3 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -1052,6 +1052,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 Mon Feb 27 19:53:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1749123 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=JLbdpp6B; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=xtX/vGn7; 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 4PQWc004slz1yWw for ; Tue, 28 Feb 2023 07:01:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6109785BDA; Mon, 27 Feb 2023 20:57: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="JLbdpp6B"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="xtX/vGn7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BD8EF85A9B; Mon, 27 Feb 2023 20:55: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 C10AA85AAA for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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 4PQWSW3rVSz9sjR; Mon, 27 Feb 2023 20:55:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527723; 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=rH/zceteblL9QeiOGpKObgxkY3fAIHinioKTsV89tCM=; b=JLbdpp6BDd03cTa5ZPZdkq/drALOG7Fx0Gm/En7ttN6Q9T4m20u7XMynYVeeqdW69uelY7 TsWssYPpRVhA2y3TeowqNWfaugP5GdOydUByYUq6ep/WHpeljhtPWGICKa/+zdsack+2qu PAthceYD1fjd0U7GEbfeCFBAOn2jKT97ZQjLy9qcoR2RVTiRUwqKmJAgjaMDQLeCjUu172 CfkqWQAdeeVy2UDmf8ri+hPz4pUSLiBO/5OtSXtRCinHnP5RjxM2xkiDbzkXYSta22Xlin 2A7of8AIhzXAw8FydBn25g3binryAhp7SjA7Cb8PcztVPzG4DqErK3UWLm9TDw== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527721; 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=rH/zceteblL9QeiOGpKObgxkY3fAIHinioKTsV89tCM=; b=xtX/vGn7FzhfiS60ZL1tfJOlBK20Xh4+A2vj/lcEcsKXd0lNXWlofU4QKG93WbSwNvp5UL TrGjxsQ4ZiqnIihB6YUmkDXXIg0OiWnKmqjSky8sn1PohvQCg0KmboDZwKrH7/49AUKZ6p CPueVMIojsM1KY5BLEuSZoVR1L1VFUSVen2V+2J2NRh1bSZtSEmk2Utd1wIe9CPAwaJGU8 etsEdJyJAdeo0X0luLkByAmpYBKE8b3TIS1cBakYSX1jXiCC+zub9DqHAaeL82iaubLT2d sw4VhFYf7lAYdTA2Qr+gHtcYAvCgJaNVOImZvhc+kkPA+TyA85PqH+aj0gkYmw== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 27/32] test: cmd: fdt: Test fdt bootcpu Date: Mon, 27 Feb 2023 20:53:52 +0100 Message-Id: <20230227195357.98723-27-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: 86dounjdnxo8jb51cq3c8eeiz44o63mi X-MBO-RS-ID: 0491b6ada91549e4b82 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- test/cmd/fdt.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index b0c7ff52ca3..f4dd4238ad2 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -1111,6 +1111,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 Mon Feb 27 19:53:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1749126 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=xTVn5frz; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=Gsp8NbR+; 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 4PQWcn4XGsz1yWw for ; Tue, 28 Feb 2023 07:02:33 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 956FC85C00; Mon, 27 Feb 2023 20:57: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="xTVn5frz"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="Gsp8NbR+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 46E82855BA; Mon, 27 Feb 2023 20:55: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-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 A34AE85AB8 for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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 4PQWSX2kvpz9sxb; Mon, 27 Feb 2023 20:55:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527724; 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=VB66s2DTT5OZC3mB73tsuU3xRy3xh9+y0YDFlXrwqI4=; b=xTVn5frzwMeJFWoQ/e91x/SdMoIlb7nkkpXqDOUknGcVN/yC+/5XFzIJfR9s3hSXDyPqZF Z+Eh/HuWKcEwij9zb4jQklxV81+yeKN00x1Qp2/ly8V8Zi2cIp4y+yeeja4IGu2nbLHS6z qDiOJdtOot7BiNiE0B0CmliCl9yOWHYHVzQLO9VCNKU8bHKx8ObET6kjET6p36ecYjylAr MT8bZT/439iwcgjPfd+fANBJbSw8U4aQuimmzqcaD8wXQOqiDTxNXZnIStPS+Mgg5fPMYJ BUSRt7GYfR6PlXYXY10G5E48APJlRgPXhha+htVYdt7LQ5nDHaUswOXIdOBVbw== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527722; 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=VB66s2DTT5OZC3mB73tsuU3xRy3xh9+y0YDFlXrwqI4=; b=Gsp8NbR+GwdKHGe5EarGvSoVilLR5lPzlx757FNymkl5mMbgqYYOpR+0YuZmFtdx46BFTl ztPwSv3ea8JQBBSU9Ge0+P8t3f0JlA/aN6s3006GDLydQ4Cd+/tNW9Yo2k0iRXBlIXv6fH SlYt7fAAjXeT3dU1vHLIeyZp5WibTb2dnXtTFrzIYcUf8y3pWuB5uEXkzdsUbwTnfvlN1m SUBlZ+wgBH9wU2/SSdu2wjLluqyurUTS33Hp/p4URNYiIIoFMR3TY/E3pr7iuaw3pSnnvW P/rOnN2ZRNq13GZ08WwXA3C4jS0hPzK7eEPPqP+wQZRaoqllccfEjVy45mfbxw== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 28/32] test: cmd: fdt: Test fdt memory Date: Mon, 27 Feb 2023 20:53:53 +0100 Message-Id: <20230227195357.98723-28-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: rj749fb4dwpkmb97cu6ush4jgskcr3rg X-MBO-RS-ID: 827ab9e348a30b8b01b 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 --- test/cmd/fdt.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index f4dd4238ad2..ff97571a64b 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -1144,6 +1144,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 Mon Feb 27 19:53:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1749125 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=ZB3a+hkw; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=JlfE7JbF; 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 4PQWcV2LwFz1yWw for ; Tue, 28 Feb 2023 07:02:18 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 49D9F85C0C; Mon, 27 Feb 2023 20:57: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="ZB3a+hkw"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="JlfE7JbF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B9E8B855BA; Mon, 27 Feb 2023 20:55:33 +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 7840985757 for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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 4PQWSY1SLPz9sS9; Mon, 27 Feb 2023 20:55:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527725; 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=9nuV2W8gDzC7TaBTasFYm/v2pvVIyHXOHq9GXUqPcjU=; b=ZB3a+hkwhsjC6702xj+PxeMweAeEKgQNK5EMIuA/UUDUy937UZcbCNxM4EblqV6Pi6riCu CAhhN3EY9Uc8ohXnPzyoW0Ctqx5/Wgd4KoAW8bu8PgARbEfCiHnUNJXiSooG4WXO+q2leN aQCtECkdAoIU6YmA4SIGYlcoAgxY5Y/vefecftHofCLM2OHkX3j+Um5Jbmatuv7p/WpA5S cQ6puH4c/RfV812PbT6M/wNkYdWFo8kfA9aseu5m/2ivDFC6IxePd3kdzTUxL684Yz3jIL NGa5vbxRJ3+Ael+VmoVaslptB74jpinFl7LAko0NjNCYgKdlPb3VOO9IQ1OkVA== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527723; 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=9nuV2W8gDzC7TaBTasFYm/v2pvVIyHXOHq9GXUqPcjU=; b=JlfE7JbFz9f37jkBqLuH7brHLvY7p7Ds+u5ZC9tunsvBna+6DTWa10stTSlxHLQpT/8yVM UzMB/gkez900XdkrkLvP0d2X5BBJCqLpInZaXvgIs6lHo/rE5e/tXYGKY8dWOd09sgF9DE lcOE1AaRQCywzKqMy397eoHZzm2paSS5mExUqtppYKMnpAlI5T72AO8ZzHE7UmK+J52xj5 W4iG4M9JkAcQ6EkoreKTQPe1nZp+S5ri7WO4midHGofzt2A6Vm+hwwXa9oqqtZec9W98Sa BG3pftVsB7hjwa0tn5zmjVVnBw0w+1kCmmi4wdo3LVz60UnW04PkZVq9Tto0wA== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 29/32] test: cmd: fdt: Test fdt rsvmem Date: Mon, 27 Feb 2023 20:53:54 +0100 Message-Id: <20230227195357.98723-29-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: amrs1p6ydyy45ioe83d8j3m9hshn6mz3 X-MBO-RS-ID: 0bdd29fef51ef247cf3 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- test/cmd/fdt.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index ff97571a64b..8f7a62584da 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -1227,6 +1227,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 Mon Feb 27 19:53:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1749124 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=yqW5BfH1; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=AArIyITE; 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 4PQWcF020Lz1yWw for ; Tue, 28 Feb 2023 07:02:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2082285BF1; Mon, 27 Feb 2023 20:57: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="yqW5BfH1"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="AArIyITE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B6E32855BA; Mon, 27 Feb 2023 20:55:32 +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 3FE7D85AC2 for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (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 4PQWSY6LZrz9sZF; Mon, 27 Feb 2023 20:55:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527725; 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=uvqujwOetY2HLHuaDJNO3Pm6ICC9S2TDs5In/masSzU=; b=yqW5BfH1b/oL2L6q6C2wd1E3oODG+uQrz5WcE/Z0cnjgwXidgtGZR+vLH9jKZlKqD1nkWC BIPTokb09lZNNWMoznuumrsH+BqKAE5SAkjHu1kvMwQRmvPeZGcByaguTllRFk6kQ8R0BI 08U5HQY5jkONXmQFPcZYu9s11WJxGm6kKCHk5t63VqzKsrb0wOe6E+rBvTZkV5HEU4sYj0 VOqfn+O6iG0P2Bj6/WJ+KXr+OY30UyUmUHGHIjSgYzJsEj4p8GnCYbc/XNh9i7d8Nx+D8n qIKtJQpi41LLmcoClVE/OL/KW1Ro/Tay0MIpFtX07Mrn12IKbfLy5xQF2yV5Qg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527723; 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=uvqujwOetY2HLHuaDJNO3Pm6ICC9S2TDs5In/masSzU=; b=AArIyITEECXbyucqEv4zeNNJO0E4a9mmtYRHuj4cFWg3PG6lpUieULoYRGzX2rXHoWRzk+ mIfjW6Dp1qZJpS6MBOXayrDCUo9nXEDFE3uvXGmjLbbvlK/PdD2cB4peyUe/JH/7MPZe1l 2HPB4ilnlfDTlu6jVSqGWVVqBiDCP1jmgmUXLDpJIGqoLnnbOVgfnKGbZ99ICp71W1aVwH jaF5Qew8L4qsRCSbjoTdKBGc3QNrveiUgm1jrGJ12uNnAtvlicfa1lE493kIV2C+gCdOGr gX2pN3BpaFOkjo5sN9a91wIGEvcGpAZgybLdCrPEat2o3iiefZQxIZnf3whirQ== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 30/32] test: cmd: fdt: Test fdt chosen Date: Mon, 27 Feb 2023 20:53:55 +0100 Message-Id: <20230227195357.98723-30-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: zrrcbwc8s73askthcuceksnj9ij5ugxt X-MBO-RS-ID: 0f5fe4b78a5bb510562 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- test/cmd/fdt.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 8f7a62584da..721916b070d 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -1290,6 +1290,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 Mon Feb 27 19:53:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1749128 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=obl9jf5h; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=Cpo5HZAj; 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 4PQWdK2Sc4z1yWw for ; Tue, 28 Feb 2023 07:03:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DA2C385C10; Mon, 27 Feb 2023 20:57: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=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="obl9jf5h"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="Cpo5HZAj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EEA8385A35; Mon, 27 Feb 2023 20:55: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-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 1A41D85AC3 for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 4PQWSZ5tN2z9sxl; Mon, 27 Feb 2023 20:55:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527726; 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=a2CkNc9ZxT71Nlhgt7EPuB82T6NymadKAieFfzAsU+Q=; b=obl9jf5hMbvCuDLjEgclTRu24BvrbSd8UYRI3x5PX6dniJbqq5tFQAYqE3ZaTVnXup+Wbt /fRw9X8JkI0OUwBbKNWJgNbtKrDeUcxfjX/0K/rTanKg6t8cmb37SktFWRnnx/C/EWrt7d Hi2UdF30yEpUmgJT2xYfWaxentn5KWlaTuZeR+/5EAszOCawJEV0CaAqYdPvSSF3UReTHM KGeUqbaZpGSz5Wh7M4tbhiyV7qJjbXiq+Emv8qTWn7xCdk8sTsP4nKuCAHmLZa37PWgGX9 HiuBEdPPiRfuWeyo/fe40b97GRACgE3ehqK8C3WRv/bTYdLf2R88Jumt8qmqNg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527724; 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=a2CkNc9ZxT71Nlhgt7EPuB82T6NymadKAieFfzAsU+Q=; b=Cpo5HZAjRqhBeywVVZyPttXifCiNztcWIA2rPI7h0on0MTJyd2k2EdhbgVj59viItyiYsn cZ9cRVC6fjfnyZCywYufLpIFjG3k5eKP73NebkLVck7KGBV+oPQ8Hl2Y/pVfq232eW6Pej AnAx1C0k15zBuNFpuNNdMxkfWQ0+IlATa9slbghm96uiX5g4WzkLuueRCWzPBe3S6iwGrJ mwyFILEpTluzxnKp94pmCsVzAs9fj3AaXkd6VidhFz9x8wBxY1IXIjcpmD+GTxB6t60aPR CxfzVYgPUi3ANeqPF12izmo6voM+Gu3GVEbr2EDPcmk4xm+7/CEOe7C0I3xGeQ== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 31/32] test: cmd: fdt: Test fdt apply Date: Mon, 27 Feb 2023 20:53:56 +0100 Message-Id: <20230227195357.98723-31-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: m98m3tapa1jkqr7qirx4myru7kdjxnor X-MBO-RS-ID: 24bae3caaaf11659902 X-Rspamd-Queue-Id: 4PQWSZ5tN2z9sxl 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- test/cmd/fdt.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 721916b070d..02c13e2d9b9 100644 --- a/test/cmd/fdt.c +++ b/test/cmd/fdt.c @@ -1338,6 +1338,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 Mon Feb 27 19:53:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1749127 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=f71/kFbw; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=TjhqypDs; 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 4PQWd24pjtz1yWw for ; Tue, 28 Feb 2023 07:02:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D058585C04; Mon, 27 Feb 2023 20:57: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=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="f71/kFbw"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="TjhqypDs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DA5FC85757; Mon, 27 Feb 2023 20:55:35 +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 A1C5785953 for ; Mon, 27 Feb 2023 20:55: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 smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 4PQWSb3S3xz9sgw; Mon, 27 Feb 2023 20:55:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527727; 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=3ADcZxj6qFLAVDnosLj2D5KlPEXrxEtny5IY+FJqQhw=; b=f71/kFbw1B1yqaB4cqTZkHSItHxdMjKQfpCTV+Nb84SZS6f0QUqZ0XnDGtJAdhfYBJYRx7 RIm2Hksg0c0nNVgPNBDbgE0slvC3xPF7irz783rt/iUyqz2EzZucZcqQzPm8rv9ummzwv8 2RBeYoPqVNOuDGmOkebdt+lKbreiehxQo5OyFRCROQtU7CBhF6/8YWxRMJE/Fj6nd4bVpQ kezO7L6NE/CszVVPT/wsRKr+WuPmSaB0N7aNmI9BFHIDeifWej5dLy1mjWyO9lrR1BBVrY EzIpJB5chp0LwGzQmKdnWM9IK7XonHOyveeSdlMwicajzMwj2LACl/92dvSTZA== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1677527725; 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=3ADcZxj6qFLAVDnosLj2D5KlPEXrxEtny5IY+FJqQhw=; b=TjhqypDsxLT7iLRNX3r4JdG9jBHDzb60ZHMAnOzJRZh58DSqlboNjLGZ4Q5eRShZ4mJ1VV YDgyifqS+wNm6kkEgwVtrA1wmr+6hVotuJA4GsjzwP+OVkV+qSfrNw6F0GqyQLVfZHDvN+ klZTzgFMVPlbWF9Nps0Y4Y8srkC0+fD2HiUZrCl5cH1DqDYmjA0wZiFu5HJp0M25K5NsWl CZXHlcD21mKiGRKYzXCYGY2tR4NqLNbc7cFh1crxLAW6s/4A3luLio7DWFghaZ4dffRWKv B3vqrfYzT/8rmNXhJMz3poXxyf/AQQg5hNbLX5lbPv12fYzE0uycOEoAXsfAxg== To: u-boot@lists.denx.de Cc: Marek Vasut , Heinrich Schuchardt , Simon Glass , Tom Rini Subject: [PATCH 32/32] test: cmd: fdt: Add list of remaining missing tests Date: Mon, 27 Feb 2023 20:53:57 +0100 Message-Id: <20230227195357.98723-32-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> References: <20230227195357.98723-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-META: 3zirrp1q5zhjgp615n4itnu85e85ngt6 X-MBO-RS-ID: 63ba120e7e104e76f02 X-Rspamd-Queue-Id: 4PQWSb3S3xz9sgw 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 --- Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini --- test/cmd/fdt.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/cmd/fdt.c b/test/cmd/fdt.c index 02c13e2d9b9..cb9379cdd4f 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)