diff mbox series

[4/4] uefirtauthvar: check variable runtime services supported before testing (LP: #1913351)

Message ID 20210513100145.29713-4-ivan.hu@canonical.com
State Accepted
Headers show
Series [1/4] uefirttime: check time services supported before testing (LP: #1913351) | expand

Commit Message

Ivan Hu May 13, 2021, 10:01 a.m. UTC
The uefirtauthvar tests use the getvariable and setvariable runtime services.
Add checking the get and set variable services supported status before runing
the related tests.

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/uefi/uefirtauthvar/uefirtauthvar.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Alex Hung May 13, 2021, 7:24 p.m. UTC | #1
On 2021-05-13 4:01 a.m., Ivan Hu wrote:
> The uefirtauthvar tests use the getvariable and setvariable runtime services.
> Add checking the get and set variable services supported status before runing
> the related tests.
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  src/uefi/uefirtauthvar/uefirtauthvar.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c
> index 644d99c9..e6ab9d45 100644
> --- a/src/uefi/uefirtauthvar/uefirtauthvar.c
> +++ b/src/uefi/uefirtauthvar/uefirtauthvar.c
> @@ -54,6 +54,8 @@ static const uint32_t attributes =
>  
>  static uint16_t variablenametest[] = {'A', 'u', 't', 'h', 'V', 'a', 'r', 'T', 'e', 's', 't', '\0'};
>  
> +static uint32_t runtimeservicessupported;
> +
>  static long setvar(
>  	EFI_GUID *guid,
>  	uint32_t var_attributes,
> @@ -118,6 +120,18 @@ static int uefirtauthvar_init(fwts_framework *fw)
>  	if (fwts_lib_efi_runtime_module_init(fw, &fd) == FWTS_ABORTED)
>  		return FWTS_ABORTED;
>  
> +	fwts_uefi_rt_support_status_get(fd, &runtimeservicessupported);
> +
> +	if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_VARIABLE)) {
> +		fwts_skipped(fw, "Skipping test, SetVariable runtime service "
> +			"is not supported on this platform.");
> +		return FWTS_SKIP;
> +	} else if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_VARIABLE)) {
> +		fwts_skipped(fw, "Skipping test, GetVariable runtime service "
> +			"is not supported on this platform.");
> +		return FWTS_SKIP;
> +	}
> +
>  	uefirtvariable_env_cleanup();
>  
>  	return FWTS_OK;
> 


Acked-by: Alex Hung <alex.hung@canonical.com>
Colin Ian King May 13, 2021, 9:48 p.m. UTC | #2
On 13/05/2021 11:01, Ivan Hu wrote:
> The uefirtauthvar tests use the getvariable and setvariable runtime services.
> Add checking the get and set variable services supported status before runing
> the related tests.
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  src/uefi/uefirtauthvar/uefirtauthvar.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c
> index 644d99c9..e6ab9d45 100644
> --- a/src/uefi/uefirtauthvar/uefirtauthvar.c
> +++ b/src/uefi/uefirtauthvar/uefirtauthvar.c
> @@ -54,6 +54,8 @@ static const uint32_t attributes =
>  
>  static uint16_t variablenametest[] = {'A', 'u', 't', 'h', 'V', 'a', 'r', 'T', 'e', 's', 't', '\0'};
>  
> +static uint32_t runtimeservicessupported;
> +
>  static long setvar(
>  	EFI_GUID *guid,
>  	uint32_t var_attributes,
> @@ -118,6 +120,18 @@ static int uefirtauthvar_init(fwts_framework *fw)
>  	if (fwts_lib_efi_runtime_module_init(fw, &fd) == FWTS_ABORTED)
>  		return FWTS_ABORTED;
>  
> +	fwts_uefi_rt_support_status_get(fd, &runtimeservicessupported);
> +
> +	if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_VARIABLE)) {
> +		fwts_skipped(fw, "Skipping test, SetVariable runtime service "
> +			"is not supported on this platform.");
> +		return FWTS_SKIP;
> +	} else if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_VARIABLE)) {
> +		fwts_skipped(fw, "Skipping test, GetVariable runtime service "
> +			"is not supported on this platform.");
> +		return FWTS_SKIP;
> +	}
> +
>  	uefirtvariable_env_cleanup();
>  
>  	return FWTS_OK;
> 

Acked-by: Colin Ian King <colin.king@canonical.com>
diff mbox series

Patch

diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c
index 644d99c9..e6ab9d45 100644
--- a/src/uefi/uefirtauthvar/uefirtauthvar.c
+++ b/src/uefi/uefirtauthvar/uefirtauthvar.c
@@ -54,6 +54,8 @@  static const uint32_t attributes =
 
 static uint16_t variablenametest[] = {'A', 'u', 't', 'h', 'V', 'a', 'r', 'T', 'e', 's', 't', '\0'};
 
+static uint32_t runtimeservicessupported;
+
 static long setvar(
 	EFI_GUID *guid,
 	uint32_t var_attributes,
@@ -118,6 +120,18 @@  static int uefirtauthvar_init(fwts_framework *fw)
 	if (fwts_lib_efi_runtime_module_init(fw, &fd) == FWTS_ABORTED)
 		return FWTS_ABORTED;
 
+	fwts_uefi_rt_support_status_get(fd, &runtimeservicessupported);
+
+	if (!(runtimeservicessupported & EFI_RT_SUPPORTED_SET_VARIABLE)) {
+		fwts_skipped(fw, "Skipping test, SetVariable runtime service "
+			"is not supported on this platform.");
+		return FWTS_SKIP;
+	} else if (!(runtimeservicessupported & EFI_RT_SUPPORTED_GET_VARIABLE)) {
+		fwts_skipped(fw, "Skipping test, GetVariable runtime service "
+			"is not supported on this platform.");
+		return FWTS_SKIP;
+	}
+
 	uefirtvariable_env_cleanup();
 
 	return FWTS_OK;