From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=eric.jin@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 965AE2117FD58 for ; Tue, 30 Oct 2018 01:39:10 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Oct 2018 01:39:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,443,1534834800"; d="scan'208";a="276803277" Received: from shwdeopenpsi175.ccr.corp.intel.com ([10.239.9.140]) by fmsmga006.fm.intel.com with ESMTP; 30 Oct 2018 01:39:08 -0700 From: Eric Jin To: edk2-devel@lists.01.org Cc: Supreeth Venkatesh , Jiaxin Wu Date: Tue, 30 Oct 2018 16:38:36 +0800 Message-Id: <20181030083836.7184-1-eric.jin@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 Subject: [edk2-test][Patch] uefi-sct/SctPkg:Assign 0 to the tail of the HwErrRecVariableName X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Oct 2018 08:39:10 -0000 Make the HwErrRecVariableName as valid the string. Ensure the HwErrRecVariable could be deleted before the test exit. Cc: Supreeth Venkatesh Cc: Jiaxin Wu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Jin --- .../BlackBoxTest/VariableServicesBBTestFunction.c | 12 +++++++----- .../BlackBoxTest/VariableServicesBBTestMain.h | 10 +++++++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/VariableServices/BlackBoxTest/VariableServicesBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/VariableServices/BlackBoxTest/VariableServicesBBTestFunction.c index d1064ce..df1bbe7 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/VariableServices/BlackBoxTest/VariableServicesBBTestFunction.c +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/VariableServices/BlackBoxTest/VariableServicesBBTestFunction.c @@ -1,7 +1,7 @@ /** @file Copyright 2006 - 2012 Unified EFI, Inc.
- Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -2855,7 +2855,7 @@ HardwareErrorRecordFuncTest ( UINT64 RemainingVariableStorageSize; UINT64 MaximumVariableSize; - CHAR16 HwErrRecVariableName[13]; + CHAR16 HwErrRecVariableName[HwErrRecVariableNameLength]; CHAR16 HwErrRecVariable[] = L"This is a HwErrRec variable!"; CHAR16 GetVariableName[MAX_BUFFER_SIZE]; @@ -3015,6 +3015,7 @@ HardwareErrorRecordFuncTest ( HwErrRecVariableName[0] = L'\0'; SctStrCat ( HwErrRecVariableName, L"HwErrRec" ); Myitox( MaxNum, HwErrRecVariableName+8 ); + HwErrRecVariableName[HwErrRecVariableNameLength-1] = L'\0'; // // Set the new HwErrRec variable to the global variable @@ -3036,8 +3037,8 @@ HardwareErrorRecordFuncTest ( // Write reset record // RecoveryData[0] = 2; - SctStrnCpy ( (CHAR16*)(&RecoveryData[2]), HwErrRecVariableName, 12 ); - RecoveryLib->WriteResetRecord( RecoveryLib, 13*sizeof(CHAR16)+2, RecoveryData ); + SctStrnCpy ( (CHAR16*)(&RecoveryData[2]), HwErrRecVariableName, HwErrRecVariableNameLength-1 ); + RecoveryLib->WriteResetRecord( RecoveryLib, HwErrRecVariableNameLength*sizeof(CHAR16)+2, RecoveryData ); // // Prompt the user about the cold reset and reset the system @@ -3052,7 +3053,8 @@ HardwareErrorRecordFuncTest ( // step2: DataSize = 255; - SctStrnCpy ( HwErrRecVariableName, (CHAR16*)(RecoveryData+2), 12 ); + HwErrRecVariableName[HwErrRecVariableNameLength-1] = L'\0'; + SctStrnCpy ( HwErrRecVariableName, (CHAR16*)(RecoveryData+2), HwErrRecVariableNameLength-1 ); Status = RT->GetVariable ( HwErrRecVariableName, &gHwErrRecGuid, diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/VariableServices/BlackBoxTest/VariableServicesBBTestMain.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/VariableServices/BlackBoxTest/VariableServicesBBTestMain.h index 051ae6f..b645b55 100644 --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/VariableServices/BlackBoxTest/VariableServicesBBTestMain.h +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/RuntimeServices/VariableServices/BlackBoxTest/VariableServicesBBTestMain.h @@ -1,7 +1,7 @@ /** @file Copyright 2006 - 2016 Unified EFI, Inc.
- Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -125,6 +125,14 @@ Abstract: #endif // +// The Variable Name of Hardware Error Record Variables +// defined in the UEFI Spec is HwErrRec####. For example, +// HwErrRec0001, HwErrRec0002, HwErrRecF31A, etc. +// Consider the tail of string, the length is 13. +// +#define HwErrRecVariableNameLength 13 + +// // Global Variables // -- 2.9.0.windows.1