From patchwork Thu Dec 27 08:06:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 208278 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 2E5B72C0092 for ; Thu, 27 Dec 2012 19:06:42 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1To8UC-0003Gg-Vk; Thu, 27 Dec 2012 08:06:41 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1To8UC-0003GS-27 for fwts-devel@lists.ubuntu.com; Thu, 27 Dec 2012 08:06:40 +0000 Received: from [175.41.48.77] (helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1To8UB-0002d9-50; Thu, 27 Dec 2012 08:06:40 +0000 From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH 1/2] uefirtvariable: add stress test for UEFI runtime interface GetVariable Date: Thu, 27 Dec 2012 16:06:35 +0800 Message-Id: <1356595595-24161-1-git-send-email-ivan.hu@canonical.com> X-Mailer: git-send-email 1.7.10.4 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: fwts-devel-bounces@lists.ubuntu.com Errors-To: fwts-devel-bounces@lists.ubuntu.com This stress test tests the UEFI runtime interface GetVariable by calling multiple times. Signed-off-by: Ivan Hu Acked-by: Colin Ian King Acked-by: Alex Hung --- src/uefi/uefirtvariable/uefirtvariable.c | 37 ++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/uefi/uefirtvariable/uefirtvariable.c b/src/uefi/uefirtvariable/uefirtvariable.c index 2b66371..a8b9326 100644 --- a/src/uefi/uefirtvariable/uefirtvariable.c +++ b/src/uefi/uefirtvariable/uefirtvariable.c @@ -80,7 +80,7 @@ static int uefirtvariable_deinit(fwts_framework *fw) return FWTS_OK; } -static int getvariable_test(fwts_framework *fw, uint64_t datasize, uint16_t *varname) +static int getvariable_test(fwts_framework *fw, uint64_t datasize, uint16_t *varname, uint32_t multitesttime) { long ioret; struct efi_getvariable getvariable; @@ -93,6 +93,8 @@ static int getvariable_test(fwts_framework *fw, uint64_t datasize, uint16_t *var uint32_t attributestest; uint8_t data[datasize+1]; + uint32_t i; + for (dataindex = 0; dataindex < datasize; dataindex++) data[dataindex] = (uint8_t)dataindex; data[dataindex] = '\0'; @@ -120,14 +122,15 @@ static int getvariable_test(fwts_framework *fw, uint64_t datasize, uint16_t *var getvariable.Data = testdata; getvariable.status = &status; - ioret = ioctl(fd, EFI_RUNTIME_GET_VARIABLE, &getvariable); - if (ioret == -1) { - fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetVariable", - "Failed to get variable with UEFI runtime service."); - fwts_uefi_print_status_info(fw, status); - goto err_restore_env; + for (i = 0; i < multitesttime; i++) { + ioret = ioctl(fd, EFI_RUNTIME_GET_VARIABLE, &getvariable); + if (ioret == -1) { + fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetVariable", + "Failed to get variable with UEFI runtime service."); + fwts_uefi_print_status_info(fw, status); + goto err_restore_env; + } } - if (*getvariable.status != EFI_SUCCESS) { fwts_failed(fw, LOG_LEVEL_HIGH, "UEFIRuntimeGetVariableStatus", "Failed to get variable, return status isn't EFI_SUCCESS."); @@ -718,8 +721,9 @@ static int do_queryvariableinfo(uint64_t *status, uint64_t *remvarstoragesize, u static int uefirtvariable_test1(fwts_framework *fw) { uint64_t datasize = 10; + uint32_t multitesttime = 1; - if (getvariable_test(fw, datasize, variablenametest) == FWTS_ERROR) + if (getvariable_test(fw, datasize, variablenametest, multitesttime) == FWTS_ERROR) return FWTS_ERROR; fwts_passed(fw, "UEFI runtime service GetVariable interface test passed."); @@ -799,11 +803,26 @@ static int uefirtvariable_test4(fwts_framework *fw) return FWTS_OK; } +static int uefirtvariable_test5(fwts_framework *fw) +{ + uint32_t multitesttime = 1024; + uint64_t datasize = 10; + + fwts_log_info(fw, "Testing GetVariable on getting the variable multiple times."); + if (getvariable_test(fw, datasize, variablenametest, multitesttime) == FWTS_ERROR) + return FWTS_ERROR; + fwts_passed(fw, "GetVariable on getting the variable multiple times passed."); + + return FWTS_OK; + +} + 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." }, { uefirtvariable_test3, "Test UEFI RT service set variable interface." }, { uefirtvariable_test4, "Test UEFI RT service query variable info interface." }, + { uefirtvariable_test5, "Test UEFI RT service variable interface stress test." }, { NULL, NULL } };