From patchwork Fri Jul 19 12:43:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 813388 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp732367wro; Fri, 19 Jul 2024 05:45:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVdBS3kszt2lWemPPrFnTHEDTDQ6mrh/3g2ivJY7nyEzq/Wzj9s9SOXP9kkCKm587HnPO0pwcOhBXyCuRi4/18o X-Google-Smtp-Source: AGHT+IEmzFC/SQ5WzogxpimehkFUJaIl72mSm7tu5HU++lqhjmU5Rfq50sNm/ZhHIIT4q6zIiM6+ X-Received: by 2002:a2e:9eca:0:b0:2ee:86c1:f73d with SMTP id 38308e7fff4ca-2ef05c7aaadmr35972111fa.18.1721393135680; Fri, 19 Jul 2024 05:45:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721393135; cv=none; d=google.com; s=arc-20160816; b=DMDKjUGqTciQzhxwws/Oulp4sI8hl2Yuq8Gf3fZcckSx5dXTlkkoAvgKU23yvSAVQC S/o/TemNGnJngdBDDE6ZkOYVhNIkxdIU6A0YVS00ypHvxlZrajwVgNDXCVOdDFHuDbV6 duY34YtVmXCy5+W09VyBPw5wE1Byxxd7ZltspGMgAdaFGC4eQehmZjI4dAGWDFHVzv9r udO+0nbhRCudAbeMlu7bAVnzTEz37+Pol3SdTTgXCDxSG+Z4FoqT97bbVyXXEro7zS98 8bmpzwCHKFV9lRst972MNLxtpX/PMVCFUtoBosuSCLJ6V5MZ3OHKPbDsY35/MtrlFMzn e/MQ== 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=ANeWJLSnvDLVzkYEaJuKs+4UWkSeDquEqfDFghLMMHY=; fh=VOcyFTUh29YEldJsEiv/kPGQXbvTOkmQS+JoMw1eJ3g=; b=tLsmlXX90GalmHtnH/03JQ6kK49JOTl/oVMiwooqJbi0Z80Z9gADvNBgIW2DQd7W1X WckssGE07Lp3fu9/dPkM3h1bPa3VpNJ8UjLRJ8If/aXepUIm8KxgUI6DIzTEp8a6NAQ1 aMehORtDUMD61RtyF8wee3aC80bcGWD1Mf3NSwGXfJg4OTwqlMqjizBSVHE9cE6Bj/h/ h0ERowrf0naK5+Gi3Lnl1F4TBn99S7LW/ftRxYBAf71Wmx9GY+bD9mOJEhRzZx7kwaMF oepfoTiuw4trR8I6Uw25GF2ndt0ARjV9ap0cy8uEfWnKFaWZ05bayUYWukF8O7LY6g5R anag==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="BNkQ/GYq"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 38308e7fff4ca-2ef0fd0d550si3354541fa.425.2024.07.19.05.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jul 2024 05:45:35 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="BNkQ/GYq"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 8F74488BF0; Fri, 19 Jul 2024 14:44:03 +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="BNkQ/GYq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 22C5088BA9; Fri, 19 Jul 2024 14:44:02 +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-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) (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 23B2A88B8B for ; Fri, 19 Jul 2024 14:44:00 +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-lf1-x133.google.com with SMTP id 2adb3069b0e04-52ea7d2a039so1480968e87.3 for ; Fri, 19 Jul 2024 05:44:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721393039; x=1721997839; 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=ANeWJLSnvDLVzkYEaJuKs+4UWkSeDquEqfDFghLMMHY=; b=BNkQ/GYq0mtfKnAjg1xE7IdOr4Q7bPn8EGymNVUaiJwbgPK++Y65fBrlkbaQPkog/6 fTctw3aVIsDWm8b6Pc1PcTatcLs2oasBcgzWwu2P4RFi1sg00LR4jzsdNtUE83KGXnJW ckRaOor41f2ymv86CTlKlJ7TZ7rW0bpHlqPRCUGS2LtXLcHBcwC3+g3UC0X4AubdtwSF 6PrrhrvMe3yOotgMNGfiLbKaqakZ15zOoWW/DCtV8usEdOgXZa/MjEA7tTTVijQ7DZqG S9YLZ/6TKhlUjrhcVO2oWYq4VmojySNXM3gRYZcxoHrACaxSNrqHGEjxU1SE3Sdjl8Fd jNYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721393039; x=1721997839; 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=ANeWJLSnvDLVzkYEaJuKs+4UWkSeDquEqfDFghLMMHY=; b=w2bUB8DBUFH6RbuaYKpoPEvvAx5n50YlrElaTCpY9R7LTvouIWLcoafCEKHQAqZ0EI QVXhTy12o3+gKJ6HPy4Eahylio8B/GyhTyOBnTBwp/iqcUyXKW3eAdJGyO0TSfpyKy+A hvQfCnAx85Gn9q5jyzP2v295iBUWWaW+0bpX2gwmTJO1gl1b9/sC/lseMZhP3gI5NogZ C3dmy0TjsrLj2G4iQSbW1+VvnXOH6Uy/NTBZX8klxxj5pRlgrifrlLzRE+nJzXEyVaLR impl9fa3t0wqWW8t67QS+mUC6eXHimIRtWq95oeWU5h9aFFnhuWBrsmPMu3tmCClrBz9 taTg== X-Forwarded-Encrypted: i=1; AJvYcCXYmtCuLl59qmsuHKcpvRuKmYT2oEAaaJgGN2POnl1aXI9MUxWTrfX4obp7F7nFwsJA8UdPviwcEkD/cTB/eBifXg96mQ== X-Gm-Message-State: AOJu0YycxgygCDE7mmhx+LWuNRtzbh4oRquc4xgtXCNR4ZFIJfhutZPc 2O21YqQGhSsIca+n/62ma0WEFmVY4EUK1PxH56RUkwt49bf5kwgMSr+5Rf2+klE= X-Received: by 2002:a05:6512:15a4:b0:52e:74d5:89ae with SMTP id 2adb3069b0e04-52ee53d447emr5796360e87.39.1721393039538; Fri, 19 Jul 2024 05:43:59 -0700 (PDT) Received: from [192.168.2.172] ([90.187.152.45]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c785e97sm28577466b.39.2024.07.19.05.43.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jul 2024 05:43:59 -0700 (PDT) From: Caleb Connolly Date: Fri, 19 Jul 2024 14:43:51 +0200 Subject: [PATCH v5 11/11] test: lib/uuid: add tests for UUID version/variant bits MIME-Version: 1.0 Message-Id: <20240719-b4-dynamic-uuid-v5-11-8a83de3fe3dc@linaro.org> References: <20240719-b4-dynamic-uuid-v5-0-8a83de3fe3dc@linaro.org> In-Reply-To: <20240719-b4-dynamic-uuid-v5-0-8a83de3fe3dc@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=1713; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=hbA6/H+9tCFtKZr+AsEDLwQ7R+IJkf/hHZEhk5YCMc4=; b=owEBbQKS/ZANAwAIAQWDMSsZX2S2AcsmYgBmml+B2IRIraTAWksJ2+1aPhKLZ4UeYyzkBvtF7 qW06OhCcLyJAjMEAAEIAB0WIQS2UaFGPGq+0GkMVc0FgzErGV9ktgUCZppfgQAKCRAFgzErGV9k tuXGD/90faMRSkJe72+HEK2uM01mQsKVyNyqQ6uN1Scz1cPHFejrZxUyNCB3egGR1MvlKlvnxSG XmOoRQAJ9fsL29zrfUS7S7kj2NGGJqDNpO39ILkGTwuD3CsVOO4HdsH0OELdyxWyEt0L6TO7HYg k7S/iEogPL2EiuDoawxAxgF7R1h3Je9lAP0EinuwpVC6rIfSfdnIUGv7rdri/InY/1Xkc7k6UkP 4HarBRL8gZElXNx92zBUKX9igsmPaTki/G5qUgiHl+/efL+auSkn/X8lkM73Dh7fXPAiU7+Wd60 9uKmhg+ZZWMCclgCKprnaYhn/+Vq33h1E5oyqtAhFVC9gaHuZMStmLzKPWnu1n2ULBCfjNBt1xT 9jpBzj93X31G+wa52XWpb8nfeP4sdHYFn0RB4Np39GuBodl/J0/WfBzre+r7H1ARwXSkCItQ+OA Cw4hHT6M5TPPP6hLJxM9N9Cg0wBzhfHcz4zvczdeq49Uu/vmKdCIp1AOsOOk/N8VR76c1kIwUrB maJUfEt/7NsnPiyMeS2kllDozLcKcpt+U2ZYlhM/3u8HFwz+N1yIJfV2egM/ctTKFU0kdDJDN+c yCkXUT8M5tMXwT9raau+zmDRDJEkXkwzVrcO0BCePZ1mNPkW5F1DF4jzd/C2fGZnjuFljWcsevy tyYNZZgupivLKBA== 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 a test to check the version/variant bits of v4 and v5 UUIDs. Signed-off-by: Caleb Connolly --- test/lib/uuid.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/lib/uuid.c b/test/lib/uuid.c index 2c6cfd42ddc3..63d36e120623 100644 --- a/test/lib/uuid.c +++ b/test/lib/uuid.c @@ -43,8 +43,44 @@ static int lib_test_uuid_to_le(struct unit_test_state *uts) } LIB_TEST(lib_test_uuid_to_le, 0); +/* Test UUID attribute bits (version, variant) */ +static int lib_test_uuid_bits(struct unit_test_state *uts) +{ + unsigned char uuid[16]; + efi_guid_t guid; + int i; + + /* + * Reduce the chance of a randomly generated UUID disguising + * a regression by testing multiple times. + */ + for (i = 0; i < 5; i++) { + /* Test UUID v4 */ + gen_rand_uuid((unsigned char *)&uuid); + + printf("v4 UUID: %pUb\n", (efi_guid_t *)uuid); + + ut_assert((uuid[6] & 0xf0) == 0x40); /* version 4 */ + ut_assert((uuid[8] & UUID_VARIANT_MASK) == (UUID_VARIANT << UUID_VARIANT_SHIFT)); /* variant 1 */ + + /* Test v5, use the v4 UUID as the namespace */ + gen_v5_guid((struct uuid *)uuid, + &guid, "test", 4, NULL); + + printf("v5 GUID: %pUl\n", (efi_guid_t *)uuid); + + /* This is a GUID so bits 6 and 7 are swapped (little endian) */ + ut_assert((guid.b[7] & 0xf0) == 0x50); /* version 5 */ + ut_assert((guid.b[8] & UUID_VARIANT_MASK) == (UUID_VARIANT << UUID_VARIANT_SHIFT)); /* variant 1 */ + } + + return 0; +} + +LIB_TEST(lib_test_uuid_bits, 0); + struct dynamic_uuid_test_data { const char *compatible; const u16 *images[4]; const char *expected_uuids[4];