[PATCH] uefi: uefirtvariable: add options to specify iterations in variable stress tests (LP: #1197742)
Colin King
colin.king at canonical.com
Thu Jul 4 10:27:09 UTC 2013
From: Colin Ian King <colin.king at canonical.com>
While the defaults to the uefirtvariable stress tests are great,
it would be useful if we can set the number of iterations to push
the stress testing further if required.
Adding three new command line options:
--uefi-get-var-multiple, --uefi-set-var-multiple, --uefi-query-var-multiple
And updating the man page accordingly
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
doc/fwts.1 | 9 +++
src/uefi/uefirtvariable/uefirtvariable.c | 96 +++++++++++++++++++++++++++++---
2 files changed, 96 insertions(+), 9 deletions(-)
diff --git a/doc/fwts.1 b/doc/fwts.1
index 187751c..ad93287 100644
--- a/doc/fwts.1
+++ b/doc/fwts.1
@@ -95,6 +95,15 @@ Load ACPI tables from output generated from acpidump or from sudo fwts \-\-dump.
latter is preferred as fwts \-\-dump is able to dump more tables than acpidump. This
allows one to dump tables from one machine and processes them with fwts on another machine.
.TP
+.B \-\-uefi\-get\-var\-multiple
+Specifies the number of times to get a variable in the uefirtvariable get variable stress test.
+.TP
+.B \-\-uefi\-set\-var\-multiple
+Specifies the number of times to set a variable in the uefirtvariable set variable stress test.
+.TP
+.B \-\-uefi\-query\-var\-multiple
+Specifies the number of times to query a variable in the uefirtvariable query variable stress test.
+.TP
.B \-\-filter\-error\-discard
Specifies the errors that one wants to silently ignore. One supplies a comma sperated
list of fwts error message labels that one wants fwts to not report as errors. fwts will
diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c
index 42e4545..09aa457 100644
--- a/src/uefi/uefirtvariable/uefirtvariable.c
+++ b/src/uefi/uefirtvariable/uefirtvariable.c
@@ -46,6 +46,14 @@ static int fd;
static EFI_GUID gtestguid1 = TEST_GUID1;
static EFI_GUID gtestguid2 = TEST_GUID2;
+static uint32_t uefi_get_variable_multiple = 1024;
+static uint32_t uefi_set_variable_multiple = 40;
+static uint32_t uefi_query_variable_multiple = 1024;
+
+#define UEFI_GET_VARIABLE_MULTIPLE_MAX (100000)
+#define UEFI_SET_VARIABLE_MULTIPLE_MAX (10000)
+#define UEFI_QUERY_VARIABLE_MULTIPLE_MAX (100000)
+
static uint32_t attributes =
FWTS_UEFI_VAR_NON_VOLATILE |
FWTS_UEFI_VAR_BOOTSERVICE_ACCESS |
@@ -1406,10 +1414,11 @@ static int uefirtvariable_test4(fwts_framework *fw)
static int uefirtvariable_test5(fwts_framework *fw)
{
int ret;
- uint32_t multitesttime = 1024;
+ uint32_t multitesttime = uefi_get_variable_multiple;
uint64_t datasize = 10;
- fwts_log_info(fw, "Testing GetVariable on getting the variable multiple times.");
+ fwts_log_info(fw, "Testing GetVariable on getting the variable %" PRIu32
+ " times.", uefi_get_variable_multiple);
ret = getvariable_test(fw, datasize, variablenametest, multitesttime);
if (ret != FWTS_OK)
return ret;
@@ -1428,14 +1437,15 @@ static int uefirtvariable_test5(fwts_framework *fw)
static int uefirtvariable_test6(fwts_framework *fw)
{
int ret;
- uint32_t multitesttime = 40;
+ uint32_t multitesttime = uefi_set_variable_multiple;
uint64_t datasize = 10;
uint8_t datadiff = 0;
uint32_t i, j;
uint8_t variablenamelength = 32;
uint16_t variablenametest4[variablenamelength+1];
- fwts_log_info(fw, "Testing SetVariable on setting the variable with the same data multiple times.");
+ fwts_log_info(fw, "Testing SetVariable on setting the variable with the same data %" PRIu32
+ " times.", uefi_set_variable_multiple);
for (i = 0; i < multitesttime; i++) {
ret = setvariable_insertvariable(fw, attributes, datasize,
variablenametest, >estguid1, datadiff);
@@ -1512,12 +1522,15 @@ static int uefirtvariable_test6(fwts_framework *fw)
static int uefirtvariable_test7(fwts_framework *fw)
{
- uint32_t multitesttime = 1024;
+ uint32_t multitesttime = uefi_query_variable_multiple;
uint64_t status;
uint64_t remvarstoragesize;
uint64_t maxvariablesize;
uint32_t i;
+ fwts_log_info(fw, "Testing QueryVariableInfo on querying the variable %" PRIu32
+ " times.", uefi_query_variable_multiple);
+
/* first check if the firmware support QueryVariableInfo interface */
if (do_queryvariableinfo(&status, &remvarstoragesize, &maxvariablesize) == FWTS_ERROR) {
if (status == EFI_UNSUPPORTED) {
@@ -1555,6 +1568,68 @@ static int uefirtvariable_test7(fwts_framework *fw)
return FWTS_OK;
}
+static int options_check(fwts_framework *fw)
+{
+ FWTS_UNUSED(fw);
+
+ if ((uefi_get_variable_multiple < 1) ||
+ (uefi_get_variable_multiple > UEFI_GET_VARIABLE_MULTIPLE_MAX)) {
+ fprintf(stderr, "--uefi-get-variable-multiple is %" PRIu32", it "
+ "should be 1..%" PRIu32 "\n",
+ uefi_get_variable_multiple, UEFI_GET_VARIABLE_MULTIPLE_MAX);
+ return FWTS_ERROR;
+ }
+ if ((uefi_set_variable_multiple < 1) ||
+ (uefi_set_variable_multiple > UEFI_SET_VARIABLE_MULTIPLE_MAX)) {
+ fprintf(stderr, "--uefi-set-variable-multiple is %" PRIu32", it "
+ "should be 1..%" PRIu32 "\n",
+ uefi_set_variable_multiple, UEFI_SET_VARIABLE_MULTIPLE_MAX);
+ return FWTS_ERROR;
+ }
+ if ((uefi_query_variable_multiple < 1) ||
+ (uefi_query_variable_multiple > UEFI_QUERY_VARIABLE_MULTIPLE_MAX)) {
+ fprintf(stderr, "--uefi-query-variable-multiple is %" PRIu32", it "
+ "should be 1..%" PRIu32 "\n",
+ uefi_query_variable_multiple, UEFI_QUERY_VARIABLE_MULTIPLE_MAX);
+ return FWTS_ERROR;
+ }
+ return FWTS_OK;
+}
+
+static int options_handler(
+ fwts_framework *fw,
+ int argc,
+ char * const argv[],
+ int option_char,
+ int long_index)
+{
+ FWTS_UNUSED(fw);
+ FWTS_UNUSED(argc);
+ FWTS_UNUSED(argv);
+
+ if (option_char == 0) {
+ switch (long_index) {
+ case 0: /* --uefi-get-var-multiple */
+ uefi_get_variable_multiple = strtoul(optarg, NULL, 10);
+ break;
+ case 1: /* --uefi-set-var-multiple */
+ uefi_set_variable_multiple = strtoul(optarg, NULL, 10);
+ break;
+ case 2: /* --uefi-query-var-multiple */
+ uefi_query_variable_multiple = strtoul(optarg, NULL, 10);
+ break;
+ }
+ }
+ return FWTS_OK;
+}
+
+static fwts_option options[] = {
+ { "uefi-get-var-multiple", "", 1, "Run uefirtvariable get variable test multiple times." },
+ { "uefi-set-var-multiple", "", 1, "Run uefirtvariable set variable test multiple times." },
+ { "uefi-query-var-multiple", "", 1, "Run uefirtvariable query variable test multiple times." },
+ { NULL, NULL, 0, NULL }
+};
+
static fwts_framework_minor_test uefirtvariable_tests[] = {
{ uefirtvariable_test1, "Test UEFI RT service get variable interface." },
{ uefirtvariable_test2, "Test UEFI RT service get next variable name interface." },
@@ -1567,10 +1642,13 @@ static fwts_framework_minor_test uefirtvariable_tests[] = {
};
static fwts_framework_ops uefirtvariable_ops = {
- .description = "UEFI Runtime service variable interface tests.",
- .init = uefirtvariable_init,
- .deinit = uefirtvariable_deinit,
- .minor_tests = uefirtvariable_tests
+ .description = "UEFI Runtime service variable interface tests.",
+ .init = uefirtvariable_init,
+ .deinit = uefirtvariable_deinit,
+ .minor_tests = uefirtvariable_tests,
+ .options = options,
+ .options_handler = options_handler,
+ .options_check = options_check,
};
FWTS_REGISTER("uefirtvariable", &uefirtvariable_ops, FWTS_TEST_ANYTIME, FWTS_FLAG_UNSAFE | FWTS_FLAG_ROOT_PRIV);
--
1.8.1.2
More information about the fwts-devel
mailing list