diff mbox series

[v2,1/2] lib/uuid.c: use unique name for PARTITION_SYSTEM_GUID

Message ID 20250415204917.1250109-2-jerome.forissier@linaro.org
State New
Headers show
Series ut: fix print_guid() and enable UNIT_TEST for qemu_arm64 | expand

Commit Message

Jerome Forissier April 15, 2025, 8:49 p.m. UTC
The name defined for PARTITION_SYSTEM_GUID in list_guid[] depends on
configuration options. It is "system" if CONFIG_PARTITION_TYPE_GUID is
enabled or "System Partition" if CONFIG_CMD_EFIDEBUG or CONFIG_EFI are
enabled. In addition, the unit test in test/common/print.c is incorrect
because it expects only "system" (or a hex GUID).

Make things more consistent by using a clear and unique name: "EFI
System Partition" whatever the configuration, and update the unit test
accordingly.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---

Changes in v2:
- Remove useless braces in if expression
- Change partition name and make it the same for all configs. Update the
  commit subject.

 lib/uuid.c          | 4 ++--
 test/common/print.c | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

Comments

Heinrich Schuchardt April 16, 2025, 3:54 a.m. UTC | #1
On 4/15/25 22:49, Jerome Forissier wrote:
> The name defined for PARTITION_SYSTEM_GUID in list_guid[] depends on
> configuration options. It is "system" if CONFIG_PARTITION_TYPE_GUID is
> enabled or "System Partition" if CONFIG_CMD_EFIDEBUG or CONFIG_EFI are
> enabled. In addition, the unit test in test/common/print.c is incorrect
> because it expects only "system" (or a hex GUID).
> 
> Make things more consistent by using a clear and unique name: "EFI
> System Partition" whatever the configuration, and update the unit test
> accordingly.
> 
> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
> Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> 
> Changes in v2:
> - Remove useless braces in if expression
> - Change partition name and make it the same for all configs. Update the
>    commit subject.
> 
>   lib/uuid.c          | 4 ++--
>   test/common/print.c | 8 ++++----
>   2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/uuid.c b/lib/uuid.c
> index 75658778044..4ad2cca64c5 100644
> --- a/lib/uuid.c
> +++ b/lib/uuid.c
> @@ -68,7 +68,7 @@ static const struct {
>   } list_guid[] = {
>   #ifndef USE_HOSTCC
>   #ifdef CONFIG_PARTITION_TYPE_GUID
> -	{"system",	PARTITION_SYSTEM_GUID},
> +	{"EFI System Partition", PARTITION_SYSTEM_GUID},
>   	{"mbr",		LEGACY_MBR_PARTITION_GUID},
>   	{"msft",	PARTITION_MSFT_RESERVED_GUID},
>   	{"data",	PARTITION_BASIC_DATA_GUID},
> @@ -184,7 +184,7 @@ static const struct {
>   		EFI_TCG2_PROTOCOL_GUID,
>   		},
>   	{
> -		"System Partition",
> +		"EFI System Partition",
>   		PARTITION_SYSTEM_GUID

We should avoid having the entry twice in the array for
CONFIG_PARTITION_TYPE_GUID=y && (CONFIG_CMD_EFIDEBUG=y || CONFIG_EFI=y).

I guess it needs its own #if block.

Otherwise looks good to me.

Best regards

Heinrich

>   	},
>   	{
> diff --git a/test/common/print.c b/test/common/print.c
> index e3711b10809..c48efc2783f 100644
> --- a/test/common/print.c
> +++ b/test/common/print.c
> @@ -45,11 +45,11 @@ static int print_guid(struct unit_test_state *uts)
>   	sprintf(str, "%pUL", guid);
>   	ut_asserteq_str("04030201-0605-0807-090A-0B0C0D0E0F10", str);
>   	sprintf(str, "%pUs", guid_esp);
> -	if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)) { /* brace needed */
> -		ut_asserteq_str("system", str);
> -	} else {
> +	if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID) ||
> +	    IS_ENABLED(CONFIG_CMD_EFIDEBUG) || IS_ENABLED(CONFIG_EFI))
> +		ut_asserteq_str("EFI System Partition", str);
> +	else
>   		ut_asserteq_str("c12a7328-f81f-11d2-ba4b-00a0c93ec93b", str);
> -	}
>   	ret = snprintf(str, 4, "%pUL", guid);
>   	ut_asserteq(0, str[3]);
>   	ut_asserteq(36, ret);
diff mbox series

Patch

diff --git a/lib/uuid.c b/lib/uuid.c
index 75658778044..4ad2cca64c5 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -68,7 +68,7 @@  static const struct {
 } list_guid[] = {
 #ifndef USE_HOSTCC
 #ifdef CONFIG_PARTITION_TYPE_GUID
-	{"system",	PARTITION_SYSTEM_GUID},
+	{"EFI System Partition", PARTITION_SYSTEM_GUID},
 	{"mbr",		LEGACY_MBR_PARTITION_GUID},
 	{"msft",	PARTITION_MSFT_RESERVED_GUID},
 	{"data",	PARTITION_BASIC_DATA_GUID},
@@ -184,7 +184,7 @@  static const struct {
 		EFI_TCG2_PROTOCOL_GUID,
 		},
 	{
-		"System Partition",
+		"EFI System Partition",
 		PARTITION_SYSTEM_GUID
 	},
 	{
diff --git a/test/common/print.c b/test/common/print.c
index e3711b10809..c48efc2783f 100644
--- a/test/common/print.c
+++ b/test/common/print.c
@@ -45,11 +45,11 @@  static int print_guid(struct unit_test_state *uts)
 	sprintf(str, "%pUL", guid);
 	ut_asserteq_str("04030201-0605-0807-090A-0B0C0D0E0F10", str);
 	sprintf(str, "%pUs", guid_esp);
-	if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)) { /* brace needed */
-		ut_asserteq_str("system", str);
-	} else {
+	if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID) ||
+	    IS_ENABLED(CONFIG_CMD_EFIDEBUG) || IS_ENABLED(CONFIG_EFI))
+		ut_asserteq_str("EFI System Partition", str);
+	else
 		ut_asserteq_str("c12a7328-f81f-11d2-ba4b-00a0c93ec93b", str);
-	}
 	ret = snprintf(str, 4, "%pUL", guid);
 	ut_asserteq(0, str[3]);
 	ut_asserteq(36, ret);