diff mbox

[4/4] uefirtvariable: add stress test for UEFI runtime interface SetVariable with different name and data

Message ID 1357290383-4352-1-git-send-email-ivan.hu@canonical.com
State Accepted
Headers show

Commit Message

Ivan Hu Jan. 4, 2013, 9:06 a.m. UTC
This stress test tests the UEFI runtime interface SetVariable by
calling with different name and data multiple times.

This combine test do a lot of setvariable, reduce variablenamelength
and multitesttime, for saving the setvariable times to avoid running
out of nvram space and getting the EFI_OUT_OF_RESOURCES.

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

Comments

Colin Ian King Jan. 4, 2013, 11:40 a.m. UTC | #1
On 04/01/13 09:06, Ivan Hu wrote:
> This stress test tests the UEFI runtime interface SetVariable by
> calling with different name and data multiple times.
>
> This combine test do a lot of setvariable, reduce variablenamelength
> and multitesttime, for saving the setvariable times to avoid running
> out of nvram space and getting the EFI_OUT_OF_RESOURCES.
>
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>   src/uefi/uefirtvariable/uefirtvariable.c |   23 ++++++++++++++++++++++-
>   1 file changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c
> index d2927d0..6cbb449 100644
> --- a/src/uefi/uefirtvariable/uefirtvariable.c
> +++ b/src/uefi/uefirtvariable/uefirtvariable.c
> @@ -906,7 +906,7 @@ static int uefirtvariable_test6(fwts_framework *fw)
>   	uint32_t multitesttime = 40;
>   	uint64_t datasize = 10;
>   	uint8_t datadiff = 0;
> -	uint32_t i;
> +	uint32_t i, j;
>   	uint8_t variablenamelength = 32;
>   	uint16_t variablenametest4[variablenamelength+1];
>
> @@ -949,6 +949,27 @@ static int uefirtvariable_test6(fwts_framework *fw)
>   	}
>   	fwts_passed(fw, "Testing SetVariable on setting the variable with different name multiple times passed.");
>
> +	fwts_log_info(fw, "Testing SetVariable on setting the variable with different name and data multiple times.");
> +
> +	/* This combine test do a lot of setvariable, reduce variablenamelength and multitesttime, for saving the setvariable
> +	   times to avoid running out of nvram space and getting the EFI_OUT_OF_RESOURCES */
> +	variablenamelength /= 4;
> +	multitesttime /= 4;
> +
> +	for (i = 0; i < variablenamelength; i++) {
> +		variablenametest4[i] = 'a';
> +		variablenametest4[i+1] = '\0';
> +		for (j = 0; j < multitesttime; j++) {
> +			if (setvariable_insertvariable(fw, attributes, datasize+j, variablenametest4,
> +								&gtestguid1, datadiff) == FWTS_ERROR)
> +				return FWTS_ERROR;
> +			if (setvariable_insertvariable(fw, attributes, 0, variablenametest4,
> +								&gtestguid1, datadiff) == FWTS_ERROR)
> +				return FWTS_ERROR;
> +		}
> +	}
> +	fwts_passed(fw, "Testing SetVariable on setting the variable with different name and data multiple times passed.");
> +
>   	return FWTS_OK;
>   }
>
>
Acked-by: Colin Ian King <colin.king@canonical.com>
Keng-Yu Lin Jan. 14, 2013, 6:34 a.m. UTC | #2
On Fri, Jan 4, 2013 at 5:06 PM, Ivan Hu <ivan.hu@canonical.com> wrote:
> This stress test tests the UEFI runtime interface SetVariable by
> calling with different name and data multiple times.
>
> This combine test do a lot of setvariable, reduce variablenamelength
> and multitesttime, for saving the setvariable times to avoid running
> out of nvram space and getting the EFI_OUT_OF_RESOURCES.
>
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  src/uefi/uefirtvariable/uefirtvariable.c |   23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c
> index d2927d0..6cbb449 100644
> --- a/src/uefi/uefirtvariable/uefirtvariable.c
> +++ b/src/uefi/uefirtvariable/uefirtvariable.c
> @@ -906,7 +906,7 @@ static int uefirtvariable_test6(fwts_framework *fw)
>         uint32_t multitesttime = 40;
>         uint64_t datasize = 10;
>         uint8_t datadiff = 0;
> -       uint32_t i;
> +       uint32_t i, j;
>         uint8_t variablenamelength = 32;
>         uint16_t variablenametest4[variablenamelength+1];
>
> @@ -949,6 +949,27 @@ static int uefirtvariable_test6(fwts_framework *fw)
>         }
>         fwts_passed(fw, "Testing SetVariable on setting the variable with different name multiple times passed.");
>
> +       fwts_log_info(fw, "Testing SetVariable on setting the variable with different name and data multiple times.");
> +
> +       /* This combine test do a lot of setvariable, reduce variablenamelength and multitesttime, for saving the setvariable
> +          times to avoid running out of nvram space and getting the EFI_OUT_OF_RESOURCES */
> +       variablenamelength /= 4;
> +       multitesttime /= 4;
> +
> +       for (i = 0; i < variablenamelength; i++) {
> +               variablenametest4[i] = 'a';
> +               variablenametest4[i+1] = '\0';
> +               for (j = 0; j < multitesttime; j++) {
> +                       if (setvariable_insertvariable(fw, attributes, datasize+j, variablenametest4,
> +                                                               &gtestguid1, datadiff) == FWTS_ERROR)
> +                               return FWTS_ERROR;
> +                       if (setvariable_insertvariable(fw, attributes, 0, variablenametest4,
> +                                                               &gtestguid1, datadiff) == FWTS_ERROR)
> +                               return FWTS_ERROR;
> +               }
> +       }
> +       fwts_passed(fw, "Testing SetVariable on setting the variable with different name and data multiple times passed.");
> +
>         return FWTS_OK;
>  }
>
> --
> 1.7.9.5
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
diff mbox

