From patchwork Tue Feb 2 15:23:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1434783 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=secospa.onmicrosoft.com header.i=@secospa.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-secospa-onmicrosoft-com header.b=xQAKWJ20; 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DVTBv4Xqrz9tT8 for ; Wed, 3 Feb 2021 02:24:55 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8748582674; Tue, 2 Feb 2021 16:24:32 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=seco.com 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=secospa.onmicrosoft.com header.i=@secospa.onmicrosoft.com header.b="xQAKWJ20"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 24F37801D8; Tue, 2 Feb 2021 16:24:29 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on20626.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1b::626]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 16F54801D8 for ; Tue, 2 Feb 2021 16:24:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N+sEuMEUbRjy8B/R1J0kkcuitWi17MmVUJfUtw4Suahoq88DzuQsFmwwb5zrt6MZNY3KMbHncPmybjjptFKrb9iin9KtZ8hPElrCGikZvDXHcLPdfIcrw196mnVvK74tVDAfxPXqBsMniYn9Jdf4nDSQrLbg3hv9GBbWp4AE+Okgc5zLHD9ROfgm92srrWZcgar+YA3AGoD2dF398PdtTJUiz1KfP35ocRCGySq8mZz1+5s9B2IxcOG/F+uiEirKXAwYezfSGrZ9sbd8/dLsDAbQdjBElU9/7uIewBuwXvTiz4ITZhnHhMTCcHUhhHz5AT7Az2kuAHXM8zTDil9V8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PWu4XWfXcmAst4LHe0PwX0syT5XIp1GySIK8L3nRZ38=; b=BxlJkW1Lqod7+XvMKbFMs/uEXyhRtdt1IZTKQADA3HRWVwJb7SAvG/oGqFYuYklo1Gecf1Rd9hl75Znw18w5ZIWXHqtfiS+agRYOzcCp8lMVasOArNhI0vrx6/RKsSi/NWNxsC4rD0nhQIAOmu+/lCAcybmdqD7MLpCNOfgUc2WlozZXRBsZmuLhgB6iNgRKUyMfUxkAkFSKNEUNP+5wme4HJpdkOPSGwZqjITBMAs6BOwL2KivgkxsqbljTYxQjcmlWcnLgpeLEJmhnZVDQB32wOiW/tRzR2Mn+6IAWgpEeuENPw58DgnxlpZNnlY01wOC0aL/aFL0WXFvdZ7f+bg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secospa.onmicrosoft.com; s=selector2-secospa-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PWu4XWfXcmAst4LHe0PwX0syT5XIp1GySIK8L3nRZ38=; b=xQAKWJ20n76GAbRWB/pQWo7gL3eAO1OzUzkDLlc71W2X9dZTkoZU5qiccdfp0zrOsuR2GjLTlaE5I6i+tYCS/TkPpZ5l+MQyGrG+8BLNHaditVkkqP+yxTP7Q+uDTjN2tZqg3KYYZo2UgwSkOfDCWzb+JxvTez4PK6BExlnG5Qg= Authentication-Results: lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=seco.com; Received: from AM9PR03MB7251.eurprd03.prod.outlook.com (2603:10a6:20b:26e::16) by VI1PR0302MB2816.eurprd03.prod.outlook.com (2603:10a6:800:e4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.19; Tue, 2 Feb 2021 15:24:22 +0000 Received: from AM9PR03MB7251.eurprd03.prod.outlook.com ([fe80::a8f2:7dd:46e5:8526]) by AM9PR03MB7251.eurprd03.prod.outlook.com ([fe80::a8f2:7dd:46e5:8526%6]) with mapi id 15.20.3805.028; Tue, 2 Feb 2021 15:24:22 +0000 From: Sean Anderson To: u-boot@lists.denx.de Cc: Lukasz Majewski , Simon Glass , Sean Anderson , Mario Six Subject: [PATCH v4 2/9] test: dm: Add test for fastboot mmc partition naming Date: Tue, 2 Feb 2021 10:23:45 -0500 Message-Id: <20210202152352.33245-3-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210202152352.33245-1-sean.anderson@seco.com> References: <20210202152352.33245-1-sean.anderson@seco.com> X-Originating-IP: [50.195.82.171] X-ClientProxiedBy: BL1PR13CA0432.namprd13.prod.outlook.com (2603:10b6:208:2c3::17) To AM9PR03MB7251.eurprd03.prod.outlook.com (2603:10a6:20b:26e::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from plantagenet.inhand.com (50.195.82.171) by BL1PR13CA0432.namprd13.prod.outlook.com (2603:10b6:208:2c3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.16 via Frontend Transport; Tue, 2 Feb 2021 15:24:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cc3fb13a-599b-45ab-cbbc-08d8c78e9e2a X-MS-TrafficTypeDiagnostic: VI1PR0302MB2816: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:209; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NHnMr6XhAn1/QwxyRPHYVP/sXPRCq6tJWQOYEx+Sial4ZuFOOWgV2XN/YaHW7nO7nEuz80DQm56+NLNrodQ27sB7v3lUFm45wVppBrZdElH8kuR0jE1qjQtsPOiTWb7hQoFifnUd0ZMMJ/l2JoCdHYIuZo5ex50rW++YM54HgWi4DwcaqAZy1omi2h0BB2wAdrggpKI8zemL81D2PToghlczu9e7WVHAYEmNVvDbWr6hPgUpewWSvC9OhBtkZzf27wt6DDERkECMiXXBFMXFeLE8325EwEXs7fhou9iUJ9gc3e1T+7qQ7FfojKx8xev32P/aoD4w+cddE/OyIHyXOJuzj6WJ3uWODv5WkLVzvsfTA83c/vp2mQ8DorYnIpdpv2WF30vc+Fcvocilt68p9R9VA5+AKdqb0XWpYKo/p/BC+ZXEEkNjd6dEuI1cuLAIotqowE27lgGj0XD7mwZA2EWeKItZ5nmVSy+24PJifTp4a3nEbzmcE+RgBzBkrVYUBvstMD2+pjihRDjXQmaRBA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR03MB7251.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(396003)(346002)(39850400004)(366004)(136003)(54906003)(6512007)(1076003)(6916009)(316002)(478600001)(66476007)(66556008)(6666004)(5660300002)(16526019)(66946007)(2616005)(83380400001)(6506007)(2906002)(6486002)(52116002)(186003)(44832011)(4326008)(956004)(36756003)(8676002)(8936002)(86362001)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: B66G1NaQskzmPYWWhB33Z7+AUe3UQfoFEw3rD2ermggtAaGYE5oz7Z2r5OlLHIhLXueWqFoTqgr9/R2c77swBZBzd8w8wId4eLaMDL/1F3ILfCENLAW1WxyeDkSSJLxgde1w3sqHS9sceEusxbbpoyI+VCkeMdxYVgoLMYv1JbhNg104CnE5roVdZAhpu8ZGdHZ9oaYyb3vUlmjfAPHYljd7/n3pu0jHNSdLVLNt4ifMna5GZAZBugQkA/zPSEoo5k/CZp1G85zXYHnwE5Cep8T+qEG0GZN/PKSkWHVUL/mLdniFpz7E2tMmF/jXGNEgL9r1UnWi0iKJ98jWQWKr5ZsemktnlviikHgSt0/7Mw8TWl2qwWn7G1/Jl6IAyn/1ZsPuqHgJK8z+aB0REnIgCDy8KjigqHIk3Pzcy9qR1Hek4Rve01mFNywRk3YcBG7cVa8PFzhQcOLUl68Jmgh8xVZU3jSneKh6SeDE/3SIaLLeiFnAIxGvIZBy1lura8Cm66Ck6KDkMrrR4oyIFLTeCeL9o4UVwzPnGcacf5CGLIcUtWRoeUiQgaoa1c4QVeMR+Wl1RnPHq6XAy5xtGpGlUtdkR/kf9AXjZm2qnlm4qc5RJDEerwl1/E8LUfIWhlvLww/H14XxlpfuG/ZspMJMFU19w/QegUe4VI68UhYhJzlfFLC8Y83uIsYH/RzYsavPZKgwJKJGQMZc6ZPWAy7VcXNBpyXf3fRezdqckwlZnQN8qvz2rhkynfB93sFUm1ndB+n85eyGJSj5kVHBJ8a276LJJ52DrFfI/XRIJ8Cd5KJYK98I3zPQLjfHUEnhxN5FU7uh6na6WdMcT0JkO/+loNyYvzGCAIQafe8S3kblZnItFneRLT4uMOSKpaqKQt/Xp5ji6OR99JpFKz4gwsF23c5Kx7velYUbtiwXLLbWE8iDZ5acQKGQ2fFWztiO7wQqOFOR6aQC5bkz9UImTzS9QgfXe0WqJ51xuj4mh+eTIPUZkfeCQVcWO9zcyQCmoiZSg6JGwjIEh9lP/IrP6Hqk2G1dXNuI7dh2PFNsnVWYYi0iREXxi05udWUbFZOAr+qm X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc3fb13a-599b-45ab-cbbc-08d8c78e9e2a X-MS-Exchange-CrossTenant-AuthSource: AM9PR03MB7251.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2021 15:24:22.6799 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: A+2wxn2l18uiRzRzBK0+MKx6TRYF2lOLBaiFR6mUJs2fECc78GQSKH/Emqgf1nBKm1npGxhzDbn3T1cU0NosQg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0302MB2816 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean This test verifies the mapping between fastboot partitions and partitions as understood by U-Boot. It also tests the creation of GPT partitions, though that is not the primary goal. Signed-off-by: Sean Anderson Reviewed-by: Simon Glass --- (no changes since v1) configs/sandbox64_defconfig | 2 ++ configs/sandbox_defconfig | 2 ++ test/dm/Makefile | 3 ++ test/dm/fastboot.c | 64 +++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 test/dm/fastboot.c diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig index 4e67819559..9fe07f0c38 100644 --- a/configs/sandbox64_defconfig +++ b/configs/sandbox64_defconfig @@ -110,6 +110,8 @@ CONFIG_DM_DEMO=y CONFIG_DM_DEMO_SIMPLE=y CONFIG_DM_DEMO_SHAPE=y CONFIG_DFU_SF=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_GPIO_HOG=y CONFIG_DM_GPIO_LOOKUP_LABEL=y CONFIG_PM8916_GPIO=y diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 0c7674efc9..269288783f 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -135,6 +135,8 @@ CONFIG_DFU_SF=y CONFIG_DMA=y CONFIG_DMA_CHANNELS=y CONFIG_SANDBOX_DMA=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 CONFIG_GPIO_HOG=y CONFIG_DM_GPIO_LOOKUP_LABEL=y CONFIG_PM8916_GPIO=y diff --git a/test/dm/Makefile b/test/dm/Makefile index 46e076ed09..be4385c709 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -91,5 +91,8 @@ obj-$(CONFIG_SCMI_FIRMWARE) += scmi.o ifneq ($(CONFIG_PINMUX),) obj-$(CONFIG_PINCONF) += pinmux.o endif +ifneq ($(CONFIG_EFI_PARTITION)$(CONFIG_FASTBOOT_FLASH_MMC),) +obj-y += fastboot.o +endif endif endif # !SPL diff --git a/test/dm/fastboot.c b/test/dm/fastboot.c new file mode 100644 index 0000000000..8f905d8fa8 --- /dev/null +++ b/test/dm/fastboot.c @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2015 Google, Inc + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define FB_ALIAS_PREFIX "fastboot_partition_alias_" + +static int dm_test_fastboot_mmc_part(struct unit_test_state *uts) +{ + char response[FASTBOOT_RESPONSE_LEN] = {0}; + char str_disk_guid[UUID_STR_LEN + 1]; + struct blk_desc *mmc_dev_desc, *fb_dev_desc; + struct disk_partition part_info; + struct disk_partition parts[2] = { + { + .start = 48, /* GPT data takes up the first 34 blocks or so */ + .size = 1, + .name = "test1", + }, + { + .start = 49, + .size = 1, + .name = "test2", + }, + }; + + ut_assertok(blk_get_device_by_str("mmc", + __stringify(CONFIG_FASTBOOT_FLASH_MMC_DEV), + &mmc_dev_desc)); + if (CONFIG_IS_ENABLED(RANDOM_UUID)) { + gen_rand_uuid_str(parts[0].uuid, UUID_STR_FORMAT_STD); + gen_rand_uuid_str(parts[1].uuid, UUID_STR_FORMAT_STD); + gen_rand_uuid_str(str_disk_guid, UUID_STR_FORMAT_STD); + } + ut_assertok(gpt_restore(mmc_dev_desc, str_disk_guid, parts, + ARRAY_SIZE(parts))); + + /* "Classic" partition labels */ + ut_asserteq(1, fastboot_mmc_get_part_info("test1", &fb_dev_desc, + &part_info, response)); + ut_asserteq(2, fastboot_mmc_get_part_info("test2", &fb_dev_desc, + &part_info, response)); + + /* Test aliases */ + ut_assertnull(env_get(FB_ALIAS_PREFIX "test3")); + ut_assertok(env_set(FB_ALIAS_PREFIX "test3", "test1")); + ut_asserteq(1, fastboot_mmc_get_part_info("test3", &fb_dev_desc, + &part_info, response)); + ut_assertok(env_set(FB_ALIAS_PREFIX "test3", NULL)); + + return 0; +} +DM_TEST(dm_test_fastboot_mmc_part, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);