[PATCH 2/2] fwts: uefi: clean up all test variable before doing the uefirtvariable test (LP: #1313554)
Colin Ian King
colin.king at canonical.com
Fri May 2 09:44:23 UTC 2014
On 28/04/14 09:07, Ivan Hu wrote:
> Try to delete all the test variables that used by the uefirtvariable test,
> before doing the uefirtvariable tests. Make sure there are no preexisting
> test variables that cause the the uefirtvariable test fail, when the
> variable tests accidentally stopped, terminated by the buggy firmware, power
> fail etc.
>
> Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
> ---
> src/uefi/uefirtvariable/uefirtvariable.c | 31 ++++++++++++++++++++++++++++--
> 1 file changed, 29 insertions(+), 2 deletions(-)
>
> diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c
> index 6e40542..7ddfeb1 100644
> --- a/src/uefi/uefirtvariable/uefirtvariable.c
> +++ b/src/uefi/uefirtvariable/uefirtvariable.c
> @@ -59,6 +59,33 @@ static uint32_t attributes =
> FWTS_UEFI_VAR_BOOTSERVICE_ACCESS |
> FWTS_UEFI_VAR_RUNTIME_ACCESS;
> static uint16_t variablenametest[] = {'T', 'e', 's', 't', 'v', 'a', 'r', '\0'};
> +static uint16_t variablenametest2[] = {'T', 'e', 's', 't', 'v', 'a', 'r', ' ', '\0'};
> +static uint16_t variablenametest3[] = {'T', 'e', 's', 't', 'v', 'a', '\0'};
> +
> +static void uefirtvariable_env_cleanup(void)
> +{
> + struct efi_setvariable setvariable;
> + uint64_t status;
> + uint8_t data = 0;
> +
> + setvariable.VariableName = variablenametest;
> + setvariable.VendorGuid = >estguid1;
> + setvariable.Attributes = 0;
> + setvariable.DataSize = 0;
> + setvariable.Data = &data;
> + setvariable.status = &status;
> + ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
> +
> + setvariable.VariableName = variablenametest2;
> + ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
> +
> + setvariable.VariableName = variablenametest3;
> + ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
> +
> + setvariable.VariableName = variablenametest;
> + setvariable.VendorGuid = >estguid2;
> + ioctl(fd, EFI_RUNTIME_SET_VARIABLE, &setvariable);
> +}
I see that we're not checking the ioctl return here. What is the
outcome if the variables do exist and the deletion fails to the tests
that require these variables to not exist?
Perhaps a more "robust" thing to do is:
Check if they exist, *then* attempt to deleted them, and if that fails,
report this as an error as this will mess up subsequent tests.
Or am I being overly pedantic here?
>
> static int uefirtvariable_init(fwts_framework *fw)
> {
> @@ -78,6 +105,8 @@ static int uefirtvariable_init(fwts_framework *fw)
> return FWTS_ABORTED;
> }
>
> + uefirtvariable_env_cleanup();
> +
> return FWTS_OK;
> }
>
> @@ -1044,8 +1073,6 @@ static int setvariable_test3(fwts_framework *fw)
> int ret;
> uint64_t datasize = 10;
> uint8_t datadiff1 = 0, datadiff2 = 1, datadiff3 = 2;
> - uint16_t variablenametest2[] = {'T', 'e', 's', 't', 'v', 'a', 'r', ' ', '\0'};
> - uint16_t variablenametest3[] = {'T', 'e', 's', 't', 'v', 'a', '\0'};
>
> ret = setvariable_insertvariable(fw, attributes, datasize,
> variablenametest2, >estguid1, datadiff2);
>
More information about the fwts-devel
mailing list