From patchwork Wed Sep 3 13:36:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 195 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756906627; bh=XgHbUyGYpnPh2k0AiLiOCzX9iMAoRnVaZ38tsMJxjm0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=WdOCdq4F2cQBzeyXNfuvyrmeOjnGBkDcP14g5HrLgBXp1bE+iZORYwDFfq19SmOsn YwluGsrzzohL1XNZ1P8wVSmCb05DsDHEedSJNNQ9LQcdndhjusHLZqSCtufvHiNYFv /vM0izjpfSNI31QBNVoRacA2J9qFiQu3mqRep1hCTtMYmtSI+SCr9cScP0TSRMNpVk 71/dOEpoMyTBuUWxIRHhUx3FNdK/b50TachtW2uibe1I6OzsLzFt87G73zea90xmHH 5FJs5NuV0h+uBBulYiPsb/cuCzggs4z0Z0RkQdjHPFfHOp18S/8zLRbonfz0kuE1uN FpSiJFBsqH+tg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 609736791D for ; Wed, 3 Sep 2025 07:37:07 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id NDUr27o0Ei-6 for ; Wed, 3 Sep 2025 07:37:07 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756906626; bh=XgHbUyGYpnPh2k0AiLiOCzX9iMAoRnVaZ38tsMJxjm0=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ZicPlqymtUwyaNHjRLeXBn2J8ubxzIs6zGWtaTwjowAWqsmSDbLWw8BATk5voi8+q MyLFKehrS6zxnP1kFjBHvHkxRPIXd5ol371ffDxVICVYhZWdSKlWEa19OBeHi7K+7y kxd4vsyRwXLKJdUmMPNUKE0qJ8hsr9QJ4UEglG29T94sqRPn0XfTAgfLVkoA19XlGx dm9zde/CajRD8fcFX9mIYDCOL3jVDwFgCzXpjsz3QMZUY56gTqh20gTdSCCsNCB1nk OyKaDHc2NCT39qtZpQQvMKEwgPNxquOdHI/6BzkOy8REQBaq1cwn0yLXqurLNP+wK1 gpRHQyRvp6LQw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 72555678F3 for ; Wed, 3 Sep 2025 07:37:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756906624; bh=zS2ILdyHOr1+5aYxM8RZWQWZGhF2iBt21Mq2SF/S6W4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KRqMCnuTBb4NmC/SeIdFDLSutNSXrGxdSJXCUNRG5hxpf0RoB5M2FN5TAH5UM7BQo sn4FdRm2KP1L0AM+cPF7kUM7uF0x8db0+VnQKwjclKwJsvCL4mf7B2xFaHkGTtqS1p Qc9heVEBuqpn3gNW0utI0L/71psUf48n8O1UFcK+q1xb02MWTYL/WC9j4pxgCUdRGT Uzavm3nUQsMhTNK0YFUZZwdxse0ABcDTz+PSoLX0h8b9RFEeJe/De1NfKuGdC5mHKl kYw3G97Vwq29Sm8x+O2ulG0annYhwnj4GvbuiZnBcB4KXLV/wNBT7VeYnIZM408hus pECPh5s1gfPVg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EB5915FE1B; Wed, 3 Sep 2025 07:37:04 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id mEpETH-qBykD; Wed, 3 Sep 2025 07:37:04 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756906624; bh=xMDcyF+hEK1NwdLUSyqsHGHdnYLHcOnF+76ui1N5BMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uRwU30POPA4gx/shAVpGk15aguXlfXIJE7c5T3QQXen54RoHSwIhhLjnOXkUVc7Lr 7x6xgZ08rjSXY8KQNws0lwzsvzZfOMSX1FekVH0UEVWE0LO8KXvd7Lgof61PoatH/+ TO+ugHueutzNza+y8oX56RWinWu66TvZ0ANQEH7jldS8jQM/LzIoMAD8T5yMkum9gl p5574UVKYgjaUnLbl6jEbfGqIsr6LbiI7ye1hmWKIVl3KFlEKYD648rDMwVxjFr8Vv x8COg7eXzEhXLX/wQv3iUR+yUpfkSJpSMu6fLAOb2xaJnzfC7PbjblHVBLV+uM11j/ 1pb/gYfkVfrWA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 485FD5FCF5; Wed, 3 Sep 2025 07:37:04 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Wed, 3 Sep 2025 07:36:06 -0600 Message-ID: <20250903133639.3235920-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250903133639.3235920-1-sjg@u-boot.org> References: <20250903133639.3235920-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: LBI5POS2T3ICKUOO2GAQ3K2ISEFCTYV6 X-Message-ID-Hash: LBI5POS2T3ICKUOO2GAQ3K2ISEFCTYV6 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 06/25] smbios: Provide a sandbox test List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Create a sandbox test for the smbios command. This checks that the expected output is produced. Drop the unnecessary 0x before each address, since U-Boot uses hex by default. Co-developed-by: Claude Signed-off-by: Simon Glass --- cmd/smbios.c | 4 +- test/cmd/Makefile | 1 + test/cmd/smbios.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 test/cmd/smbios.c diff --git a/cmd/smbios.c b/cmd/smbios.c index 4f672d3f4ad..ef4bc54644b 100644 --- a/cmd/smbios.c +++ b/cmd/smbios.c @@ -489,12 +489,12 @@ static int do_smbios(struct cmd_tbl *cmdtp, int flag, int argc, (info.version >> 8) & 0xff, info.version & 0xff); printf("%d structures occupying %d bytes\n", info.count, info.max_size); - printf("Table at 0x%llx\n", + printf("Table at %llx\n", (unsigned long long)map_to_sysmem(info.table)); for (struct smbios_header *pos = info.table; pos; pos = smbios_next_table(&info, pos)) { - printf("\nHandle 0x%04x, DMI type %d, %d bytes at 0x%llx\n", + printf("\nHandle 0x%04x, DMI type %d, %d bytes at %llx\n", pos->handle, pos->type, pos->length, (unsigned long long)map_to_sysmem(pos)); switch (pos->type) { diff --git a/test/cmd/Makefile b/test/cmd/Makefile index 0fa6599dfd7..ec39bd46e76 100644 --- a/test/cmd/Makefile +++ b/test/cmd/Makefile @@ -38,6 +38,7 @@ obj-$(CONFIG_CMD_PINMUX) += pinmux.o obj-$(CONFIG_CMD_PWM) += pwm.o obj-$(CONFIG_CMD_READ) += rw.o obj-$(CONFIG_CMD_SETEXPR) += setexpr.o +obj-$(CONFIG_CMD_SMBIOS) += smbios.o obj-$(CONFIG_CMD_TEMPERATURE) += temperature.o ifdef CONFIG_NET obj-$(CONFIG_CMD_WGET) += wget.o diff --git a/test/cmd/smbios.c b/test/cmd/smbios.c new file mode 100644 index 00000000000..e8ed38af2ed --- /dev/null +++ b/test/cmd/smbios.c @@ -0,0 +1,137 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test for smbios command + * + * Copyright 2025 Simon Glass + */ + +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +/* Test the 'smbios' command */ +static int cmd_smbios_test(struct unit_test_state *uts) +{ + uint hdr_size = ALIGN(sizeof(struct smbios3_entry), 16); + + /* Test basic smbios command and verify expected output */ + ut_assertok(run_command("smbios", 0)); + + ut_assert_nextline("SMBIOS 3.7.0 present."); + ut_assert_nextlinen("7 structures occupying "); + ut_assert_nextlinen("Table at %lx", gd_smbios_start() + hdr_size); + ut_assert_nextline_empty(); + ut_assert_nextlinen("Handle 0x0000, DMI type 0, 26 bytes at"); + ut_assert_nextline("BIOS Information"); + ut_assert_nextline("\tVendor: U-Boot"); + ut_assert_nextlinen("\tBIOS Version: "); + ut_assert_nextlinen("\tBIOS Release Date:"); + ut_assert_nextline("\tBIOS ROM Size: 0x00"); + ut_assert_nextline("\tBIOS Characteristics: 0x0000000000010880"); + ut_assert_nextline("\tBIOS Characteristics Extension Byte 1: 0x01"); + ut_assert_nextline("\tBIOS Characteristics Extension Byte 2: 0x0c"); + ut_assert_nextlinen("\tSystem BIOS Major Release:"); + ut_assert_nextlinen("\tSystem BIOS Minor Release:"); + ut_assert_nextline("\tEmbedded Controller Firmware Major Release: 0xff"); + ut_assert_nextline("\tEmbedded Controller Firmware Minor Release: 0xff"); + ut_assert_nextline("\tExtended BIOS ROM Size: 0x0000"); + ut_assert_nextline_empty(); + ut_assert_nextlinen("Handle 0x0001, DMI type 1, 27 bytes at"); + ut_assert_nextline("System Information"); + ut_assert_nextline("\tManufacturer: sandbox"); + ut_assert_nextline("\tProduct Name: sandbox"); + ut_assert_nextline("\tVersion: "); + ut_assert_nextline("\tSerial Number: "); + ut_assert_nextline("\tUUID: 00000000-0000-0000-0000-000000000000"); + ut_assert_nextline("\tWake-up Type: Unknown"); + ut_assert_nextline("\tSKU Number: "); + ut_assert_nextline("\tFamily: "); + ut_assert_nextline_empty(); + ut_assert_nextlinen("Handle 0x0002, DMI type 2, 15 bytes at"); + ut_assert_nextline("Baseboard Information"); + ut_assert_nextline("\tManufacturer: sandbox"); + ut_assert_nextline("\tProduct Name: sandbox"); + ut_assert_nextline("\tVersion: "); + ut_assert_nextline("\tSerial Number: "); + ut_assert_nextline("\tAsset Tag: "); + ut_assert_nextline("\tFeature Flags: 0x00"); + ut_assert_nextline("\tChassis Location: "); + ut_assert_nextline("\tChassis Handle: 0x0003"); + ut_assert_nextline("\tBoard Type: Unknown"); + ut_assert_nextline("\tNumber of Contained Object Handles: 0x00"); + ut_assert_nextline_empty(); + ut_assert_nextlinen("Handle 0x0003, DMI type 3, 22 bytes at"); + ut_assert_nextline("Baseboard Information"); + ut_assert_nextline("\tManufacturer: "); + ut_assert_nextline("\tType: 0x02"); + ut_assert_nextline("\tVersion: "); + ut_assert_nextline("\tSerial Number: "); + ut_assert_nextline("\tAsset Tag: "); + ut_assert_nextline("\tBoot-up State: Unknown"); + ut_assert_nextline("\tPower Supply State: Unknown"); + ut_assert_nextline("\tThermal State: Unknown"); + ut_assert_nextline("\tSecurity Status: Unknown"); + ut_assert_nextline("\tOEM-defined: 0x00000000"); + ut_assert_nextline("\tHeight: 0x00"); + ut_assert_nextline("\tNumber of Power Cords: 0x00"); + ut_assert_nextline("\tContained Element Count: 0x00"); + ut_assert_nextline("\tContained Element Record Length: 0x00"); + ut_assert_nextline("\tSKU Number: "); + ut_assert_nextline_empty(); + ut_assert_nextlinen("Handle 0x0004, DMI type 4, 50 bytes at"); + ut_assert_nextline("Processor Information:"); + ut_assert_nextline("\tSocket Designation: "); + ut_assert_nextline("\tProcessor Type: Unknown"); + ut_assert_nextline("\tProcessor Family: Unknown"); + ut_assert_nextline("\tProcessor Manufacturer: Languid Example Garbage Inc."); + ut_assert_nextline("\tProcessor ID word 0: 0x00000000"); + ut_assert_nextline("\tProcessor ID word 1: 0x00000000"); + ut_assert_nextline("\tProcessor Version: LEG Inc. SuperMegaUltraTurbo CPU No. 1"); + ut_assert_nextline("\tVoltage: 0x00"); + ut_assert_nextline("\tExternal Clock: 0x0000"); + ut_assert_nextline("\tMax Speed: 0x0000"); + ut_assert_nextline("\tCurrent Speed: 0x0000"); + ut_assert_nextline("\tStatus: 0x00"); + ut_assert_nextline("\tProcessor Upgrade: Unknown"); + ut_assert_nextline("\tL1 Cache Handle: 0xffff"); + ut_assert_nextline("\tL2 Cache Handle: 0xffff"); + ut_assert_nextline("\tL3 Cache Handle: 0xffff"); + ut_assert_nextline("\tSerial Number: "); + ut_assert_nextline("\tAsset Tag: "); + ut_assert_nextline("\tPart Number: "); + ut_assert_nextline("\tCore Count: 0x00"); + ut_assert_nextline("\tCore Enabled: 0x00"); + ut_assert_nextline("\tThread Count: 0x00"); + ut_assert_nextline("\tProcessor Characteristics: 0x0000"); + ut_assert_nextline("\tProcessor Family 2: [0000]"); + ut_assert_nextline("\tCore Count 2: 0x0000"); + ut_assert_nextline("\tCore Enabled 2: 0x0000"); + ut_assert_nextline("\tThread Count 2: 0x0000"); + ut_assert_nextline("\tThread Enabled: 0x0000"); + ut_assert_nextline_empty(); + ut_assert_nextlinen("Handle 0x0005, DMI type 32, 11 bytes at"); + ut_assert_nextline("Header and Data:"); + ut_assert_nextline("\t00000000: 20 0b 05 00 00 00 00 00 00 00 00"); + ut_assert_nextline_empty(); + ut_assert_nextlinen("Handle 0x0006, DMI type 127, 4 bytes at"); + ut_assert_nextline("End Of Table"); + ut_assert_console_end(); + + return 0; +} +CMD_TEST(cmd_smbios_test, UTF_CONSOLE); + +/* Test invalid smbios command */ +static int cmd_smbios_invalid_test(struct unit_test_state *uts) +{ + /* Test smbios command with invalid arguments */ + ut_asserteq(1, run_command("smbios invalid", 0)); + + return 0; +} +CMD_TEST(cmd_smbios_invalid_test, UTF_CONSOLE);