From patchwork Thu Jul 4 10:51:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 256871 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 985922C008F for ; Thu, 4 Jul 2013 20:51:54 +1000 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1Uuh8i-0004SW-Hw; Thu, 04 Jul 2013 10:51:52 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1Uuh8b-0004SD-28 for fwts-devel@lists.ubuntu.com; Thu, 04 Jul 2013 10:51:45 +0000 Received: from cpc3-craw6-2-0-cust180.croy.cable.virginmedia.com ([77.100.248.181] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1Uuh8a-0001P8-So for fwts-devel@lists.ubuntu.com; Thu, 04 Jul 2013 10:51:45 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH][RESEND] uefi: uefirtvariable: add options to specify iterations in variable stress tests (LP: #1197742) Date: Thu, 4 Jul 2013 11:51:44 +0100 Message-Id: <1372935104-29502-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.8.1.2 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King 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 Acked-by: Alex Hung Acked-by: Ivan Hu --- doc/fwts.1 | 9 +++ src/uefi/uefirtvariable/uefirtvariable.c | 105 +++++++++++++++++++++++++++---- 2 files changed, 102 insertions(+), 12 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..e223f82 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); @@ -1452,7 +1462,8 @@ static int uefirtvariable_test6(fwts_framework *fw) return ret; fwts_passed(fw, "SetVariable on setting the variable with the same data multiple times passed."); - fwts_log_info(fw, "Testing SetVariable on setting the variable with different data multiple times."); + fwts_log_info(fw, "Testing SetVariable on setting the variable with different data %" PRIu32 + " times.", uefi_set_variable_multiple); for (i = 0; i < multitesttime; i++) { ret = setvariable_insertvariable(fw, attributes, datasize+i, variablenametest, >estguid1, datadiff); @@ -1465,7 +1476,8 @@ static int uefirtvariable_test6(fwts_framework *fw) } fwts_passed(fw, "Testing SetVariable on setting the variable with different data multiple times passed."); - fwts_log_info(fw, "Testing SetVariable on setting the variable with different name multiple times."); + fwts_log_info(fw, "Testing SetVariable on setting the variable with different name %" PRIu32 + " times.", uefi_set_variable_multiple); for (i = 0; i < variablenamelength; i++) { variablenametest4[i] = 'a'; variablenametest4[i+1] = '\0'; @@ -1480,7 +1492,8 @@ 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."); + fwts_log_info(fw, "Testing SetVariable on setting the variable with different name and data %" PRIu32 + " times.", uefi_set_variable_multiple); /* * This combine test do a lot of setvariable, reduce variablenamelength @@ -1512,12 +1525,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 +1571,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 +1645,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);