From patchwork Thu Aug 8 16:21:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 817723 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e11:0:b0:367:895a:4699 with SMTP id p17csp944547wrt; Thu, 8 Aug 2024 09:24:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUt9Mh0vPn2JdKl2pDpOT1DGvHidnxx06T4kLqKn83uLvpiKxt1AlvwWMSG6BuEVZPNFCgtcjugUEXPs49bQLqV X-Google-Smtp-Source: AGHT+IEhu5AQukxuACUwDGSKcXaQ8jJDwMlqLBIcR4V8ECPilczsk4Xr98oBCRQAZ34YLvAHIPEe X-Received: by 2002:a05:6512:15aa:b0:52e:936e:a237 with SMTP id 2adb3069b0e04-530e581fef4mr2403831e87.16.1723134246912; Thu, 08 Aug 2024 09:24:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723134246; cv=none; d=google.com; s=arc-20160816; b=djnidkpp9uzVrUU/Xvsu2vObQZa34h46Tj0k1QkfsGGwokIEShxTKbE1NKSlxkSomO PbiHIWzvmIILv6V17x0k/mX5H6HqyAmT9/fSxo+kUEE517jx9f2MA7b/a9V8YTpw4q8X YKeO7oyvZRX6WKBQK3/Nn1enlqwBxHLZHD4Qctxknnk5qp5hd0eSu4QCUJlees3CARJ8 C7S8gUAhjmRpu67kn3MwbgLfhAkO9fG1nKISnllbgm0Lnb7t50+HuUgcBrA1E3mNkpv7 xDMLajuTUdbejcqx1hg5naBKPVilwwWZRlLl68oKeqbNnM+Ej7jvGnTQuICGVt7tyhr0 OdMQ== 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=nJdu383bEZmoEf0jaSYoXbeYDyVA149Dgz3Uuc+tKw8=; fh=+bBRjCX6mhnun/TVUugwq1WBNnTXgK0h/bzWBQ6CSRk=; b=g6/wOw1X68MEGDIKjvr+deZkpcybrgSULYvfTUnh7wpa9gJQ6lDm1woHrMK1ZB6xtg N42RkM+kjAZ5H0JU/en4ZkvrAmrXHE8IY/6Iya2/2M+nXvQjivN0YbZFrAW5o1QE/+7w JJbTnNeaOzthYgiEAUF7HLxh57uUiUUzDzBgOHMBmfW5mHN7f4srTMo20erqCyW7uzbl LsXxIDPpVru8Q+BSmYpCuUDLwUrNVFoXCYJjqngfTcp6n6/i067Vk53mV5wHtHVId6tA 84gmSrwTPqYW3k4CDqWrdaNwHFjmyUFraDMT1tnb2M1Ga2BUjIEh9IE80Pg32g2hTLvF wqmw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y8qAMRxV; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a640c23a62f3a-a7dc9d6f9b8si817383866b.415.2024.08.08.09.24.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 09:24:06 -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=y8qAMRxV; 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; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CD64087903; Thu, 8 Aug 2024 18:22:09 +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="y8qAMRxV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D9264874AC; Thu, 8 Aug 2024 18:22:07 +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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) (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 DBBFE874AC for ; Thu, 8 Aug 2024 18:22:05 +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-ej1-x631.google.com with SMTP id a640c23a62f3a-a7ab63a388bso49761366b.1 for ; Thu, 08 Aug 2024 09:22:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723134125; x=1723738925; 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=nJdu383bEZmoEf0jaSYoXbeYDyVA149Dgz3Uuc+tKw8=; b=y8qAMRxVO5l5Vj0N0L/oK5td47Yqj8IRQi8lqOgKg1qFpVhjG6tilpXhgoMjqBkzs4 1nzMBAv/AGRuGEOewND+6Zbd/o1cvUrKJ71YFDCLE1GoItirpkPH1OzYxPw9rQww2uQc QTzhZMcr4DbGY8XKmkH8eXkCaEkb9rAzy7XrKNcH5R3l03GpeP52qyJtLbPiFPLKRlso O3G9M4q7pmiK9hIigUgWaxWjTHKQdtV/ZhIdTib7u8hnahxEkSjUXCtA3IjqYeJEbF8Q FlZB32iYOmOPCKrSZVfyQ/0fw80vkJ54VSrTJcOk2ftoktZG3UG0PkTHj2xjzPjCcxSW n6ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723134125; x=1723738925; 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=nJdu383bEZmoEf0jaSYoXbeYDyVA149Dgz3Uuc+tKw8=; b=CK8qSXb1hHvfnhmQ82rJifZ/WQf//GwzdbQaXCkXiis33ayJHjjT3dMuh0tgd6RHSQ GyTwTsQR7fW3pnKJNsIao9FJQR78a+MfgWfBqtLB32VFickXQfNIZ1l6TqJCiSoE/XfH Y3Dme/PDSSZFIsjMnzH8stAt7lg+KbTwZEsJwHBvmLtGyLpUGEsNP1+J5JS2CexM+bf7 x8CnbBh+OcCH4QJPYvflFnNEt91vzDNa+zCeD3AsWG+xobR/ZVuxsv4JaU/uu9vFFP+A 4E7ZxakpB1zHMpfLtAPHwg+s6gBt8LgLAmWHEsG2wEry/iP6kJg/LzriTdcVb69QQPdq xOYA== X-Forwarded-Encrypted: i=1; AJvYcCXQ7V7czwFGmAdq3Vll472eXnJom9+zGkkOCxvBwII57FTMv7/4SZxd8eVz6Eay9cyxvRBQFq3sv37ymAFT86f7MK1m3A== X-Gm-Message-State: AOJu0Yz92eu69uOD9OnYncqZWSXSUigP9feOBWVYDeQFm8oX3XAKgK5Z OeVq3Pw5bLiV7h4IgwD0Gmoi/Isef6u0Xzv46suNo2fSQL7ZkMI3xdUuLFgFQew= X-Received: by 2002:a05:6402:3908:b0:5a3:619:949f with SMTP id 4fb4d7f45d1cf-5bbb249af79mr2450291a12.32.1723134125292; Thu, 08 Aug 2024 09:22:05 -0700 (PDT) Received: from [192.168.0.113] ([2a02:8109:aa0d:be00::7424]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5bbb2e5c8fbsm812351a12.79.2024.08.08.09.22.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 09:22:04 -0700 (PDT) From: Caleb Connolly Date: Thu, 08 Aug 2024 18:21:57 +0200 Subject: [PATCH v6 10/11] test: lib/uuid: add unit tests for dynamic UUIDs MIME-Version: 1.0 Message-Id: <20240808-b4-dynamic-uuid-v6-10-9332e7237119@linaro.org> References: <20240808-b4-dynamic-uuid-v6-0-9332e7237119@linaro.org> In-Reply-To: <20240808-b4-dynamic-uuid-v6-0-9332e7237119@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=3066; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=F5O31Nk7Cky+OrDFFf3eaBrzcyso+9+tOqyXI5DtTgE=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmtPCfaCZThIAo3wrP1imjo0idje9cr3O5oNkg0 dbmS+ppdBCJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZrTwnwAKCRAFgzErGV9k tpFnD/45O2xeNE7BiBR4CG7q3uEs+0LTZVVWc+yakokCrTEoP+Xs2czpQvK71tus5ERfMYBUbmy W8FsyCdIRUD/Qrx/2WhOs1zBJmXYQZ30OkYrxncTF9Mk6x9gQor8KBzkOR2zk9qrDOy2y3CKqjt qmXqIVtu/w1j8aNkMkQrXZR4SuEXR0Vmskv2PWtWhVXJPi/ML6StVCN+U7X2Z/idH0MrCIlSknU eIPt6/MrvrUHuh9RXvSt9gXB7BJCSZVsXzSsy8kyahviyztLlaNLTMJO8VTfOfuwJ47lSb0otM4 lnbTGJCzf2HLLmWi9tIe6989zTrMygHV4/R4KPM/+RCwJ4SGz04zizYB6lf1viqAdsZe2k3Yw5I 5ITL0vsek/KE9Q+2IYnBZ3CZS+jaujRO93GA+hvxGxbm17bFY8EhdI6CpMEck9TbvwZunzK0yZg /Jimo+INIlJhAJ8wdVGwIh2qXCaEmnORe6IGL3iO4jrG+6keYdIX2z83Tdv6TuQ6U5qMFXTR06M h6/+VDWoQWSfmz2oTx+2KqBFc+l15KbRqVcgFm7HpTDqx+7vLuGLaLuiFuI/lP1uduYtn0vNvMZ eVTHflP1sYKgUBGX1VPtetYAw8zLNhVMdgcTKxEJq26YdVdaIDeiQ0Uk7OKMeDviK8xmmI+YFEf draFM4jyPjrZPDA== 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. Acked-by: Ilias Apalodimas Signed-off-by: Caleb Connolly --- test/lib/uuid.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/test/lib/uuid.c b/test/lib/uuid.c index 9629d378c329..2c6cfd42ddc3 100644 --- a/test/lib/uuid.c +++ b/test/lib/uuid.c @@ -7,15 +7,20 @@ * Authors: * Abdellatif El Khlifi */ +#include #include #include #include #include +#include + /* test UUID */ #define TEST_SVC_UUID "ed32d533-4209-99e6-2d72-cdd998a79cc0" +/* U-Boot default fw image namespace */ +#define DEFAULT_FW_IMAGE_NAMESPACE "8c9f137e-91dc-427b-b2d6-b420faebaf2a" #define UUID_SIZE 16 /* The UUID binary data (little-endian format) */ @@ -37,4 +42,81 @@ static int lib_test_uuid_to_le(struct unit_test_state *uts) return 0; } LIB_TEST(lib_test_uuid_to_le, 0); + +struct dynamic_uuid_test_data { + 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(DEFAULT_FW_IMAGE_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]; + efi_guid_t uuid; + char uuid_str[37]; + + gen_v5_guid(&namespace, &uuid, + data->compatible, strlen(data->compatible), + image, u16_strlen(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", + .images = { + u"SANDBOX-UBOOT", + u"SANDBOX-UBOOT-ENV", + u"SANDBOX-FIT", + NULL, + }, + .expected_uuids = { + "985f2937-7c2e-5e9a-8a5e-8e063312964b", + "9e339473-c2eb-530a-a69b-0cd6bbbed40e", + "46610520-469e-59dc-a8dd-c11832b877ea", + NULL, + } + }, + { + .compatible = "qcom,qrb4210-rb2", + .images = { + u"QUALCOMM-UBOOT", + NULL, + }, + .expected_uuids = { + "d5021fac-8dd0-5ed7-90c2-763c304aaf86", + 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); +