From patchwork Wed Sep 21 14:21:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1680728 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 (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=knaS1wev; 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 4MXgfj3STNz1ypX for ; Thu, 22 Sep 2022 00:25:01 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8288A84CD5; Wed, 21 Sep 2022 16:23:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="knaS1wev"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 618AF84CCF; Wed, 21 Sep 2022 16:22:55 +0200 (CEST) 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,DKIMWL_WL_HIGH, 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 mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7BA3384C9C for ; Wed, 21 Sep 2022 16:22:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-ej1-x62c.google.com with SMTP id y17so14037880ejo.6 for ; Wed, 21 Sep 2022 07:22:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=uGZTZtSpIveZVHVabm4fW7tFeRWK/ZaOuIY30cY3TCk=; b=knaS1wevR3gwHJ7TkVBGRjocFIqp7v1JHwPl5QYabPeiWKuseIVM0nvDzAULw1prl2 EPbInlB4MzvcXTiTFMqgri8TprvNEIofHb4gtiHn1+4lPrYjsl6Zs8/azZcnY+7zuOGE VClRAFM+KLpFnRSTZ0nLZocXFz79JEoNfYslw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=uGZTZtSpIveZVHVabm4fW7tFeRWK/ZaOuIY30cY3TCk=; b=y7Sdb5JE4KSxFnnYOs0sWYtRoOCSGgTKsFJv5DFXPN+IBqZcfLIvoBtPhlW4jGKWFq k2XXPlIw+9+uc0wV0rcLaGx3bUgg8b2EoNGHNdSHAOkhKlAZgWfNYn+jBZD3egkvvL1x z2lZv/JKaOMpiyvF9Sie8D/9ZwUjnbLdXsYUcXSL9VOZ1rv4NGmI/6XkMko4VIXc96L1 oJblQOmUn0dcaDVayzehLK3oFW6MBF+oZGgmAXyMoz/02OqI/P3+6Y/OzlhPczGfuEDv EtNgdPUrorVBtpBqQ+NyvMkCQgRq7eno8Pg4YlPtjpv8vU0sbw5LtWC/UHTP3eJNm+aZ 3pdA== X-Gm-Message-State: ACrzQf2a4VaG32zWhuQB0qFMucGCLABfPHj2PJBiFulqOrHKS5OwZYT+ XE0Iu/ZlcJcaTTBuXpy4gNrOqIzc+V7jI+dj X-Google-Smtp-Source: AMsMyM7VC9ZY4N8JAIC9hO6NvHUITsCMIgDn9mMNFQx811EuhKBNlpBV8azHYKLwXFiIDAU+jbFvqA== X-Received: by 2002:a17:907:746:b0:741:4a1b:cb1f with SMTP id xc6-20020a170907074600b007414a1bcb1fmr20398991ejb.370.1663770157938; Wed, 21 Sep 2022 07:22:37 -0700 (PDT) Received: from sjg1.roam.corp.google.com (66.218.241.83.in-addr.dgcsystems.net. [83.241.218.66]) by smtp.gmail.com with ESMTPSA id 17-20020a170906219100b007807e4f6b30sm1387089eju.103.2022.09.21.07.22.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 07:22:37 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Andrew Scull , Etienne Carriere , Heinrich Schuchardt , =?utf-8?q?Marek_Beh=C3=BAn?= , Patrick Delaunay , Philippe Reynes , Ramon Fried , Sean Anderson Subject: [PATCH v2 15/15] sandbox: Add a test for SCSI Date: Wed, 21 Sep 2022 16:21:47 +0200 Message-Id: <20220921142147.1083886-16-sjg@chromium.org> X-Mailer: git-send-email 2.37.3.968.ga6b4b080e4-goog In-Reply-To: <20220921142147.1083886-1-sjg@chromium.org> References: <20220921142147.1083886-1-sjg@chromium.org> MIME-Version: 1.0 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 a simple uclass test for SCSI. It reads the partition table from a disk image and checks that it looks correct. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) arch/sandbox/dts/sandbox.dtsi | 4 ++++ arch/sandbox/dts/test.dts | 5 +++++ test/dm/Makefile | 1 + test/dm/scsi.c | 39 +++++++++++++++++++++++++++++++++++ test/py/tests/test_ut.py | 9 ++++++++ 5 files changed, 58 insertions(+) create mode 100644 test/dm/scsi.c diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi index 56e6b38bfa7..de7a218f457 100644 --- a/arch/sandbox/dts/sandbox.dtsi +++ b/arch/sandbox/dts/sandbox.dtsi @@ -245,6 +245,10 @@ compatible = "sandbox,sandbox-rng"; }; + scsi { + compatible = "sandbox,scsi"; + }; + sound { compatible = "sandbox,sound"; cpu { diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index c7fffa2da27..4ee471238ee 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -1158,6 +1158,11 @@ backlight = <&backlight 0 100>; }; + scsi { + compatible = "sandbox,scsi"; + sandbox,filepath = "scsi.img"; + }; + smem@0 { compatible = "sandbox,smem"; }; diff --git a/test/dm/Makefile b/test/dm/Makefile index 7543df8823c..5178daa7cf0 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -91,6 +91,7 @@ obj-$(CONFIG_DM_REGULATOR) += regulator.o obj-$(CONFIG_DM_RNG) += rng.o obj-$(CONFIG_DM_RTC) += rtc.o obj-$(CONFIG_SCMI_FIRMWARE) += scmi.o +obj-$(CONFIG_SCSI) += scsi.o obj-$(CONFIG_DM_SERIAL) += serial.o obj-$(CONFIG_DM_SPI_FLASH) += sf.o obj-$(CONFIG_SIMPLE_BUS) += simple-bus.o diff --git a/test/dm/scsi.c b/test/dm/scsi.c new file mode 100644 index 00000000000..380cfc88bab --- /dev/null +++ b/test/dm/scsi.c @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2015 Google, Inc + */ + +#include +#include +#include +#include +#include +#include +#include + +/* Test that sandbox SCSI works correctly */ +static int dm_test_scsi_base(struct unit_test_state *uts) +{ + const struct disk_partition *info; + const struct disk_part *part; + struct udevice *dev; + + ut_assertok(scsi_scan(false)); + + /* + * We expect some sort of partition on the disk image, created by + * test_ut_dm_init() + */ + ut_assertok(uclass_first_device_err(UCLASS_PARTITION, &dev)); + + part = dev_get_uclass_plat(dev); + ut_asserteq(1, part->partnum); + + info = &part->gpt_part_info; + ut_asserteq_str("sda1", info->name); + ut_asserteq_str("U-Boot", info->type); + ut_asserteq(0x83 /* linux */, info->sys_ind); + + return 0; +} +DM_TEST(dm_test_scsi_base, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py index 35fb393c1ff..9d423903736 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -114,6 +114,15 @@ def test_ut_dm_init(u_boot_console): with open(fn, 'wb') as fh: fh.write(data) + # Create a file with a single partition + fn = u_boot_console.config.source_dir + '/scsi.img' + if not os.path.exists(fn): + data = b'\x00' * (2 * 1024 * 1024) + with open(fn, 'wb') as fh: + fh.write(data) + u_boot_utils.run_and_log( + u_boot_console, f'sfdisk {fn}', stdin=b'type=83') + @pytest.mark.buildconfigspec('cmd_bootflow') def test_ut_dm_init_bootstd(u_boot_console): """Initialise data for bootflow tests"""