From patchwork Fri May 31 13:50:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 800542 Delivered-To: patch@linaro.org Received: by 2002:a5d:65c4:0:b0:35b:5a80:51b4 with SMTP id e4csp742691wrw; Fri, 31 May 2024 06:52:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVJ3TQcSU/LjzMXRqFMadx0zF0NlX+HE30zwxA/4rD5qY0RxRSfXi4PIM15YH5hiSma3YURH7ZQrPb5pfUl3nzU X-Google-Smtp-Source: AGHT+IFp6G/M9h9I0IPUZ1YPyoB8PJkzTQvWxNUp7rm2NnPz0wfPSfzhZelKzit5Favnk5QIRitD X-Received: by 2002:a05:6512:214e:b0:51b:528e:ce7d with SMTP id 2adb3069b0e04-52b89563236mr1381719e87.34.1717163531769; Fri, 31 May 2024 06:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717163531; cv=none; d=google.com; s=arc-20160816; b=e8LcW2ojNp0Mxp0iN58UmIwqGP+ULt9QHEucJ6PzlYtodSQj2cMUzyleFzNz6WJR+h 1gQBzzjrVVt410LdUX4tOTOWc+CGLvBx7Rx7KBCP9LD5vvPta439PvUizFTjhrYOtmsE EKalOK2aW3EcaqUGQQY0y+2IQR6b1c4BDfTsyjUfFFhOSHDuSImwAiDDyMcPtSxMGCy3 mjPnVWyrfTW1qMe7dJAbEfG7LXv4O1Aeh3Q7wejd1ZXD4j7VbaZax+fhb/hVxQ9Jimq7 FKQkFW7cgL8pZQH2/DlV2iq0yXUlXh3gheKY9ptS7rDPnLTE7g/KedtkJxlyhunLRQ9U FUtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=7HsaSU/GVMju5xN/sg3znUxqC7KLIcXCPlkqzo9nf7Q=; fh=zX7U4vIu7oNTjjMAKTNKYyyHcAJ73i3J88TmmXEVpfw=; b=b0wxlBZBaafsoiXtm9WUEDjn3rmm/n6lP9TQ6rynOMw+0rsWaycE7zMdTo+7PhPAYv LTOnAVOVeDo2nVvDOGXRFkanMWiBX9DcuYrGQBtjR79yYeJja1Q3R03F4dGtVuIuU+fB 6mExnKFc/UJ5rhu7MLmYb8/5DgF05MID77A/9InYswndcEVvWi5UdNJ6juuYuPGEKTjH 1Uygm8zsG4E7XLB8MQTEyxt3kRyHyxyRYIFYXCCg61RIgO5ToK6++ljSXn1A9j/Xff6m R82rblbQFWHHJj1Mi2+g/pd1v3B5SV2dCSk6wF7/w10OAjh6YeguveAPrLDZOpmp9UYu +MKw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BqYgSCTh; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-a67e73f716csi93721666b.229.2024.05.31.06.52.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 06:52:11 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BqYgSCTh; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9E386887DB; Fri, 31 May 2024 15:50:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.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; unprotected) header.d=linaro.org header.i=@linaro.org header.b="BqYgSCTh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AA810887BA; Fri, 31 May 2024 15:50:56 +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,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) (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 A0EA3887D0 for ; Fri, 31 May 2024 15:50:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2e6f51f9de4so29106251fa.3 for ; Fri, 31 May 2024 06:50:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717163454; x=1717768254; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=7HsaSU/GVMju5xN/sg3znUxqC7KLIcXCPlkqzo9nf7Q=; b=BqYgSCThNvZZOPr1vudqPKPqh5C8PqLfByEf4LmOPBIruNcNwpjNH6YaZqXeFyg6E2 HUyNj/zzDmwfxwD9npeWL1BxYQHGhkNY1sFVbCneszugMfM10M0P3QlY5b8k+EFHF9KA IWj8Y5Wt0S+6/ZV/8jzkCHKWXLOJcTMpvsGoedspgjy68CkSxLlSlp32bkLWLWporZ6J 8kMfCh1nAAiHDwAkzBOWwcFp3idIcF6QO5lpTEXELL29cJdLzU/KA/3CDULsoGXSZVye 7FjjEzllXN/1Ei39MKhJTbv4ssQWIywtvEJxtIbq+hsoytBb+8iPJMiw/mRJqHDb90Qr tBMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717163454; x=1717768254; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7HsaSU/GVMju5xN/sg3znUxqC7KLIcXCPlkqzo9nf7Q=; b=MoZuBXBq/wScMxdD38eUq8vYAybIjiVwmq9m6PM7dyCK3Kc0Agd0l1neKltHpY1hBZ EaOYtSv0b5Y/i23VspYPPgh/JKAi0S1FfDAtjhLFR8ZcNLDSlCWdfoB0ZK4zZGfLpboJ h8gAVPUgD01vG0TxaO7iFmtRpgkHj/6+UtL0RAjOIBm6ynrHoyH7bhx/7sVgOoqwEvo1 hjhnPNOs9IoAZKEez+Kvfz2F7qJDAXWzE0GooLqhsOR7LVRRAR4N6nuoikXwU/2ZbYUo ckX4OW4FdNsWpZehZLyxASyvFMXYkkg+YoRBCXTcnHABEVaNCn8TfJIp2fMVEjtNZKY0 fKLg== X-Forwarded-Encrypted: i=1; AJvYcCXuM8V+a/lwYgoKAQXImp2Zf+VJx15Ob12RK6vByPmQ3ygKiMhm/UPUfJOtrSN3ghE1K+R1VCXFBrBIfYLPSe65w6ZmkQ== X-Gm-Message-State: AOJu0YxicvK5/To9CNENkZVeruK+0ShPZCn9CIaPnKeCpGhfBEa5oFur VKLhUtaNtLaVafZZwtCsoeSU/XA1kaWR4Bbh3URkYyIgEuHr1lxz7DGgWMZWbPs= X-Received: by 2002:a2e:b049:0:b0:2ea:9194:ab2d with SMTP id 38308e7fff4ca-2ea951147afmr15601601fa.18.1717163453955; Fri, 31 May 2024 06:50:53 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::8090]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a67eab84a99sm89442866b.143.2024.05.31.06.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 06:50:53 -0700 (PDT) From: Caleb Connolly Date: Fri, 31 May 2024 15:50:41 +0200 Subject: [PATCH v3 7/7] test: lib/uuid: add unit tests for dynamic UUIDs MIME-Version: 1.0 Message-Id: <20240531-b4-dynamic-uuid-v3-7-ca4a4865db00@linaro.org> References: <20240531-b4-dynamic-uuid-v3-0-ca4a4865db00@linaro.org> In-Reply-To: <20240531-b4-dynamic-uuid-v3-0-ca4a4865db00@linaro.org> To: Tom Rini , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Mario Six , Alper Nebi Yasak , Abdellatif El Khlifi Cc: Richard Hughes , u-boot@lists.denx.de, Caleb Connolly X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3273; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=nUd+KMu0GfIDUzb8thPbkHD1IRE34vCpsyeDcvHSIBM=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmWdW0mg21Aq/DDFoTHnTl/kH1n9n/dH1kyh+va AUPmiJ3M7+JAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZlnVtAAKCRAFgzErGV9k trqhEACWA0ooZxLgDiEmaHGfAkOZYRJc26wbGa8cDsYhsSj3B/ass4bKqbzh8tyjb07Qhu2bytE QOGLy8ea7EIW4uXNm9PPI8WpN86BUQmmYIudDlyn61dkKOJp8Ymha6w9+qqT8PVDdUstlP1Habi Tjsw3ZxnujJUn93SdkPC8PdmVo+Cvxp99IuqPkEawxCwP4aD9aRHDGunCxkaTiAB7rwZ1DX7/ZB xz6mOM3gXcVyQpkVxbHom8LKeHajgAhAFwY4Lx+MgoiqlNpErL7giz57TDdvpi0hRlXWG1V3zsK IJd9YNR0mGr5RywadKcARSHy7GOiXdDuUKDxrugrNmPqhKGGg2AnbwRo23AlSi5NlnyawWnP1b1 P6gPUtlDz+NDu/8/UidpFGlvNSauCG5qTx9RsjxGkO9eq/OZSQwk9+9jUKKn5do9p4nxKje3ZKf TevZwf8T5VkYy406OAB+UibwSXYNeOeGJbbIh1JAEjGrp6+kftEIfwthmTjrPpbHnuMy1y49Eo0 0JlrJrKKAxuskBgc6DjyrUzLHLpmWFNHB8ImOlBi2vc8dzqpbidk2HyAFnOBM+M46tbHd1758Hp 9YdSX4pSsSqgRN7Ckrwrydb3b+GHLk+xWSLnv6ebI1YmCUJlTqGFdTo8IliLBugbZzIic5eX97I dxkE3hi0jPb+jjQ== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean Add some basic unit tests to validate that the UUID generation behaves as expected. This matches the implementation in efi_loader for sandbox and a Qualcomm board and should catch any regressions. Signed-off-by: Caleb Connolly --- test/lib/uuid.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/test/lib/uuid.c b/test/lib/uuid.c index 0914f2c47e77..dc485189ae68 100644 --- a/test/lib/uuid.c +++ b/test/lib/uuid.c @@ -7,15 +7,20 @@ * Authors: * Abdellatif El Khlifi */ +#include #include #include #include #include /* test UUID */ #define TEST_SVC_UUID "ed32d533-4209-99e6-2d72-cdd998a79cc0" +/* Sandbox namespace UUID */ +#define SANDBOX_NAMESPACE_UUID "09d7cf52-0720-4710-91d1-08469b7fe9c8" +/* Qcom namespace UUID */ +#define QCOM_NAMESPACE_UUID "2a5aa852-b856-4d97-baa9-5c5f4421551f" #define UUID_SIZE 16 /* The UUID binary data (little-endian format) */ @@ -37,4 +42,87 @@ static int lib_test_uuid_to_le(struct unit_test_state *uts) return 0; } LIB_TEST(lib_test_uuid_to_le, 0); + +#if CONFIG_IS_ENABLED(EFI_CAPSULE_DYNAMIC_UUIDS) +struct dynamic_uuid_test_data { + const char *namespace; + const char *compatible; + const u16 *images[4]; + const char *expected_uuids[4]; +}; + +static int lib_test_dynamic_uuid_case(struct unit_test_state *uts, + const struct dynamic_uuid_test_data *data) +{ + struct uuid namespace; + int j; + + ut_assertok(uuid_str_to_bin(data->namespace, (unsigned char *)&namespace, + UUID_STR_FORMAT_GUID)); + + for (j = 0; data->images[j]; j++) { + const char *expected_uuid = data->expected_uuids[j]; + const u16 *image = data->images[j]; + struct uuid uuid; + char uuid_str[37]; + + gen_uuid_v5(&namespace, &uuid, + data->compatible, strlen(data->compatible), + image, u16_strsize(image) - sizeof(uint16_t), + NULL); + uuid_bin_to_str((unsigned char *)&uuid, uuid_str, UUID_STR_FORMAT_GUID); + + ut_asserteq_str(expected_uuid, uuid_str); + } + + return 0; +} + +static int lib_test_dynamic_uuid(struct unit_test_state *uts) +{ + int ret, i; + const struct dynamic_uuid_test_data test_data[] = { + { + .compatible = "sandbox", + .namespace = SANDBOX_NAMESPACE_UUID, + .images = { + u"SANDBOX-UBOOT", + u"SANDBOX-UBOOT-ENV", + u"SANDBOX-FIT", + NULL, + }, + .expected_uuids = { + "fd5db83c-12f3-a46b-80a9-e3007c7ff56e", + "935fe837-fac8-4394-c008-737d8852c60d", + "ffd97379-0956-fa94-c003-8bfcf5cc097b", + NULL, + } + }, + { + .compatible = "qcom,qrb4210-rb2", + .namespace = QCOM_NAMESPACE_UUID, + .images = { + u"QUALCOMM-UBOOT", + NULL, + }, + .expected_uuids = { + "8ee418dc-7e00-e156-80a7-274fbbc05ba8", + NULL, + } + }, + }; + + for (i = 0; i < ARRAY_SIZE(test_data); i++) { + ret = lib_test_dynamic_uuid_case(uts, &test_data[i]); + if (ret) + return ret; + } + + return 0; +} + +LIB_TEST(lib_test_dynamic_uuid, 0); + +#endif /* CONFIG_IS_ENABLED(EFI_CAPSULE_DYNAMIC_UUIDS) */ +