Patch

diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c
index d2927d0..6cbb449 100644
--- a/src/uefi/uefirtvariable/uefirtvariable.c
+++ b/src/uefi/uefirtvariable/uefirtvariable.c
@@ -906,7 +906,7 @@  static int uefirtvariable_test6(fwts_framework *fw)
 	uint32_t multitesttime = 40;
 	uint64_t datasize = 10;
 	uint8_t datadiff = 0;
-	uint32_t i;
+	uint32_t i, j;
 	uint8_t variablenamelength = 32;
 	uint16_t variablenametest4[variablenamelength+1];
 
@@ -949,6 +949,27 @@  static int uefirtvariable_test6(fwts_framework *fw)
 	}
 	fwts_passed(fw, "Testing SetVariable on setting the variable with different name multiple times passed.");
 
+	fwts_log_info(fw, "Testing SetVariable on setting the variable with different name and data multiple times.");
+
+	/* This combine test do a lot of setvariable, reduce variablenamelength and multitesttime, for saving the setvariable
+	   times to avoid running out of nvram space and getting the EFI_OUT_OF_RESOURCES */
+	variablenamelength /= 4;
+	multitesttime /= 4;
+
+	for (i = 0; i < variablenamelength; i++) {
+		variablenametest4[i] = 'a';
+		variablenametest4[i+1] = '\0';
+		for (j = 0; j < multitesttime; j++) {
+			if (setvariable_insertvariable(fw, attributes, datasize+j, variablenametest4,
+								&gtestguid1, datadiff) == FWTS_ERROR)
+				return FWTS_ERROR;
+			if (setvariable_insertvariable(fw, attributes, 0, variablenametest4,
+								&gtestguid1, datadiff) == FWTS_ERROR)
+				return FWTS_ERROR;
+		}
+	}
+	fwts_passed(fw, "Testing SetVariable on setting the variable with different name and data multiple times passed.");
+
 	return FWTS_OK;
 }